diff --git a/of/ctl/conf/checkstyle/checkstyle_maven.properties b/of/ctl/conf/checkstyle/checkstyle_maven.properties
index 4677e08..916928c 100644
--- a/of/ctl/conf/checkstyle/checkstyle_maven.properties
+++ b/of/ctl/conf/checkstyle/checkstyle_maven.properties
@@ -1,2 +1,2 @@
 # See: http://rolf-engelhard.de/2011/04/using-the-same-suppression-filter-for-checkstyle-in-eclipse-and-maven/
-config_loc=conf/checkstyle
+config_loc=ctl/conf/checkstyle
diff --git a/of/ctl/pom.xml b/of/ctl/pom.xml
index 38b0c38..a837339 100644
--- a/of/ctl/pom.xml
+++ b/of/ctl/pom.xml
@@ -4,11 +4,11 @@
   <prerequisites>
     <maven>3.0.4</maven>
   </prerequisites>
-  <groupId>net.onrc.onos.sb</groupId>
-  <artifactId>onos-sb</artifactId>
+  <groupId>net.onrc.onos.of.ctl</groupId>
+  <artifactId>io</artifactId>
   <version>0.0.1</version>
   <packaging>bundle</packaging>
-  <name>ONOS-SB</name>
+  <name>of-ctl</name>
   <url>http://onlab.us/</url>
   <licenses>
     <license>
@@ -49,7 +49,7 @@
     <findbugs.version>3.0.0</findbugs.version>
     <findbugs-plugin.version>3.0.0</findbugs-plugin.version>
     <findbugs.effort>Max</findbugs.effort>
-    <findbugs.excludeFilterFile>conf/findbugs/exclude.xml</findbugs.excludeFilterFile>
+    <findbugs.excludeFilterFile>${project.basedir}/conf/findbugs/exclude.xml</findbugs.excludeFilterFile>
     <checkstyle-plugin.version>2.12</checkstyle-plugin.version>
     <!-- To publish javadoc to github,
      uncomment com.github.github site-maven-plugin and
@@ -97,8 +97,8 @@
         <artifactId>maven-checkstyle-plugin</artifactId>
         <version>${checkstyle-plugin.version}</version>
         <configuration>
-          <configLocation>conf/checkstyle/sun_checks.xml</configLocation>
-          <propertiesLocation>${basedir}/conf/checkstyle/checkstyle_maven.properties</propertiesLocation>
+          <configLocation>${project.basedir}/conf/checkstyle/sun_checks.xml</configLocation>
+          <propertiesLocation>${project.basedir}/conf/checkstyle/checkstyle_maven.properties</propertiesLocation>
           <failsOnError>false</failsOnError>
           <logViolationsToConsole>true</logViolationsToConsole>
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFActionType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFActionType.java
new file mode 100644
index 0000000..fe5320d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFActionType.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFActionType {
+     OUTPUT,
+     SET_VLAN_VID,
+     SET_VLAN_PCP,
+     STRIP_VLAN,
+     SET_DL_SRC,
+     SET_DL_DST,
+     SET_NW_SRC,
+     SET_NW_DST,
+     SET_NW_TOS,
+     SET_TP_SRC,
+     SET_TP_DST,
+     ENQUEUE,
+     EXPERIMENTER,
+     SET_NW_ECN,
+     COPY_TTL_OUT,
+     COPY_TTL_IN,
+     SET_MPLS_LABEL,
+     SET_MPLS_TC,
+     SET_MPLS_TTL,
+     DEC_MPLS_TTL,
+     PUSH_VLAN,
+     POP_VLAN,
+     PUSH_MPLS,
+     POP_MPLS,
+     SET_QUEUE,
+     GROUP,
+     SET_NW_TTL,
+     DEC_NW_TTL,
+     SET_FIELD,
+     PUSH_PBB,
+     POP_PBB;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAggregateStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAggregateStatsReply.java
new file mode 100644
index 0000000..ce8478d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAggregateStatsReply.java
@@ -0,0 +1,58 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFAggregateStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    U64 getPacketCount();
+    U64 getByteCount();
+    long getFlowCount();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFAggregateStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        U64 getPacketCount();
+        Builder setPacketCount(U64 packetCount);
+        U64 getByteCount();
+        Builder setByteCount(U64 byteCount);
+        long getFlowCount();
+        Builder setFlowCount(long flowCount);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAggregateStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAggregateStatsRequest.java
new file mode 100644
index 0000000..e2c6cc2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAggregateStatsRequest.java
@@ -0,0 +1,67 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFAggregateStatsRequest extends OFObject, OFStatsRequest<OFAggregateStatsReply>, OFRequest<OFAggregateStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    TableId getTableId();
+    OFPort getOutPort();
+    OFGroup getOutGroup() throws UnsupportedOperationException;
+    U64 getCookie() throws UnsupportedOperationException;
+    U64 getCookieMask() throws UnsupportedOperationException;
+    Match getMatch();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFAggregateStatsReply> {
+        OFAggregateStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        OFPort getOutPort();
+        Builder setOutPort(OFPort outPort);
+        OFGroup getOutGroup() throws UnsupportedOperationException;
+        Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
+        U64 getCookie() throws UnsupportedOperationException;
+        Builder setCookie(U64 cookie) throws UnsupportedOperationException;
+        U64 getCookieMask() throws UnsupportedOperationException;
+        Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
+        Match getMatch();
+        Builder setMatch(Match match);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncGetReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncGetReply.java
new file mode 100644
index 0000000..d29b921
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncGetReply.java
@@ -0,0 +1,61 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFAsyncGetReply extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getPacketInMaskEqualMaster();
+    long getPacketInMaskSlave();
+    long getPortStatusMaskEqualMaster();
+    long getPortStatusMaskSlave();
+    long getFlowRemovedMaskEqualMaster();
+    long getFlowRemovedMaskSlave();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFAsyncGetReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getPacketInMaskEqualMaster();
+        Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
+        long getPacketInMaskSlave();
+        Builder setPacketInMaskSlave(long packetInMaskSlave);
+        long getPortStatusMaskEqualMaster();
+        Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
+        long getPortStatusMaskSlave();
+        Builder setPortStatusMaskSlave(long portStatusMaskSlave);
+        long getFlowRemovedMaskEqualMaster();
+        Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
+        long getFlowRemovedMaskSlave();
+        Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncGetRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncGetRequest.java
new file mode 100644
index 0000000..6f52220
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncGetRequest.java
@@ -0,0 +1,61 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFAsyncGetRequest extends OFObject, OFMessage, OFRequest<OFAsyncGetReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getPacketInMaskEqualMaster();
+    long getPacketInMaskSlave();
+    long getPortStatusMaskEqualMaster();
+    long getPortStatusMaskSlave();
+    long getFlowRemovedMaskEqualMaster();
+    long getFlowRemovedMaskSlave();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFAsyncGetRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getPacketInMaskEqualMaster();
+        Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
+        long getPacketInMaskSlave();
+        Builder setPacketInMaskSlave(long packetInMaskSlave);
+        long getPortStatusMaskEqualMaster();
+        Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
+        long getPortStatusMaskSlave();
+        Builder setPortStatusMaskSlave(long portStatusMaskSlave);
+        long getFlowRemovedMaskEqualMaster();
+        Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
+        long getFlowRemovedMaskSlave();
+        Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncSet.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncSet.java
new file mode 100644
index 0000000..ff3927e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFAsyncSet.java
@@ -0,0 +1,62 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFAsyncSet extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getPacketInMaskEqualMaster();
+    long getPacketInMaskSlave();
+    long getPortStatusMaskEqualMaster();
+    long getPortStatusMaskSlave();
+    long getFlowRemovedMaskEqualMaster();
+    long getFlowRemovedMaskSlave();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFAsyncSet build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getPacketInMaskEqualMaster();
+        Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster);
+        long getPacketInMaskSlave();
+        Builder setPacketInMaskSlave(long packetInMaskSlave);
+        long getPortStatusMaskEqualMaster();
+        Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster);
+        long getPortStatusMaskSlave();
+        Builder setPortStatusMaskSlave(long portStatusMaskSlave);
+        long getFlowRemovedMaskEqualMaster();
+        Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster);
+        long getFlowRemovedMaskSlave();
+        Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadActionCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadActionCode.java
new file mode 100644
index 0000000..13d5543
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadActionCode.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBadActionCode {
+     BAD_TYPE,
+     BAD_LEN,
+     BAD_EXPERIMENTER,
+     BAD_EXPERIMENTER_TYPE,
+     BAD_OUT_PORT,
+     BAD_ARGUMENT,
+     EPERM,
+     TOO_MANY,
+     BAD_QUEUE,
+     BAD_OUT_GROUP,
+     MATCH_INCONSISTENT,
+     UNSUPPORTED_ORDER,
+     BAD_TAG,
+     BAD_SET_TYPE,
+     BAD_SET_LEN,
+     BAD_SET_ARGUMENT;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadInstructionCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadInstructionCode.java
new file mode 100644
index 0000000..dfe86d3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadInstructionCode.java
@@ -0,0 +1,38 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBadInstructionCode {
+     UNKNOWN_INST,
+     UNSUP_INST,
+     BAD_TABLE_ID,
+     UNSUP_METADATA,
+     UNSUP_METADATA_MASK,
+     UNSUP_EXP_INST,
+     BAD_EXPERIMENTER,
+     BAD_EXPERIMENTER_TYPE,
+     BAD_LEN,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadMatchCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadMatchCode.java
new file mode 100644
index 0000000..02f689a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadMatchCode.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBadMatchCode {
+     BAD_TYPE,
+     BAD_LEN,
+     BAD_TAG,
+     BAD_DL_ADDR_MASK,
+     BAD_NW_ADDR_MASK,
+     BAD_WILDCARDS,
+     BAD_FIELD,
+     BAD_VALUE,
+     BAD_MASK,
+     BAD_PREREQ,
+     DUP_FIELD,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadRequestCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadRequestCode.java
new file mode 100644
index 0000000..e254cb2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBadRequestCode.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBadRequestCode {
+     BAD_VERSION,
+     BAD_TYPE,
+     BAD_STAT,
+     BAD_EXPERIMENTER,
+     BAD_SUBTYPE,
+     EPERM,
+     BAD_LEN,
+     BUFFER_EMPTY,
+     BUFFER_UNKNOWN,
+     BAD_TABLE_ID,
+     BAD_EXPERIMENTER_TYPE,
+     IS_SLAVE,
+     BAD_PORT,
+     BAD_PACKET,
+     MULTIPART_BUFFER_OVERFLOW;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBarrierReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBarrierReply.java
new file mode 100644
index 0000000..f64f16e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBarrierReply.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBarrierReply extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFBarrierReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBarrierRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBarrierRequest.java
new file mode 100644
index 0000000..b41e104
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBarrierRequest.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBarrierRequest extends OFObject, OFMessage, OFRequest<OFBarrierReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFBarrierRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnArpIdle.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnArpIdle.java
new file mode 100644
index 0000000..3d1893e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnArpIdle.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnArpIdle extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    int getVlanVid();
+    IPv4Address getIpv4Addr();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnArpIdle build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        int getVlanVid();
+        Builder setVlanVid(int vlanVid);
+        IPv4Address getIpv4Addr();
+        Builder setIpv4Addr(IPv4Address ipv4Addr);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwClearDataReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwClearDataReply.java
new file mode 100644
index 0000000..78e74c5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwClearDataReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnBwClearDataReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnBwClearDataReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwClearDataRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwClearDataRequest.java
new file mode 100644
index 0000000..bb9c2bb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwClearDataRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnBwClearDataRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnBwClearDataReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnBwClearDataRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableGetReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableGetReply.java
new file mode 100644
index 0000000..e8ae108
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableGetReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnBwEnableGetReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getEnabled();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnBwEnableGetReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getEnabled();
+        Builder setEnabled(long enabled);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableGetRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableGetRequest.java
new file mode 100644
index 0000000..15ccbdc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableGetRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnBwEnableGetRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnBwEnableGetReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnBwEnableGetRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableSetReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableSetReply.java
new file mode 100644
index 0000000..6d25d7e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableSetReply.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnBwEnableSetReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getEnable();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnBwEnableSetReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getEnable();
+        Builder setEnable(long enable);
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableSetRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableSetRequest.java
new file mode 100644
index 0000000..2b23800
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnBwEnableSetRequest.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnBwEnableSetRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnBwEnableSetReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getEnable();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnBwEnableSetRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getEnable();
+        Builder setEnable(long enable);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnection.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnection.java
new file mode 100644
index 0000000..6d11288
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnection.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnControllerConnection extends OFObject {
+    OFBsnControllerConnectionState getState();
+    OFAuxId getAuxiliaryId();
+    OFControllerRole getRole();
+    String getUri();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnControllerConnection build();
+        OFBsnControllerConnectionState getState();
+        Builder setState(OFBsnControllerConnectionState state);
+        OFAuxId getAuxiliaryId();
+        Builder setAuxiliaryId(OFAuxId auxiliaryId);
+        OFControllerRole getRole();
+        Builder setRole(OFControllerRole role);
+        String getUri();
+        Builder setUri(String uri);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionState.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionState.java
new file mode 100644
index 0000000..df1312f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionState.java
@@ -0,0 +1,30 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnControllerConnectionState {
+     BSN_CONTROLLER_CONNECTION_STATE_DISCONNECTED,
+     BSN_CONTROLLER_CONNECTION_STATE_CONNECTED;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionsReply.java
new file mode 100644
index 0000000..ffa03c4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionsReply.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnControllerConnectionsReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnControllerConnection> getConnections();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnControllerConnectionsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnControllerConnection> getConnections();
+        Builder setConnections(List<OFBsnControllerConnection> connections);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionsRequest.java
new file mode 100644
index 0000000..efee303
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerConnectionsRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnControllerConnectionsRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnControllerConnectionsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnControllerConnectionsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerRoleReason.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerRoleReason.java
new file mode 100644
index 0000000..a8eb119
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnControllerRoleReason.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnControllerRoleReason {
+     BSN_CONTROLLER_ROLE_REASON_MASTER_REQUEST,
+     BSN_CONTROLLER_ROLE_REASON_CONFIG,
+     BSN_CONTROLLER_ROLE_REASON_EXPERIMENTER;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsEntry.java
new file mode 100644
index 0000000..0aa4407
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsEntry.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnDebugCounterDescStatsEntry extends OFObject {
+    U64 getCounterId();
+    String getName();
+    String getDescription();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnDebugCounterDescStatsEntry build();
+        U64 getCounterId();
+        Builder setCounterId(U64 counterId);
+        String getName();
+        Builder setName(String name);
+        String getDescription();
+        Builder setDescription(String description);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsReply.java
new file mode 100644
index 0000000..5f72426
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnDebugCounterDescStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnDebugCounterDescStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnDebugCounterDescStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnDebugCounterDescStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnDebugCounterDescStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsRequest.java
new file mode 100644
index 0000000..ebd3b9b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterDescStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnDebugCounterDescStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnDebugCounterDescStatsReply>, OFRequest<OFBsnDebugCounterDescStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnDebugCounterDescStatsReply> {
+        OFBsnDebugCounterDescStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsEntry.java
new file mode 100644
index 0000000..f3d28d0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsEntry.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnDebugCounterStatsEntry extends OFObject {
+    U64 getCounterId();
+    U64 getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnDebugCounterStatsEntry build();
+        U64 getCounterId();
+        Builder setCounterId(U64 counterId);
+        U64 getValue();
+        Builder setValue(U64 value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsReply.java
new file mode 100644
index 0000000..9edf42a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnDebugCounterStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnDebugCounterStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnDebugCounterStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnDebugCounterStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnDebugCounterStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsRequest.java
new file mode 100644
index 0000000..cb2d5f9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnDebugCounterStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnDebugCounterStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnDebugCounterStatsReply>, OFRequest<OFBsnDebugCounterStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnDebugCounterStatsReply> {
+        OFBsnDebugCounterStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsEntry.java
new file mode 100644
index 0000000..d709799
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsEntry.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnFlowChecksumBucketStatsEntry extends OFObject {
+    U64 getChecksum();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnFlowChecksumBucketStatsEntry build();
+        U64 getChecksum();
+        Builder setChecksum(U64 checksum);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsReply.java
new file mode 100644
index 0000000..4759d45
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnFlowChecksumBucketStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnFlowChecksumBucketStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnFlowChecksumBucketStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnFlowChecksumBucketStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnFlowChecksumBucketStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsRequest.java
new file mode 100644
index 0000000..1f4ed0d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowChecksumBucketStatsRequest.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnFlowChecksumBucketStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnFlowChecksumBucketStatsReply>, OFRequest<OFBsnFlowChecksumBucketStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    TableId getTableId();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnFlowChecksumBucketStatsReply> {
+        OFBsnFlowChecksumBucketStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdle.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdle.java
new file mode 100644
index 0000000..88a2b14
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdle.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnFlowIdle extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    U64 getCookie();
+    int getPriority();
+    TableId getTableId();
+    Match getMatch();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnFlowIdle build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        int getPriority();
+        Builder setPriority(int priority);
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        Match getMatch();
+        Builder setMatch(Match match);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableGetReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableGetReply.java
new file mode 100644
index 0000000..cf38356
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableGetReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnFlowIdleEnableGetReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getEnabled();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnFlowIdleEnableGetReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getEnabled();
+        Builder setEnabled(long enabled);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableGetRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableGetRequest.java
new file mode 100644
index 0000000..aacb08c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableGetRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnFlowIdleEnableGetRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnFlowIdleEnableGetReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnFlowIdleEnableGetRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableSetReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableSetReply.java
new file mode 100644
index 0000000..6c0b274
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableSetReply.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnFlowIdleEnableSetReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getEnable();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnFlowIdleEnableSetReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getEnable();
+        Builder setEnable(long enable);
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableSetRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableSetRequest.java
new file mode 100644
index 0000000..aae991d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnFlowIdleEnableSetRequest.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnFlowIdleEnableSetRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnFlowIdleEnableSetReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getEnable();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnFlowIdleEnableSetRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getEnable();
+        Builder setEnable(long enable);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsEntry.java
new file mode 100644
index 0000000..d69a444
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsEntry.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableBucketStatsEntry extends OFObject {
+    U128 getChecksum();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnGentableBucketStatsEntry build();
+        U128 getChecksum();
+        Builder setChecksum(U128 checksum);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsReply.java
new file mode 100644
index 0000000..0b08078
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableBucketStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnGentableBucketStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnGentableBucketStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnGentableBucketStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnGentableBucketStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsRequest.java
new file mode 100644
index 0000000..72b5983
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableBucketStatsRequest.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableBucketStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnGentableBucketStatsReply>, OFRequest<OFBsnGentableBucketStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    GenTableId getTableId();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnGentableBucketStatsReply> {
+        OFBsnGentableBucketStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableClearReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableClearReply.java
new file mode 100644
index 0000000..d0c7015
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableClearReply.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableClearReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    GenTableId getTableId();
+    long getDeletedCount();
+    long getErrorCount();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGentableClearReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        long getDeletedCount();
+        Builder setDeletedCount(long deletedCount);
+        long getErrorCount();
+        Builder setErrorCount(long errorCount);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableClearRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableClearRequest.java
new file mode 100644
index 0000000..e61f3f6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableClearRequest.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableClearRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnGentableClearReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    GenTableId getTableId();
+    U128 getChecksum();
+    U128 getChecksumMask();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGentableClearRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        U128 getChecksum();
+        Builder setChecksum(U128 checksum);
+        U128 getChecksumMask();
+        Builder setChecksumMask(U128 checksumMask);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsEntry.java
new file mode 100644
index 0000000..b39fd10
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsEntry.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableDescStatsEntry extends OFObject {
+    GenTableId getTableId();
+    String getName();
+    long getBucketsSize();
+    long getMaxEntries();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnGentableDescStatsEntry build();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        String getName();
+        Builder setName(String name);
+        long getBucketsSize();
+        Builder setBucketsSize(long bucketsSize);
+        long getMaxEntries();
+        Builder setMaxEntries(long maxEntries);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsReply.java
new file mode 100644
index 0000000..6d2de9d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableDescStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnGentableDescStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnGentableDescStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnGentableDescStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnGentableDescStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsRequest.java
new file mode 100644
index 0000000..8fa686d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableDescStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableDescStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnGentableDescStatsReply>, OFRequest<OFBsnGentableDescStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnGentableDescStatsReply> {
+        OFBsnGentableDescStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryAdd.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryAdd.java
new file mode 100644
index 0000000..ef358fa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryAdd.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableEntryAdd extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    GenTableId getTableId();
+    U128 getChecksum();
+    List<OFBsnTlv> getKey();
+    List<OFBsnTlv> getValue();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGentableEntryAdd build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        U128 getChecksum();
+        Builder setChecksum(U128 checksum);
+        List<OFBsnTlv> getKey();
+        Builder setKey(List<OFBsnTlv> key);
+        List<OFBsnTlv> getValue();
+        Builder setValue(List<OFBsnTlv> value);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDelete.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDelete.java
new file mode 100644
index 0000000..79093a3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDelete.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableEntryDelete extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    GenTableId getTableId();
+    List<OFBsnTlv> getKey();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGentableEntryDelete build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        List<OFBsnTlv> getKey();
+        Builder setKey(List<OFBsnTlv> key);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsEntry.java
new file mode 100644
index 0000000..b0783c7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsEntry.java
@@ -0,0 +1,48 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableEntryDescStatsEntry extends OFObject {
+    U128 getChecksum();
+    List<OFBsnTlv> getKey();
+    List<OFBsnTlv> getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnGentableEntryDescStatsEntry build();
+        U128 getChecksum();
+        Builder setChecksum(U128 checksum);
+        List<OFBsnTlv> getKey();
+        Builder setKey(List<OFBsnTlv> key);
+        List<OFBsnTlv> getValue();
+        Builder setValue(List<OFBsnTlv> value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsReply.java
new file mode 100644
index 0000000..c859998
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableEntryDescStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnGentableEntryDescStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnGentableEntryDescStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnGentableEntryDescStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnGentableEntryDescStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsRequest.java
new file mode 100644
index 0000000..ba35738
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryDescStatsRequest.java
@@ -0,0 +1,62 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableEntryDescStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnGentableEntryDescStatsReply>, OFRequest<OFBsnGentableEntryDescStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    GenTableId getTableId();
+    U128 getChecksum();
+    U128 getChecksumMask();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnGentableEntryDescStatsReply> {
+        OFBsnGentableEntryDescStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        U128 getChecksum();
+        Builder setChecksum(U128 checksum);
+        U128 getChecksumMask();
+        Builder setChecksumMask(U128 checksumMask);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsEntry.java
new file mode 100644
index 0000000..ec0fb5b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsEntry.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableEntryStatsEntry extends OFObject {
+    List<OFBsnTlv> getKey();
+    List<OFBsnTlv> getStats();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnGentableEntryStatsEntry build();
+        List<OFBsnTlv> getKey();
+        Builder setKey(List<OFBsnTlv> key);
+        List<OFBsnTlv> getStats();
+        Builder setStats(List<OFBsnTlv> stats);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsReply.java
new file mode 100644
index 0000000..fd88fb7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableEntryStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnGentableEntryStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnGentableEntryStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnGentableEntryStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnGentableEntryStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsRequest.java
new file mode 100644
index 0000000..90a6475
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableEntryStatsRequest.java
@@ -0,0 +1,62 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableEntryStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnGentableEntryStatsReply>, OFRequest<OFBsnGentableEntryStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    GenTableId getTableId();
+    U128 getChecksum();
+    U128 getChecksumMask();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnGentableEntryStatsReply> {
+        OFBsnGentableEntryStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        U128 getChecksum();
+        Builder setChecksum(U128 checksum);
+        U128 getChecksumMask();
+        Builder setChecksumMask(U128 checksumMask);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableSetBucketsSize.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableSetBucketsSize.java
new file mode 100644
index 0000000..5066e21
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableSetBucketsSize.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableSetBucketsSize extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    GenTableId getTableId();
+    long getBucketsSize();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGentableSetBucketsSize build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        long getBucketsSize();
+        Builder setBucketsSize(long bucketsSize);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsEntry.java
new file mode 100644
index 0000000..d4b0cc8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsEntry.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableStatsEntry extends OFObject {
+    GenTableId getTableId();
+    long getEntryCount();
+    U128 getChecksum();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnGentableStatsEntry build();
+        GenTableId getTableId();
+        Builder setTableId(GenTableId tableId);
+        long getEntryCount();
+        Builder setEntryCount(long entryCount);
+        U128 getChecksum();
+        Builder setChecksum(U128 checksum);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsReply.java
new file mode 100644
index 0000000..f1d4b74
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnGentableStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnGentableStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnGentableStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnGentableStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsRequest.java
new file mode 100644
index 0000000..9fc4b7a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGentableStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGentableStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnGentableStatsReply>, OFRequest<OFBsnGentableStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnGentableStatsReply> {
+        OFBsnGentableStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetInterfacesReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetInterfacesReply.java
new file mode 100644
index 0000000..951541b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetInterfacesReply.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetInterfacesReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnInterface> getInterfaces();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetInterfacesReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnInterface> getInterfaces();
+        Builder setInterfaces(List<OFBsnInterface> interfaces);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetInterfacesRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetInterfacesRequest.java
new file mode 100644
index 0000000..62951a6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetInterfacesRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetInterfacesRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnGetInterfacesReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetInterfacesRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetIpMaskReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetIpMaskReply.java
new file mode 100644
index 0000000..ddb293b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetIpMaskReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetIpMaskReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getIndex();
+    long getMask();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetIpMaskReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getIndex();
+        Builder setIndex(short index);
+        long getMask();
+        Builder setMask(long mask);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetIpMaskRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetIpMaskRequest.java
new file mode 100644
index 0000000..0b7a63e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetIpMaskRequest.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetIpMaskRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnGetIpMaskReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getIndex();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetIpMaskRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getIndex();
+        Builder setIndex(short index);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetL2TableReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetL2TableReply.java
new file mode 100644
index 0000000..41125e7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetL2TableReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetL2TableReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getL2TableEnable();
+    int getL2TablePriority();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetL2TableReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getL2TableEnable();
+        Builder setL2TableEnable(short l2TableEnable);
+        int getL2TablePriority();
+        Builder setL2TablePriority(int l2TablePriority);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetL2TableRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetL2TableRequest.java
new file mode 100644
index 0000000..d7afc84
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetL2TableRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetL2TableRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnGetL2TableReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetL2TableRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetMirroringReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetMirroringReply.java
new file mode 100644
index 0000000..44290fc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetMirroringReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetMirroringReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getReportMirrorPorts();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetMirroringReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getReportMirrorPorts();
+        Builder setReportMirrorPorts(short reportMirrorPorts);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetMirroringRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetMirroringRequest.java
new file mode 100644
index 0000000..0fc5419
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetMirroringRequest.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetMirroringRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnGetMirroringReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getReportMirrorPorts();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetMirroringRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getReportMirrorPorts();
+        Builder setReportMirrorPorts(short reportMirrorPorts);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetSwitchPipelineReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetSwitchPipelineReply.java
new file mode 100644
index 0000000..32f5647
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetSwitchPipelineReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetSwitchPipelineReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    String getPipeline();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetSwitchPipelineReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        String getPipeline();
+        Builder setPipeline(String pipeline);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetSwitchPipelineRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetSwitchPipelineRequest.java
new file mode 100644
index 0000000..e4ff994
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnGetSwitchPipelineRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnGetSwitchPipelineRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnGetSwitchPipelineReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnGetSwitchPipelineRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHeader.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHeader.java
new file mode 100644
index 0000000..1081da9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHeader.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnHeader extends OFObject, OFExperimenter {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFExperimenter.Builder {
+        OFBsnHeader build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHybridGetReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHybridGetReply.java
new file mode 100644
index 0000000..68946fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHybridGetReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnHybridGetReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getHybridEnable();
+    int getHybridVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnHybridGetReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getHybridEnable();
+        Builder setHybridEnable(short hybridEnable);
+        int getHybridVersion();
+        Builder setHybridVersion(int hybridVersion);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHybridGetRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHybridGetRequest.java
new file mode 100644
index 0000000..0f2a690
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnHybridGetRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnHybridGetRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnHybridGetReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnHybridGetRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnImageDescStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnImageDescStatsReply.java
new file mode 100644
index 0000000..9ce6823
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnImageDescStatsReply.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnImageDescStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    String getImageChecksum();
+    String getStartupConfigChecksum();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnImageDescStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        String getImageChecksum();
+        Builder setImageChecksum(String imageChecksum);
+        String getStartupConfigChecksum();
+        Builder setStartupConfigChecksum(String startupConfigChecksum);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnImageDescStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnImageDescStatsRequest.java
new file mode 100644
index 0000000..154a137
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnImageDescStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnImageDescStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnImageDescStatsReply>, OFRequest<OFBsnImageDescStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnImageDescStatsReply> {
+        OFBsnImageDescStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnInterface.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnInterface.java
new file mode 100644
index 0000000..44f7739
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnInterface.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnInterface extends OFObject {
+    MacAddress getHwAddr();
+    String getName();
+    IPv4Address getIpv4Addr();
+    IPv4Address getIpv4Netmask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnInterface build();
+        MacAddress getHwAddr();
+        Builder setHwAddr(MacAddress hwAddr);
+        String getName();
+        Builder setName(String name);
+        IPv4Address getIpv4Addr();
+        Builder setIpv4Addr(IPv4Address ipv4Addr);
+        IPv4Address getIpv4Netmask();
+        Builder setIpv4Netmask(IPv4Address ipv4Netmask);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpConvergenceNotif.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpConvergenceNotif.java
new file mode 100644
index 0000000..d3b1d72
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpConvergenceNotif.java
@@ -0,0 +1,83 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnLacpConvergenceNotif extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getConvergenceStatus();
+    OFPort getPortNo();
+    int getActorSysPriority();
+    MacAddress getActorSysMac();
+    int getActorPortPriority();
+    int getActorPortNum();
+    int getActorKey();
+    int getPartnerSysPriority();
+    MacAddress getPartnerSysMac();
+    int getPartnerPortPriority();
+    int getPartnerPortNum();
+    int getPartnerKey();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnLacpConvergenceNotif build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getConvergenceStatus();
+        Builder setConvergenceStatus(short convergenceStatus);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        int getActorSysPriority();
+        Builder setActorSysPriority(int actorSysPriority);
+        MacAddress getActorSysMac();
+        Builder setActorSysMac(MacAddress actorSysMac);
+        int getActorPortPriority();
+        Builder setActorPortPriority(int actorPortPriority);
+        int getActorPortNum();
+        Builder setActorPortNum(int actorPortNum);
+        int getActorKey();
+        Builder setActorKey(int actorKey);
+        int getPartnerSysPriority();
+        Builder setPartnerSysPriority(int partnerSysPriority);
+        MacAddress getPartnerSysMac();
+        Builder setPartnerSysMac(MacAddress partnerSysMac);
+        int getPartnerPortPriority();
+        Builder setPartnerPortPriority(int partnerPortPriority);
+        int getPartnerPortNum();
+        Builder setPartnerPortNum(int partnerPortNum);
+        int getPartnerKey();
+        Builder setPartnerKey(int partnerKey);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpConvergenceStatusT.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpConvergenceStatusT.java
new file mode 100644
index 0000000..15505a2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpConvergenceStatusT.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnLacpConvergenceStatusT {
+     SUCCESS,
+     TIMEDOUT,
+     OUT_OF_SYNC;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsEntry.java
new file mode 100644
index 0000000..ac3ac18
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsEntry.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnLacpStatsEntry extends OFObject {
+    OFPort getPortNo();
+    int getActorSysPriority();
+    MacAddress getActorSysMac();
+    int getActorPortPriority();
+    int getActorPortNum();
+    int getActorKey();
+    short getConvergenceStatus();
+    int getPartnerSysPriority();
+    MacAddress getPartnerSysMac();
+    int getPartnerPortPriority();
+    int getPartnerPortNum();
+    int getPartnerKey();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnLacpStatsEntry build();
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        int getActorSysPriority();
+        Builder setActorSysPriority(int actorSysPriority);
+        MacAddress getActorSysMac();
+        Builder setActorSysMac(MacAddress actorSysMac);
+        int getActorPortPriority();
+        Builder setActorPortPriority(int actorPortPriority);
+        int getActorPortNum();
+        Builder setActorPortNum(int actorPortNum);
+        int getActorKey();
+        Builder setActorKey(int actorKey);
+        short getConvergenceStatus();
+        Builder setConvergenceStatus(short convergenceStatus);
+        int getPartnerSysPriority();
+        Builder setPartnerSysPriority(int partnerSysPriority);
+        MacAddress getPartnerSysMac();
+        Builder setPartnerSysMac(MacAddress partnerSysMac);
+        int getPartnerPortPriority();
+        Builder setPartnerPortPriority(int partnerPortPriority);
+        int getPartnerPortNum();
+        Builder setPartnerPortNum(int partnerPortNum);
+        int getPartnerKey();
+        Builder setPartnerKey(int partnerKey);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsReply.java
new file mode 100644
index 0000000..a1f354f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnLacpStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnLacpStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnLacpStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnLacpStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnLacpStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsRequest.java
new file mode 100644
index 0000000..f8765f3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLacpStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnLacpStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnLacpStatsReply>, OFRequest<OFBsnLacpStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnLacpStatsReply> {
+        OFBsnLacpStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLog.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLog.java
new file mode 100644
index 0000000..15c0862
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLog.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnLog extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    OFBsnLoglevel getLoglevel();
+    String getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnLog build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        OFBsnLoglevel getLoglevel();
+        Builder setLoglevel(OFBsnLoglevel loglevel);
+        String getData();
+        Builder setData(String data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLoglevel.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLoglevel.java
new file mode 100644
index 0000000..fd9cadd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnLoglevel.java
@@ -0,0 +1,34 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnLoglevel {
+     BSN_LOGLEVEL_MSG,
+     BSN_LOGLEVEL_ERROR,
+     BSN_LOGLEVEL_WARN,
+     BSN_LOGLEVEL_INFO,
+     BSN_LOGLEVEL_VERBOSE,
+     BSN_LOGLEVEL_TRACE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxReply.java
new file mode 100644
index 0000000..9601a76
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxReply.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnPduRxReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+    OFPort getPortNo();
+    short getSlotNum();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnPduRxReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        short getSlotNum();
+        Builder setSlotNum(short slotNum);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxRequest.java
new file mode 100644
index 0000000..1fa01cf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxRequest.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnPduRxRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnPduRxReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getTimeoutMs();
+    OFPort getPortNo();
+    short getSlotNum();
+    byte[] getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnPduRxRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getTimeoutMs();
+        Builder setTimeoutMs(long timeoutMs);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        short getSlotNum();
+        Builder setSlotNum(short slotNum);
+        byte[] getData();
+        Builder setData(byte[] data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxTimeout.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxTimeout.java
new file mode 100644
index 0000000..21f999d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduRxTimeout.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnPduRxTimeout extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    OFPort getPortNo();
+    short getSlotNum();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnPduRxTimeout build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        short getSlotNum();
+        Builder setSlotNum(short slotNum);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduSlotNumT.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduSlotNumT.java
new file mode 100644
index 0000000..a843ca2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduSlotNumT.java
@@ -0,0 +1,29 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnPduSlotNumT {
+     PDU_SLOT_NUM_ANY;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduTxReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduTxReply.java
new file mode 100644
index 0000000..50ee693
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduTxReply.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnPduTxReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+    OFPort getPortNo();
+    short getSlotNum();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnPduTxReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        short getSlotNum();
+        Builder setSlotNum(short slotNum);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduTxRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduTxRequest.java
new file mode 100644
index 0000000..22c4f72
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPduTxRequest.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnPduTxRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnPduTxReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getTxIntervalMs();
+    OFPort getPortNo();
+    short getSlotNum();
+    byte[] getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnPduTxRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getTxIntervalMs();
+        Builder setTxIntervalMs(long txIntervalMs);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        short getSlotNum();
+        Builder setSlotNum(short slotNum);
+        byte[] getData();
+        Builder setData(byte[] data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPktinFlag.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPktinFlag.java
new file mode 100644
index 0000000..1c45232
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPktinFlag.java
@@ -0,0 +1,39 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnPktinFlag {
+     BSN_PKTIN_FLAG_PDU,
+     BSN_PKTIN_FLAG_NEW_HOST,
+     BSN_PKTIN_FLAG_STATION_MOVE,
+     BSN_PKTIN_FLAG_ARP,
+     BSN_PKTIN_FLAG_DHCP,
+     BSN_PKTIN_FLAG_L2_CPU,
+     BSN_PKTIN_FLAG_DEBUG,
+     BSN_PKTIN_FLAG_TTL_EXPIRED,
+     BSN_PKTIN_FLAG_L3_MISS,
+     BSN_PKTIN_FLAG_L3_CPU,
+     BSN_PKTIN_FLAG_INGRESS_ACL;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounter.java
new file mode 100644
index 0000000..b73290a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounter.java
@@ -0,0 +1,55 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnPortCounter {
+     BSN_PORT_COUNTER_RX_BYTES,
+     BSN_PORT_COUNTER_RX_PACKETS_UNICAST,
+     BSN_PORT_COUNTER_RX_PACKETS_BROADCAST,
+     BSN_PORT_COUNTER_RX_PACKETS_MULTICAST,
+     BSN_PORT_COUNTER_RX_DROPPED,
+     BSN_PORT_COUNTER_RX_ERRORS,
+     BSN_PORT_COUNTER_TX_BYTES,
+     BSN_PORT_COUNTER_TX_PACKETS_UNICAST,
+     BSN_PORT_COUNTER_TX_PACKETS_BROADCAST,
+     BSN_PORT_COUNTER_TX_PACKETS_MULTICAST,
+     BSN_PORT_COUNTER_TX_DROPPED,
+     BSN_PORT_COUNTER_TX_ERRORS,
+     BSN_PORT_COUNTER_RX_RUNTS,
+     BSN_PORT_COUNTER_RX_GIANTS,
+     BSN_PORT_COUNTER_RX_CRC_ERRORS,
+     BSN_PORT_COUNTER_RX_ALIGNMENT_ERRORS,
+     BSN_PORT_COUNTER_RX_SYMBOL_ERRORS,
+     BSN_PORT_COUNTER_RX_PAUSE_INPUT,
+     BSN_PORT_COUNTER_TX_COLLISIONS,
+     BSN_PORT_COUNTER_TX_LATE_COLLISIONS,
+     BSN_PORT_COUNTER_TX_DEFERRED,
+     BSN_PORT_COUNTER_TX_PAUSE_OUTPUT,
+     BSN_PORT_COUNTER_RX_PACKETS,
+     BSN_PORT_COUNTER_TX_PACKETS,
+     BSN_PORT_COUNTER_RX_LENGTH_ERRORS,
+     BSN_PORT_COUNTER_RX_OVERFLOW_ERRORS,
+     BSN_PORT_COUNTER_TX_CARRIER_ERRORS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsEntry.java
new file mode 100644
index 0000000..19caab7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsEntry.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnPortCounterStatsEntry extends OFObject {
+    OFPort getPortNo();
+    List<U64> getValues();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnPortCounterStatsEntry build();
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        List<U64> getValues();
+        Builder setValues(List<U64> values);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsReply.java
new file mode 100644
index 0000000..4f618d5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnPortCounterStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnPortCounterStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnPortCounterStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnPortCounterStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnPortCounterStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsRequest.java
new file mode 100644
index 0000000..21ade35
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnPortCounterStatsRequest.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnPortCounterStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnPortCounterStatsReply>, OFRequest<OFBsnPortCounterStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    OFPort getPortNo();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnPortCounterStatsReply> {
+        OFBsnPortCounterStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnRoleStatus.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnRoleStatus.java
new file mode 100644
index 0000000..d28172c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnRoleStatus.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnRoleStatus extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    OFControllerRole getRole();
+    OFBsnControllerRoleReason getReason();
+    U64 getGenerationId();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnRoleStatus build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        OFControllerRole getRole();
+        Builder setRole(OFControllerRole role);
+        OFBsnControllerRoleReason getReason();
+        Builder setReason(OFBsnControllerRoleReason reason);
+        U64 getGenerationId();
+        Builder setGenerationId(U64 generationId);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetAuxCxnsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetAuxCxnsReply.java
new file mode 100644
index 0000000..6d0e2dd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetAuxCxnsReply.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetAuxCxnsReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getNumAux();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetAuxCxnsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getNumAux();
+        Builder setNumAux(long numAux);
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetAuxCxnsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetAuxCxnsRequest.java
new file mode 100644
index 0000000..9c7561f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetAuxCxnsRequest.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetAuxCxnsRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnSetAuxCxnsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getNumAux();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetAuxCxnsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getNumAux();
+        Builder setNumAux(long numAux);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetIpMask.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetIpMask.java
new file mode 100644
index 0000000..c435362
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetIpMask.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetIpMask extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getIndex();
+    long getMask();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetIpMask build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getIndex();
+        Builder setIndex(short index);
+        long getMask();
+        Builder setMask(long mask);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetL2TableReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetL2TableReply.java
new file mode 100644
index 0000000..3847e3a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetL2TableReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetL2TableReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    boolean isL2TableEnable();
+    int getL2TablePriority();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetL2TableReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        boolean isL2TableEnable();
+        Builder setL2TableEnable(boolean l2TableEnable);
+        int getL2TablePriority();
+        Builder setL2TablePriority(int l2TablePriority);
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetL2TableRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetL2TableRequest.java
new file mode 100644
index 0000000..efff0cc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetL2TableRequest.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetL2TableRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnSetL2TableReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    boolean isL2TableEnable();
+    int getL2TablePriority();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetL2TableRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        boolean isL2TableEnable();
+        Builder setL2TableEnable(boolean l2TableEnable);
+        int getL2TablePriority();
+        Builder setL2TablePriority(int l2TablePriority);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetLacpReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetLacpReply.java
new file mode 100644
index 0000000..4451548
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetLacpReply.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetLacpReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+    OFPort getPortNo();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetLacpReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetLacpRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetLacpRequest.java
new file mode 100644
index 0000000..a9c133d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetLacpRequest.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetLacpRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnSetLacpReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getEnabled();
+    OFPort getPortNo();
+    int getActorSysPriority();
+    MacAddress getActorSysMac();
+    int getActorPortPriority();
+    int getActorPortNum();
+    int getActorKey();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetLacpRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getEnabled();
+        Builder setEnabled(short enabled);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        int getActorSysPriority();
+        Builder setActorSysPriority(int actorSysPriority);
+        MacAddress getActorSysMac();
+        Builder setActorSysMac(MacAddress actorSysMac);
+        int getActorPortPriority();
+        Builder setActorPortPriority(int actorPortPriority);
+        int getActorPortNum();
+        Builder setActorPortNum(int actorPortNum);
+        int getActorKey();
+        Builder setActorKey(int actorKey);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetMirroring.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetMirroring.java
new file mode 100644
index 0000000..2a0e36c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetMirroring.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetMirroring extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    short getReportMirrorPorts();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetMirroring build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        short getReportMirrorPorts();
+        Builder setReportMirrorPorts(short reportMirrorPorts);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetPktinSuppressionReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetPktinSuppressionReply.java
new file mode 100644
index 0000000..33b4834
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetPktinSuppressionReply.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetPktinSuppressionReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetPktinSuppressionReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetPktinSuppressionRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetPktinSuppressionRequest.java
new file mode 100644
index 0000000..07a3f88
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetPktinSuppressionRequest.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetPktinSuppressionRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnSetPktinSuppressionReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    boolean isEnabled();
+    int getIdleTimeout();
+    int getHardTimeout();
+    int getPriority();
+    U64 getCookie();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetPktinSuppressionRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        boolean isEnabled();
+        Builder setEnabled(boolean enabled);
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout();
+        Builder setHardTimeout(int hardTimeout);
+        int getPriority();
+        Builder setPriority(int priority);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetSwitchPipelineReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetSwitchPipelineReply.java
new file mode 100644
index 0000000..23f377a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetSwitchPipelineReply.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetSwitchPipelineReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetSwitchPipelineReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetSwitchPipelineRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetSwitchPipelineRequest.java
new file mode 100644
index 0000000..5c6bb48
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSetSwitchPipelineRequest.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSetSwitchPipelineRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnSetSwitchPipelineReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    String getPipeline();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnSetSwitchPipelineRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        String getPipeline();
+        Builder setPipeline(String pipeline);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellCommand.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellCommand.java
new file mode 100644
index 0000000..a88be4b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellCommand.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnShellCommand extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getService();
+    byte[] getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnShellCommand build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getService();
+        Builder setService(long service);
+        byte[] getData();
+        Builder setData(byte[] data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellOutput.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellOutput.java
new file mode 100644
index 0000000..65f183a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellOutput.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnShellOutput extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    byte[] getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnShellOutput build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        byte[] getData();
+        Builder setData(byte[] data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellStatus.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellStatus.java
new file mode 100644
index 0000000..07ea119
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnShellStatus.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnShellStatus extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnShellStatus build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnStatsReply.java
new file mode 100644
index 0000000..ee045bc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnStatsReply extends OFObject, OFExperimenterStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFExperimenterStatsReply.Builder {
+        OFBsnStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnStatsRequest.java
new file mode 100644
index 0000000..f65bbb4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnStatsRequest<T extends OFBsnStatsReply> extends OFObject, OFExperimenterStatsRequest<T> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder<T> createBuilder();
+    public interface Builder<T extends OFBsnStatsReply> extends OFExperimenterStatsRequest.Builder<T> {
+        OFBsnStatsRequest<T> build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder<T> setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder<T> setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsEntry.java
new file mode 100644
index 0000000..7d11ed0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsEntry.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSwitchPipelineStatsEntry extends OFObject {
+    String getPipeline();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnSwitchPipelineStatsEntry build();
+        String getPipeline();
+        Builder setPipeline(String pipeline);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsReply.java
new file mode 100644
index 0000000..40cee33
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSwitchPipelineStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnSwitchPipelineStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnSwitchPipelineStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnSwitchPipelineStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnSwitchPipelineStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsRequest.java
new file mode 100644
index 0000000..e395412
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnSwitchPipelineStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnSwitchPipelineStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnSwitchPipelineStatsReply>, OFRequest<OFBsnSwitchPipelineStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnSwitchPipelineStatsReply> {
+        OFBsnSwitchPipelineStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsEntry.java
new file mode 100644
index 0000000..399a16a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsEntry.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTableChecksumStatsEntry extends OFObject {
+    TableId getTableId();
+    U64 getChecksum();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnTableChecksumStatsEntry build();
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        U64 getChecksum();
+        Builder setChecksum(U64 checksum);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsReply.java
new file mode 100644
index 0000000..dadef01c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTableChecksumStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnTableChecksumStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnTableChecksumStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnTableChecksumStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnTableChecksumStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsRequest.java
new file mode 100644
index 0000000..121f74b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableChecksumStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTableChecksumStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnTableChecksumStatsReply>, OFRequest<OFBsnTableChecksumStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnTableChecksumStatsReply> {
+        OFBsnTableChecksumStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableSetBucketsSize.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableSetBucketsSize.java
new file mode 100644
index 0000000..f86f447
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTableSetBucketsSize.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTableSetBucketsSize extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    TableId getTableId();
+    long getBucketsSize();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnTableSetBucketsSize build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        long getBucketsSize();
+        Builder setBucketsSize(long bucketsSize);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTcpFlag.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTcpFlag.java
new file mode 100644
index 0000000..0883a10
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTcpFlag.java
@@ -0,0 +1,37 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnTcpFlag {
+     BSN_TCP_FLAG_FIN,
+     BSN_TCP_FLAG_SYN,
+     BSN_TCP_FLAG_RST,
+     BSN_TCP_FLAG_PSH,
+     BSN_TCP_FLAG_ACK,
+     BSN_TCP_FLAG_URG,
+     BSN_TCP_FLAG_ECE,
+     BSN_TCP_FLAG_CWR,
+     BSN_TCP_FLAG_NS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTimeReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTimeReply.java
new file mode 100644
index 0000000..2b73179
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTimeReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTimeReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    U64 getTimeMs();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnTimeReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        U64 getTimeMs();
+        Builder setTimeMs(U64 timeMs);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTimeRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTimeRequest.java
new file mode 100644
index 0000000..438f2d5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnTimeRequest.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTimeRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnTimeReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnTimeRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnUdfAnchor.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnUdfAnchor.java
new file mode 100644
index 0000000..afdd4c8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnUdfAnchor.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnUdfAnchor {
+     BSN_UDF_ANCHOR_PACKET_START,
+     BSN_UDF_ANCHOR_L3_HEADER_START,
+     BSN_UDF_ANCHOR_L4_HEADER_START;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortCreateReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortCreateReply.java
new file mode 100644
index 0000000..5e17e22
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortCreateReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVirtualPortCreateReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+    long getVportNo();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnVirtualPortCreateReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+        long getVportNo();
+        Builder setVportNo(long vportNo);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortCreateRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortCreateRequest.java
new file mode 100644
index 0000000..e916e0f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortCreateRequest.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVirtualPortCreateRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnVirtualPortCreateReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    OFBsnVport getVport();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnVirtualPortCreateRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        OFBsnVport getVport();
+        Builder setVport(OFBsnVport vport);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortRemoveReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortRemoveReply.java
new file mode 100644
index 0000000..d83182e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortRemoveReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVirtualPortRemoveReply extends OFObject, OFBsnHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getStatus();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnVirtualPortRemoveReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getStatus();
+        Builder setStatus(long status);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortRemoveRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortRemoveRequest.java
new file mode 100644
index 0000000..ae43dea
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVirtualPortRemoveRequest.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVirtualPortRemoveRequest extends OFObject, OFBsnHeader, OFRequest<OFBsnVirtualPortRemoveReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    long getVportNo();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnHeader.Builder {
+        OFBsnVirtualPortRemoveRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        long getVportNo();
+        Builder setVportNo(long vportNo);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterConstants.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterConstants.java
new file mode 100644
index 0000000..0c85363
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterConstants.java
@@ -0,0 +1,29 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnVlanCounterConstants {
+     BSN_VLAN_ALL;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsEntry.java
new file mode 100644
index 0000000..d8e2dde
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsEntry.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVlanCounterStatsEntry extends OFObject {
+    int getVlanVid();
+    List<U64> getValues();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnVlanCounterStatsEntry build();
+        int getVlanVid();
+        Builder setVlanVid(int vlanVid);
+        List<U64> getValues();
+        Builder setValues(List<U64> values);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsReply.java
new file mode 100644
index 0000000..0789370
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVlanCounterStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnVlanCounterStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnVlanCounterStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnVlanCounterStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnVlanCounterStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsRequest.java
new file mode 100644
index 0000000..b29f0d9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterStatsRequest.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVlanCounterStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnVlanCounterStatsReply>, OFRequest<OFBsnVlanCounterStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    int getVlanVid();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnVlanCounterStatsReply> {
+        OFBsnVlanCounterStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        int getVlanVid();
+        Builder setVlanVid(int vlanVid);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterT.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterT.java
new file mode 100644
index 0000000..911f702
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVlanCounterT.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnVlanCounterT {
+     BSN_VLAN_COUNTER_RX_BYTES,
+     BSN_VLAN_COUNTER_RX_PACKETS,
+     BSN_VLAN_COUNTER_TX_BYTES,
+     BSN_VLAN_COUNTER_TX_PACKETS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVport.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVport.java
new file mode 100644
index 0000000..20f71bf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVport.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVport extends OFObject {
+    int getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnVport build();
+        int getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportL2Gre.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportL2Gre.java
new file mode 100644
index 0000000..58144b1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportL2Gre.java
@@ -0,0 +1,77 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVportL2Gre extends OFObject, OFBsnVport {
+    int getType();
+    Set<OFBsnVportL2GreFlags> getFlags();
+    OFPort getPortNo();
+    OFPort getLoopbackPortNo();
+    MacAddress getLocalMac();
+    MacAddress getNhMac();
+    IPv4Address getSrcIp();
+    IPv4Address getDstIp();
+    short getDscp();
+    short getTtl();
+    long getVpn();
+    long getRateLimit();
+    String getIfName();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnVport.Builder {
+        OFBsnVportL2Gre build();
+        int getType();
+        Set<OFBsnVportL2GreFlags> getFlags();
+        Builder setFlags(Set<OFBsnVportL2GreFlags> flags);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        OFPort getLoopbackPortNo();
+        Builder setLoopbackPortNo(OFPort loopbackPortNo);
+        MacAddress getLocalMac();
+        Builder setLocalMac(MacAddress localMac);
+        MacAddress getNhMac();
+        Builder setNhMac(MacAddress nhMac);
+        IPv4Address getSrcIp();
+        Builder setSrcIp(IPv4Address srcIp);
+        IPv4Address getDstIp();
+        Builder setDstIp(IPv4Address dstIp);
+        short getDscp();
+        Builder setDscp(short dscp);
+        short getTtl();
+        Builder setTtl(short ttl);
+        long getVpn();
+        Builder setVpn(long vpn);
+        long getRateLimit();
+        Builder setRateLimit(long rateLimit);
+        String getIfName();
+        Builder setIfName(String ifName);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportL2GreFlags.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportL2GreFlags.java
new file mode 100644
index 0000000..8a8728b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportL2GreFlags.java
@@ -0,0 +1,33 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnVportL2GreFlags {
+     BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID,
+     BSN_VPORT_L2GRE_DSCP_ASSIGN,
+     BSN_VPORT_L2GRE_DSCP_COPY,
+     BSN_VPORT_L2GRE_LOOPBACK_IS_VALID,
+     BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQ.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQ.java
new file mode 100644
index 0000000..3b05be9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQ.java
@@ -0,0 +1,58 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVportQInQ extends OFObject, OFBsnVport {
+    int getType();
+    long getPortNo();
+    int getIngressTpid();
+    int getIngressVlanId();
+    int getEgressTpid();
+    int getEgressVlanId();
+    String getIfName();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnVport.Builder {
+        OFBsnVportQInQ build();
+        int getType();
+        long getPortNo();
+        Builder setPortNo(long portNo);
+        int getIngressTpid();
+        Builder setIngressTpid(int ingressTpid);
+        int getIngressVlanId();
+        Builder setIngressVlanId(int ingressVlanId);
+        int getEgressTpid();
+        Builder setEgressTpid(int egressTpid);
+        int getEgressVlanId();
+        Builder setEgressVlanId(int egressVlanId);
+        String getIfName();
+        Builder setIfName(String ifName);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQUntagged.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQUntagged.java
new file mode 100644
index 0000000..7e2a4be
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportQInQUntagged.java
@@ -0,0 +1,29 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnVportQInQUntagged {
+     BSN_VPORT_Q_IN_Q_UNTAGGED;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportStatus.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportStatus.java
new file mode 100644
index 0000000..f5e3132
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVportStatus.java
@@ -0,0 +1,30 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnVportStatus {
+     BSN_VPORT_STATUS_OK,
+     BSN_VPORT_STATUS_FAILED;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterConstants.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterConstants.java
new file mode 100644
index 0000000..21088de
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterConstants.java
@@ -0,0 +1,29 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnVrfCounterConstants {
+     BSN_VRF_ALL;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsEntry.java
new file mode 100644
index 0000000..18d6245
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsEntry.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVrfCounterStatsEntry extends OFObject {
+    long getVrf();
+    List<U64> getValues();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnVrfCounterStatsEntry build();
+        long getVrf();
+        Builder setVrf(long vrf);
+        List<U64> getValues();
+        Builder setValues(List<U64> values);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsReply.java
new file mode 100644
index 0000000..2a564d0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsReply.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVrfCounterStatsReply extends OFObject, OFBsnStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    List<OFBsnVrfCounterStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsReply.Builder {
+        OFBsnVrfCounterStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        List<OFBsnVrfCounterStatsEntry> getEntries();
+        Builder setEntries(List<OFBsnVrfCounterStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsRequest.java
new file mode 100644
index 0000000..36bd75b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterStatsRequest.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnVrfCounterStatsRequest extends OFObject, OFBsnStatsRequest<OFBsnVrfCounterStatsReply>, OFRequest<OFBsnVrfCounterStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+    long getSubtype();
+    long getVrf();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnStatsRequest.Builder<OFBsnVrfCounterStatsReply> {
+        OFBsnVrfCounterStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+        long getSubtype();
+        long getVrf();
+        Builder setVrf(long vrf);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterT.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterT.java
new file mode 100644
index 0000000..38e537d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBsnVrfCounterT.java
@@ -0,0 +1,30 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFBsnVrfCounterT {
+     BSN_VRF_COUNTER_BYTES,
+     BSN_VRF_COUNTER_PACKETS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBucket.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBucket.java
new file mode 100644
index 0000000..02af70a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBucket.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBucket extends OFObject {
+    int getWeight();
+    OFPort getWatchPort();
+    OFGroup getWatchGroup();
+    List<OFAction> getActions();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBucket build();
+        int getWeight();
+        Builder setWeight(int weight);
+        OFPort getWatchPort();
+        Builder setWatchPort(OFPort watchPort);
+        OFGroup getWatchGroup();
+        Builder setWatchGroup(OFGroup watchGroup);
+        List<OFAction> getActions();
+        Builder setActions(List<OFAction> actions);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBucketCounter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBucketCounter.java
new file mode 100644
index 0000000..7ee630a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFBucketCounter.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBucketCounter extends OFObject {
+    U64 getPacketCount();
+    U64 getByteCount();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBucketCounter build();
+        U64 getPacketCount();
+        Builder setPacketCount(U64 packetCount);
+        U64 getByteCount();
+        Builder setByteCount(U64 byteCount);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFCapabilities.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFCapabilities.java
new file mode 100644
index 0000000..5444962
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFCapabilities.java
@@ -0,0 +1,38 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFCapabilities {
+     FLOW_STATS,
+     TABLE_STATS,
+     PORT_STATS,
+     STP,
+     RESERVED,
+     IP_REASM,
+     QUEUE_STATS,
+     ARP_MATCH_IP,
+     GROUP_STATS,
+     PORT_BLOCKED;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFConfigFlags.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFConfigFlags.java
new file mode 100644
index 0000000..8ea061b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFConfigFlags.java
@@ -0,0 +1,33 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFConfigFlags {
+     FRAG_NORMAL,
+     FRAG_DROP,
+     FRAG_REASM,
+     FRAG_MASK,
+     INVALID_TTL_TO_CONTROLLER;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFControllerMaxLen.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFControllerMaxLen.java
new file mode 100644
index 0000000..c2759d9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFControllerMaxLen.java
@@ -0,0 +1,30 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFControllerMaxLen {
+     MAX,
+     NO_BUFFER;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFControllerRole.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFControllerRole.java
new file mode 100644
index 0000000..4880189
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFControllerRole.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFControllerRole {
+     ROLE_NOCHANGE,
+     ROLE_EQUAL,
+     ROLE_MASTER,
+     ROLE_SLAVE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFDescStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFDescStatsReply.java
new file mode 100644
index 0000000..cdcd1bf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFDescStatsReply.java
@@ -0,0 +1,64 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFDescStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    String getMfrDesc();
+    String getHwDesc();
+    String getSwDesc();
+    String getSerialNum();
+    String getDpDesc();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFDescStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        String getMfrDesc();
+        Builder setMfrDesc(String mfrDesc);
+        String getHwDesc();
+        Builder setHwDesc(String hwDesc);
+        String getSwDesc();
+        Builder setSwDesc(String swDesc);
+        String getSerialNum();
+        Builder setSerialNum(String serialNum);
+        String getDpDesc();
+        Builder setDpDesc(String dpDesc);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFDescStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFDescStatsRequest.java
new file mode 100644
index 0000000..e0efe40
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFDescStatsRequest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFDescStatsRequest extends OFObject, OFStatsRequest<OFDescStatsReply>, OFRequest<OFDescStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFDescStatsReply> {
+        OFDescStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFEchoReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFEchoReply.java
new file mode 100644
index 0000000..ba8b181
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFEchoReply.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFEchoReply extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    byte[] getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFEchoReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        byte[] getData();
+        Builder setData(byte[] data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFEchoRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFEchoRequest.java
new file mode 100644
index 0000000..6276280
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFEchoRequest.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFEchoRequest extends OFObject, OFMessage, OFRequest<OFEchoReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    byte[] getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFEchoRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        byte[] getData();
+        Builder setData(byte[] data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFErrorMsg.java
new file mode 100644
index 0000000..dea4e97
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFErrorMsg.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFErrorMsg extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFErrorType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFErrorType.java
new file mode 100644
index 0000000..53fd319
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFErrorType.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFErrorType {
+     HELLO_FAILED,
+     BAD_REQUEST,
+     BAD_ACTION,
+     FLOW_MOD_FAILED,
+     PORT_MOD_FAILED,
+     QUEUE_OP_FAILED,
+     BAD_INSTRUCTION,
+     BAD_MATCH,
+     GROUP_MOD_FAILED,
+     TABLE_MOD_FAILED,
+     SWITCH_CONFIG_FAILED,
+     ROLE_REQUEST_FAILED,
+     EXPERIMENTER,
+     METER_MOD_FAILED,
+     TABLE_FEATURES_FAILED;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenter.java
new file mode 100644
index 0000000..f953879
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenter.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFExperimenter extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFExperimenter build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenterStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenterStatsReply.java
new file mode 100644
index 0000000..a308ab2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenterStatsReply.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFExperimenterStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getExperimenter();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFExperimenterStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getExperimenter();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenterStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenterStatsRequest.java
new file mode 100644
index 0000000..bb92557
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFExperimenterStatsRequest.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFExperimenterStatsRequest<T extends OFExperimenterStatsReply> extends OFObject, OFStatsRequest<T> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getExperimenter();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder<T> createBuilder();
+    public interface Builder<T extends OFExperimenterStatsReply> extends OFStatsRequest.Builder<T> {
+        OFExperimenterStatsRequest<T> build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder<T> setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder<T> setFlags(Set<OFStatsRequestFlags> flags);
+        long getExperimenter();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFactories.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFactories.java
new file mode 100644
index 0000000..afc2f1f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFactories.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factories.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public final class OFFactories {
+
+    private static final GenericReader GENERIC_READER = new GenericReader();
+
+    public static OFFactory getFactory(OFVersion version) {
+        switch(version) {
+            case OF_10:
+                return org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10.INSTANCE;
+            case OF_11:
+                return org.projectfloodlight.openflow.protocol.ver11.OFFactoryVer11.INSTANCE;
+            case OF_12:
+                return org.projectfloodlight.openflow.protocol.ver12.OFFactoryVer12.INSTANCE;
+            case OF_13:
+                return org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13.INSTANCE;
+            default:
+                throw new IllegalArgumentException("Unknown version: "+version);
+            }
+    }
+
+    private static class GenericReader implements OFMessageReader<OFMessage> {
+        public OFMessage readFrom(ChannelBuffer bb) throws OFParseError {
+            short wireVersion = U8.f(bb.getByte(0));
+            OFFactory factory;
+            switch (wireVersion) {
+            case 1:
+                factory = org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10.INSTANCE;
+                break;
+            case 2:
+                factory = org.projectfloodlight.openflow.protocol.ver11.OFFactoryVer11.INSTANCE;
+                break;
+            case 3:
+                factory = org.projectfloodlight.openflow.protocol.ver12.OFFactoryVer12.INSTANCE;
+                break;
+            case 4:
+                factory = org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13.INSTANCE;
+                break;
+            default:
+                throw new IllegalArgumentException("Unknown wire version: " + wireVersion);
+            }
+            return factory.getReader().readFrom(bb);
+        }
+    }
+
+    public static OFMessageReader<OFMessage> getGenericReader() {
+        return GENERIC_READER;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFactory.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFactory.java
new file mode 100644
index 0000000..7f1ae47
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFactory.java
@@ -0,0 +1,336 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+
+public interface OFFactory extends XidGenerator {
+    // Subfactories
+    OFActions actions();
+    OFInstructions instructions();
+    OFMeterBands meterBands();
+    OFOxms oxms();
+    OFQueueProps queueProps();
+    OFErrorMsgs errorMsgs();
+    OFActionIds actionIds();
+    OFInstructionIds instructionIds();
+    OFBsnTlvs bsnTlvs();
+
+    OFAggregateStatsReply.Builder buildAggregateStatsReply();
+    OFAggregateStatsRequest.Builder buildAggregateStatsRequest();
+    OFBarrierReply.Builder buildBarrierReply();
+    OFBarrierReply barrierReply();
+    OFBarrierRequest.Builder buildBarrierRequest();
+    OFBarrierRequest barrierRequest();
+    OFBsnBwClearDataReply.Builder buildBsnBwClearDataReply();
+    OFBsnBwClearDataReply bsnBwClearDataReply(long status);
+    OFBsnBwClearDataRequest.Builder buildBsnBwClearDataRequest();
+    OFBsnBwClearDataRequest bsnBwClearDataRequest();
+    OFBsnBwEnableGetReply.Builder buildBsnBwEnableGetReply();
+    OFBsnBwEnableGetReply bsnBwEnableGetReply(long enabled);
+    OFBsnBwEnableGetRequest.Builder buildBsnBwEnableGetRequest();
+    OFBsnBwEnableGetRequest bsnBwEnableGetRequest();
+    OFBsnBwEnableSetReply.Builder buildBsnBwEnableSetReply();
+    OFBsnBwEnableSetRequest.Builder buildBsnBwEnableSetRequest();
+    OFBsnBwEnableSetRequest bsnBwEnableSetRequest(long enable);
+    OFBsnGetInterfacesReply.Builder buildBsnGetInterfacesReply();
+    OFBsnGetInterfacesReply bsnGetInterfacesReply(List<OFBsnInterface> interfaces);
+    OFBsnGetInterfacesRequest.Builder buildBsnGetInterfacesRequest();
+    OFBsnGetInterfacesRequest bsnGetInterfacesRequest();
+    OFBsnGetIpMaskReply.Builder buildBsnGetIpMaskReply() throws UnsupportedOperationException;
+    OFBsnGetIpMaskRequest.Builder buildBsnGetIpMaskRequest() throws UnsupportedOperationException;
+    OFBsnGetIpMaskRequest bsnGetIpMaskRequest(short index);
+    OFBsnGetL2TableReply.Builder buildBsnGetL2TableReply() throws UnsupportedOperationException;
+    OFBsnGetL2TableRequest.Builder buildBsnGetL2TableRequest() throws UnsupportedOperationException;
+    OFBsnGetL2TableRequest bsnGetL2TableRequest();
+    OFBsnGetMirroringReply.Builder buildBsnGetMirroringReply();
+    OFBsnGetMirroringReply bsnGetMirroringReply(short reportMirrorPorts);
+    OFBsnGetMirroringRequest.Builder buildBsnGetMirroringRequest();
+    OFBsnGetMirroringRequest bsnGetMirroringRequest(short reportMirrorPorts);
+    OFBsnHybridGetReply.Builder buildBsnHybridGetReply() throws UnsupportedOperationException;
+    OFBsnHybridGetRequest.Builder buildBsnHybridGetRequest() throws UnsupportedOperationException;
+    OFBsnHybridGetRequest bsnHybridGetRequest();
+    OFBsnInterface.Builder buildBsnInterface();
+    OFBsnPduRxReply.Builder buildBsnPduRxReply();
+    OFBsnPduRxRequest.Builder buildBsnPduRxRequest();
+    OFBsnPduRxTimeout.Builder buildBsnPduRxTimeout();
+    OFBsnPduTxReply.Builder buildBsnPduTxReply();
+    OFBsnPduTxRequest.Builder buildBsnPduTxRequest();
+    OFBsnSetIpMask.Builder buildBsnSetIpMask() throws UnsupportedOperationException;
+    OFBsnSetL2TableReply.Builder buildBsnSetL2TableReply() throws UnsupportedOperationException;
+    OFBsnSetL2TableRequest.Builder buildBsnSetL2TableRequest() throws UnsupportedOperationException;
+    OFBsnSetMirroring.Builder buildBsnSetMirroring();
+    OFBsnSetMirroring bsnSetMirroring(short reportMirrorPorts);
+    OFBsnSetPktinSuppressionReply.Builder buildBsnSetPktinSuppressionReply();
+    OFBsnSetPktinSuppressionReply bsnSetPktinSuppressionReply(long status);
+    OFBsnSetPktinSuppressionRequest.Builder buildBsnSetPktinSuppressionRequest();
+    OFBsnShellCommand.Builder buildBsnShellCommand() throws UnsupportedOperationException;
+    OFBsnShellOutput.Builder buildBsnShellOutput() throws UnsupportedOperationException;
+    OFBsnShellOutput bsnShellOutput(byte[] data);
+    OFBsnShellStatus.Builder buildBsnShellStatus() throws UnsupportedOperationException;
+    OFBsnShellStatus bsnShellStatus(long status);
+    OFBsnVirtualPortCreateReply.Builder buildBsnVirtualPortCreateReply();
+    OFBsnVirtualPortCreateRequest.Builder buildBsnVirtualPortCreateRequest();
+    OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest(OFBsnVport vport);
+    OFBsnVirtualPortRemoveReply.Builder buildBsnVirtualPortRemoveReply();
+    OFBsnVirtualPortRemoveReply bsnVirtualPortRemoveReply(long status);
+    OFBsnVirtualPortRemoveRequest.Builder buildBsnVirtualPortRemoveRequest();
+    OFBsnVirtualPortRemoveRequest bsnVirtualPortRemoveRequest(long vportNo);
+    OFBsnVportL2Gre.Builder buildBsnVportL2Gre();
+    OFBsnVportQInQ.Builder buildBsnVportQInQ();
+    OFDescStatsReply.Builder buildDescStatsReply();
+    OFDescStatsRequest.Builder buildDescStatsRequest();
+    OFDescStatsRequest descStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFEchoReply.Builder buildEchoReply();
+    OFEchoReply echoReply(byte[] data);
+    OFEchoRequest.Builder buildEchoRequest();
+    OFEchoRequest echoRequest(byte[] data);
+    OFFeaturesReply.Builder buildFeaturesReply();
+    OFFeaturesRequest.Builder buildFeaturesRequest();
+    OFFeaturesRequest featuresRequest();
+    OFFlowAdd.Builder buildFlowAdd();
+    OFFlowDelete.Builder buildFlowDelete();
+    OFFlowDeleteStrict.Builder buildFlowDeleteStrict();
+    OFFlowModify.Builder buildFlowModify();
+    OFFlowModifyStrict.Builder buildFlowModifyStrict();
+    OFFlowRemoved.Builder buildFlowRemoved();
+    OFFlowStatsEntry.Builder buildFlowStatsEntry();
+    OFFlowStatsReply.Builder buildFlowStatsReply();
+    OFFlowStatsRequest.Builder buildFlowStatsRequest();
+    OFGetConfigReply.Builder buildGetConfigReply();
+    OFGetConfigRequest.Builder buildGetConfigRequest();
+    OFGetConfigRequest getConfigRequest();
+    OFHello.Builder buildHello();
+    OFHello hello(List<OFHelloElem> elements);
+    OFMatchV1.Builder buildMatchV1() throws UnsupportedOperationException;
+    OFNiciraControllerRoleReply.Builder buildNiciraControllerRoleReply() throws UnsupportedOperationException;
+    OFNiciraControllerRoleReply niciraControllerRoleReply(OFNiciraControllerRole role);
+    OFNiciraControllerRoleRequest.Builder buildNiciraControllerRoleRequest() throws UnsupportedOperationException;
+    OFNiciraControllerRoleRequest niciraControllerRoleRequest(OFNiciraControllerRole role);
+    OFPacketIn.Builder buildPacketIn();
+    OFPacketOut.Builder buildPacketOut();
+    OFPacketQueue.Builder buildPacketQueue();
+    OFPortDesc.Builder buildPortDesc();
+    OFPortMod.Builder buildPortMod();
+    OFPortStatsEntry.Builder buildPortStatsEntry();
+    OFPortStatsReply.Builder buildPortStatsReply();
+    OFPortStatsRequest.Builder buildPortStatsRequest();
+    OFPortStatus.Builder buildPortStatus();
+    OFQueueGetConfigReply.Builder buildQueueGetConfigReply();
+    OFQueueGetConfigRequest.Builder buildQueueGetConfigRequest();
+    OFQueueGetConfigRequest queueGetConfigRequest(OFPort port);
+    OFQueueStatsEntry.Builder buildQueueStatsEntry();
+    OFQueueStatsReply.Builder buildQueueStatsReply();
+    OFQueueStatsRequest.Builder buildQueueStatsRequest();
+    OFSetConfig.Builder buildSetConfig();
+    OFTableMod.Builder buildTableMod();
+    OFTableStatsEntry.Builder buildTableStatsEntry();
+    OFTableStatsReply.Builder buildTableStatsReply();
+    OFTableStatsRequest.Builder buildTableStatsRequest();
+    OFTableStatsRequest tableStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBucket.Builder buildBucket() throws UnsupportedOperationException;
+    OFBucketCounter.Builder buildBucketCounter() throws UnsupportedOperationException;
+    OFBucketCounter bucketCounter(U64 packetCount, U64 byteCount);
+    OFGroupAdd.Builder buildGroupAdd() throws UnsupportedOperationException;
+    OFGroupDelete.Builder buildGroupDelete() throws UnsupportedOperationException;
+    OFGroupDescStatsEntry.Builder buildGroupDescStatsEntry() throws UnsupportedOperationException;
+    OFGroupDescStatsReply.Builder buildGroupDescStatsReply() throws UnsupportedOperationException;
+    OFGroupDescStatsRequest.Builder buildGroupDescStatsRequest() throws UnsupportedOperationException;
+    OFGroupDescStatsRequest groupDescStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFGroupModify.Builder buildGroupModify() throws UnsupportedOperationException;
+    OFGroupStatsEntry.Builder buildGroupStatsEntry() throws UnsupportedOperationException;
+    OFGroupStatsReply.Builder buildGroupStatsReply() throws UnsupportedOperationException;
+    OFGroupStatsRequest.Builder buildGroupStatsRequest() throws UnsupportedOperationException;
+    OFMatchV2.Builder buildMatchV2() throws UnsupportedOperationException;
+    OFGroupFeaturesStatsReply.Builder buildGroupFeaturesStatsReply() throws UnsupportedOperationException;
+    OFGroupFeaturesStatsRequest.Builder buildGroupFeaturesStatsRequest() throws UnsupportedOperationException;
+    OFGroupFeaturesStatsRequest groupFeaturesStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFMatchV3.Builder buildMatchV3() throws UnsupportedOperationException;
+    OFMatchV3 matchV3(OFOxmList oxmList);
+    OFRoleReply.Builder buildRoleReply() throws UnsupportedOperationException;
+    OFRoleRequest.Builder buildRoleRequest() throws UnsupportedOperationException;
+    OFAsyncGetReply.Builder buildAsyncGetReply() throws UnsupportedOperationException;
+    OFAsyncGetRequest.Builder buildAsyncGetRequest() throws UnsupportedOperationException;
+    OFAsyncSet.Builder buildAsyncSet() throws UnsupportedOperationException;
+    OFBsnArpIdle.Builder buildBsnArpIdle() throws UnsupportedOperationException;
+    OFBsnControllerConnection.Builder buildBsnControllerConnection() throws UnsupportedOperationException;
+    OFBsnControllerConnectionsReply.Builder buildBsnControllerConnectionsReply() throws UnsupportedOperationException;
+    OFBsnControllerConnectionsReply bsnControllerConnectionsReply(List<OFBsnControllerConnection> connections);
+    OFBsnControllerConnectionsRequest.Builder buildBsnControllerConnectionsRequest() throws UnsupportedOperationException;
+    OFBsnControllerConnectionsRequest bsnControllerConnectionsRequest();
+    OFBsnDebugCounterDescStatsEntry.Builder buildBsnDebugCounterDescStatsEntry() throws UnsupportedOperationException;
+    OFBsnDebugCounterDescStatsReply.Builder buildBsnDebugCounterDescStatsReply() throws UnsupportedOperationException;
+    OFBsnDebugCounterDescStatsRequest.Builder buildBsnDebugCounterDescStatsRequest() throws UnsupportedOperationException;
+    OFBsnDebugCounterDescStatsRequest bsnDebugCounterDescStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBsnDebugCounterStatsEntry.Builder buildBsnDebugCounterStatsEntry() throws UnsupportedOperationException;
+    OFBsnDebugCounterStatsEntry bsnDebugCounterStatsEntry(U64 counterId, U64 value);
+    OFBsnDebugCounterStatsReply.Builder buildBsnDebugCounterStatsReply() throws UnsupportedOperationException;
+    OFBsnDebugCounterStatsRequest.Builder buildBsnDebugCounterStatsRequest() throws UnsupportedOperationException;
+    OFBsnDebugCounterStatsRequest bsnDebugCounterStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBsnFlowChecksumBucketStatsEntry.Builder buildBsnFlowChecksumBucketStatsEntry() throws UnsupportedOperationException;
+    OFBsnFlowChecksumBucketStatsEntry bsnFlowChecksumBucketStatsEntry(U64 checksum);
+    OFBsnFlowChecksumBucketStatsReply.Builder buildBsnFlowChecksumBucketStatsReply() throws UnsupportedOperationException;
+    OFBsnFlowChecksumBucketStatsRequest.Builder buildBsnFlowChecksumBucketStatsRequest() throws UnsupportedOperationException;
+    OFBsnFlowIdle.Builder buildBsnFlowIdle() throws UnsupportedOperationException;
+    OFBsnFlowIdleEnableGetReply.Builder buildBsnFlowIdleEnableGetReply() throws UnsupportedOperationException;
+    OFBsnFlowIdleEnableGetReply bsnFlowIdleEnableGetReply(long enabled);
+    OFBsnFlowIdleEnableGetRequest.Builder buildBsnFlowIdleEnableGetRequest() throws UnsupportedOperationException;
+    OFBsnFlowIdleEnableGetRequest bsnFlowIdleEnableGetRequest();
+    OFBsnFlowIdleEnableSetReply.Builder buildBsnFlowIdleEnableSetReply() throws UnsupportedOperationException;
+    OFBsnFlowIdleEnableSetRequest.Builder buildBsnFlowIdleEnableSetRequest() throws UnsupportedOperationException;
+    OFBsnFlowIdleEnableSetRequest bsnFlowIdleEnableSetRequest(long enable);
+    OFBsnGentableBucketStatsEntry.Builder buildBsnGentableBucketStatsEntry() throws UnsupportedOperationException;
+    OFBsnGentableBucketStatsEntry bsnGentableBucketStatsEntry(U128 checksum);
+    OFBsnGentableBucketStatsReply.Builder buildBsnGentableBucketStatsReply() throws UnsupportedOperationException;
+    OFBsnGentableBucketStatsRequest.Builder buildBsnGentableBucketStatsRequest() throws UnsupportedOperationException;
+    OFBsnGentableClearReply.Builder buildBsnGentableClearReply() throws UnsupportedOperationException;
+    OFBsnGentableClearRequest.Builder buildBsnGentableClearRequest() throws UnsupportedOperationException;
+    OFBsnGentableDescStatsEntry.Builder buildBsnGentableDescStatsEntry() throws UnsupportedOperationException;
+    OFBsnGentableDescStatsReply.Builder buildBsnGentableDescStatsReply() throws UnsupportedOperationException;
+    OFBsnGentableDescStatsRequest.Builder buildBsnGentableDescStatsRequest() throws UnsupportedOperationException;
+    OFBsnGentableDescStatsRequest bsnGentableDescStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBsnGentableEntryAdd.Builder buildBsnGentableEntryAdd() throws UnsupportedOperationException;
+    OFBsnGentableEntryDelete.Builder buildBsnGentableEntryDelete() throws UnsupportedOperationException;
+    OFBsnGentableEntryDescStatsEntry.Builder buildBsnGentableEntryDescStatsEntry() throws UnsupportedOperationException;
+    OFBsnGentableEntryDescStatsReply.Builder buildBsnGentableEntryDescStatsReply() throws UnsupportedOperationException;
+    OFBsnGentableEntryDescStatsRequest.Builder buildBsnGentableEntryDescStatsRequest() throws UnsupportedOperationException;
+    OFBsnGentableEntryStatsEntry.Builder buildBsnGentableEntryStatsEntry() throws UnsupportedOperationException;
+    OFBsnGentableEntryStatsEntry bsnGentableEntryStatsEntry(List<OFBsnTlv> key, List<OFBsnTlv> stats);
+    OFBsnGentableEntryStatsReply.Builder buildBsnGentableEntryStatsReply() throws UnsupportedOperationException;
+    OFBsnGentableEntryStatsRequest.Builder buildBsnGentableEntryStatsRequest() throws UnsupportedOperationException;
+    OFBsnGentableSetBucketsSize.Builder buildBsnGentableSetBucketsSize() throws UnsupportedOperationException;
+    OFBsnGentableStatsEntry.Builder buildBsnGentableStatsEntry() throws UnsupportedOperationException;
+    OFBsnGentableStatsReply.Builder buildBsnGentableStatsReply() throws UnsupportedOperationException;
+    OFBsnGentableStatsRequest.Builder buildBsnGentableStatsRequest() throws UnsupportedOperationException;
+    OFBsnGentableStatsRequest bsnGentableStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBsnGetSwitchPipelineReply.Builder buildBsnGetSwitchPipelineReply() throws UnsupportedOperationException;
+    OFBsnGetSwitchPipelineReply bsnGetSwitchPipelineReply(String pipeline);
+    OFBsnGetSwitchPipelineRequest.Builder buildBsnGetSwitchPipelineRequest() throws UnsupportedOperationException;
+    OFBsnGetSwitchPipelineRequest bsnGetSwitchPipelineRequest();
+    OFBsnImageDescStatsReply.Builder buildBsnImageDescStatsReply() throws UnsupportedOperationException;
+    OFBsnImageDescStatsRequest.Builder buildBsnImageDescStatsRequest() throws UnsupportedOperationException;
+    OFBsnImageDescStatsRequest bsnImageDescStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBsnLacpConvergenceNotif.Builder buildBsnLacpConvergenceNotif() throws UnsupportedOperationException;
+    OFBsnLacpStatsEntry.Builder buildBsnLacpStatsEntry() throws UnsupportedOperationException;
+    OFBsnLacpStatsReply.Builder buildBsnLacpStatsReply() throws UnsupportedOperationException;
+    OFBsnLacpStatsRequest.Builder buildBsnLacpStatsRequest() throws UnsupportedOperationException;
+    OFBsnLacpStatsRequest bsnLacpStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBsnLog.Builder buildBsnLog() throws UnsupportedOperationException;
+    OFBsnPortCounterStatsEntry.Builder buildBsnPortCounterStatsEntry() throws UnsupportedOperationException;
+    OFBsnPortCounterStatsEntry bsnPortCounterStatsEntry(OFPort portNo, List<U64> values);
+    OFBsnPortCounterStatsReply.Builder buildBsnPortCounterStatsReply() throws UnsupportedOperationException;
+    OFBsnPortCounterStatsRequest.Builder buildBsnPortCounterStatsRequest() throws UnsupportedOperationException;
+    OFBsnRoleStatus.Builder buildBsnRoleStatus() throws UnsupportedOperationException;
+    OFBsnSetAuxCxnsReply.Builder buildBsnSetAuxCxnsReply() throws UnsupportedOperationException;
+    OFBsnSetAuxCxnsRequest.Builder buildBsnSetAuxCxnsRequest() throws UnsupportedOperationException;
+    OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest(long numAux);
+    OFBsnSetLacpReply.Builder buildBsnSetLacpReply() throws UnsupportedOperationException;
+    OFBsnSetLacpRequest.Builder buildBsnSetLacpRequest() throws UnsupportedOperationException;
+    OFBsnSetSwitchPipelineReply.Builder buildBsnSetSwitchPipelineReply() throws UnsupportedOperationException;
+    OFBsnSetSwitchPipelineReply bsnSetSwitchPipelineReply(long status);
+    OFBsnSetSwitchPipelineRequest.Builder buildBsnSetSwitchPipelineRequest() throws UnsupportedOperationException;
+    OFBsnSetSwitchPipelineRequest bsnSetSwitchPipelineRequest(String pipeline);
+    OFBsnSwitchPipelineStatsEntry.Builder buildBsnSwitchPipelineStatsEntry() throws UnsupportedOperationException;
+    OFBsnSwitchPipelineStatsEntry bsnSwitchPipelineStatsEntry(String pipeline);
+    OFBsnSwitchPipelineStatsReply.Builder buildBsnSwitchPipelineStatsReply() throws UnsupportedOperationException;
+    OFBsnSwitchPipelineStatsRequest.Builder buildBsnSwitchPipelineStatsRequest() throws UnsupportedOperationException;
+    OFBsnSwitchPipelineStatsRequest bsnSwitchPipelineStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBsnTableChecksumStatsEntry.Builder buildBsnTableChecksumStatsEntry() throws UnsupportedOperationException;
+    OFBsnTableChecksumStatsEntry bsnTableChecksumStatsEntry(TableId tableId, U64 checksum);
+    OFBsnTableChecksumStatsReply.Builder buildBsnTableChecksumStatsReply() throws UnsupportedOperationException;
+    OFBsnTableChecksumStatsRequest.Builder buildBsnTableChecksumStatsRequest() throws UnsupportedOperationException;
+    OFBsnTableChecksumStatsRequest bsnTableChecksumStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFBsnTableSetBucketsSize.Builder buildBsnTableSetBucketsSize() throws UnsupportedOperationException;
+    OFBsnTimeReply.Builder buildBsnTimeReply() throws UnsupportedOperationException;
+    OFBsnTimeReply bsnTimeReply(U64 timeMs);
+    OFBsnTimeRequest.Builder buildBsnTimeRequest() throws UnsupportedOperationException;
+    OFBsnTimeRequest bsnTimeRequest();
+    OFBsnVlanCounterStatsEntry.Builder buildBsnVlanCounterStatsEntry() throws UnsupportedOperationException;
+    OFBsnVlanCounterStatsEntry bsnVlanCounterStatsEntry(int vlanVid, List<U64> values);
+    OFBsnVlanCounterStatsReply.Builder buildBsnVlanCounterStatsReply() throws UnsupportedOperationException;
+    OFBsnVlanCounterStatsRequest.Builder buildBsnVlanCounterStatsRequest() throws UnsupportedOperationException;
+    OFBsnVrfCounterStatsEntry.Builder buildBsnVrfCounterStatsEntry() throws UnsupportedOperationException;
+    OFBsnVrfCounterStatsEntry bsnVrfCounterStatsEntry(long vrf, List<U64> values);
+    OFBsnVrfCounterStatsReply.Builder buildBsnVrfCounterStatsReply() throws UnsupportedOperationException;
+    OFBsnVrfCounterStatsRequest.Builder buildBsnVrfCounterStatsRequest() throws UnsupportedOperationException;
+    OFHelloElemVersionbitmap.Builder buildHelloElemVersionbitmap() throws UnsupportedOperationException;
+    OFHelloElemVersionbitmap helloElemVersionbitmap(List<U32> bitmaps);
+    OFMeterBandStats.Builder buildMeterBandStats() throws UnsupportedOperationException;
+    OFMeterBandStats meterBandStats(U64 packetBandCount, U64 byteBandCount);
+    OFMeterConfig.Builder buildMeterConfig() throws UnsupportedOperationException;
+    OFMeterConfigStatsReply.Builder buildMeterConfigStatsReply() throws UnsupportedOperationException;
+    OFMeterConfigStatsRequest.Builder buildMeterConfigStatsRequest() throws UnsupportedOperationException;
+    OFMeterFeatures.Builder buildMeterFeatures() throws UnsupportedOperationException;
+    OFMeterFeaturesStatsReply.Builder buildMeterFeaturesStatsReply() throws UnsupportedOperationException;
+    OFMeterFeaturesStatsRequest.Builder buildMeterFeaturesStatsRequest() throws UnsupportedOperationException;
+    OFMeterFeaturesStatsRequest meterFeaturesStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFMeterMod.Builder buildMeterMod() throws UnsupportedOperationException;
+    OFMeterStats.Builder buildMeterStats() throws UnsupportedOperationException;
+    OFMeterStatsReply.Builder buildMeterStatsReply() throws UnsupportedOperationException;
+    OFMeterStatsRequest.Builder buildMeterStatsRequest() throws UnsupportedOperationException;
+    OFPortDescStatsReply.Builder buildPortDescStatsReply() throws UnsupportedOperationException;
+    OFPortDescStatsRequest.Builder buildPortDescStatsRequest() throws UnsupportedOperationException;
+    OFPortDescStatsRequest portDescStatsRequest(Set<OFStatsRequestFlags> flags);
+    OFTableFeaturePropApplyActions.Builder buildTableFeaturePropApplyActions() throws UnsupportedOperationException;
+    OFTableFeaturePropApplyActions tableFeaturePropApplyActions(List<OFActionId> actionIds);
+    OFTableFeaturePropApplyActionsMiss.Builder buildTableFeaturePropApplyActionsMiss() throws UnsupportedOperationException;
+    OFTableFeaturePropApplyActionsMiss tableFeaturePropApplyActionsMiss(List<OFActionId> actionIds);
+    OFTableFeaturePropApplySetfield.Builder buildTableFeaturePropApplySetfield() throws UnsupportedOperationException;
+    OFTableFeaturePropApplySetfield tableFeaturePropApplySetfield(List<U32> oxmIds);
+    OFTableFeaturePropApplySetfieldMiss.Builder buildTableFeaturePropApplySetfieldMiss() throws UnsupportedOperationException;
+    OFTableFeaturePropApplySetfieldMiss tableFeaturePropApplySetfieldMiss(List<U32> oxmIds);
+    OFTableFeaturePropExperimenter.Builder buildTableFeaturePropExperimenter() throws UnsupportedOperationException;
+    OFTableFeaturePropExperimenterMiss.Builder buildTableFeaturePropExperimenterMiss() throws UnsupportedOperationException;
+    OFTableFeaturePropInstructions.Builder buildTableFeaturePropInstructions() throws UnsupportedOperationException;
+    OFTableFeaturePropInstructions tableFeaturePropInstructions(List<OFInstructionId> instructionIds);
+    OFTableFeaturePropInstructionsMiss.Builder buildTableFeaturePropInstructionsMiss() throws UnsupportedOperationException;
+    OFTableFeaturePropInstructionsMiss tableFeaturePropInstructionsMiss(List<OFInstructionId> instructionIds);
+    OFTableFeaturePropMatch.Builder buildTableFeaturePropMatch() throws UnsupportedOperationException;
+    OFTableFeaturePropMatch tableFeaturePropMatch(List<U32> oxmIds);
+    OFTableFeaturePropNextTables.Builder buildTableFeaturePropNextTables() throws UnsupportedOperationException;
+    OFTableFeaturePropNextTables tableFeaturePropNextTables(List<U8> nextTableIds);
+    OFTableFeaturePropNextTablesMiss.Builder buildTableFeaturePropNextTablesMiss() throws UnsupportedOperationException;
+    OFTableFeaturePropNextTablesMiss tableFeaturePropNextTablesMiss(List<U8> nextTableIds);
+    OFTableFeaturePropWildcards.Builder buildTableFeaturePropWildcards() throws UnsupportedOperationException;
+    OFTableFeaturePropWildcards tableFeaturePropWildcards(List<U32> oxmIds);
+    OFTableFeaturePropWriteActions.Builder buildTableFeaturePropWriteActions() throws UnsupportedOperationException;
+    OFTableFeaturePropWriteActions tableFeaturePropWriteActions(List<OFActionId> actionIds);
+    OFTableFeaturePropWriteActionsMiss.Builder buildTableFeaturePropWriteActionsMiss() throws UnsupportedOperationException;
+    OFTableFeaturePropWriteActionsMiss tableFeaturePropWriteActionsMiss(List<OFActionId> actionIds);
+    OFTableFeaturePropWriteSetfield.Builder buildTableFeaturePropWriteSetfield() throws UnsupportedOperationException;
+    OFTableFeaturePropWriteSetfield tableFeaturePropWriteSetfield(List<U32> oxmIds);
+    OFTableFeaturePropWriteSetfieldMiss.Builder buildTableFeaturePropWriteSetfieldMiss() throws UnsupportedOperationException;
+    OFTableFeaturePropWriteSetfieldMiss tableFeaturePropWriteSetfieldMiss(List<U32> oxmIds);
+    OFTableFeatures.Builder buildTableFeatures() throws UnsupportedOperationException;
+    OFTableFeaturesStatsReply.Builder buildTableFeaturesStatsReply() throws UnsupportedOperationException;
+    OFTableFeaturesStatsRequest.Builder buildTableFeaturesStatsRequest() throws UnsupportedOperationException;
+    OFUint64.Builder buildUint64() throws UnsupportedOperationException;
+    OFUint64 uint64(U64 value);
+    Match.Builder buildMatch();
+    Match matchWildcardAll();
+
+    OFMessageReader<OFMessage> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFeaturesReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFeaturesReply.java
new file mode 100644
index 0000000..4d0ab31
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFeaturesReply.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFeaturesReply extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    DatapathId getDatapathId();
+    long getNBuffers();
+    short getNTables();
+    Set<OFCapabilities> getCapabilities();
+    long getReserved() throws UnsupportedOperationException;
+    List<OFPortDesc> getPorts() throws UnsupportedOperationException;
+    Set<OFActionType> getActions() throws UnsupportedOperationException;
+    OFAuxId getAuxiliaryId() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFFeaturesReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        DatapathId getDatapathId();
+        Builder setDatapathId(DatapathId datapathId);
+        long getNBuffers();
+        Builder setNBuffers(long nBuffers);
+        short getNTables();
+        Builder setNTables(short nTables);
+        Set<OFCapabilities> getCapabilities();
+        Builder setCapabilities(Set<OFCapabilities> capabilities);
+        long getReserved() throws UnsupportedOperationException;
+        Builder setReserved(long reserved) throws UnsupportedOperationException;
+        List<OFPortDesc> getPorts() throws UnsupportedOperationException;
+        Builder setPorts(List<OFPortDesc> ports) throws UnsupportedOperationException;
+        Set<OFActionType> getActions() throws UnsupportedOperationException;
+        Builder setActions(Set<OFActionType> actions) throws UnsupportedOperationException;
+        OFAuxId getAuxiliaryId() throws UnsupportedOperationException;
+        Builder setAuxiliaryId(OFAuxId auxiliaryId) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFeaturesRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFeaturesRequest.java
new file mode 100644
index 0000000..78cb71b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFeaturesRequest.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFeaturesRequest extends OFObject, OFMessage, OFRequest<OFFeaturesReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFFeaturesRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowAdd.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowAdd.java
new file mode 100644
index 0000000..19dccbf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowAdd.java
@@ -0,0 +1,86 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowAdd extends OFObject, OFFlowMod {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    U64 getCookie();
+    U64 getCookieMask() throws UnsupportedOperationException;
+    TableId getTableId() throws UnsupportedOperationException;
+    OFFlowModCommand getCommand();
+    int getIdleTimeout();
+    int getHardTimeout();
+    int getPriority();
+    OFBufferId getBufferId();
+    OFPort getOutPort();
+    OFGroup getOutGroup() throws UnsupportedOperationException;
+    Set<OFFlowModFlags> getFlags();
+    Match getMatch();
+    List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+    List<OFAction> getActions() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFFlowMod.Builder {
+        OFFlowAdd build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        U64 getCookieMask() throws UnsupportedOperationException;
+        Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
+        TableId getTableId() throws UnsupportedOperationException;
+        Builder setTableId(TableId tableId) throws UnsupportedOperationException;
+        OFFlowModCommand getCommand();
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout();
+        Builder setHardTimeout(int hardTimeout);
+        int getPriority();
+        Builder setPriority(int priority);
+        OFBufferId getBufferId();
+        Builder setBufferId(OFBufferId bufferId);
+        OFPort getOutPort();
+        Builder setOutPort(OFPort outPort);
+        OFGroup getOutGroup() throws UnsupportedOperationException;
+        Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
+        Set<OFFlowModFlags> getFlags();
+        Builder setFlags(Set<OFFlowModFlags> flags);
+        Match getMatch();
+        Builder setMatch(Match match);
+        List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+        Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException;
+        List<OFAction> getActions() throws UnsupportedOperationException;
+        Builder setActions(List<OFAction> actions) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowDelete.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowDelete.java
new file mode 100644
index 0000000..09f7f3a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowDelete.java
@@ -0,0 +1,86 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowDelete extends OFObject, OFFlowMod {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    U64 getCookie();
+    U64 getCookieMask() throws UnsupportedOperationException;
+    TableId getTableId() throws UnsupportedOperationException;
+    OFFlowModCommand getCommand();
+    int getIdleTimeout();
+    int getHardTimeout();
+    int getPriority();
+    OFBufferId getBufferId();
+    OFPort getOutPort();
+    OFGroup getOutGroup() throws UnsupportedOperationException;
+    Set<OFFlowModFlags> getFlags();
+    Match getMatch();
+    List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+    List<OFAction> getActions() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFFlowMod.Builder {
+        OFFlowDelete build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        U64 getCookieMask() throws UnsupportedOperationException;
+        Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
+        TableId getTableId() throws UnsupportedOperationException;
+        Builder setTableId(TableId tableId) throws UnsupportedOperationException;
+        OFFlowModCommand getCommand();
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout();
+        Builder setHardTimeout(int hardTimeout);
+        int getPriority();
+        Builder setPriority(int priority);
+        OFBufferId getBufferId();
+        Builder setBufferId(OFBufferId bufferId);
+        OFPort getOutPort();
+        Builder setOutPort(OFPort outPort);
+        OFGroup getOutGroup() throws UnsupportedOperationException;
+        Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
+        Set<OFFlowModFlags> getFlags();
+        Builder setFlags(Set<OFFlowModFlags> flags);
+        Match getMatch();
+        Builder setMatch(Match match);
+        List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+        Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException;
+        List<OFAction> getActions() throws UnsupportedOperationException;
+        Builder setActions(List<OFAction> actions) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowDeleteStrict.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowDeleteStrict.java
new file mode 100644
index 0000000..72931d1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowDeleteStrict.java
@@ -0,0 +1,86 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowDeleteStrict extends OFObject, OFFlowMod {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    U64 getCookie();
+    U64 getCookieMask() throws UnsupportedOperationException;
+    TableId getTableId() throws UnsupportedOperationException;
+    OFFlowModCommand getCommand();
+    int getIdleTimeout();
+    int getHardTimeout();
+    int getPriority();
+    OFBufferId getBufferId();
+    OFPort getOutPort();
+    OFGroup getOutGroup() throws UnsupportedOperationException;
+    Set<OFFlowModFlags> getFlags();
+    Match getMatch();
+    List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+    List<OFAction> getActions() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFFlowMod.Builder {
+        OFFlowDeleteStrict build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        U64 getCookieMask() throws UnsupportedOperationException;
+        Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
+        TableId getTableId() throws UnsupportedOperationException;
+        Builder setTableId(TableId tableId) throws UnsupportedOperationException;
+        OFFlowModCommand getCommand();
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout();
+        Builder setHardTimeout(int hardTimeout);
+        int getPriority();
+        Builder setPriority(int priority);
+        OFBufferId getBufferId();
+        Builder setBufferId(OFBufferId bufferId);
+        OFPort getOutPort();
+        Builder setOutPort(OFPort outPort);
+        OFGroup getOutGroup() throws UnsupportedOperationException;
+        Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
+        Set<OFFlowModFlags> getFlags();
+        Builder setFlags(Set<OFFlowModFlags> flags);
+        Match getMatch();
+        Builder setMatch(Match match);
+        List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+        Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException;
+        List<OFAction> getActions() throws UnsupportedOperationException;
+        Builder setActions(List<OFAction> actions) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowMod.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowMod.java
new file mode 100644
index 0000000..76da051
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowMod.java
@@ -0,0 +1,86 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowMod extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    U64 getCookie();
+    U64 getCookieMask() throws UnsupportedOperationException;
+    TableId getTableId() throws UnsupportedOperationException;
+    OFFlowModCommand getCommand();
+    int getIdleTimeout();
+    int getHardTimeout();
+    int getPriority();
+    OFBufferId getBufferId();
+    OFPort getOutPort();
+    OFGroup getOutGroup() throws UnsupportedOperationException;
+    Set<OFFlowModFlags> getFlags();
+    Match getMatch();
+    List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+    List<OFAction> getActions() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFFlowMod build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        U64 getCookieMask() throws UnsupportedOperationException;
+        Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
+        TableId getTableId() throws UnsupportedOperationException;
+        Builder setTableId(TableId tableId) throws UnsupportedOperationException;
+        OFFlowModCommand getCommand();
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout();
+        Builder setHardTimeout(int hardTimeout);
+        int getPriority();
+        Builder setPriority(int priority);
+        OFBufferId getBufferId();
+        Builder setBufferId(OFBufferId bufferId);
+        OFPort getOutPort();
+        Builder setOutPort(OFPort outPort);
+        OFGroup getOutGroup() throws UnsupportedOperationException;
+        Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
+        Set<OFFlowModFlags> getFlags();
+        Builder setFlags(Set<OFFlowModFlags> flags);
+        Match getMatch();
+        Builder setMatch(Match match);
+        List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+        Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException;
+        List<OFAction> getActions() throws UnsupportedOperationException;
+        Builder setActions(List<OFAction> actions) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModCommand.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModCommand.java
new file mode 100644
index 0000000..dd0b856
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModCommand.java
@@ -0,0 +1,33 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFFlowModCommand {
+     ADD,
+     MODIFY,
+     MODIFY_STRICT,
+     DELETE,
+     DELETE_STRICT;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModFailedCode.java
new file mode 100644
index 0000000..17cf0d2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModFailedCode.java
@@ -0,0 +1,39 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFFlowModFailedCode {
+     ALL_TABLES_FULL,
+     OVERLAP,
+     EPERM,
+     BAD_EMERG_TIMEOUT,
+     BAD_COMMAND,
+     UNSUPPORTED,
+     UNKNOWN,
+     TABLE_FULL,
+     BAD_TABLE_ID,
+     BAD_TIMEOUT,
+     BAD_FLAGS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModFlags.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModFlags.java
new file mode 100644
index 0000000..86c709f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModFlags.java
@@ -0,0 +1,35 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFFlowModFlags {
+     SEND_FLOW_REM,
+     CHECK_OVERLAP,
+     EMERG,
+     RESET_COUNTS,
+     NO_PKT_COUNTS,
+     NO_BYT_COUNTS,
+     BSN_SEND_IDLE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModify.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModify.java
new file mode 100644
index 0000000..cc3129f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModify.java
@@ -0,0 +1,86 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowModify extends OFObject, OFFlowMod {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    U64 getCookie();
+    U64 getCookieMask() throws UnsupportedOperationException;
+    TableId getTableId() throws UnsupportedOperationException;
+    OFFlowModCommand getCommand();
+    int getIdleTimeout();
+    int getHardTimeout();
+    int getPriority();
+    OFBufferId getBufferId();
+    OFPort getOutPort();
+    OFGroup getOutGroup() throws UnsupportedOperationException;
+    Set<OFFlowModFlags> getFlags();
+    Match getMatch();
+    List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+    List<OFAction> getActions() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFFlowMod.Builder {
+        OFFlowModify build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        U64 getCookieMask() throws UnsupportedOperationException;
+        Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
+        TableId getTableId() throws UnsupportedOperationException;
+        Builder setTableId(TableId tableId) throws UnsupportedOperationException;
+        OFFlowModCommand getCommand();
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout();
+        Builder setHardTimeout(int hardTimeout);
+        int getPriority();
+        Builder setPriority(int priority);
+        OFBufferId getBufferId();
+        Builder setBufferId(OFBufferId bufferId);
+        OFPort getOutPort();
+        Builder setOutPort(OFPort outPort);
+        OFGroup getOutGroup() throws UnsupportedOperationException;
+        Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
+        Set<OFFlowModFlags> getFlags();
+        Builder setFlags(Set<OFFlowModFlags> flags);
+        Match getMatch();
+        Builder setMatch(Match match);
+        List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+        Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException;
+        List<OFAction> getActions() throws UnsupportedOperationException;
+        Builder setActions(List<OFAction> actions) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModifyStrict.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModifyStrict.java
new file mode 100644
index 0000000..15809c9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowModifyStrict.java
@@ -0,0 +1,86 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowModifyStrict extends OFObject, OFFlowMod {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    U64 getCookie();
+    U64 getCookieMask() throws UnsupportedOperationException;
+    TableId getTableId() throws UnsupportedOperationException;
+    OFFlowModCommand getCommand();
+    int getIdleTimeout();
+    int getHardTimeout();
+    int getPriority();
+    OFBufferId getBufferId();
+    OFPort getOutPort();
+    OFGroup getOutGroup() throws UnsupportedOperationException;
+    Set<OFFlowModFlags> getFlags();
+    Match getMatch();
+    List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+    List<OFAction> getActions() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFFlowMod.Builder {
+        OFFlowModifyStrict build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        U64 getCookieMask() throws UnsupportedOperationException;
+        Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
+        TableId getTableId() throws UnsupportedOperationException;
+        Builder setTableId(TableId tableId) throws UnsupportedOperationException;
+        OFFlowModCommand getCommand();
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout();
+        Builder setHardTimeout(int hardTimeout);
+        int getPriority();
+        Builder setPriority(int priority);
+        OFBufferId getBufferId();
+        Builder setBufferId(OFBufferId bufferId);
+        OFPort getOutPort();
+        Builder setOutPort(OFPort outPort);
+        OFGroup getOutGroup() throws UnsupportedOperationException;
+        Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
+        Set<OFFlowModFlags> getFlags();
+        Builder setFlags(Set<OFFlowModFlags> flags);
+        Match getMatch();
+        Builder setMatch(Match match);
+        List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+        Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException;
+        List<OFAction> getActions() throws UnsupportedOperationException;
+        Builder setActions(List<OFAction> actions) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowRemoved.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowRemoved.java
new file mode 100644
index 0000000..186b8a6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowRemoved.java
@@ -0,0 +1,76 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowRemoved extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    U64 getCookie();
+    int getPriority();
+    short getReason();
+    TableId getTableId() throws UnsupportedOperationException;
+    long getDurationSec();
+    long getDurationNsec();
+    int getIdleTimeout();
+    int getHardTimeout() throws UnsupportedOperationException;
+    U64 getPacketCount();
+    U64 getByteCount();
+    Match getMatch();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFFlowRemoved build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        int getPriority();
+        Builder setPriority(int priority);
+        short getReason();
+        Builder setReason(short reason);
+        TableId getTableId() throws UnsupportedOperationException;
+        Builder setTableId(TableId tableId) throws UnsupportedOperationException;
+        long getDurationSec();
+        Builder setDurationSec(long durationSec);
+        long getDurationNsec();
+        Builder setDurationNsec(long durationNsec);
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout() throws UnsupportedOperationException;
+        Builder setHardTimeout(int hardTimeout) throws UnsupportedOperationException;
+        U64 getPacketCount();
+        Builder setPacketCount(U64 packetCount);
+        U64 getByteCount();
+        Builder setByteCount(U64 byteCount);
+        Match getMatch();
+        Builder setMatch(Match match);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowRemovedReason.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowRemovedReason.java
new file mode 100644
index 0000000..689b43f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowRemovedReason.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFFlowRemovedReason {
+     IDLE_TIMEOUT,
+     HARD_TIMEOUT,
+     DELETE,
+     GROUP_DELETE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsEntry.java
new file mode 100644
index 0000000..db9b486
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsEntry.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowStatsEntry extends OFObject {
+    TableId getTableId();
+    long getDurationSec();
+    long getDurationNsec();
+    int getPriority();
+    int getIdleTimeout();
+    int getHardTimeout();
+    U64 getCookie();
+    U64 getPacketCount();
+    U64 getByteCount();
+    Match getMatch();
+    List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+    List<OFAction> getActions() throws UnsupportedOperationException;
+    Set<OFFlowModFlags> getFlags() throws UnsupportedOperationException;
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFFlowStatsEntry build();
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        long getDurationSec();
+        Builder setDurationSec(long durationSec);
+        long getDurationNsec();
+        Builder setDurationNsec(long durationNsec);
+        int getPriority();
+        Builder setPriority(int priority);
+        int getIdleTimeout();
+        Builder setIdleTimeout(int idleTimeout);
+        int getHardTimeout();
+        Builder setHardTimeout(int hardTimeout);
+        U64 getCookie();
+        Builder setCookie(U64 cookie);
+        U64 getPacketCount();
+        Builder setPacketCount(U64 packetCount);
+        U64 getByteCount();
+        Builder setByteCount(U64 byteCount);
+        Match getMatch();
+        Builder setMatch(Match match);
+        List<OFInstruction> getInstructions() throws UnsupportedOperationException;
+        Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException;
+        List<OFAction> getActions() throws UnsupportedOperationException;
+        Builder setActions(List<OFAction> actions) throws UnsupportedOperationException;
+        Set<OFFlowModFlags> getFlags() throws UnsupportedOperationException;
+        Builder setFlags(Set<OFFlowModFlags> flags) throws UnsupportedOperationException;
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsReply.java
new file mode 100644
index 0000000..488acc2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFFlowStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFFlowStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFFlowStatsEntry> getEntries();
+        Builder setEntries(List<OFFlowStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsRequest.java
new file mode 100644
index 0000000..56fd5d8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowStatsRequest.java
@@ -0,0 +1,67 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowStatsRequest extends OFObject, OFStatsRequest<OFFlowStatsReply>, OFRequest<OFFlowStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    TableId getTableId();
+    OFPort getOutPort();
+    OFGroup getOutGroup() throws UnsupportedOperationException;
+    U64 getCookie() throws UnsupportedOperationException;
+    U64 getCookieMask() throws UnsupportedOperationException;
+    Match getMatch();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFFlowStatsReply> {
+        OFFlowStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        OFPort getOutPort();
+        Builder setOutPort(OFPort outPort);
+        OFGroup getOutGroup() throws UnsupportedOperationException;
+        Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException;
+        U64 getCookie() throws UnsupportedOperationException;
+        Builder setCookie(U64 cookie) throws UnsupportedOperationException;
+        U64 getCookieMask() throws UnsupportedOperationException;
+        Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException;
+        Match getMatch();
+        Builder setMatch(Match match);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowWildcards.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowWildcards.java
new file mode 100644
index 0000000..d732d7d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFFlowWildcards.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFFlowWildcards {
+     IN_PORT,
+     DL_VLAN,
+     DL_SRC,
+     DL_DST,
+     DL_TYPE,
+     NW_PROTO,
+     TP_SRC,
+     TP_DST,
+     NW_SRC_ALL,
+     NW_SRC_MASK,
+     NW_DST_ALL,
+     NW_DST_MASK,
+     DL_VLAN_PCP,
+     NW_TOS,
+     ALL,
+     MPLS_LABEL,
+     MPLS_TC;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGetConfigReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGetConfigReply.java
new file mode 100644
index 0000000..d3c0bd8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGetConfigReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGetConfigReply extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    Set<OFConfigFlags> getFlags();
+    int getMissSendLen();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFGetConfigReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        Set<OFConfigFlags> getFlags();
+        Builder setFlags(Set<OFConfigFlags> flags);
+        int getMissSendLen();
+        Builder setMissSendLen(int missSendLen);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGetConfigRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGetConfigRequest.java
new file mode 100644
index 0000000..ec49dfe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGetConfigRequest.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGetConfigRequest extends OFObject, OFMessage, OFRequest<OFGetConfigReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFGetConfigRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupAdd.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupAdd.java
new file mode 100644
index 0000000..6502d85
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupAdd.java
@@ -0,0 +1,55 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupAdd extends OFObject, OFGroupMod {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFGroupModCommand getCommand();
+    OFGroupType getGroupType();
+    OFGroup getGroup();
+    List<OFBucket> getBuckets();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFGroupMod.Builder {
+        OFGroupAdd build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFGroupModCommand getCommand();
+        OFGroupType getGroupType();
+        Builder setGroupType(OFGroupType groupType);
+        OFGroup getGroup();
+        Builder setGroup(OFGroup group);
+        List<OFBucket> getBuckets();
+        Builder setBuckets(List<OFBucket> buckets);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupCapabilities.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupCapabilities.java
new file mode 100644
index 0000000..679fad6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupCapabilities.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFGroupCapabilities {
+     SELECT_WEIGHT,
+     SELECT_LIVENESS,
+     CHAINING,
+     CHAINING_CHECKS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDelete.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDelete.java
new file mode 100644
index 0000000..c649b82
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDelete.java
@@ -0,0 +1,55 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupDelete extends OFObject, OFGroupMod {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFGroupModCommand getCommand();
+    OFGroupType getGroupType();
+    OFGroup getGroup();
+    List<OFBucket> getBuckets();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFGroupMod.Builder {
+        OFGroupDelete build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFGroupModCommand getCommand();
+        OFGroupType getGroupType();
+        Builder setGroupType(OFGroupType groupType);
+        OFGroup getGroup();
+        Builder setGroup(OFGroup group);
+        List<OFBucket> getBuckets();
+        Builder setBuckets(List<OFBucket> buckets);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsEntry.java
new file mode 100644
index 0000000..be11fa0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsEntry.java
@@ -0,0 +1,48 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupDescStatsEntry extends OFObject {
+    OFGroupType getGroupType();
+    OFGroup getGroup();
+    List<OFBucket> getBuckets();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFGroupDescStatsEntry build();
+        OFGroupType getGroupType();
+        Builder setGroupType(OFGroupType groupType);
+        OFGroup getGroup();
+        Builder setGroup(OFGroup group);
+        List<OFBucket> getBuckets();
+        Builder setBuckets(List<OFBucket> buckets);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsReply.java
new file mode 100644
index 0000000..c3943e8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupDescStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFGroupDescStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFGroupDescStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFGroupDescStatsEntry> getEntries();
+        Builder setEntries(List<OFGroupDescStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsRequest.java
new file mode 100644
index 0000000..260e411
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupDescStatsRequest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupDescStatsRequest extends OFObject, OFStatsRequest<OFGroupDescStatsReply>, OFRequest<OFGroupDescStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFGroupDescStatsReply> {
+        OFGroupDescStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupFeaturesStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupFeaturesStatsReply.java
new file mode 100644
index 0000000..c449fdf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupFeaturesStatsReply.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupFeaturesStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    long getTypes();
+    long getCapabilities();
+    long getMaxGroupsAll();
+    long getMaxGroupsSelect();
+    long getMaxGroupsIndirect();
+    long getMaxGroupsFf();
+    long getActionsAll();
+    long getActionsSelect();
+    long getActionsIndirect();
+    long getActionsFf();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFGroupFeaturesStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        long getTypes();
+        Builder setTypes(long types);
+        long getCapabilities();
+        Builder setCapabilities(long capabilities);
+        long getMaxGroupsAll();
+        Builder setMaxGroupsAll(long maxGroupsAll);
+        long getMaxGroupsSelect();
+        Builder setMaxGroupsSelect(long maxGroupsSelect);
+        long getMaxGroupsIndirect();
+        Builder setMaxGroupsIndirect(long maxGroupsIndirect);
+        long getMaxGroupsFf();
+        Builder setMaxGroupsFf(long maxGroupsFf);
+        long getActionsAll();
+        Builder setActionsAll(long actionsAll);
+        long getActionsSelect();
+        Builder setActionsSelect(long actionsSelect);
+        long getActionsIndirect();
+        Builder setActionsIndirect(long actionsIndirect);
+        long getActionsFf();
+        Builder setActionsFf(long actionsFf);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupFeaturesStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupFeaturesStatsRequest.java
new file mode 100644
index 0000000..741a13d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupFeaturesStatsRequest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupFeaturesStatsRequest extends OFObject, OFStatsRequest<OFGroupFeaturesStatsReply>, OFRequest<OFGroupFeaturesStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFGroupFeaturesStatsReply> {
+        OFGroupFeaturesStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupMod.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupMod.java
new file mode 100644
index 0000000..65bfe68
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupMod.java
@@ -0,0 +1,55 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupMod extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFGroupModCommand getCommand();
+    OFGroupType getGroupType();
+    OFGroup getGroup();
+    List<OFBucket> getBuckets();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFGroupMod build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFGroupModCommand getCommand();
+        OFGroupType getGroupType();
+        Builder setGroupType(OFGroupType groupType);
+        OFGroup getGroup();
+        Builder setGroup(OFGroup group);
+        List<OFBucket> getBuckets();
+        Builder setBuckets(List<OFBucket> buckets);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModCommand.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModCommand.java
new file mode 100644
index 0000000..30f122c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModCommand.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFGroupModCommand {
+     ADD,
+     MODIFY,
+     DELETE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModFailedCode.java
new file mode 100644
index 0000000..e88b22d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModFailedCode.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFGroupModFailedCode {
+     GROUP_EXISTS,
+     INVALID_GROUP,
+     WEIGHT_UNSUPPORTED,
+     OUT_OF_GROUPS,
+     OUT_OF_BUCKETS,
+     CHAINING_UNSUPPORTED,
+     WATCH_UNSUPPORTED,
+     LOOP,
+     UNKNOWN_GROUP,
+     CHAINED_GROUP,
+     BAD_TYPE,
+     BAD_COMMAND,
+     BAD_BUCKET,
+     BAD_WATCH,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModify.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModify.java
new file mode 100644
index 0000000..3c408fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupModify.java
@@ -0,0 +1,55 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupModify extends OFObject, OFGroupMod {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFGroupModCommand getCommand();
+    OFGroupType getGroupType();
+    OFGroup getGroup();
+    List<OFBucket> getBuckets();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFGroupMod.Builder {
+        OFGroupModify build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFGroupModCommand getCommand();
+        OFGroupType getGroupType();
+        Builder setGroupType(OFGroupType groupType);
+        OFGroup getGroup();
+        Builder setGroup(OFGroup group);
+        List<OFBucket> getBuckets();
+        Builder setBuckets(List<OFBucket> buckets);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsEntry.java
new file mode 100644
index 0000000..efa4bf2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsEntry.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupStatsEntry extends OFObject {
+    OFGroup getGroup();
+    long getRefCount();
+    U64 getPacketCount();
+    U64 getByteCount();
+    List<OFBucketCounter> getBucketStats();
+    long getDurationSec() throws UnsupportedOperationException;
+    long getDurationNsec() throws UnsupportedOperationException;
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFGroupStatsEntry build();
+        OFGroup getGroup();
+        Builder setGroup(OFGroup group);
+        long getRefCount();
+        Builder setRefCount(long refCount);
+        U64 getPacketCount();
+        Builder setPacketCount(U64 packetCount);
+        U64 getByteCount();
+        Builder setByteCount(U64 byteCount);
+        List<OFBucketCounter> getBucketStats();
+        Builder setBucketStats(List<OFBucketCounter> bucketStats);
+        long getDurationSec() throws UnsupportedOperationException;
+        Builder setDurationSec(long durationSec) throws UnsupportedOperationException;
+        long getDurationNsec() throws UnsupportedOperationException;
+        Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException;
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsReply.java
new file mode 100644
index 0000000..df8ea80
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFGroupStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFGroupStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFGroupStatsEntry> getEntries();
+        Builder setEntries(List<OFGroupStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsRequest.java
new file mode 100644
index 0000000..24bdcb5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupStatsRequest.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupStatsRequest extends OFObject, OFStatsRequest<OFGroupStatsReply>, OFRequest<OFGroupStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    OFGroup getGroup();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFGroupStatsReply> {
+        OFGroupStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        OFGroup getGroup();
+        Builder setGroup(OFGroup group);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupType.java
new file mode 100644
index 0000000..bd7c37e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFGroupType.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFGroupType {
+     ALL,
+     SELECT,
+     INDIRECT,
+     FF;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHello.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHello.java
new file mode 100644
index 0000000..0858559
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHello.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFHello extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    List<OFHelloElem> getElements() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFHello build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        List<OFHelloElem> getElements() throws UnsupportedOperationException;
+        Builder setElements(List<OFHelloElem> elements) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElem.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElem.java
new file mode 100644
index 0000000..68d69cc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElem.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFHelloElem extends OFObject {
+    int getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFHelloElem build();
+        int getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElemType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElemType.java
new file mode 100644
index 0000000..1b221bd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElemType.java
@@ -0,0 +1,29 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFHelloElemType {
+     VERSIONBITMAP;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElemVersionbitmap.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElemVersionbitmap.java
new file mode 100644
index 0000000..e8eb3c7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloElemVersionbitmap.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFHelloElemVersionbitmap extends OFObject, OFHelloElem {
+    int getType();
+    List<U32> getBitmaps();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFHelloElem.Builder {
+        OFHelloElemVersionbitmap build();
+        int getType();
+        List<U32> getBitmaps();
+        Builder setBitmaps(List<U32> bitmaps);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloFailedCode.java
new file mode 100644
index 0000000..92312dd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFHelloFailedCode.java
@@ -0,0 +1,30 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFHelloFailedCode {
+     INCOMPATIBLE,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFInstructionType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFInstructionType.java
new file mode 100644
index 0000000..8fc38eb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFInstructionType.java
@@ -0,0 +1,35 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFInstructionType {
+     GOTO_TABLE,
+     WRITE_METADATA,
+     WRITE_ACTIONS,
+     APPLY_ACTIONS,
+     CLEAR_ACTIONS,
+     EXPERIMENTER,
+     METER;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFIpv6ExthdrFlags.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFIpv6ExthdrFlags.java
new file mode 100644
index 0000000..7c33b94
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFIpv6ExthdrFlags.java
@@ -0,0 +1,37 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFIpv6ExthdrFlags {
+     NONEXT,
+     ESP,
+     AUTH,
+     DEST,
+     FRAG,
+     ROUTER,
+     HOP,
+     UNREP,
+     UNSEQ;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchType.java
new file mode 100644
index 0000000..17e768c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchType.java
@@ -0,0 +1,30 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFMatchType {
+     STANDARD,
+     OXM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV1.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV1.java
new file mode 100644
index 0000000..06deb6b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV1.java
@@ -0,0 +1,77 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMatchV1 extends OFObject, Match {
+    int getWildcards();
+    OFPort getInPort();
+    MacAddress getEthSrc();
+    MacAddress getEthDst();
+    OFVlanVidMatch getVlanVid();
+    VlanPcp getVlanPcp();
+    EthType getEthType();
+    IpDscp getIpDscp();
+    IpProtocol getIpProto();
+    IPv4Address getIpv4Src();
+    IPv4Address getIpv4Dst();
+    TransportPort getTcpSrc();
+    TransportPort getTcpDst();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends Match.Builder {
+        OFMatchV1 build();
+        int getWildcards();
+        Builder setWildcards(int wildcards);
+        OFPort getInPort();
+        Builder setInPort(OFPort inPort);
+        MacAddress getEthSrc();
+        Builder setEthSrc(MacAddress ethSrc);
+        MacAddress getEthDst();
+        Builder setEthDst(MacAddress ethDst);
+        OFVlanVidMatch getVlanVid();
+        Builder setVlanVid(OFVlanVidMatch vlanVid);
+        VlanPcp getVlanPcp();
+        Builder setVlanPcp(VlanPcp vlanPcp);
+        EthType getEthType();
+        Builder setEthType(EthType ethType);
+        IpDscp getIpDscp();
+        Builder setIpDscp(IpDscp ipDscp);
+        IpProtocol getIpProto();
+        Builder setIpProto(IpProtocol ipProto);
+        IPv4Address getIpv4Src();
+        Builder setIpv4Src(IPv4Address ipv4Src);
+        IPv4Address getIpv4Dst();
+        Builder setIpv4Dst(IPv4Address ipv4Dst);
+        TransportPort getTcpSrc();
+        Builder setTcpSrc(TransportPort tcpSrc);
+        TransportPort getTcpDst();
+        Builder setTcpDst(TransportPort tcpDst);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV2.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV2.java
new file mode 100644
index 0000000..7d40266
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV2.java
@@ -0,0 +1,103 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMatchV2 extends OFObject, Match {
+    int getType();
+    OFPort getInPort();
+    int getWildcards();
+    MacAddress getEthSrc();
+    MacAddress getEthSrcMask();
+    MacAddress getEthDst();
+    MacAddress getEthDstMask();
+    int getVlanVid();
+    short getVlanPcp();
+    int getEthType();
+    short getIpDscp();
+    short getIpProto();
+    IPv4Address getIpv4Src();
+    IPv4Address getIpv4SrcMask();
+    IPv4Address getIpv4Dst();
+    IPv4Address getIpv4DstMask();
+    int getTcpSrc();
+    int getTcpDst();
+    long getMplsLabel();
+    short getMplsTc();
+    U64 getMetadata();
+    U64 getMetadataMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends Match.Builder {
+        OFMatchV2 build();
+        int getType();
+        OFPort getInPort();
+        Builder setInPort(OFPort inPort);
+        int getWildcards();
+        Builder setWildcards(int wildcards);
+        MacAddress getEthSrc();
+        Builder setEthSrc(MacAddress ethSrc);
+        MacAddress getEthSrcMask();
+        Builder setEthSrcMask(MacAddress ethSrcMask);
+        MacAddress getEthDst();
+        Builder setEthDst(MacAddress ethDst);
+        MacAddress getEthDstMask();
+        Builder setEthDstMask(MacAddress ethDstMask);
+        int getVlanVid();
+        Builder setVlanVid(int vlanVid);
+        short getVlanPcp();
+        Builder setVlanPcp(short vlanPcp);
+        int getEthType();
+        Builder setEthType(int ethType);
+        short getIpDscp();
+        Builder setIpDscp(short ipDscp);
+        short getIpProto();
+        Builder setIpProto(short ipProto);
+        IPv4Address getIpv4Src();
+        Builder setIpv4Src(IPv4Address ipv4Src);
+        IPv4Address getIpv4SrcMask();
+        Builder setIpv4SrcMask(IPv4Address ipv4SrcMask);
+        IPv4Address getIpv4Dst();
+        Builder setIpv4Dst(IPv4Address ipv4Dst);
+        IPv4Address getIpv4DstMask();
+        Builder setIpv4DstMask(IPv4Address ipv4DstMask);
+        int getTcpSrc();
+        Builder setTcpSrc(int tcpSrc);
+        int getTcpDst();
+        Builder setTcpDst(int tcpDst);
+        long getMplsLabel();
+        Builder setMplsLabel(long mplsLabel);
+        short getMplsTc();
+        Builder setMplsTc(short mplsTc);
+        U64 getMetadata();
+        Builder setMetadata(U64 metadata);
+        U64 getMetadataMask();
+        Builder setMetadataMask(U64 metadataMask);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV3.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV3.java
new file mode 100644
index 0000000..6bfca6e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMatchV3.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMatchV3 extends OFObject, Match {
+    int getType();
+    OFOxmList getOxmList();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends Match.Builder {
+        OFMatchV3 build();
+        int getType();
+        OFOxmList getOxmList();
+        Builder setOxmList(OFOxmList oxmList);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMessage.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMessage.java
new file mode 100644
index 0000000..9a9d6f4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMessage.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMessage extends OFObject {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFMessage build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeter.java
new file mode 100644
index 0000000..20b4e47
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeter.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFMeter {
+     MAX,
+     SLOWPATH,
+     CONTROLLER,
+     ALL;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterBandStats.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterBandStats.java
new file mode 100644
index 0000000..32adcc0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterBandStats.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterBandStats extends OFObject {
+    U64 getPacketBandCount();
+    U64 getByteBandCount();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFMeterBandStats build();
+        U64 getPacketBandCount();
+        Builder setPacketBandCount(U64 packetBandCount);
+        U64 getByteBandCount();
+        Builder setByteBandCount(U64 byteBandCount);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterBandType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterBandType.java
new file mode 100644
index 0000000..ac61fb2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterBandType.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFMeterBandType {
+     DROP,
+     DSCP_REMARK,
+     EXPERIMENTER;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfig.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfig.java
new file mode 100644
index 0000000..5cd55b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfig.java
@@ -0,0 +1,48 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterConfig extends OFObject {
+    int getFlags();
+    long getMeterId();
+    List<OFMeterBand> getEntries();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFMeterConfig build();
+        int getFlags();
+        Builder setFlags(int flags);
+        long getMeterId();
+        Builder setMeterId(long meterId);
+        List<OFMeterBand> getEntries();
+        Builder setEntries(List<OFMeterBand> entries);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfigStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfigStatsReply.java
new file mode 100644
index 0000000..b80c158
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfigStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterConfigStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFMeterBand> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFMeterConfigStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFMeterBand> getEntries();
+        Builder setEntries(List<OFMeterBand> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfigStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfigStatsRequest.java
new file mode 100644
index 0000000..6ab1828
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterConfigStatsRequest.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterConfigStatsRequest extends OFObject, OFStatsRequest<OFMeterConfigStatsReply>, OFRequest<OFMeterConfigStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getMeterId();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFMeterConfigStatsReply> {
+        OFMeterConfigStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getMeterId();
+        Builder setMeterId(long meterId);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeatures.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeatures.java
new file mode 100644
index 0000000..4108de3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeatures.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterFeatures extends OFObject {
+    long getMaxMeter();
+    long getBandTypes();
+    long getCapabilities();
+    short getMaxBands();
+    short getMaxColor();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFMeterFeatures build();
+        long getMaxMeter();
+        Builder setMaxMeter(long maxMeter);
+        long getBandTypes();
+        Builder setBandTypes(long bandTypes);
+        long getCapabilities();
+        Builder setCapabilities(long capabilities);
+        short getMaxBands();
+        Builder setMaxBands(short maxBands);
+        short getMaxColor();
+        Builder setMaxColor(short maxColor);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeaturesStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeaturesStatsReply.java
new file mode 100644
index 0000000..be19e8d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeaturesStatsReply.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterFeaturesStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    OFMeterFeatures getFeatures();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFMeterFeaturesStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        OFMeterFeatures getFeatures();
+        Builder setFeatures(OFMeterFeatures features);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeaturesStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeaturesStatsRequest.java
new file mode 100644
index 0000000..b239a22
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFeaturesStatsRequest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterFeaturesStatsRequest extends OFObject, OFStatsRequest<OFMeterFeaturesStatsReply>, OFRequest<OFMeterFeaturesStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFMeterFeaturesStatsReply> {
+        OFMeterFeaturesStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFlags.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFlags.java
new file mode 100644
index 0000000..2df9c70
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterFlags.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFMeterFlags {
+     KBPS,
+     PKTPS,
+     BURST,
+     STATS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterMod.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterMod.java
new file mode 100644
index 0000000..b01f37c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterMod.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterMod extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    int getCommand();
+    int getFlags();
+    long getMeterId();
+    List<OFMeterBand> getMeters();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFMeterMod build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        int getCommand();
+        Builder setCommand(int command);
+        int getFlags();
+        Builder setFlags(int flags);
+        long getMeterId();
+        Builder setMeterId(long meterId);
+        List<OFMeterBand> getMeters();
+        Builder setMeters(List<OFMeterBand> meters);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterModCommand.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterModCommand.java
new file mode 100644
index 0000000..31bbe23
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterModCommand.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFMeterModCommand {
+     ADD,
+     MODIFY,
+     DELETE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterModFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterModFailedCode.java
new file mode 100644
index 0000000..b977cc3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterModFailedCode.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFMeterModFailedCode {
+     UNKNOWN,
+     METER_EXISTS,
+     INVALID_METER,
+     UNKNOWN_METER,
+     BAD_COMMAND,
+     BAD_FLAGS,
+     BAD_RATE,
+     BAD_BURST,
+     BAD_BAND,
+     BAD_BAND_VALUE,
+     OUT_OF_METERS,
+     OUT_OF_BANDS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStats.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStats.java
new file mode 100644
index 0000000..a5310eb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStats.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterStats extends OFObject {
+    long getMeterId();
+    long getFlowCount();
+    U64 getPacketInCount();
+    U64 getByteInCount();
+    long getDurationSec();
+    long getDurationNsec();
+    List<OFMeterBandStats> getBandStats();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFMeterStats build();
+        long getMeterId();
+        Builder setMeterId(long meterId);
+        long getFlowCount();
+        Builder setFlowCount(long flowCount);
+        U64 getPacketInCount();
+        Builder setPacketInCount(U64 packetInCount);
+        U64 getByteInCount();
+        Builder setByteInCount(U64 byteInCount);
+        long getDurationSec();
+        Builder setDurationSec(long durationSec);
+        long getDurationNsec();
+        Builder setDurationNsec(long durationNsec);
+        List<OFMeterBandStats> getBandStats();
+        Builder setBandStats(List<OFMeterBandStats> bandStats);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStatsReply.java
new file mode 100644
index 0000000..7795fae
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFMeterStats> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFMeterStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFMeterStats> getEntries();
+        Builder setEntries(List<OFMeterStats> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStatsRequest.java
new file mode 100644
index 0000000..f48fb64
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFMeterStatsRequest.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterStatsRequest extends OFObject, OFStatsRequest<OFMeterStatsReply>, OFRequest<OFMeterStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    long getMeterId();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFMeterStatsReply> {
+        OFMeterStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        long getMeterId();
+        Builder setMeterId(long meterId);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRole.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRole.java
new file mode 100644
index 0000000..e3babe3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRole.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFNiciraControllerRole {
+     ROLE_OTHER,
+     ROLE_MASTER,
+     ROLE_SLAVE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRoleReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRoleReply.java
new file mode 100644
index 0000000..5ec1cb4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRoleReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFNiciraControllerRoleReply extends OFObject, OFNiciraHeader {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    OFNiciraControllerRole getRole();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFNiciraHeader.Builder {
+        OFNiciraControllerRoleReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        OFNiciraControllerRole getRole();
+        Builder setRole(OFNiciraControllerRole role);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRoleRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRoleRequest.java
new file mode 100644
index 0000000..002980c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraControllerRoleRequest.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFNiciraControllerRoleRequest extends OFObject, OFNiciraHeader, OFRequest<OFNiciraControllerRoleReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+    OFNiciraControllerRole getRole();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFNiciraHeader.Builder {
+        OFNiciraControllerRoleRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+        OFNiciraControllerRole getRole();
+        Builder setRole(OFNiciraControllerRole role);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraHeader.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraHeader.java
new file mode 100644
index 0000000..9be1c52
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFNiciraHeader.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFNiciraHeader extends OFObject, OFExperimenter {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    long getExperimenter();
+    long getSubtype();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFExperimenter.Builder {
+        OFNiciraHeader build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        long getExperimenter();
+        long getSubtype();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFOxmClass.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFOxmClass.java
new file mode 100644
index 0000000..005b0e9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFOxmClass.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFOxmClass {
+     NXM_0,
+     NXM_1,
+     OPENFLOW_BASIC,
+     EXPERIMENTER;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketIn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketIn.java
new file mode 100644
index 0000000..f1b1297
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketIn.java
@@ -0,0 +1,70 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPacketIn extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFBufferId getBufferId();
+    int getTotalLen();
+    OFPacketInReason getReason();
+    TableId getTableId() throws UnsupportedOperationException;
+    Match getMatch() throws UnsupportedOperationException;
+    byte[] getData();
+    OFPort getInPort() throws UnsupportedOperationException;
+    OFPort getInPhyPort() throws UnsupportedOperationException;
+    U64 getCookie() throws UnsupportedOperationException;
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFPacketIn build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFBufferId getBufferId();
+        Builder setBufferId(OFBufferId bufferId);
+        int getTotalLen();
+        Builder setTotalLen(int totalLen);
+        OFPacketInReason getReason();
+        Builder setReason(OFPacketInReason reason);
+        TableId getTableId() throws UnsupportedOperationException;
+        Builder setTableId(TableId tableId) throws UnsupportedOperationException;
+        Match getMatch() throws UnsupportedOperationException;
+        Builder setMatch(Match match) throws UnsupportedOperationException;
+        byte[] getData();
+        Builder setData(byte[] data);
+        OFPort getInPort() throws UnsupportedOperationException;
+        Builder setInPort(OFPort inPort) throws UnsupportedOperationException;
+        OFPort getInPhyPort() throws UnsupportedOperationException;
+        Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException;
+        U64 getCookie() throws UnsupportedOperationException;
+        Builder setCookie(U64 cookie) throws UnsupportedOperationException;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketInReason.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketInReason.java
new file mode 100644
index 0000000..f13fb3c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketInReason.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFPacketInReason {
+     NO_MATCH,
+     ACTION,
+     INVALID_TTL,
+     BSN_NEW_HOST,
+     BSN_STATION_MOVE,
+     BSN_BAD_VLAN,
+     BSN_DESTINATION_LOOKUP_FAILURE,
+     BSN_NO_ROUTE,
+     BSN_ICMP_ECHO_REQUEST,
+     BSN_DEST_NETWORK_UNREACHABLE,
+     BSN_DEST_HOST_UNREACHABLE,
+     BSN_DEST_PORT_UNREACHABLE,
+     BSN_FRAGMENTATION_REQUIRED,
+     BSN_ARP,
+     BSN_DHCP,
+     BSN_DEBUG,
+     BSN_PACKET_OF_DEATH;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketOut.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketOut.java
new file mode 100644
index 0000000..e17516d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketOut.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPacketOut extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFBufferId getBufferId();
+    OFPort getInPort();
+    List<OFAction> getActions();
+    byte[] getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFPacketOut build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFBufferId getBufferId();
+        Builder setBufferId(OFBufferId bufferId);
+        OFPort getInPort();
+        Builder setInPort(OFPort inPort);
+        List<OFAction> getActions();
+        Builder setActions(List<OFAction> actions);
+        byte[] getData();
+        Builder setData(byte[] data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketQueue.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketQueue.java
new file mode 100644
index 0000000..33d6521
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPacketQueue.java
@@ -0,0 +1,48 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPacketQueue extends OFObject {
+    long getQueueId();
+    OFPort getPort() throws UnsupportedOperationException;
+    List<OFQueueProp> getProperties();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFPacketQueue build();
+        long getQueueId();
+        Builder setQueueId(long queueId);
+        OFPort getPort() throws UnsupportedOperationException;
+        Builder setPort(OFPort port) throws UnsupportedOperationException;
+        List<OFQueueProp> getProperties();
+        Builder setProperties(List<OFQueueProp> properties);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortConfig.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortConfig.java
new file mode 100644
index 0000000..5201415
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortConfig.java
@@ -0,0 +1,36 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFPortConfig {
+     PORT_DOWN,
+     NO_STP,
+     NO_RECV,
+     NO_RECV_STP,
+     NO_FLOOD,
+     NO_FWD,
+     NO_PACKET_IN,
+     BSN_MIRROR_DEST;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDesc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDesc.java
new file mode 100644
index 0000000..4e2d85a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDesc.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortDesc extends OFObject {
+    OFPort getPortNo();
+    MacAddress getHwAddr();
+    String getName();
+    Set<OFPortConfig> getConfig();
+    Set<OFPortState> getState();
+    Set<OFPortFeatures> getCurr();
+    Set<OFPortFeatures> getAdvertised();
+    Set<OFPortFeatures> getSupported();
+    Set<OFPortFeatures> getPeer();
+    long getCurrSpeed() throws UnsupportedOperationException;
+    long getMaxSpeed() throws UnsupportedOperationException;
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFPortDesc build();
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        MacAddress getHwAddr();
+        Builder setHwAddr(MacAddress hwAddr);
+        String getName();
+        Builder setName(String name);
+        Set<OFPortConfig> getConfig();
+        Builder setConfig(Set<OFPortConfig> config);
+        Set<OFPortState> getState();
+        Builder setState(Set<OFPortState> state);
+        Set<OFPortFeatures> getCurr();
+        Builder setCurr(Set<OFPortFeatures> curr);
+        Set<OFPortFeatures> getAdvertised();
+        Builder setAdvertised(Set<OFPortFeatures> advertised);
+        Set<OFPortFeatures> getSupported();
+        Builder setSupported(Set<OFPortFeatures> supported);
+        Set<OFPortFeatures> getPeer();
+        Builder setPeer(Set<OFPortFeatures> peer);
+        long getCurrSpeed() throws UnsupportedOperationException;
+        Builder setCurrSpeed(long currSpeed) throws UnsupportedOperationException;
+        long getMaxSpeed() throws UnsupportedOperationException;
+        Builder setMaxSpeed(long maxSpeed) throws UnsupportedOperationException;
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDescStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDescStatsReply.java
new file mode 100644
index 0000000..c445c24
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDescStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortDescStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFPortDesc> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFPortDescStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFPortDesc> getEntries();
+        Builder setEntries(List<OFPortDesc> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDescStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDescStatsRequest.java
new file mode 100644
index 0000000..418e612
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortDescStatsRequest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortDescStatsRequest extends OFObject, OFStatsRequest<OFPortDescStatsReply>, OFRequest<OFPortDescStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFPortDescStatsReply> {
+        OFPortDescStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortFeatures.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortFeatures.java
new file mode 100644
index 0000000..fd33a69
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortFeatures.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFPortFeatures {
+     PF_10MB_HD(PortSpeed.SPEED_10MB),
+     PF_10MB_FD(PortSpeed.SPEED_10MB),
+     PF_100MB_HD(PortSpeed.SPEED_100MB),
+     PF_100MB_FD(PortSpeed.SPEED_100MB),
+     PF_1GB_HD(PortSpeed.SPEED_1GB),
+     PF_1GB_FD(PortSpeed.SPEED_1GB),
+     PF_10GB_FD(PortSpeed.SPEED_10GB),
+     PF_COPPER(PortSpeed.SPEED_NONE),
+     PF_FIBER(PortSpeed.SPEED_NONE),
+     PF_AUTONEG(PortSpeed.SPEED_NONE),
+     PF_PAUSE(PortSpeed.SPEED_NONE),
+     PF_PAUSE_ASYM(PortSpeed.SPEED_NONE),
+     PF_40GB_FD(PortSpeed.SPEED_40GB),
+     PF_100GB_FD(PortSpeed.SPEED_100GB),
+     PF_1TB_FD(PortSpeed.SPEED_1TB),
+     PF_OTHER(PortSpeed.SPEED_NONE);
+
+     private final PortSpeed portSpeed;
+
+     private OFPortFeatures(PortSpeed portSpeed) {
+        this.portSpeed = portSpeed;
+     }
+
+     public PortSpeed getPortSpeed() {
+         return portSpeed;
+     }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortMod.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortMod.java
new file mode 100644
index 0000000..5c81061
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortMod.java
@@ -0,0 +1,58 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortMod extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFPort getPortNo();
+    MacAddress getHwAddr();
+    long getConfig();
+    long getMask();
+    long getAdvertise();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFPortMod build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        MacAddress getHwAddr();
+        Builder setHwAddr(MacAddress hwAddr);
+        long getConfig();
+        Builder setConfig(long config);
+        long getMask();
+        Builder setMask(long mask);
+        long getAdvertise();
+        Builder setAdvertise(long advertise);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortModFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortModFailedCode.java
new file mode 100644
index 0000000..e43b52c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortModFailedCode.java
@@ -0,0 +1,33 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFPortModFailedCode {
+     BAD_PORT,
+     BAD_HW_ADDR,
+     BAD_CONFIG,
+     BAD_ADVERTISE,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortReason.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortReason.java
new file mode 100644
index 0000000..2e75baa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortReason.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFPortReason {
+     ADD,
+     DELETE,
+     MODIFY;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortState.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortState.java
new file mode 100644
index 0000000..40d1c6b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortState.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFPortState {
+     LINK_DOWN(false),
+     STP_LISTEN(true),
+     STP_LEARN(true),
+     STP_FORWARD(true),
+     STP_BLOCK(true),
+     STP_MASK(true),
+     BLOCKED(false),
+     LIVE(false);
+
+     private final boolean stpState;
+
+     private OFPortState(boolean stpState) {
+        this.stpState = stpState;
+     }
+
+     public boolean isStpState() {
+         return stpState;
+     }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsEntry.java
new file mode 100644
index 0000000..fd844f9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsEntry.java
@@ -0,0 +1,83 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortStatsEntry extends OFObject {
+    OFPort getPortNo();
+    U64 getRxPackets();
+    U64 getTxPackets();
+    U64 getRxBytes();
+    U64 getTxBytes();
+    U64 getRxDropped();
+    U64 getTxDropped();
+    U64 getRxErrors();
+    U64 getTxErrors();
+    U64 getRxFrameErr();
+    U64 getRxOverErr();
+    U64 getRxCrcErr();
+    U64 getCollisions();
+    long getDurationSec() throws UnsupportedOperationException;
+    long getDurationNsec() throws UnsupportedOperationException;
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFPortStatsEntry build();
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        U64 getRxPackets();
+        Builder setRxPackets(U64 rxPackets);
+        U64 getTxPackets();
+        Builder setTxPackets(U64 txPackets);
+        U64 getRxBytes();
+        Builder setRxBytes(U64 rxBytes);
+        U64 getTxBytes();
+        Builder setTxBytes(U64 txBytes);
+        U64 getRxDropped();
+        Builder setRxDropped(U64 rxDropped);
+        U64 getTxDropped();
+        Builder setTxDropped(U64 txDropped);
+        U64 getRxErrors();
+        Builder setRxErrors(U64 rxErrors);
+        U64 getTxErrors();
+        Builder setTxErrors(U64 txErrors);
+        U64 getRxFrameErr();
+        Builder setRxFrameErr(U64 rxFrameErr);
+        U64 getRxOverErr();
+        Builder setRxOverErr(U64 rxOverErr);
+        U64 getRxCrcErr();
+        Builder setRxCrcErr(U64 rxCrcErr);
+        U64 getCollisions();
+        Builder setCollisions(U64 collisions);
+        long getDurationSec() throws UnsupportedOperationException;
+        Builder setDurationSec(long durationSec) throws UnsupportedOperationException;
+        long getDurationNsec() throws UnsupportedOperationException;
+        Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException;
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsReply.java
new file mode 100644
index 0000000..90e0c31
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFPortStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFPortStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFPortStatsEntry> getEntries();
+        Builder setEntries(List<OFPortStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsRequest.java
new file mode 100644
index 0000000..2bbdf93
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatsRequest.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortStatsRequest extends OFObject, OFStatsRequest<OFPortStatsReply>, OFRequest<OFPortStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    OFPort getPortNo();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFPortStatsReply> {
+        OFPortStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatus.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatus.java
new file mode 100644
index 0000000..e7bee5b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFPortStatus.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortStatus extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFPortReason getReason();
+    OFPortDesc getDesc();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFPortStatus build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFPortReason getReason();
+        Builder setReason(OFPortReason reason);
+        OFPortDesc getDesc();
+        Builder setDesc(OFPortDesc desc);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueGetConfigReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueGetConfigReply.java
new file mode 100644
index 0000000..d31aab4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueGetConfigReply.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueueGetConfigReply extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFPort getPort();
+    List<OFPacketQueue> getQueues();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFQueueGetConfigReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFPort getPort();
+        Builder setPort(OFPort port);
+        List<OFPacketQueue> getQueues();
+        Builder setQueues(List<OFPacketQueue> queues);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueGetConfigRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueGetConfigRequest.java
new file mode 100644
index 0000000..cddc9f0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueGetConfigRequest.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueueGetConfigRequest extends OFObject, OFMessage, OFRequest<OFQueueGetConfigReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFPort getPort();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFQueueGetConfigRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFPort getPort();
+        Builder setPort(OFPort port);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueOpFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueOpFailedCode.java
new file mode 100644
index 0000000..21549e2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueOpFailedCode.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFQueueOpFailedCode {
+     BAD_PORT,
+     BAD_QUEUE,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueProperties.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueProperties.java
new file mode 100644
index 0000000..a5a11fc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueProperties.java
@@ -0,0 +1,32 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFQueueProperties {
+     NONE,
+     MIN_RATE,
+     MAX_RATE,
+     EXPERIMENTER;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsEntry.java
new file mode 100644
index 0000000..4f04ad8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsEntry.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueueStatsEntry extends OFObject {
+    OFPort getPortNo();
+    long getQueueId();
+    U64 getTxBytes();
+    U64 getTxPackets();
+    U64 getTxErrors();
+    long getDurationSec() throws UnsupportedOperationException;
+    long getDurationNsec() throws UnsupportedOperationException;
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFQueueStatsEntry build();
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        long getQueueId();
+        Builder setQueueId(long queueId);
+        U64 getTxBytes();
+        Builder setTxBytes(U64 txBytes);
+        U64 getTxPackets();
+        Builder setTxPackets(U64 txPackets);
+        U64 getTxErrors();
+        Builder setTxErrors(U64 txErrors);
+        long getDurationSec() throws UnsupportedOperationException;
+        Builder setDurationSec(long durationSec) throws UnsupportedOperationException;
+        long getDurationNsec() throws UnsupportedOperationException;
+        Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException;
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsReply.java
new file mode 100644
index 0000000..efeb67d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueueStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFQueueStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFQueueStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFQueueStatsEntry> getEntries();
+        Builder setEntries(List<OFQueueStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsRequest.java
new file mode 100644
index 0000000..3101abe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFQueueStatsRequest.java
@@ -0,0 +1,55 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueueStatsRequest extends OFObject, OFStatsRequest<OFQueueStatsReply>, OFRequest<OFQueueStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    OFPort getPortNo();
+    long getQueueId();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFQueueStatsReply> {
+        OFQueueStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        OFPort getPortNo();
+        Builder setPortNo(OFPort portNo);
+        long getQueueId();
+        Builder setQueueId(long queueId);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleReply.java
new file mode 100644
index 0000000..2b3a992
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleReply.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFRoleReply extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFControllerRole getRole();
+    U64 getGenerationId();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFRoleReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFControllerRole getRole();
+        Builder setRole(OFControllerRole role);
+        U64 getGenerationId();
+        Builder setGenerationId(U64 generationId);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleRequest.java
new file mode 100644
index 0000000..15bae7e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleRequest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFRoleRequest extends OFObject, OFMessage, OFRequest<OFRoleReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFControllerRole getRole();
+    U64 getGenerationId();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFRoleRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFControllerRole getRole();
+        Builder setRole(OFControllerRole role);
+        U64 getGenerationId();
+        Builder setGenerationId(U64 generationId);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleRequestFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleRequestFailedCode.java
new file mode 100644
index 0000000..19793ec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFRoleRequestFailedCode.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFRoleRequestFailedCode {
+     STALE,
+     UNSUP,
+     BAD_ROLE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFSetConfig.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFSetConfig.java
new file mode 100644
index 0000000..2caf3f4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFSetConfig.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFSetConfig extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    Set<OFConfigFlags> getFlags();
+    int getMissSendLen();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFSetConfig build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        Set<OFConfigFlags> getFlags();
+        Builder setFlags(Set<OFConfigFlags> flags);
+        int getMissSendLen();
+        Builder setMissSendLen(int missSendLen);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsReply.java
new file mode 100644
index 0000000..504180a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsReply.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFStatsReply extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsReplyFlags.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsReplyFlags.java
new file mode 100644
index 0000000..e521381
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsReplyFlags.java
@@ -0,0 +1,29 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFStatsReplyFlags {
+     REPLY_MORE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsRequest.java
new file mode 100644
index 0000000..94ea80b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsRequest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFStatsRequest<T extends OFStatsReply> extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder<T> createBuilder();
+    public interface Builder<T extends OFStatsReply> extends OFMessage.Builder {
+        OFStatsRequest<T> build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder<T> setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder<T> setFlags(Set<OFStatsRequestFlags> flags);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsRequestFlags.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsRequestFlags.java
new file mode 100644
index 0000000..80ba542
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsRequestFlags.java
@@ -0,0 +1,29 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFStatsRequestFlags {
+     REQ_MORE;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsType.java
new file mode 100644
index 0000000..fee8757
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFStatsType.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFStatsType {
+     DESC,
+     FLOW,
+     AGGREGATE,
+     TABLE,
+     PORT,
+     QUEUE,
+     EXPERIMENTER,
+     GROUP,
+     GROUP_DESC,
+     GROUP_FEATURES,
+     METER,
+     METER_CONFIG,
+     METER_FEATURES,
+     TABLE_FEATURES,
+     PORT_DESC;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFSwitchConfigFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFSwitchConfigFailedCode.java
new file mode 100644
index 0000000..646ce00
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFSwitchConfigFailedCode.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFSwitchConfigFailedCode {
+     BAD_FLAGS,
+     BAD_LEN,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTable.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTable.java
new file mode 100644
index 0000000..301ce93
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTable.java
@@ -0,0 +1,30 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFTable {
+     MAX,
+     ALL;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableConfig.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableConfig.java
new file mode 100644
index 0000000..d620606
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableConfig.java
@@ -0,0 +1,33 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFTableConfig {
+     TABLE_MISS_CONTROLLER,
+     TABLE_MISS_CONTINUE,
+     TABLE_MISS_DROP,
+     TABLE_MISS_MASK,
+     DEPRECATED_MASK;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeatureProp.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeatureProp.java
new file mode 100644
index 0000000..4df78c2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeatureProp.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeatureProp extends OFObject {
+    int getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFTableFeatureProp build();
+        int getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplyActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplyActions.java
new file mode 100644
index 0000000..35ac87a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplyActions.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropApplyActions extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<OFActionId> getActionIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropApplyActions build();
+        int getType();
+        List<OFActionId> getActionIds();
+        Builder setActionIds(List<OFActionId> actionIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplyActionsMiss.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplyActionsMiss.java
new file mode 100644
index 0000000..00dff4d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplyActionsMiss.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropApplyActionsMiss extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<OFActionId> getActionIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropApplyActionsMiss build();
+        int getType();
+        List<OFActionId> getActionIds();
+        Builder setActionIds(List<OFActionId> actionIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplySetfield.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplySetfield.java
new file mode 100644
index 0000000..2fc37f7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplySetfield.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropApplySetfield extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<U32> getOxmIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropApplySetfield build();
+        int getType();
+        List<U32> getOxmIds();
+        Builder setOxmIds(List<U32> oxmIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplySetfieldMiss.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplySetfieldMiss.java
new file mode 100644
index 0000000..a1208be
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropApplySetfieldMiss.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropApplySetfieldMiss extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<U32> getOxmIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropApplySetfieldMiss build();
+        int getType();
+        List<U32> getOxmIds();
+        Builder setOxmIds(List<U32> oxmIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropExperimenter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropExperimenter.java
new file mode 100644
index 0000000..2b80219
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropExperimenter.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropExperimenter extends OFObject, OFTableFeatureProp {
+    int getType();
+    long getExperimenter();
+    long getSubtype();
+    byte[] getExperimenterData();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropExperimenter build();
+        int getType();
+        long getExperimenter();
+        Builder setExperimenter(long experimenter);
+        long getSubtype();
+        Builder setSubtype(long subtype);
+        byte[] getExperimenterData();
+        Builder setExperimenterData(byte[] experimenterData);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropExperimenterMiss.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropExperimenterMiss.java
new file mode 100644
index 0000000..74a2040
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropExperimenterMiss.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropExperimenterMiss extends OFObject, OFTableFeatureProp {
+    int getType();
+    long getExperimenter();
+    long getSubtype();
+    byte[] getExperimenterData();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropExperimenterMiss build();
+        int getType();
+        long getExperimenter();
+        Builder setExperimenter(long experimenter);
+        long getSubtype();
+        Builder setSubtype(long subtype);
+        byte[] getExperimenterData();
+        Builder setExperimenterData(byte[] experimenterData);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropInstructions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropInstructions.java
new file mode 100644
index 0000000..43d489f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropInstructions.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropInstructions extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<OFInstructionId> getInstructionIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropInstructions build();
+        int getType();
+        List<OFInstructionId> getInstructionIds();
+        Builder setInstructionIds(List<OFInstructionId> instructionIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropInstructionsMiss.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropInstructionsMiss.java
new file mode 100644
index 0000000..edd4684
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropInstructionsMiss.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropInstructionsMiss extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<OFInstructionId> getInstructionIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropInstructionsMiss build();
+        int getType();
+        List<OFInstructionId> getInstructionIds();
+        Builder setInstructionIds(List<OFInstructionId> instructionIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropMatch.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropMatch.java
new file mode 100644
index 0000000..a065105
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropMatch.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropMatch extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<U32> getOxmIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropMatch build();
+        int getType();
+        List<U32> getOxmIds();
+        Builder setOxmIds(List<U32> oxmIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropNextTables.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropNextTables.java
new file mode 100644
index 0000000..ec3dc29
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropNextTables.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropNextTables extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<U8> getNextTableIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropNextTables build();
+        int getType();
+        List<U8> getNextTableIds();
+        Builder setNextTableIds(List<U8> nextTableIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropNextTablesMiss.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropNextTablesMiss.java
new file mode 100644
index 0000000..d9c5911
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropNextTablesMiss.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropNextTablesMiss extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<U8> getNextTableIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropNextTablesMiss build();
+        int getType();
+        List<U8> getNextTableIds();
+        Builder setNextTableIds(List<U8> nextTableIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropType.java
new file mode 100644
index 0000000..36691ee
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropType.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFTableFeaturePropType {
+     INSTRUCTIONS,
+     INSTRUCTIONS_MISS,
+     NEXT_TABLES,
+     NEXT_TABLES_MISS,
+     WRITE_ACTIONS,
+     WRITE_ACTIONS_MISS,
+     APPLY_ACTIONS,
+     APPLY_ACTIONS_MISS,
+     MATCH,
+     WILDCARDS,
+     WRITE_SETFIELD,
+     WRITE_SETFIELD_MISS,
+     APPLY_SETFIELD,
+     APPLY_SETFIELD_MISS,
+     EXPERIMENTER,
+     EXPERIMENTER_MISS;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWildcards.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWildcards.java
new file mode 100644
index 0000000..c513561
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWildcards.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropWildcards extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<U32> getOxmIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropWildcards build();
+        int getType();
+        List<U32> getOxmIds();
+        Builder setOxmIds(List<U32> oxmIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteActions.java
new file mode 100644
index 0000000..9b7dec1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteActions.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropWriteActions extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<OFActionId> getActionIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropWriteActions build();
+        int getType();
+        List<OFActionId> getActionIds();
+        Builder setActionIds(List<OFActionId> actionIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteActionsMiss.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteActionsMiss.java
new file mode 100644
index 0000000..e3deb3c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteActionsMiss.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropWriteActionsMiss extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<OFActionId> getActionIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropWriteActionsMiss build();
+        int getType();
+        List<OFActionId> getActionIds();
+        Builder setActionIds(List<OFActionId> actionIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteSetfield.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteSetfield.java
new file mode 100644
index 0000000..7b5811b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteSetfield.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropWriteSetfield extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<U32> getOxmIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropWriteSetfield build();
+        int getType();
+        List<U32> getOxmIds();
+        Builder setOxmIds(List<U32> oxmIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteSetfieldMiss.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteSetfieldMiss.java
new file mode 100644
index 0000000..f68d90d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturePropWriteSetfieldMiss.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturePropWriteSetfieldMiss extends OFObject, OFTableFeatureProp {
+    int getType();
+    List<U32> getOxmIds();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFTableFeatureProp.Builder {
+        OFTableFeaturePropWriteSetfieldMiss build();
+        int getType();
+        List<U32> getOxmIds();
+        Builder setOxmIds(List<U32> oxmIds);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeatures.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeatures.java
new file mode 100644
index 0000000..d74de81
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeatures.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeatures extends OFObject {
+    TableId getTableId();
+    String getName();
+    U64 getMetadataMatch();
+    U64 getMetadataWrite();
+    long getConfig();
+    long getMaxEntries();
+    List<OFTableFeatureProp> getProperties();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFTableFeatures build();
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        String getName();
+        Builder setName(String name);
+        U64 getMetadataMatch();
+        Builder setMetadataMatch(U64 metadataMatch);
+        U64 getMetadataWrite();
+        Builder setMetadataWrite(U64 metadataWrite);
+        long getConfig();
+        Builder setConfig(long config);
+        long getMaxEntries();
+        Builder setMaxEntries(long maxEntries);
+        List<OFTableFeatureProp> getProperties();
+        Builder setProperties(List<OFTableFeatureProp> properties);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesFailedCode.java
new file mode 100644
index 0000000..5703e53
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesFailedCode.java
@@ -0,0 +1,34 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFTableFeaturesFailedCode {
+     BAD_TABLE,
+     BAD_METADATA,
+     BAD_TYPE,
+     BAD_LEN,
+     BAD_ARGUMENT,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesStatsReply.java
new file mode 100644
index 0000000..10d48ff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturesStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFTableFeatures> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFTableFeaturesStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFTableFeatures> getEntries();
+        Builder setEntries(List<OFTableFeatures> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesStatsRequest.java
new file mode 100644
index 0000000..00dc72d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableFeaturesStatsRequest.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturesStatsRequest extends OFObject, OFStatsRequest<OFTableFeaturesStatsReply>, OFRequest<OFTableFeaturesStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+    List<OFTableFeatures> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFTableFeaturesStatsReply> {
+        OFTableFeaturesStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+        List<OFTableFeatures> getEntries();
+        Builder setEntries(List<OFTableFeatures> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableMod.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableMod.java
new file mode 100644
index 0000000..be009c9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableMod.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableMod extends OFObject, OFMessage {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    TableId getTableId();
+    long getConfig();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMessage.Builder {
+        OFTableMod build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        long getConfig();
+        Builder setConfig(long config);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableModFailedCode.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableModFailedCode.java
new file mode 100644
index 0000000..6f81b11
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableModFailedCode.java
@@ -0,0 +1,31 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFTableModFailedCode {
+     BAD_TABLE,
+     BAD_CONFIG,
+     EPERM;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsEntry.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsEntry.java
new file mode 100644
index 0000000..ee02f19
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsEntry.java
@@ -0,0 +1,87 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableStatsEntry extends OFObject {
+    TableId getTableId();
+    String getName() throws UnsupportedOperationException;
+    OFMatchBmap getMatch() throws UnsupportedOperationException;
+    int getWildcards() throws UnsupportedOperationException;
+    long getWriteActions() throws UnsupportedOperationException;
+    long getApplyActions() throws UnsupportedOperationException;
+    U64 getWriteSetfields() throws UnsupportedOperationException;
+    U64 getApplySetfields() throws UnsupportedOperationException;
+    U64 getMetadataMatch() throws UnsupportedOperationException;
+    U64 getMetadataWrite() throws UnsupportedOperationException;
+    long getInstructions() throws UnsupportedOperationException;
+    long getConfig() throws UnsupportedOperationException;
+    long getMaxEntries() throws UnsupportedOperationException;
+    long getActiveCount();
+    U64 getLookupCount();
+    U64 getMatchedCount();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFTableStatsEntry build();
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        String getName() throws UnsupportedOperationException;
+        Builder setName(String name) throws UnsupportedOperationException;
+        OFMatchBmap getMatch() throws UnsupportedOperationException;
+        Builder setMatch(OFMatchBmap match) throws UnsupportedOperationException;
+        int getWildcards() throws UnsupportedOperationException;
+        Builder setWildcards(int wildcards) throws UnsupportedOperationException;
+        long getWriteActions() throws UnsupportedOperationException;
+        Builder setWriteActions(long writeActions) throws UnsupportedOperationException;
+        long getApplyActions() throws UnsupportedOperationException;
+        Builder setApplyActions(long applyActions) throws UnsupportedOperationException;
+        U64 getWriteSetfields() throws UnsupportedOperationException;
+        Builder setWriteSetfields(U64 writeSetfields) throws UnsupportedOperationException;
+        U64 getApplySetfields() throws UnsupportedOperationException;
+        Builder setApplySetfields(U64 applySetfields) throws UnsupportedOperationException;
+        U64 getMetadataMatch() throws UnsupportedOperationException;
+        Builder setMetadataMatch(U64 metadataMatch) throws UnsupportedOperationException;
+        U64 getMetadataWrite() throws UnsupportedOperationException;
+        Builder setMetadataWrite(U64 metadataWrite) throws UnsupportedOperationException;
+        long getInstructions() throws UnsupportedOperationException;
+        Builder setInstructions(long instructions) throws UnsupportedOperationException;
+        long getConfig() throws UnsupportedOperationException;
+        Builder setConfig(long config) throws UnsupportedOperationException;
+        long getMaxEntries() throws UnsupportedOperationException;
+        Builder setMaxEntries(long maxEntries) throws UnsupportedOperationException;
+        long getActiveCount();
+        Builder setActiveCount(long activeCount);
+        U64 getLookupCount();
+        Builder setLookupCount(U64 lookupCount);
+        U64 getMatchedCount();
+        Builder setMatchedCount(U64 matchedCount);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsReply.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsReply.java
new file mode 100644
index 0000000..e16d879
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsReply.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableStatsReply extends OFObject, OFStatsReply {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsReplyFlags> getFlags();
+    List<OFTableStatsEntry> getEntries();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsReply.Builder {
+        OFTableStatsReply build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsReplyFlags> getFlags();
+        Builder setFlags(Set<OFStatsReplyFlags> flags);
+        List<OFTableStatsEntry> getEntries();
+        Builder setEntries(List<OFTableStatsEntry> entries);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsRequest.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsRequest.java
new file mode 100644
index 0000000..a9dff30
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFTableStatsRequest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableStatsRequest extends OFObject, OFStatsRequest<OFTableStatsReply>, OFRequest<OFTableStatsReply> {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFStatsType getStatsType();
+    Set<OFStatsRequestFlags> getFlags();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFStatsRequest.Builder<OFTableStatsReply> {
+        OFTableStatsRequest build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFStatsType getStatsType();
+        Set<OFStatsRequestFlags> getFlags();
+        Builder setFlags(Set<OFStatsRequestFlags> flags);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFType.java
new file mode 100644
index 0000000..aef779f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFType.java
@@ -0,0 +1,58 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public enum OFType {
+     HELLO,
+     ERROR,
+     ECHO_REQUEST,
+     ECHO_REPLY,
+     EXPERIMENTER,
+     FEATURES_REQUEST,
+     FEATURES_REPLY,
+     GET_CONFIG_REQUEST,
+     GET_CONFIG_REPLY,
+     SET_CONFIG,
+     PACKET_IN,
+     FLOW_REMOVED,
+     PORT_STATUS,
+     PACKET_OUT,
+     FLOW_MOD,
+     PORT_MOD,
+     STATS_REQUEST,
+     STATS_REPLY,
+     BARRIER_REQUEST,
+     BARRIER_REPLY,
+     QUEUE_GET_CONFIG_REQUEST,
+     QUEUE_GET_CONFIG_REPLY,
+     GROUP_MOD,
+     TABLE_MOD,
+     ROLE_REQUEST,
+     ROLE_REPLY,
+     GET_ASYNC_REQUEST,
+     GET_ASYNC_REPLY,
+     SET_ASYNC,
+     METER_MOD;
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFUint64.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFUint64.java
new file mode 100644
index 0000000..c9d5edd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/OFUint64.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFUint64 extends OFObject {
+    U64 getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFUint64 build();
+        U64 getValue();
+        Builder setValue(U64 value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFAction.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFAction.java
new file mode 100644
index 0000000..6a2f731
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFAction.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFAction extends OFObject {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFAction build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsn.java
new file mode 100644
index 0000000..c644ffd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsn.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionBsn extends OFObject, OFActionExperimenter {
+    OFActionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionExperimenter.Builder {
+        OFActionBsn build();
+        OFActionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnChecksum.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnChecksum.java
new file mode 100644
index 0000000..e09c19c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnChecksum.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionBsnChecksum extends OFObject, OFActionBsn {
+    OFActionType getType();
+    long getExperimenter();
+    long getSubtype();
+    U128 getChecksum();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionBsn.Builder {
+        OFActionBsnChecksum build();
+        OFActionType getType();
+        long getExperimenter();
+        long getSubtype();
+        U128 getChecksum();
+        Builder setChecksum(U128 checksum);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnMirror.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnMirror.java
new file mode 100644
index 0000000..8b15cd2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnMirror.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionBsnMirror extends OFObject, OFActionBsn {
+    OFActionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFPort getDestPort();
+    long getVlanTag();
+    short getCopyStage();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionBsn.Builder {
+        OFActionBsnMirror build();
+        OFActionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFPort getDestPort();
+        Builder setDestPort(OFPort destPort);
+        long getVlanTag();
+        Builder setVlanTag(long vlanTag);
+        short getCopyStage();
+        Builder setCopyStage(short copyStage);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnSetTunnelDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnSetTunnelDst.java
new file mode 100644
index 0000000..24dbb3a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionBsnSetTunnelDst.java
@@ -0,0 +1,48 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionBsnSetTunnelDst extends OFObject, OFActionBsn {
+    OFActionType getType();
+    long getExperimenter();
+    long getSubtype();
+    long getDst();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionBsn.Builder {
+        OFActionBsnSetTunnelDst build();
+        OFActionType getType();
+        long getExperimenter();
+        long getSubtype();
+        long getDst();
+        Builder setDst(long dst);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionCopyTtlIn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionCopyTtlIn.java
new file mode 100644
index 0000000..166d4a7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionCopyTtlIn.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionCopyTtlIn extends OFObject, OFAction {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionCopyTtlIn build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionCopyTtlOut.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionCopyTtlOut.java
new file mode 100644
index 0000000..d78e511
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionCopyTtlOut.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionCopyTtlOut extends OFObject, OFAction {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionCopyTtlOut build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionDecMplsTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionDecMplsTtl.java
new file mode 100644
index 0000000..e855cf0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionDecMplsTtl.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionDecMplsTtl extends OFObject, OFAction {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionDecMplsTtl build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionDecNwTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionDecNwTtl.java
new file mode 100644
index 0000000..5dbec27
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionDecNwTtl.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionDecNwTtl extends OFObject, OFAction {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionDecNwTtl build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionEnqueue.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionEnqueue.java
new file mode 100644
index 0000000..11ab1a6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionEnqueue.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionEnqueue extends OFObject, OFAction {
+    OFActionType getType();
+    OFPort getPort();
+    long getQueueId();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionEnqueue build();
+        OFActionType getType();
+        OFPort getPort();
+        Builder setPort(OFPort port);
+        long getQueueId();
+        Builder setQueueId(long queueId);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionExperimenter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionExperimenter.java
new file mode 100644
index 0000000..56d9ef9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionExperimenter.java
@@ -0,0 +1,42 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionExperimenter extends OFObject, OFAction {
+    OFActionType getType();
+    long getExperimenter();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionExperimenter build();
+        OFActionType getType();
+        long getExperimenter();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionGroup.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionGroup.java
new file mode 100644
index 0000000..8d65fa8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionGroup.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionGroup extends OFObject, OFAction {
+    OFActionType getType();
+    OFGroup getGroup();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionGroup build();
+        OFActionType getType();
+        OFGroup getGroup();
+        Builder setGroup(OFGroup group);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionNicira.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionNicira.java
new file mode 100644
index 0000000..aad3c35
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionNicira.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionNicira extends OFObject, OFActionExperimenter {
+    OFActionType getType();
+    long getExperimenter();
+    int getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionExperimenter.Builder {
+        OFActionNicira build();
+        OFActionType getType();
+        long getExperimenter();
+        int getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionNiciraDecTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionNiciraDecTtl.java
new file mode 100644
index 0000000..55b81c9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionNiciraDecTtl.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionNiciraDecTtl extends OFObject, OFActionNicira {
+    OFActionType getType();
+    long getExperimenter();
+    int getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionNicira.Builder {
+        OFActionNiciraDecTtl build();
+        OFActionType getType();
+        long getExperimenter();
+        int getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionOutput.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionOutput.java
new file mode 100644
index 0000000..b673a22
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionOutput.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionOutput extends OFObject, OFAction {
+    OFActionType getType();
+    OFPort getPort();
+    int getMaxLen();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionOutput build();
+        OFActionType getType();
+        OFPort getPort();
+        Builder setPort(OFPort port);
+        int getMaxLen();
+        Builder setMaxLen(int maxLen);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopMpls.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopMpls.java
new file mode 100644
index 0000000..3067e2f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopMpls.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionPopMpls extends OFObject, OFAction {
+    OFActionType getType();
+    EthType getEthertype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionPopMpls build();
+        OFActionType getType();
+        EthType getEthertype();
+        Builder setEthertype(EthType ethertype);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopPbb.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopPbb.java
new file mode 100644
index 0000000..33934b6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopPbb.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionPopPbb extends OFObject, OFAction {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionPopPbb build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopVlan.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopVlan.java
new file mode 100644
index 0000000..998f7db
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPopVlan.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionPopVlan extends OFObject, OFAction {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionPopVlan build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushMpls.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushMpls.java
new file mode 100644
index 0000000..76b7da2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushMpls.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionPushMpls extends OFObject, OFAction {
+    OFActionType getType();
+    EthType getEthertype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionPushMpls build();
+        OFActionType getType();
+        EthType getEthertype();
+        Builder setEthertype(EthType ethertype);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushPbb.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushPbb.java
new file mode 100644
index 0000000..0177569
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushPbb.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionPushPbb extends OFObject, OFAction {
+    OFActionType getType();
+    EthType getEthertype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionPushPbb build();
+        OFActionType getType();
+        EthType getEthertype();
+        Builder setEthertype(EthType ethertype);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushVlan.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushVlan.java
new file mode 100644
index 0000000..e98513b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionPushVlan.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionPushVlan extends OFObject, OFAction {
+    OFActionType getType();
+    EthType getEthertype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionPushVlan build();
+        OFActionType getType();
+        EthType getEthertype();
+        Builder setEthertype(EthType ethertype);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetDlDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetDlDst.java
new file mode 100644
index 0000000..1897651
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetDlDst.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetDlDst extends OFObject, OFAction {
+    OFActionType getType();
+    MacAddress getDlAddr();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetDlDst build();
+        OFActionType getType();
+        MacAddress getDlAddr();
+        Builder setDlAddr(MacAddress dlAddr);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetDlSrc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetDlSrc.java
new file mode 100644
index 0000000..8dcc7f5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetDlSrc.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetDlSrc extends OFObject, OFAction {
+    OFActionType getType();
+    MacAddress getDlAddr();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetDlSrc build();
+        OFActionType getType();
+        MacAddress getDlAddr();
+        Builder setDlAddr(MacAddress dlAddr);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetField.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetField.java
new file mode 100644
index 0000000..25f91ce
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetField.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetField extends OFObject, OFAction {
+    OFActionType getType();
+    OFOxm<?> getField();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetField build();
+        OFActionType getType();
+        OFOxm<?> getField();
+        Builder setField(OFOxm<?> field);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsLabel.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsLabel.java
new file mode 100644
index 0000000..214d66b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsLabel.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetMplsLabel extends OFObject, OFAction {
+    OFActionType getType();
+    long getMplsLabel();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetMplsLabel build();
+        OFActionType getType();
+        long getMplsLabel();
+        Builder setMplsLabel(long mplsLabel);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsTc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsTc.java
new file mode 100644
index 0000000..6c43156
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsTc.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetMplsTc extends OFObject, OFAction {
+    OFActionType getType();
+    short getMplsTc();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetMplsTc build();
+        OFActionType getType();
+        short getMplsTc();
+        Builder setMplsTc(short mplsTc);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsTtl.java
new file mode 100644
index 0000000..c8513c6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetMplsTtl.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetMplsTtl extends OFObject, OFAction {
+    OFActionType getType();
+    short getMplsTtl();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetMplsTtl build();
+        OFActionType getType();
+        short getMplsTtl();
+        Builder setMplsTtl(short mplsTtl);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwDst.java
new file mode 100644
index 0000000..539cd37
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwDst.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetNwDst extends OFObject, OFAction {
+    OFActionType getType();
+    IPv4Address getNwAddr();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetNwDst build();
+        OFActionType getType();
+        IPv4Address getNwAddr();
+        Builder setNwAddr(IPv4Address nwAddr);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwEcn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwEcn.java
new file mode 100644
index 0000000..a42e2c8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwEcn.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetNwEcn extends OFObject, OFAction {
+    OFActionType getType();
+    IpEcn getNwEcn();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetNwEcn build();
+        OFActionType getType();
+        IpEcn getNwEcn();
+        Builder setNwEcn(IpEcn nwEcn);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwSrc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwSrc.java
new file mode 100644
index 0000000..cd27977
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwSrc.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetNwSrc extends OFObject, OFAction {
+    OFActionType getType();
+    IPv4Address getNwAddr();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetNwSrc build();
+        OFActionType getType();
+        IPv4Address getNwAddr();
+        Builder setNwAddr(IPv4Address nwAddr);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwTos.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwTos.java
new file mode 100644
index 0000000..38a133b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwTos.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetNwTos extends OFObject, OFAction {
+    OFActionType getType();
+    short getNwTos();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetNwTos build();
+        OFActionType getType();
+        short getNwTos();
+        Builder setNwTos(short nwTos);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwTtl.java
new file mode 100644
index 0000000..ed35d59
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetNwTtl.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetNwTtl extends OFObject, OFAction {
+    OFActionType getType();
+    short getNwTtl();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetNwTtl build();
+        OFActionType getType();
+        short getNwTtl();
+        Builder setNwTtl(short nwTtl);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetQueue.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetQueue.java
new file mode 100644
index 0000000..b2115ab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetQueue.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetQueue extends OFObject, OFAction {
+    OFActionType getType();
+    long getQueueId();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetQueue build();
+        OFActionType getType();
+        long getQueueId();
+        Builder setQueueId(long queueId);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetTpDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetTpDst.java
new file mode 100644
index 0000000..680b99a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetTpDst.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetTpDst extends OFObject, OFAction {
+    OFActionType getType();
+    TransportPort getTpPort();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetTpDst build();
+        OFActionType getType();
+        TransportPort getTpPort();
+        Builder setTpPort(TransportPort tpPort);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetTpSrc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetTpSrc.java
new file mode 100644
index 0000000..bf555aa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetTpSrc.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetTpSrc extends OFObject, OFAction {
+    OFActionType getType();
+    TransportPort getTpPort();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetTpSrc build();
+        OFActionType getType();
+        TransportPort getTpPort();
+        Builder setTpPort(TransportPort tpPort);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetVlanPcp.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetVlanPcp.java
new file mode 100644
index 0000000..a448078
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetVlanPcp.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetVlanPcp extends OFObject, OFAction {
+    OFActionType getType();
+    VlanPcp getVlanPcp();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetVlanPcp build();
+        OFActionType getType();
+        VlanPcp getVlanPcp();
+        Builder setVlanPcp(VlanPcp vlanPcp);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetVlanVid.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetVlanVid.java
new file mode 100644
index 0000000..5bbf2c7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionSetVlanVid.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionSetVlanVid extends OFObject, OFAction {
+    OFActionType getType();
+    VlanVid getVlanVid();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionSetVlanVid build();
+        OFActionType getType();
+        VlanVid getVlanVid();
+        Builder setVlanVid(VlanVid vlanVid);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionStripVlan.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionStripVlan.java
new file mode 100644
index 0000000..d3fcc90
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActionStripVlan.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionStripVlan extends OFObject, OFAction {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFAction.Builder {
+        OFActionStripVlan build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActions.java
new file mode 100644
index 0000000..e465ac5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/action/OFActions.java
@@ -0,0 +1,93 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.action;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+public interface OFActions {
+    // Subfactories
+
+    OFActionBsnChecksum.Builder buildBsnChecksum();
+    OFActionBsnChecksum bsnChecksum(U128 checksum);
+    OFActionBsnMirror.Builder buildBsnMirror();
+    OFActionBsnSetTunnelDst.Builder buildBsnSetTunnelDst();
+    OFActionBsnSetTunnelDst bsnSetTunnelDst(long dst);
+    OFActionEnqueue.Builder buildEnqueue() throws UnsupportedOperationException;
+    OFActionEnqueue enqueue(OFPort port, long queueId);
+    OFActionNiciraDecTtl niciraDecTtl();
+    OFActionOutput.Builder buildOutput();
+    OFActionOutput output(OFPort port, int maxLen);
+    OFActionSetDlDst.Builder buildSetDlDst() throws UnsupportedOperationException;
+    OFActionSetDlDst setDlDst(MacAddress dlAddr);
+    OFActionSetDlSrc.Builder buildSetDlSrc() throws UnsupportedOperationException;
+    OFActionSetDlSrc setDlSrc(MacAddress dlAddr);
+    OFActionSetNwDst.Builder buildSetNwDst() throws UnsupportedOperationException;
+    OFActionSetNwDst setNwDst(IPv4Address nwAddr);
+    OFActionSetNwSrc.Builder buildSetNwSrc() throws UnsupportedOperationException;
+    OFActionSetNwSrc setNwSrc(IPv4Address nwAddr);
+    OFActionSetNwTos.Builder buildSetNwTos() throws UnsupportedOperationException;
+    OFActionSetNwTos setNwTos(short nwTos);
+    OFActionSetTpDst.Builder buildSetTpDst() throws UnsupportedOperationException;
+    OFActionSetTpDst setTpDst(TransportPort tpPort);
+    OFActionSetTpSrc.Builder buildSetTpSrc() throws UnsupportedOperationException;
+    OFActionSetTpSrc setTpSrc(TransportPort tpPort);
+    OFActionSetVlanPcp.Builder buildSetVlanPcp() throws UnsupportedOperationException;
+    OFActionSetVlanPcp setVlanPcp(VlanPcp vlanPcp);
+    OFActionSetVlanVid.Builder buildSetVlanVid() throws UnsupportedOperationException;
+    OFActionSetVlanVid setVlanVid(VlanVid vlanVid);
+    OFActionStripVlan stripVlan();
+    OFActionCopyTtlIn copyTtlIn();
+    OFActionCopyTtlOut copyTtlOut();
+    OFActionDecMplsTtl decMplsTtl();
+    OFActionDecNwTtl decNwTtl();
+    OFActionGroup.Builder buildGroup() throws UnsupportedOperationException;
+    OFActionGroup group(OFGroup group);
+    OFActionPopMpls.Builder buildPopMpls() throws UnsupportedOperationException;
+    OFActionPopMpls popMpls(EthType ethertype);
+    OFActionPopVlan popVlan();
+    OFActionPushMpls.Builder buildPushMpls() throws UnsupportedOperationException;
+    OFActionPushMpls pushMpls(EthType ethertype);
+    OFActionPushVlan.Builder buildPushVlan() throws UnsupportedOperationException;
+    OFActionPushVlan pushVlan(EthType ethertype);
+    OFActionSetMplsLabel.Builder buildSetMplsLabel() throws UnsupportedOperationException;
+    OFActionSetMplsLabel setMplsLabel(long mplsLabel);
+    OFActionSetMplsTc.Builder buildSetMplsTc() throws UnsupportedOperationException;
+    OFActionSetMplsTc setMplsTc(short mplsTc);
+    OFActionSetMplsTtl.Builder buildSetMplsTtl() throws UnsupportedOperationException;
+    OFActionSetMplsTtl setMplsTtl(short mplsTtl);
+    OFActionSetNwEcn.Builder buildSetNwEcn() throws UnsupportedOperationException;
+    OFActionSetNwEcn setNwEcn(IpEcn nwEcn);
+    OFActionSetNwTtl.Builder buildSetNwTtl() throws UnsupportedOperationException;
+    OFActionSetNwTtl setNwTtl(short nwTtl);
+    OFActionSetQueue.Builder buildSetQueue() throws UnsupportedOperationException;
+    OFActionSetQueue setQueue(long queueId);
+    OFActionSetField.Builder buildSetField() throws UnsupportedOperationException;
+    OFActionSetField setField(OFOxm<?> field);
+    OFActionPopPbb popPbb();
+    OFActionPushPbb.Builder buildPushPbb() throws UnsupportedOperationException;
+    OFActionPushPbb pushPbb(EthType ethertype);
+
+    OFMessageReader<OFAction> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionId.java
new file mode 100644
index 0000000..0ffacb4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionId.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionId extends OFObject {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFActionId build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsn.java
new file mode 100644
index 0000000..c74b037
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsn.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdBsn extends OFObject, OFActionIdExperimenter {
+    OFActionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionIdExperimenter.Builder {
+        OFActionIdBsn build();
+        OFActionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnChecksum.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnChecksum.java
new file mode 100644
index 0000000..b051b37
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnChecksum.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdBsnChecksum extends OFObject, OFActionIdBsn {
+    OFActionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionIdBsn.Builder {
+        OFActionIdBsnChecksum build();
+        OFActionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnMirror.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnMirror.java
new file mode 100644
index 0000000..60c4c92
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnMirror.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdBsnMirror extends OFObject, OFActionIdBsn {
+    OFActionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionIdBsn.Builder {
+        OFActionIdBsnMirror build();
+        OFActionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnSetTunnelDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnSetTunnelDst.java
new file mode 100644
index 0000000..b2c407a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdBsnSetTunnelDst.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdBsnSetTunnelDst extends OFObject, OFActionIdBsn {
+    OFActionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionIdBsn.Builder {
+        OFActionIdBsnSetTunnelDst build();
+        OFActionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdCopyTtlIn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdCopyTtlIn.java
new file mode 100644
index 0000000..0be31c3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdCopyTtlIn.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdCopyTtlIn extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdCopyTtlIn build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdCopyTtlOut.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdCopyTtlOut.java
new file mode 100644
index 0000000..b29d1ff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdCopyTtlOut.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdCopyTtlOut extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdCopyTtlOut build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdDecMplsTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdDecMplsTtl.java
new file mode 100644
index 0000000..dfcc979
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdDecMplsTtl.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdDecMplsTtl extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdDecMplsTtl build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdDecNwTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdDecNwTtl.java
new file mode 100644
index 0000000..f9b31f1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdDecNwTtl.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdDecNwTtl extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdDecNwTtl build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdExperimenter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdExperimenter.java
new file mode 100644
index 0000000..084ca57
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdExperimenter.java
@@ -0,0 +1,42 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdExperimenter extends OFObject, OFActionId {
+    OFActionType getType();
+    long getExperimenter();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdExperimenter build();
+        OFActionType getType();
+        long getExperimenter();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdGroup.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdGroup.java
new file mode 100644
index 0000000..b38c9ab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdGroup.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdGroup extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdGroup build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdNicira.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdNicira.java
new file mode 100644
index 0000000..7c723ac
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdNicira.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdNicira extends OFObject, OFActionIdExperimenter {
+    OFActionType getType();
+    long getExperimenter();
+    int getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionIdExperimenter.Builder {
+        OFActionIdNicira build();
+        OFActionType getType();
+        long getExperimenter();
+        int getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdNiciraDecTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdNiciraDecTtl.java
new file mode 100644
index 0000000..6d53414
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdNiciraDecTtl.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdNiciraDecTtl extends OFObject, OFActionIdNicira {
+    OFActionType getType();
+    long getExperimenter();
+    int getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionIdNicira.Builder {
+        OFActionIdNiciraDecTtl build();
+        OFActionType getType();
+        long getExperimenter();
+        int getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdOutput.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdOutput.java
new file mode 100644
index 0000000..ea2749c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdOutput.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdOutput extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdOutput build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopMpls.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopMpls.java
new file mode 100644
index 0000000..9308ca1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopMpls.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdPopMpls extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdPopMpls build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopPbb.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopPbb.java
new file mode 100644
index 0000000..4371ec2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopPbb.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdPopPbb extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdPopPbb build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopVlan.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopVlan.java
new file mode 100644
index 0000000..757d40a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPopVlan.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdPopVlan extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdPopVlan build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushMpls.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushMpls.java
new file mode 100644
index 0000000..5f76d66
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushMpls.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdPushMpls extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdPushMpls build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushPbb.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushPbb.java
new file mode 100644
index 0000000..0005457
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushPbb.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdPushPbb extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdPushPbb build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushVlan.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushVlan.java
new file mode 100644
index 0000000..c94cb34
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdPushVlan.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdPushVlan extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdPushVlan build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetField.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetField.java
new file mode 100644
index 0000000..d3f5328
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetField.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdSetField extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdSetField build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetMplsTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetMplsTtl.java
new file mode 100644
index 0000000..706c772
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetMplsTtl.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdSetMplsTtl extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdSetMplsTtl build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetNwTtl.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetNwTtl.java
new file mode 100644
index 0000000..8e588be
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetNwTtl.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdSetNwTtl extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdSetNwTtl build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetQueue.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetQueue.java
new file mode 100644
index 0000000..2c29b66
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIdSetQueue.java
@@ -0,0 +1,41 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFActionIdSetQueue extends OFObject, OFActionId {
+    OFActionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFActionId.Builder {
+        OFActionIdSetQueue build();
+        OFActionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIds.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIds.java
new file mode 100644
index 0000000..8c6c132
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/actionid/OFActionIds.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.actionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+public interface OFActionIds {
+    // Subfactories
+
+    OFActionIdBsnChecksum bsnChecksum();
+    OFActionIdBsnMirror bsnMirror();
+    OFActionIdBsnSetTunnelDst bsnSetTunnelDst();
+    OFActionIdCopyTtlIn copyTtlIn();
+    OFActionIdCopyTtlOut copyTtlOut();
+    OFActionIdDecMplsTtl decMplsTtl();
+    OFActionIdDecNwTtl decNwTtl();
+    OFActionIdGroup group();
+    OFActionIdNiciraDecTtl niciraDecTtl();
+    OFActionIdOutput output();
+    OFActionIdPopMpls popMpls();
+    OFActionIdPopPbb popPbb();
+    OFActionIdPopVlan popVlan();
+    OFActionIdPushMpls pushMpls();
+    OFActionIdPushPbb pushPbb();
+    OFActionIdPushVlan pushVlan();
+    OFActionIdSetField setField();
+    OFActionIdSetMplsTtl setMplsTtl();
+    OFActionIdSetNwTtl setNwTtl();
+    OFActionIdSetQueue setQueue();
+
+    OFMessageReader<OFActionId> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlv.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlv.java
new file mode 100644
index 0000000..bc150fd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlv.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlv extends OFObject {
+    int getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFBsnTlv build();
+        int getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvBroadcastQueryTimeout.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvBroadcastQueryTimeout.java
new file mode 100644
index 0000000..7de728a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvBroadcastQueryTimeout.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvBroadcastQueryTimeout extends OFObject, OFBsnTlv {
+    int getType();
+    long getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvBroadcastQueryTimeout build();
+        int getType();
+        long getValue();
+        Builder setValue(long value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvCircuitId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvCircuitId.java
new file mode 100644
index 0000000..d20aed0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvCircuitId.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvCircuitId extends OFObject, OFBsnTlv {
+    int getType();
+    byte[] getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvCircuitId build();
+        int getType();
+        byte[] getValue();
+        Builder setValue(byte[] value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvCrcEnabled.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvCrcEnabled.java
new file mode 100644
index 0000000..ec66f67
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvCrcEnabled.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvCrcEnabled extends OFObject, OFBsnTlv {
+    int getType();
+    short getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvCrcEnabled build();
+        int getType();
+        short getValue();
+        Builder setValue(short value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleNotification.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleNotification.java
new file mode 100644
index 0000000..57dd477
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleNotification.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvIdleNotification extends OFObject, OFBsnTlv {
+    int getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvIdleNotification build();
+        int getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleTime.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleTime.java
new file mode 100644
index 0000000..ac87110
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleTime.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvIdleTime extends OFObject, OFBsnTlv {
+    int getType();
+    U64 getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvIdleTime build();
+        int getType();
+        U64 getValue();
+        Builder setValue(U64 value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleTimeout.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleTimeout.java
new file mode 100644
index 0000000..deb7e68
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIdleTimeout.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvIdleTimeout extends OFObject, OFBsnTlv {
+    int getType();
+    long getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvIdleTimeout build();
+        int getType();
+        long getValue();
+        Builder setValue(long value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIpv4.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIpv4.java
new file mode 100644
index 0000000..ea7dc41
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvIpv4.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvIpv4 extends OFObject, OFBsnTlv {
+    int getType();
+    IPv4Address getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvIpv4 build();
+        int getType();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvMac.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvMac.java
new file mode 100644
index 0000000..f6978a5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvMac.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvMac extends OFObject, OFBsnTlv {
+    int getType();
+    MacAddress getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvMac build();
+        int getType();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvMissPackets.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvMissPackets.java
new file mode 100644
index 0000000..2b9a7ea
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvMissPackets.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvMissPackets extends OFObject, OFBsnTlv {
+    int getType();
+    U64 getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvMissPackets build();
+        int getType();
+        U64 getValue();
+        Builder setValue(U64 value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvPort.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvPort.java
new file mode 100644
index 0000000..536075a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvPort.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvPort extends OFObject, OFBsnTlv {
+    int getType();
+    OFPort getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvPort build();
+        int getType();
+        OFPort getValue();
+        Builder setValue(OFPort value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvQueueId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvQueueId.java
new file mode 100644
index 0000000..844c727
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvQueueId.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvQueueId extends OFObject, OFBsnTlv {
+    int getType();
+    long getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvQueueId build();
+        int getType();
+        long getValue();
+        Builder setValue(long value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvQueueWeight.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvQueueWeight.java
new file mode 100644
index 0000000..a41686d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvQueueWeight.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvQueueWeight extends OFObject, OFBsnTlv {
+    int getType();
+    long getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvQueueWeight build();
+        int getType();
+        long getValue();
+        Builder setValue(long value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvReplyPackets.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvReplyPackets.java
new file mode 100644
index 0000000..ef2d93e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvReplyPackets.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvReplyPackets extends OFObject, OFBsnTlv {
+    int getType();
+    U64 getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvReplyPackets build();
+        int getType();
+        U64 getValue();
+        Builder setValue(U64 value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvRequestPackets.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvRequestPackets.java
new file mode 100644
index 0000000..bed22ae
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvRequestPackets.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvRequestPackets extends OFObject, OFBsnTlv {
+    int getType();
+    U64 getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvRequestPackets build();
+        int getType();
+        U64 getValue();
+        Builder setValue(U64 value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvRxPackets.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvRxPackets.java
new file mode 100644
index 0000000..98ac7da
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvRxPackets.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvRxPackets extends OFObject, OFBsnTlv {
+    int getType();
+    U64 getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvRxPackets build();
+        int getType();
+        U64 getValue();
+        Builder setValue(U64 value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvTxPackets.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvTxPackets.java
new file mode 100644
index 0000000..e292b24
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvTxPackets.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvTxPackets extends OFObject, OFBsnTlv {
+    int getType();
+    U64 getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvTxPackets build();
+        int getType();
+        U64 getValue();
+        Builder setValue(U64 value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfAnchor.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfAnchor.java
new file mode 100644
index 0000000..05eea9b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfAnchor.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvUdfAnchor extends OFObject, OFBsnTlv {
+    int getType();
+    OFBsnUdfAnchor getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvUdfAnchor build();
+        int getType();
+        OFBsnUdfAnchor getValue();
+        Builder setValue(OFBsnUdfAnchor value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfId.java
new file mode 100644
index 0000000..ff5156b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfId.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvUdfId extends OFObject, OFBsnTlv {
+    int getType();
+    int getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvUdfId build();
+        int getType();
+        int getValue();
+        Builder setValue(int value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfLength.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfLength.java
new file mode 100644
index 0000000..03ed71b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfLength.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvUdfLength extends OFObject, OFBsnTlv {
+    int getType();
+    int getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvUdfLength build();
+        int getType();
+        int getValue();
+        Builder setValue(int value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfOffset.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfOffset.java
new file mode 100644
index 0000000..c572fbf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUdfOffset.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvUdfOffset extends OFObject, OFBsnTlv {
+    int getType();
+    int getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvUdfOffset build();
+        int getType();
+        int getValue();
+        Builder setValue(int value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUnicastQueryTimeout.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUnicastQueryTimeout.java
new file mode 100644
index 0000000..26c6b12
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvUnicastQueryTimeout.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvUnicastQueryTimeout extends OFObject, OFBsnTlv {
+    int getType();
+    long getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvUnicastQueryTimeout build();
+        int getType();
+        long getValue();
+        Builder setValue(long value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvVlanVid.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvVlanVid.java
new file mode 100644
index 0000000..3943538
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvVlanVid.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvVlanVid extends OFObject, OFBsnTlv {
+    int getType();
+    VlanVid getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvVlanVid build();
+        int getType();
+        VlanVid getValue();
+        Builder setValue(VlanVid value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvVrf.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvVrf.java
new file mode 100644
index 0000000..b89d0e3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvVrf.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBsnTlvVrf extends OFObject, OFBsnTlv {
+    int getType();
+    long getValue();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFBsnTlv.Builder {
+        OFBsnTlvVrf build();
+        int getType();
+        long getValue();
+        Builder setValue(long value);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvs.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvs.java
new file mode 100644
index 0000000..b89d774
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/bsntlv/OFBsnTlvs.java
@@ -0,0 +1,78 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.bsntlv;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public interface OFBsnTlvs {
+    // Subfactories
+
+    OFBsnTlvBroadcastQueryTimeout.Builder buildBroadcastQueryTimeout() throws UnsupportedOperationException;
+    OFBsnTlvBroadcastQueryTimeout broadcastQueryTimeout(long value);
+    OFBsnTlvCircuitId.Builder buildCircuitId() throws UnsupportedOperationException;
+    OFBsnTlvCircuitId circuitId(byte[] value);
+    OFBsnTlvCrcEnabled.Builder buildCrcEnabled() throws UnsupportedOperationException;
+    OFBsnTlvCrcEnabled crcEnabled(short value);
+    OFBsnTlvIdleNotification idleNotification();
+    OFBsnTlvIdleTime.Builder buildIdleTime() throws UnsupportedOperationException;
+    OFBsnTlvIdleTime idleTime(U64 value);
+    OFBsnTlvIdleTimeout.Builder buildIdleTimeout() throws UnsupportedOperationException;
+    OFBsnTlvIdleTimeout idleTimeout(long value);
+    OFBsnTlvIpv4.Builder buildIpv4() throws UnsupportedOperationException;
+    OFBsnTlvIpv4 ipv4(IPv4Address value);
+    OFBsnTlvMac.Builder buildMac() throws UnsupportedOperationException;
+    OFBsnTlvMac mac(MacAddress value);
+    OFBsnTlvMissPackets.Builder buildMissPackets() throws UnsupportedOperationException;
+    OFBsnTlvMissPackets missPackets(U64 value);
+    OFBsnTlvPort.Builder buildPort() throws UnsupportedOperationException;
+    OFBsnTlvPort port(OFPort value);
+    OFBsnTlvQueueId.Builder buildQueueId() throws UnsupportedOperationException;
+    OFBsnTlvQueueId queueId(long value);
+    OFBsnTlvQueueWeight.Builder buildQueueWeight() throws UnsupportedOperationException;
+    OFBsnTlvQueueWeight queueWeight(long value);
+    OFBsnTlvReplyPackets.Builder buildReplyPackets() throws UnsupportedOperationException;
+    OFBsnTlvReplyPackets replyPackets(U64 value);
+    OFBsnTlvRequestPackets.Builder buildRequestPackets() throws UnsupportedOperationException;
+    OFBsnTlvRequestPackets requestPackets(U64 value);
+    OFBsnTlvRxPackets.Builder buildRxPackets() throws UnsupportedOperationException;
+    OFBsnTlvRxPackets rxPackets(U64 value);
+    OFBsnTlvTxPackets.Builder buildTxPackets() throws UnsupportedOperationException;
+    OFBsnTlvTxPackets txPackets(U64 value);
+    OFBsnTlvUdfAnchor.Builder buildUdfAnchor() throws UnsupportedOperationException;
+    OFBsnTlvUdfAnchor udfAnchor(OFBsnUdfAnchor value);
+    OFBsnTlvUdfId.Builder buildUdfId() throws UnsupportedOperationException;
+    OFBsnTlvUdfId udfId(int value);
+    OFBsnTlvUdfLength.Builder buildUdfLength() throws UnsupportedOperationException;
+    OFBsnTlvUdfLength udfLength(int value);
+    OFBsnTlvUdfOffset.Builder buildUdfOffset() throws UnsupportedOperationException;
+    OFBsnTlvUdfOffset udfOffset(int value);
+    OFBsnTlvUnicastQueryTimeout.Builder buildUnicastQueryTimeout() throws UnsupportedOperationException;
+    OFBsnTlvUnicastQueryTimeout unicastQueryTimeout(long value);
+    OFBsnTlvVlanVid.Builder buildVlanVid() throws UnsupportedOperationException;
+    OFBsnTlvVlanVid vlanVid(VlanVid value);
+    OFBsnTlvVrf.Builder buildVrf() throws UnsupportedOperationException;
+    OFBsnTlvVrf vrf(long value);
+
+    OFMessageReader<OFBsnTlv> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadActionErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadActionErrorMsg.java
new file mode 100644
index 0000000..b21fd98
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadActionErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBadActionErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFBadActionCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFBadActionErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFBadActionCode getCode();
+        Builder setCode(OFBadActionCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadInstructionErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadInstructionErrorMsg.java
new file mode 100644
index 0000000..2a9ae22
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadInstructionErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBadInstructionErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFBadInstructionCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFBadInstructionErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFBadInstructionCode getCode();
+        Builder setCode(OFBadInstructionCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadMatchErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadMatchErrorMsg.java
new file mode 100644
index 0000000..73a2508
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadMatchErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBadMatchErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFBadMatchCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFBadMatchErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFBadMatchCode getCode();
+        Builder setCode(OFBadMatchCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadRequestErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadRequestErrorMsg.java
new file mode 100644
index 0000000..dac9bcc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFBadRequestErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFBadRequestErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFBadRequestCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFBadRequestErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFBadRequestCode getCode();
+        Builder setCode(OFBadRequestCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFErrorMsgs.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFErrorMsgs.java
new file mode 100644
index 0000000..db7485d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFErrorMsgs.java
@@ -0,0 +1,48 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public interface OFErrorMsgs extends XidGenerator {
+    // Subfactories
+
+    OFBadActionErrorMsg.Builder buildBadActionErrorMsg();
+    OFBadRequestErrorMsg.Builder buildBadRequestErrorMsg();
+    OFFlowModFailedErrorMsg.Builder buildFlowModFailedErrorMsg();
+    OFHelloFailedErrorMsg.Builder buildHelloFailedErrorMsg();
+    OFPortModFailedErrorMsg.Builder buildPortModFailedErrorMsg();
+    OFQueueOpFailedErrorMsg.Builder buildQueueOpFailedErrorMsg();
+    OFBadInstructionErrorMsg.Builder buildBadInstructionErrorMsg() throws UnsupportedOperationException;
+    OFBadMatchErrorMsg.Builder buildBadMatchErrorMsg() throws UnsupportedOperationException;
+    OFGroupModFailedErrorMsg.Builder buildGroupModFailedErrorMsg() throws UnsupportedOperationException;
+    OFSwitchConfigFailedErrorMsg.Builder buildSwitchConfigFailedErrorMsg() throws UnsupportedOperationException;
+    OFTableModFailedErrorMsg.Builder buildTableModFailedErrorMsg() throws UnsupportedOperationException;
+    OFExperimenterErrorMsg.Builder buildExperimenterErrorMsg() throws UnsupportedOperationException;
+    OFRoleRequestFailedErrorMsg.Builder buildRoleRequestFailedErrorMsg() throws UnsupportedOperationException;
+    OFMeterModFailedErrorMsg.Builder buildMeterModFailedErrorMsg() throws UnsupportedOperationException;
+    OFTableFeaturesFailedErrorMsg.Builder buildTableFeaturesFailedErrorMsg() throws UnsupportedOperationException;
+
+    OFMessageReader<OFErrorMsg> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFExperimenterErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFExperimenterErrorMsg.java
new file mode 100644
index 0000000..124b01e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFExperimenterErrorMsg.java
@@ -0,0 +1,54 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFExperimenterErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    int getSubtype();
+    long getExperimenter();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFExperimenterErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        int getSubtype();
+        Builder setSubtype(int subtype);
+        long getExperimenter();
+        Builder setExperimenter(long experimenter);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFFlowModFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFFlowModFailedErrorMsg.java
new file mode 100644
index 0000000..91d0d43
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFFlowModFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFFlowModFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFFlowModFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFFlowModFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFFlowModFailedCode getCode();
+        Builder setCode(OFFlowModFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFGroupModFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFGroupModFailedErrorMsg.java
new file mode 100644
index 0000000..93944c1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFGroupModFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFGroupModFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFGroupModFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFGroupModFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFGroupModFailedCode getCode();
+        Builder setCode(OFGroupModFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFHelloFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFHelloFailedErrorMsg.java
new file mode 100644
index 0000000..7cf3afd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFHelloFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFHelloFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFHelloFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFHelloFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFHelloFailedCode getCode();
+        Builder setCode(OFHelloFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFMeterModFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFMeterModFailedErrorMsg.java
new file mode 100644
index 0000000..3d7a0c3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFMeterModFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterModFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFMeterModFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFMeterModFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFMeterModFailedCode getCode();
+        Builder setCode(OFMeterModFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFPortModFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFPortModFailedErrorMsg.java
new file mode 100644
index 0000000..dfdfb79
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFPortModFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFPortModFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFPortModFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFPortModFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFPortModFailedCode getCode();
+        Builder setCode(OFPortModFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFQueueOpFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFQueueOpFailedErrorMsg.java
new file mode 100644
index 0000000..6c460df
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFQueueOpFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueueOpFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFQueueOpFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFQueueOpFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFQueueOpFailedCode getCode();
+        Builder setCode(OFQueueOpFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFRoleRequestFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFRoleRequestFailedErrorMsg.java
new file mode 100644
index 0000000..c24d291
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFRoleRequestFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFRoleRequestFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFRoleRequestFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFRoleRequestFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFRoleRequestFailedCode getCode();
+        Builder setCode(OFRoleRequestFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFSwitchConfigFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFSwitchConfigFailedErrorMsg.java
new file mode 100644
index 0000000..1c797ab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFSwitchConfigFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFSwitchConfigFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFSwitchConfigFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFSwitchConfigFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFSwitchConfigFailedCode getCode();
+        Builder setCode(OFSwitchConfigFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFTableFeaturesFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFTableFeaturesFailedErrorMsg.java
new file mode 100644
index 0000000..93075dd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFTableFeaturesFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableFeaturesFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFTableFeaturesFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFTableFeaturesFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFTableFeaturesFailedCode getCode();
+        Builder setCode(OFTableFeaturesFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFTableModFailedErrorMsg.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFTableModFailedErrorMsg.java
new file mode 100644
index 0000000..9e7c822
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/errormsg/OFTableModFailedErrorMsg.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.errormsg;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFTableModFailedErrorMsg extends OFObject, OFErrorMsg {
+    OFVersion getVersion();
+    OFType getType();
+    long getXid();
+    OFErrorType getErrType();
+    OFTableModFailedCode getCode();
+    OFErrorCauseData getData();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFErrorMsg.Builder {
+        OFTableModFailedErrorMsg build();
+        OFVersion getVersion();
+        OFType getType();
+        long getXid();
+        Builder setXid(long xid);
+        OFErrorType getErrType();
+        OFTableModFailedCode getCode();
+        Builder setCode(OFTableModFailedCode code);
+        OFErrorCauseData getData();
+        Builder setData(OFErrorCauseData data);
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstruction.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstruction.java
new file mode 100644
index 0000000..85c4292
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstruction.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstruction extends OFObject {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFInstruction build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionApplyActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionApplyActions.java
new file mode 100644
index 0000000..5547beb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionApplyActions.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionApplyActions extends OFObject, OFInstruction {
+    OFInstructionType getType();
+    List<OFAction> getActions();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstruction.Builder {
+        OFInstructionApplyActions build();
+        OFInstructionType getType();
+        List<OFAction> getActions();
+        Builder setActions(List<OFAction> actions);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsn.java
new file mode 100644
index 0000000..24f9237
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsn.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsn extends OFObject, OFInstructionExperimenter {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionExperimenter.Builder {
+        OFInstructionBsn build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnArpOffload.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnArpOffload.java
new file mode 100644
index 0000000..add97cc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnArpOffload.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnArpOffload extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnArpOffload build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDeny.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDeny.java
new file mode 100644
index 0000000..e930943
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDeny.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnDeny extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnDeny build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDhcpOffload.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDhcpOffload.java
new file mode 100644
index 0000000..eb8a422
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDhcpOffload.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnDhcpOffload extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnDhcpOffload build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableSplitHorizonCheck.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableSplitHorizonCheck.java
new file mode 100644
index 0000000..bef2b49
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableSplitHorizonCheck.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnDisableSplitHorizonCheck extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnDisableSplitHorizonCheck build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableSrcMacCheck.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableSrcMacCheck.java
new file mode 100644
index 0000000..3e38615
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableSrcMacCheck.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnDisableSrcMacCheck extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnDisableSrcMacCheck build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableVlanCounters.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableVlanCounters.java
new file mode 100644
index 0000000..9295e32
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnDisableVlanCounters.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnDisableVlanCounters extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnDisableVlanCounters build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPacketOfDeath.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPacketOfDeath.java
new file mode 100644
index 0000000..0f34780
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPacketOfDeath.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnPacketOfDeath extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnPacketOfDeath build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPermit.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPermit.java
new file mode 100644
index 0000000..a23fcf3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPermit.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnPermit extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnPermit build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPrioritizePdus.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPrioritizePdus.java
new file mode 100644
index 0000000..41c242e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnPrioritizePdus.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnPrioritizePdus extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnPrioritizePdus build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnRequireVlanXlate.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnRequireVlanXlate.java
new file mode 100644
index 0000000..b6d4f9b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionBsnRequireVlanXlate.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionBsnRequireVlanXlate extends OFObject, OFInstructionBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionBsn.Builder {
+        OFInstructionBsnRequireVlanXlate build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionClearActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionClearActions.java
new file mode 100644
index 0000000..8323776
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionClearActions.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionClearActions extends OFObject, OFInstruction {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstruction.Builder {
+        OFInstructionClearActions build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionExperimenter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionExperimenter.java
new file mode 100644
index 0000000..f6b4244
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionExperimenter.java
@@ -0,0 +1,42 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionExperimenter extends OFObject, OFInstruction {
+    OFInstructionType getType();
+    long getExperimenter();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstruction.Builder {
+        OFInstructionExperimenter build();
+        OFInstructionType getType();
+        long getExperimenter();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionGotoTable.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionGotoTable.java
new file mode 100644
index 0000000..9a80fb2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionGotoTable.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionGotoTable extends OFObject, OFInstruction {
+    OFInstructionType getType();
+    TableId getTableId();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstruction.Builder {
+        OFInstructionGotoTable build();
+        OFInstructionType getType();
+        TableId getTableId();
+        Builder setTableId(TableId tableId);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionMeter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionMeter.java
new file mode 100644
index 0000000..e965291
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionMeter.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionMeter extends OFObject, OFInstruction {
+    OFInstructionType getType();
+    long getMeterId();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstruction.Builder {
+        OFInstructionMeter build();
+        OFInstructionType getType();
+        long getMeterId();
+        Builder setMeterId(long meterId);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionWriteActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionWriteActions.java
new file mode 100644
index 0000000..a6f62c4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionWriteActions.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionWriteActions extends OFObject, OFInstruction {
+    OFInstructionType getType();
+    List<OFAction> getActions();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstruction.Builder {
+        OFInstructionWriteActions build();
+        OFInstructionType getType();
+        List<OFAction> getActions();
+        Builder setActions(List<OFAction> actions);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionWriteMetadata.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionWriteMetadata.java
new file mode 100644
index 0000000..4706932
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructionWriteMetadata.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionWriteMetadata extends OFObject, OFInstruction {
+    OFInstructionType getType();
+    U64 getMetadata();
+    U64 getMetadataMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstruction.Builder {
+        OFInstructionWriteMetadata build();
+        OFInstructionType getType();
+        U64 getMetadata();
+        Builder setMetadata(U64 metadata);
+        U64 getMetadataMask();
+        Builder setMetadataMask(U64 metadataMask);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructions.java
new file mode 100644
index 0000000..fe09c2c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instruction/OFInstructions.java
@@ -0,0 +1,55 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instruction;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+
+public interface OFInstructions {
+    // Subfactories
+
+    OFInstructionApplyActions.Builder buildApplyActions() throws UnsupportedOperationException;
+    OFInstructionApplyActions applyActions(List<OFAction> actions);
+    OFInstructionClearActions clearActions();
+    OFInstructionGotoTable.Builder buildGotoTable() throws UnsupportedOperationException;
+    OFInstructionGotoTable gotoTable(TableId tableId);
+    OFInstructionWriteActions.Builder buildWriteActions() throws UnsupportedOperationException;
+    OFInstructionWriteActions writeActions(List<OFAction> actions);
+    OFInstructionWriteMetadata.Builder buildWriteMetadata() throws UnsupportedOperationException;
+    OFInstructionWriteMetadata writeMetadata(U64 metadata, U64 metadataMask);
+    OFInstructionBsnArpOffload bsnArpOffload();
+    OFInstructionBsnDeny bsnDeny();
+    OFInstructionBsnDhcpOffload bsnDhcpOffload();
+    OFInstructionBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck();
+    OFInstructionBsnDisableSrcMacCheck bsnDisableSrcMacCheck();
+    OFInstructionBsnDisableVlanCounters bsnDisableVlanCounters();
+    OFInstructionBsnPacketOfDeath bsnPacketOfDeath();
+    OFInstructionBsnPermit bsnPermit();
+    OFInstructionBsnPrioritizePdus bsnPrioritizePdus();
+    OFInstructionBsnRequireVlanXlate bsnRequireVlanXlate();
+    OFInstructionMeter.Builder buildMeter() throws UnsupportedOperationException;
+    OFInstructionMeter meter(long meterId);
+
+    OFMessageReader<OFInstruction> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionId.java
new file mode 100644
index 0000000..906401c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionId.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionId extends OFObject {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFInstructionId build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdApplyActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdApplyActions.java
new file mode 100644
index 0000000..8d37525
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdApplyActions.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdApplyActions extends OFObject, OFInstructionId {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionId.Builder {
+        OFInstructionIdApplyActions build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsn.java
new file mode 100644
index 0000000..7114df8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsn.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsn extends OFObject, OFInstructionIdExperimenter {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdExperimenter.Builder {
+        OFInstructionIdBsn build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnArpOffload.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnArpOffload.java
new file mode 100644
index 0000000..c669714
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnArpOffload.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnArpOffload extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnArpOffload build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDeny.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDeny.java
new file mode 100644
index 0000000..5f4f489
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDeny.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnDeny extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnDeny build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDhcpOffload.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDhcpOffload.java
new file mode 100644
index 0000000..43e6fc8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDhcpOffload.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnDhcpOffload extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnDhcpOffload build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableSplitHorizonCheck.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableSplitHorizonCheck.java
new file mode 100644
index 0000000..57fc457
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableSplitHorizonCheck.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnDisableSplitHorizonCheck extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnDisableSplitHorizonCheck build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableSrcMacCheck.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableSrcMacCheck.java
new file mode 100644
index 0000000..7b92fbc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableSrcMacCheck.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnDisableSrcMacCheck extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnDisableSrcMacCheck build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableVlanCounters.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableVlanCounters.java
new file mode 100644
index 0000000..1e1366a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnDisableVlanCounters.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnDisableVlanCounters extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnDisableVlanCounters build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPacketOfDeath.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPacketOfDeath.java
new file mode 100644
index 0000000..a38265e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPacketOfDeath.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnPacketOfDeath extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnPacketOfDeath build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPermit.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPermit.java
new file mode 100644
index 0000000..a499743
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPermit.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnPermit extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnPermit build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPrioritizePdus.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPrioritizePdus.java
new file mode 100644
index 0000000..08f1e7e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnPrioritizePdus.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnPrioritizePdus extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnPrioritizePdus build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnRequireVlanXlate.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnRequireVlanXlate.java
new file mode 100644
index 0000000..f6b9dc9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdBsnRequireVlanXlate.java
@@ -0,0 +1,44 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdBsnRequireVlanXlate extends OFObject, OFInstructionIdBsn {
+    OFInstructionType getType();
+    long getExperimenter();
+    long getSubtype();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionIdBsn.Builder {
+        OFInstructionIdBsnRequireVlanXlate build();
+        OFInstructionType getType();
+        long getExperimenter();
+        long getSubtype();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdClearActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdClearActions.java
new file mode 100644
index 0000000..8c7c1d7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdClearActions.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdClearActions extends OFObject, OFInstructionId {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionId.Builder {
+        OFInstructionIdClearActions build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdExperimenter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdExperimenter.java
new file mode 100644
index 0000000..d54f3f9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdExperimenter.java
@@ -0,0 +1,42 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdExperimenter extends OFObject, OFInstructionId {
+    OFInstructionType getType();
+    long getExperimenter();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionId.Builder {
+        OFInstructionIdExperimenter build();
+        OFInstructionType getType();
+        long getExperimenter();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdGotoTable.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdGotoTable.java
new file mode 100644
index 0000000..4e12baa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdGotoTable.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdGotoTable extends OFObject, OFInstructionId {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionId.Builder {
+        OFInstructionIdGotoTable build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdMeter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdMeter.java
new file mode 100644
index 0000000..277ab6e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdMeter.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdMeter extends OFObject, OFInstructionId {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionId.Builder {
+        OFInstructionIdMeter build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdWriteActions.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdWriteActions.java
new file mode 100644
index 0000000..13b7dee
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdWriteActions.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdWriteActions extends OFObject, OFInstructionId {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionId.Builder {
+        OFInstructionIdWriteActions build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdWriteMetadata.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdWriteMetadata.java
new file mode 100644
index 0000000..96ea693
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIdWriteMetadata.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFInstructionIdWriteMetadata extends OFObject, OFInstructionId {
+    OFInstructionType getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFInstructionId.Builder {
+        OFInstructionIdWriteMetadata build();
+        OFInstructionType getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIds.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIds.java
new file mode 100644
index 0000000..901b87a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/instructionid/OFInstructionIds.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.instructionid;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public interface OFInstructionIds {
+    // Subfactories
+
+    OFInstructionIdApplyActions applyActions();
+    OFInstructionIdBsnArpOffload bsnArpOffload();
+    OFInstructionIdBsnDeny bsnDeny();
+    OFInstructionIdBsnDhcpOffload bsnDhcpOffload();
+    OFInstructionIdBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck();
+    OFInstructionIdBsnDisableSrcMacCheck bsnDisableSrcMacCheck();
+    OFInstructionIdBsnDisableVlanCounters bsnDisableVlanCounters();
+    OFInstructionIdBsnPacketOfDeath bsnPacketOfDeath();
+    OFInstructionIdBsnPermit bsnPermit();
+    OFInstructionIdBsnPrioritizePdus bsnPrioritizePdus();
+    OFInstructionIdBsnRequireVlanXlate bsnRequireVlanXlate();
+    OFInstructionIdClearActions clearActions();
+    OFInstructionIdGotoTable gotoTable();
+    OFInstructionIdMeter meter();
+    OFInstructionIdWriteActions writeActions();
+    OFInstructionIdWriteMetadata writeMetadata();
+
+    OFMessageReader<OFInstructionId> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBand.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBand.java
new file mode 100644
index 0000000..51edbfc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBand.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.meterband;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterBand extends OFObject {
+    int getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFMeterBand build();
+        int getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandDrop.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandDrop.java
new file mode 100644
index 0000000..701ac61
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandDrop.java
@@ -0,0 +1,46 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.meterband;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterBandDrop extends OFObject, OFMeterBand {
+    int getType();
+    long getRate();
+    long getBurstSize();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMeterBand.Builder {
+        OFMeterBandDrop build();
+        int getType();
+        long getRate();
+        Builder setRate(long rate);
+        long getBurstSize();
+        Builder setBurstSize(long burstSize);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandDscpRemark.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandDscpRemark.java
new file mode 100644
index 0000000..8bb096d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandDscpRemark.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.meterband;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterBandDscpRemark extends OFObject, OFMeterBand {
+    int getType();
+    long getRate();
+    long getBurstSize();
+    short getPrecLevel();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMeterBand.Builder {
+        OFMeterBandDscpRemark build();
+        int getType();
+        long getRate();
+        Builder setRate(long rate);
+        long getBurstSize();
+        Builder setBurstSize(long burstSize);
+        short getPrecLevel();
+        Builder setPrecLevel(short precLevel);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandExperimenter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandExperimenter.java
new file mode 100644
index 0000000..f621170
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBandExperimenter.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.meterband;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFMeterBandExperimenter extends OFObject, OFMeterBand {
+    int getType();
+    long getRate();
+    long getBurstSize();
+    long getExperimenter();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFMeterBand.Builder {
+        OFMeterBandExperimenter build();
+        int getType();
+        long getRate();
+        Builder setRate(long rate);
+        long getBurstSize();
+        Builder setBurstSize(long burstSize);
+        long getExperimenter();
+        Builder setExperimenter(long experimenter);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBands.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBands.java
new file mode 100644
index 0000000..52e6181
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/meterband/OFMeterBands.java
@@ -0,0 +1,37 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.meterband;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public interface OFMeterBands {
+    // Subfactories
+
+    OFMeterBandDrop.Builder buildDrop() throws UnsupportedOperationException;
+    OFMeterBandDrop drop(long rate, long burstSize);
+    OFMeterBandDscpRemark.Builder buildDscpRemark() throws UnsupportedOperationException;
+    OFMeterBandExperimenter.Builder buildExperimenter() throws UnsupportedOperationException;
+
+    OFMessageReader<OFMeterBand> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxm.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxm.java
new file mode 100644
index 0000000..d14aa42
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxm.java
@@ -0,0 +1,50 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxm<T extends OFValueType<T>> extends OFObject {
+    long getTypeLen();
+    T getValue();
+    T getMask();
+    MatchField<T> getMatchField();
+    boolean isMasked();
+    OFOxm<T> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder<T> createBuilder();
+    public interface Builder<T extends OFValueType<T>>  {
+        OFOxm<T> build();
+        long getTypeLen();
+        T getValue();
+        T getMask();
+        MatchField<T> getMatchField();
+        boolean isMasked();
+        OFOxm<T> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpOp.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpOp.java
new file mode 100644
index 0000000..5526177
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpOp.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpOp extends OFObject, OFOxm<ArpOpcode> {
+    long getTypeLen();
+    ArpOpcode getValue();
+    MatchField<ArpOpcode> getMatchField();
+    boolean isMasked();
+    OFOxm<ArpOpcode> getCanonical();
+    ArpOpcode getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ArpOpcode> {
+        OFOxmArpOp build();
+        long getTypeLen();
+        ArpOpcode getValue();
+        Builder setValue(ArpOpcode value);
+        MatchField<ArpOpcode> getMatchField();
+        boolean isMasked();
+        OFOxm<ArpOpcode> getCanonical();
+        ArpOpcode getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpOpMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpOpMasked.java
new file mode 100644
index 0000000..92e0b8a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpOpMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpOpMasked extends OFObject, OFOxm<ArpOpcode> {
+    long getTypeLen();
+    ArpOpcode getValue();
+    ArpOpcode getMask();
+    MatchField<ArpOpcode> getMatchField();
+    boolean isMasked();
+    OFOxm<ArpOpcode> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ArpOpcode> {
+        OFOxmArpOpMasked build();
+        long getTypeLen();
+        ArpOpcode getValue();
+        Builder setValue(ArpOpcode value);
+        ArpOpcode getMask();
+        Builder setMask(ArpOpcode mask);
+        MatchField<ArpOpcode> getMatchField();
+        boolean isMasked();
+        OFOxm<ArpOpcode> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSha.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSha.java
new file mode 100644
index 0000000..dcb5a02
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSha.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpSha extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    MacAddress getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmArpSha build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        MacAddress getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpShaMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpShaMasked.java
new file mode 100644
index 0000000..210fe89
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpShaMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpShaMasked extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MacAddress getMask();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmArpShaMasked build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MacAddress getMask();
+        Builder setMask(MacAddress mask);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSpa.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSpa.java
new file mode 100644
index 0000000..0b2cab1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSpa.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpSpa extends OFObject, OFOxm<IPv4Address> {
+    long getTypeLen();
+    IPv4Address getValue();
+    MatchField<IPv4Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv4Address> getCanonical();
+    IPv4Address getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv4Address> {
+        OFOxmArpSpa build();
+        long getTypeLen();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        MatchField<IPv4Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv4Address> getCanonical();
+        IPv4Address getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSpaMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSpaMasked.java
new file mode 100644
index 0000000..023fcb2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpSpaMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpSpaMasked extends OFObject, OFOxm<IPv4Address> {
+    long getTypeLen();
+    IPv4Address getValue();
+    IPv4Address getMask();
+    MatchField<IPv4Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv4Address> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv4Address> {
+        OFOxmArpSpaMasked build();
+        long getTypeLen();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        IPv4Address getMask();
+        Builder setMask(IPv4Address mask);
+        MatchField<IPv4Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv4Address> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTha.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTha.java
new file mode 100644
index 0000000..c91c1bc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTha.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpTha extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    MacAddress getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmArpTha build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        MacAddress getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpThaMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpThaMasked.java
new file mode 100644
index 0000000..e24bd33
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpThaMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpThaMasked extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MacAddress getMask();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmArpThaMasked build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MacAddress getMask();
+        Builder setMask(MacAddress mask);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTpa.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTpa.java
new file mode 100644
index 0000000..3ea1500
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTpa.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpTpa extends OFObject, OFOxm<IPv4Address> {
+    long getTypeLen();
+    IPv4Address getValue();
+    MatchField<IPv4Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv4Address> getCanonical();
+    IPv4Address getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv4Address> {
+        OFOxmArpTpa build();
+        long getTypeLen();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        MatchField<IPv4Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv4Address> getCanonical();
+        IPv4Address getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTpaMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTpaMasked.java
new file mode 100644
index 0000000..81501a7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmArpTpaMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmArpTpaMasked extends OFObject, OFOxm<IPv4Address> {
+    long getTypeLen();
+    IPv4Address getValue();
+    IPv4Address getMask();
+    MatchField<IPv4Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv4Address> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv4Address> {
+        OFOxmArpTpaMasked build();
+        long getTypeLen();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        IPv4Address getMask();
+        Builder setMask(IPv4Address mask);
+        MatchField<IPv4Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv4Address> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnEgrPortGroupId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnEgrPortGroupId.java
new file mode 100644
index 0000000..b23df57
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnEgrPortGroupId.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnEgrPortGroupId extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    ClassId getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnEgrPortGroupId build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        ClassId getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnEgrPortGroupIdMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnEgrPortGroupIdMasked.java
new file mode 100644
index 0000000..055fd7a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnEgrPortGroupIdMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnEgrPortGroupIdMasked extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    ClassId getMask();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnEgrPortGroupIdMasked build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        ClassId getMask();
+        Builder setMask(ClassId mask);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnGlobalVrfAllowed.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnGlobalVrfAllowed.java
new file mode 100644
index 0000000..b56e34c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnGlobalVrfAllowed.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnGlobalVrfAllowed extends OFObject, OFOxm<OFBooleanValue> {
+    long getTypeLen();
+    OFBooleanValue getValue();
+    MatchField<OFBooleanValue> getMatchField();
+    boolean isMasked();
+    OFOxm<OFBooleanValue> getCanonical();
+    OFBooleanValue getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFBooleanValue> {
+        OFOxmBsnGlobalVrfAllowed build();
+        long getTypeLen();
+        OFBooleanValue getValue();
+        Builder setValue(OFBooleanValue value);
+        MatchField<OFBooleanValue> getMatchField();
+        boolean isMasked();
+        OFOxm<OFBooleanValue> getCanonical();
+        OFBooleanValue getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnGlobalVrfAllowedMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnGlobalVrfAllowedMasked.java
new file mode 100644
index 0000000..7b5c7d7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnGlobalVrfAllowedMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnGlobalVrfAllowedMasked extends OFObject, OFOxm<OFBooleanValue> {
+    long getTypeLen();
+    OFBooleanValue getValue();
+    OFBooleanValue getMask();
+    MatchField<OFBooleanValue> getMatchField();
+    boolean isMasked();
+    OFOxm<OFBooleanValue> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFBooleanValue> {
+        OFOxmBsnGlobalVrfAllowedMasked build();
+        long getTypeLen();
+        OFBooleanValue getValue();
+        Builder setValue(OFBooleanValue value);
+        OFBooleanValue getMask();
+        Builder setMask(OFBooleanValue mask);
+        MatchField<OFBooleanValue> getMatchField();
+        boolean isMasked();
+        OFOxm<OFBooleanValue> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnInPorts128.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnInPorts128.java
new file mode 100644
index 0000000..42a86ff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnInPorts128.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnInPorts128 extends OFObject, OFOxm<OFBitMask128> {
+    long getTypeLen();
+    OFBitMask128 getValue();
+    MatchField<OFBitMask128> getMatchField();
+    boolean isMasked();
+    OFOxm<OFBitMask128> getCanonical();
+    OFBitMask128 getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFBitMask128> {
+        OFOxmBsnInPorts128 build();
+        long getTypeLen();
+        OFBitMask128 getValue();
+        Builder setValue(OFBitMask128 value);
+        MatchField<OFBitMask128> getMatchField();
+        boolean isMasked();
+        OFOxm<OFBitMask128> getCanonical();
+        OFBitMask128 getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnInPorts128Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnInPorts128Masked.java
new file mode 100644
index 0000000..9826f7a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnInPorts128Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnInPorts128Masked extends OFObject, OFOxm<OFBitMask128> {
+    long getTypeLen();
+    OFBitMask128 getValue();
+    OFBitMask128 getMask();
+    MatchField<OFBitMask128> getMatchField();
+    boolean isMasked();
+    OFOxm<OFBitMask128> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFBitMask128> {
+        OFOxmBsnInPorts128Masked build();
+        long getTypeLen();
+        OFBitMask128 getValue();
+        Builder setValue(OFBitMask128 value);
+        OFBitMask128 getMask();
+        Builder setMask(OFBitMask128 mask);
+        MatchField<OFBitMask128> getMatchField();
+        boolean isMasked();
+        OFOxm<OFBitMask128> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3DstClassId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3DstClassId.java
new file mode 100644
index 0000000..b587941
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3DstClassId.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnL3DstClassId extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    ClassId getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnL3DstClassId build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        ClassId getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3DstClassIdMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3DstClassIdMasked.java
new file mode 100644
index 0000000..b3619d0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3DstClassIdMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnL3DstClassIdMasked extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    ClassId getMask();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnL3DstClassIdMasked build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        ClassId getMask();
+        Builder setMask(ClassId mask);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3InterfaceClassId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3InterfaceClassId.java
new file mode 100644
index 0000000..2ab08da
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3InterfaceClassId.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnL3InterfaceClassId extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    ClassId getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnL3InterfaceClassId build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        ClassId getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3InterfaceClassIdMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3InterfaceClassIdMasked.java
new file mode 100644
index 0000000..5dbc3c2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3InterfaceClassIdMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnL3InterfaceClassIdMasked extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    ClassId getMask();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnL3InterfaceClassIdMasked build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        ClassId getMask();
+        Builder setMask(ClassId mask);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3SrcClassId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3SrcClassId.java
new file mode 100644
index 0000000..0202270
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3SrcClassId.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnL3SrcClassId extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    ClassId getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnL3SrcClassId build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        ClassId getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3SrcClassIdMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3SrcClassIdMasked.java
new file mode 100644
index 0000000..06adca0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnL3SrcClassIdMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnL3SrcClassIdMasked extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    ClassId getMask();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnL3SrcClassIdMasked build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        ClassId getMask();
+        Builder setMask(ClassId mask);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnLagId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnLagId.java
new file mode 100644
index 0000000..c8c73f6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnLagId.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnLagId extends OFObject, OFOxm<LagId> {
+    long getTypeLen();
+    LagId getValue();
+    MatchField<LagId> getMatchField();
+    boolean isMasked();
+    OFOxm<LagId> getCanonical();
+    LagId getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<LagId> {
+        OFOxmBsnLagId build();
+        long getTypeLen();
+        LagId getValue();
+        Builder setValue(LagId value);
+        MatchField<LagId> getMatchField();
+        boolean isMasked();
+        OFOxm<LagId> getCanonical();
+        LagId getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnLagIdMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnLagIdMasked.java
new file mode 100644
index 0000000..6b117dd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnLagIdMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnLagIdMasked extends OFObject, OFOxm<LagId> {
+    long getTypeLen();
+    LagId getValue();
+    LagId getMask();
+    MatchField<LagId> getMatchField();
+    boolean isMasked();
+    OFOxm<LagId> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<LagId> {
+        OFOxmBsnLagIdMasked build();
+        long getTypeLen();
+        LagId getValue();
+        Builder setValue(LagId value);
+        LagId getMask();
+        Builder setMask(LagId mask);
+        MatchField<LagId> getMatchField();
+        boolean isMasked();
+        OFOxm<LagId> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnTcpFlags.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnTcpFlags.java
new file mode 100644
index 0000000..c1a31d1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnTcpFlags.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnTcpFlags extends OFObject, OFOxm<U16> {
+    long getTypeLen();
+    U16 getValue();
+    MatchField<U16> getMatchField();
+    boolean isMasked();
+    OFOxm<U16> getCanonical();
+    U16 getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U16> {
+        OFOxmBsnTcpFlags build();
+        long getTypeLen();
+        U16 getValue();
+        Builder setValue(U16 value);
+        MatchField<U16> getMatchField();
+        boolean isMasked();
+        OFOxm<U16> getCanonical();
+        U16 getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnTcpFlagsMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnTcpFlagsMasked.java
new file mode 100644
index 0000000..694c8b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnTcpFlagsMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnTcpFlagsMasked extends OFObject, OFOxm<U16> {
+    long getTypeLen();
+    U16 getValue();
+    U16 getMask();
+    MatchField<U16> getMatchField();
+    boolean isMasked();
+    OFOxm<U16> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U16> {
+        OFOxmBsnTcpFlagsMasked build();
+        long getTypeLen();
+        U16 getValue();
+        Builder setValue(U16 value);
+        U16 getMask();
+        Builder setMask(U16 mask);
+        MatchField<U16> getMatchField();
+        boolean isMasked();
+        OFOxm<U16> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf0.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf0.java
new file mode 100644
index 0000000..7143e5a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf0.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf0 extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    UDF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf0 build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        UDF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf0Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf0Masked.java
new file mode 100644
index 0000000..ee1c5ff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf0Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf0Masked extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    UDF getMask();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf0Masked build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        UDF getMask();
+        Builder setMask(UDF mask);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf1.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf1.java
new file mode 100644
index 0000000..e45f0b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf1.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf1 extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    UDF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf1 build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        UDF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf1Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf1Masked.java
new file mode 100644
index 0000000..e28f8e2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf1Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf1Masked extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    UDF getMask();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf1Masked build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        UDF getMask();
+        Builder setMask(UDF mask);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf2.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf2.java
new file mode 100644
index 0000000..dea445d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf2.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf2 extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    UDF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf2 build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        UDF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf2Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf2Masked.java
new file mode 100644
index 0000000..549d930
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf2Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf2Masked extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    UDF getMask();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf2Masked build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        UDF getMask();
+        Builder setMask(UDF mask);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf3.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf3.java
new file mode 100644
index 0000000..094b197
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf3.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf3 extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    UDF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf3 build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        UDF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf3Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf3Masked.java
new file mode 100644
index 0000000..0a5a77f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf3Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf3Masked extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    UDF getMask();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf3Masked build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        UDF getMask();
+        Builder setMask(UDF mask);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf4.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf4.java
new file mode 100644
index 0000000..d7ea548
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf4.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf4 extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    UDF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf4 build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        UDF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf4Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf4Masked.java
new file mode 100644
index 0000000..735d3e8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf4Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf4Masked extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    UDF getMask();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf4Masked build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        UDF getMask();
+        Builder setMask(UDF mask);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf5.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf5.java
new file mode 100644
index 0000000..52a0eb0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf5.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf5 extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    UDF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf5 build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        UDF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf5Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf5Masked.java
new file mode 100644
index 0000000..138ac18
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf5Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf5Masked extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    UDF getMask();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf5Masked build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        UDF getMask();
+        Builder setMask(UDF mask);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf6.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf6.java
new file mode 100644
index 0000000..6d84593
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf6.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf6 extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    UDF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf6 build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        UDF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf6Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf6Masked.java
new file mode 100644
index 0000000..fd03177
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf6Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf6Masked extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    UDF getMask();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf6Masked build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        UDF getMask();
+        Builder setMask(UDF mask);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf7.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf7.java
new file mode 100644
index 0000000..430ec39
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf7.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf7 extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    UDF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf7 build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        UDF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf7Masked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf7Masked.java
new file mode 100644
index 0000000..6859ec3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnUdf7Masked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnUdf7Masked extends OFObject, OFOxm<UDF> {
+    long getTypeLen();
+    UDF getValue();
+    UDF getMask();
+    MatchField<UDF> getMatchField();
+    boolean isMasked();
+    OFOxm<UDF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<UDF> {
+        OFOxmBsnUdf7Masked build();
+        long getTypeLen();
+        UDF getValue();
+        Builder setValue(UDF value);
+        UDF getMask();
+        Builder setMask(UDF mask);
+        MatchField<UDF> getMatchField();
+        boolean isMasked();
+        OFOxm<UDF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVlanXlatePortGroupId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVlanXlatePortGroupId.java
new file mode 100644
index 0000000..84a94a3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVlanXlatePortGroupId.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnVlanXlatePortGroupId extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    ClassId getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnVlanXlatePortGroupId build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        ClassId getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVlanXlatePortGroupIdMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVlanXlatePortGroupIdMasked.java
new file mode 100644
index 0000000..992bd48
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVlanXlatePortGroupIdMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnVlanXlatePortGroupIdMasked extends OFObject, OFOxm<ClassId> {
+    long getTypeLen();
+    ClassId getValue();
+    ClassId getMask();
+    MatchField<ClassId> getMatchField();
+    boolean isMasked();
+    OFOxm<ClassId> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ClassId> {
+        OFOxmBsnVlanXlatePortGroupIdMasked build();
+        long getTypeLen();
+        ClassId getValue();
+        Builder setValue(ClassId value);
+        ClassId getMask();
+        Builder setMask(ClassId mask);
+        MatchField<ClassId> getMatchField();
+        boolean isMasked();
+        OFOxm<ClassId> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVrf.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVrf.java
new file mode 100644
index 0000000..b27b0f2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVrf.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnVrf extends OFObject, OFOxm<VRF> {
+    long getTypeLen();
+    VRF getValue();
+    MatchField<VRF> getMatchField();
+    boolean isMasked();
+    OFOxm<VRF> getCanonical();
+    VRF getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<VRF> {
+        OFOxmBsnVrf build();
+        long getTypeLen();
+        VRF getValue();
+        Builder setValue(VRF value);
+        MatchField<VRF> getMatchField();
+        boolean isMasked();
+        OFOxm<VRF> getCanonical();
+        VRF getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVrfMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVrfMasked.java
new file mode 100644
index 0000000..f235551
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmBsnVrfMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmBsnVrfMasked extends OFObject, OFOxm<VRF> {
+    long getTypeLen();
+    VRF getValue();
+    VRF getMask();
+    MatchField<VRF> getMatchField();
+    boolean isMasked();
+    OFOxm<VRF> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<VRF> {
+        OFOxmBsnVrfMasked build();
+        long getTypeLen();
+        VRF getValue();
+        Builder setValue(VRF value);
+        VRF getMask();
+        Builder setMask(VRF mask);
+        MatchField<VRF> getMatchField();
+        boolean isMasked();
+        OFOxm<VRF> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthDst.java
new file mode 100644
index 0000000..9c70c2e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthDst.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmEthDst extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    MacAddress getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmEthDst build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        MacAddress getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthDstMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthDstMasked.java
new file mode 100644
index 0000000..0987c6b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthDstMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmEthDstMasked extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MacAddress getMask();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmEthDstMasked build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MacAddress getMask();
+        Builder setMask(MacAddress mask);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthSrc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthSrc.java
new file mode 100644
index 0000000..7b0920a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthSrc.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmEthSrc extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    MacAddress getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmEthSrc build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        MacAddress getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthSrcMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthSrcMasked.java
new file mode 100644
index 0000000..e869585
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthSrcMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmEthSrcMasked extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MacAddress getMask();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmEthSrcMasked build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MacAddress getMask();
+        Builder setMask(MacAddress mask);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthType.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthType.java
new file mode 100644
index 0000000..6d59534
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthType.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmEthType extends OFObject, OFOxm<EthType> {
+    long getTypeLen();
+    EthType getValue();
+    MatchField<EthType> getMatchField();
+    boolean isMasked();
+    OFOxm<EthType> getCanonical();
+    EthType getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<EthType> {
+        OFOxmEthType build();
+        long getTypeLen();
+        EthType getValue();
+        Builder setValue(EthType value);
+        MatchField<EthType> getMatchField();
+        boolean isMasked();
+        OFOxm<EthType> getCanonical();
+        EthType getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthTypeMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthTypeMasked.java
new file mode 100644
index 0000000..9ae2f1f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmEthTypeMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmEthTypeMasked extends OFObject, OFOxm<EthType> {
+    long getTypeLen();
+    EthType getValue();
+    EthType getMask();
+    MatchField<EthType> getMatchField();
+    boolean isMasked();
+    OFOxm<EthType> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<EthType> {
+        OFOxmEthTypeMasked build();
+        long getTypeLen();
+        EthType getValue();
+        Builder setValue(EthType value);
+        EthType getMask();
+        Builder setMask(EthType mask);
+        MatchField<EthType> getMatchField();
+        boolean isMasked();
+        OFOxm<EthType> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4Code.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4Code.java
new file mode 100644
index 0000000..db219a7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4Code.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIcmpv4Code extends OFObject, OFOxm<ICMPv4Code> {
+    long getTypeLen();
+    ICMPv4Code getValue();
+    MatchField<ICMPv4Code> getMatchField();
+    boolean isMasked();
+    OFOxm<ICMPv4Code> getCanonical();
+    ICMPv4Code getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ICMPv4Code> {
+        OFOxmIcmpv4Code build();
+        long getTypeLen();
+        ICMPv4Code getValue();
+        Builder setValue(ICMPv4Code value);
+        MatchField<ICMPv4Code> getMatchField();
+        boolean isMasked();
+        OFOxm<ICMPv4Code> getCanonical();
+        ICMPv4Code getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4CodeMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4CodeMasked.java
new file mode 100644
index 0000000..2462b45
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4CodeMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIcmpv4CodeMasked extends OFObject, OFOxm<ICMPv4Code> {
+    long getTypeLen();
+    ICMPv4Code getValue();
+    ICMPv4Code getMask();
+    MatchField<ICMPv4Code> getMatchField();
+    boolean isMasked();
+    OFOxm<ICMPv4Code> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ICMPv4Code> {
+        OFOxmIcmpv4CodeMasked build();
+        long getTypeLen();
+        ICMPv4Code getValue();
+        Builder setValue(ICMPv4Code value);
+        ICMPv4Code getMask();
+        Builder setMask(ICMPv4Code mask);
+        MatchField<ICMPv4Code> getMatchField();
+        boolean isMasked();
+        OFOxm<ICMPv4Code> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4Type.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4Type.java
new file mode 100644
index 0000000..ede641b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4Type.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIcmpv4Type extends OFObject, OFOxm<ICMPv4Type> {
+    long getTypeLen();
+    ICMPv4Type getValue();
+    MatchField<ICMPv4Type> getMatchField();
+    boolean isMasked();
+    OFOxm<ICMPv4Type> getCanonical();
+    ICMPv4Type getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ICMPv4Type> {
+        OFOxmIcmpv4Type build();
+        long getTypeLen();
+        ICMPv4Type getValue();
+        Builder setValue(ICMPv4Type value);
+        MatchField<ICMPv4Type> getMatchField();
+        boolean isMasked();
+        OFOxm<ICMPv4Type> getCanonical();
+        ICMPv4Type getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4TypeMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4TypeMasked.java
new file mode 100644
index 0000000..7c8f011
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv4TypeMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIcmpv4TypeMasked extends OFObject, OFOxm<ICMPv4Type> {
+    long getTypeLen();
+    ICMPv4Type getValue();
+    ICMPv4Type getMask();
+    MatchField<ICMPv4Type> getMatchField();
+    boolean isMasked();
+    OFOxm<ICMPv4Type> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<ICMPv4Type> {
+        OFOxmIcmpv4TypeMasked build();
+        long getTypeLen();
+        ICMPv4Type getValue();
+        Builder setValue(ICMPv4Type value);
+        ICMPv4Type getMask();
+        Builder setMask(ICMPv4Type mask);
+        MatchField<ICMPv4Type> getMatchField();
+        boolean isMasked();
+        OFOxm<ICMPv4Type> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6Code.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6Code.java
new file mode 100644
index 0000000..7ff6ac8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6Code.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIcmpv6Code extends OFObject, OFOxm<U8> {
+    long getTypeLen();
+    U8 getValue();
+    MatchField<U8> getMatchField();
+    boolean isMasked();
+    OFOxm<U8> getCanonical();
+    U8 getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U8> {
+        OFOxmIcmpv6Code build();
+        long getTypeLen();
+        U8 getValue();
+        Builder setValue(U8 value);
+        MatchField<U8> getMatchField();
+        boolean isMasked();
+        OFOxm<U8> getCanonical();
+        U8 getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6CodeMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6CodeMasked.java
new file mode 100644
index 0000000..2cf38b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6CodeMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIcmpv6CodeMasked extends OFObject, OFOxm<U8> {
+    long getTypeLen();
+    U8 getValue();
+    U8 getMask();
+    MatchField<U8> getMatchField();
+    boolean isMasked();
+    OFOxm<U8> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U8> {
+        OFOxmIcmpv6CodeMasked build();
+        long getTypeLen();
+        U8 getValue();
+        Builder setValue(U8 value);
+        U8 getMask();
+        Builder setMask(U8 mask);
+        MatchField<U8> getMatchField();
+        boolean isMasked();
+        OFOxm<U8> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6Type.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6Type.java
new file mode 100644
index 0000000..de54d1d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6Type.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIcmpv6Type extends OFObject, OFOxm<U8> {
+    long getTypeLen();
+    U8 getValue();
+    MatchField<U8> getMatchField();
+    boolean isMasked();
+    OFOxm<U8> getCanonical();
+    U8 getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U8> {
+        OFOxmIcmpv6Type build();
+        long getTypeLen();
+        U8 getValue();
+        Builder setValue(U8 value);
+        MatchField<U8> getMatchField();
+        boolean isMasked();
+        OFOxm<U8> getCanonical();
+        U8 getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6TypeMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6TypeMasked.java
new file mode 100644
index 0000000..bb61bd5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIcmpv6TypeMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIcmpv6TypeMasked extends OFObject, OFOxm<U8> {
+    long getTypeLen();
+    U8 getValue();
+    U8 getMask();
+    MatchField<U8> getMatchField();
+    boolean isMasked();
+    OFOxm<U8> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U8> {
+        OFOxmIcmpv6TypeMasked build();
+        long getTypeLen();
+        U8 getValue();
+        Builder setValue(U8 value);
+        U8 getMask();
+        Builder setMask(U8 mask);
+        MatchField<U8> getMatchField();
+        boolean isMasked();
+        OFOxm<U8> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPhyPort.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPhyPort.java
new file mode 100644
index 0000000..85b2700
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPhyPort.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmInPhyPort extends OFObject, OFOxm<OFPort> {
+    long getTypeLen();
+    OFPort getValue();
+    MatchField<OFPort> getMatchField();
+    boolean isMasked();
+    OFOxm<OFPort> getCanonical();
+    OFPort getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFPort> {
+        OFOxmInPhyPort build();
+        long getTypeLen();
+        OFPort getValue();
+        Builder setValue(OFPort value);
+        MatchField<OFPort> getMatchField();
+        boolean isMasked();
+        OFOxm<OFPort> getCanonical();
+        OFPort getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPhyPortMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPhyPortMasked.java
new file mode 100644
index 0000000..ae20318
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPhyPortMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmInPhyPortMasked extends OFObject, OFOxm<OFPort> {
+    long getTypeLen();
+    OFPort getValue();
+    OFPort getMask();
+    MatchField<OFPort> getMatchField();
+    boolean isMasked();
+    OFOxm<OFPort> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFPort> {
+        OFOxmInPhyPortMasked build();
+        long getTypeLen();
+        OFPort getValue();
+        Builder setValue(OFPort value);
+        OFPort getMask();
+        Builder setMask(OFPort mask);
+        MatchField<OFPort> getMatchField();
+        boolean isMasked();
+        OFOxm<OFPort> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPort.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPort.java
new file mode 100644
index 0000000..11ac28b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPort.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmInPort extends OFObject, OFOxm<OFPort> {
+    long getTypeLen();
+    OFPort getValue();
+    MatchField<OFPort> getMatchField();
+    boolean isMasked();
+    OFOxm<OFPort> getCanonical();
+    OFPort getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFPort> {
+        OFOxmInPort build();
+        long getTypeLen();
+        OFPort getValue();
+        Builder setValue(OFPort value);
+        MatchField<OFPort> getMatchField();
+        boolean isMasked();
+        OFOxm<OFPort> getCanonical();
+        OFPort getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPortMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPortMasked.java
new file mode 100644
index 0000000..3e8970c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmInPortMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmInPortMasked extends OFObject, OFOxm<OFPort> {
+    long getTypeLen();
+    OFPort getValue();
+    OFPort getMask();
+    MatchField<OFPort> getMatchField();
+    boolean isMasked();
+    OFOxm<OFPort> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFPort> {
+        OFOxmInPortMasked build();
+        long getTypeLen();
+        OFPort getValue();
+        Builder setValue(OFPort value);
+        OFPort getMask();
+        Builder setMask(OFPort mask);
+        MatchField<OFPort> getMatchField();
+        boolean isMasked();
+        OFOxm<OFPort> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpDscp.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpDscp.java
new file mode 100644
index 0000000..0d829db
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpDscp.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpDscp extends OFObject, OFOxm<IpDscp> {
+    long getTypeLen();
+    IpDscp getValue();
+    MatchField<IpDscp> getMatchField();
+    boolean isMasked();
+    OFOxm<IpDscp> getCanonical();
+    IpDscp getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IpDscp> {
+        OFOxmIpDscp build();
+        long getTypeLen();
+        IpDscp getValue();
+        Builder setValue(IpDscp value);
+        MatchField<IpDscp> getMatchField();
+        boolean isMasked();
+        OFOxm<IpDscp> getCanonical();
+        IpDscp getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpDscpMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpDscpMasked.java
new file mode 100644
index 0000000..a837b72
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpDscpMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpDscpMasked extends OFObject, OFOxm<IpDscp> {
+    long getTypeLen();
+    IpDscp getValue();
+    IpDscp getMask();
+    MatchField<IpDscp> getMatchField();
+    boolean isMasked();
+    OFOxm<IpDscp> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IpDscp> {
+        OFOxmIpDscpMasked build();
+        long getTypeLen();
+        IpDscp getValue();
+        Builder setValue(IpDscp value);
+        IpDscp getMask();
+        Builder setMask(IpDscp mask);
+        MatchField<IpDscp> getMatchField();
+        boolean isMasked();
+        OFOxm<IpDscp> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpEcn.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpEcn.java
new file mode 100644
index 0000000..a70813f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpEcn.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpEcn extends OFObject, OFOxm<IpEcn> {
+    long getTypeLen();
+    IpEcn getValue();
+    MatchField<IpEcn> getMatchField();
+    boolean isMasked();
+    OFOxm<IpEcn> getCanonical();
+    IpEcn getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IpEcn> {
+        OFOxmIpEcn build();
+        long getTypeLen();
+        IpEcn getValue();
+        Builder setValue(IpEcn value);
+        MatchField<IpEcn> getMatchField();
+        boolean isMasked();
+        OFOxm<IpEcn> getCanonical();
+        IpEcn getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpEcnMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpEcnMasked.java
new file mode 100644
index 0000000..4a3a1ff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpEcnMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpEcnMasked extends OFObject, OFOxm<IpEcn> {
+    long getTypeLen();
+    IpEcn getValue();
+    IpEcn getMask();
+    MatchField<IpEcn> getMatchField();
+    boolean isMasked();
+    OFOxm<IpEcn> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IpEcn> {
+        OFOxmIpEcnMasked build();
+        long getTypeLen();
+        IpEcn getValue();
+        Builder setValue(IpEcn value);
+        IpEcn getMask();
+        Builder setMask(IpEcn mask);
+        MatchField<IpEcn> getMatchField();
+        boolean isMasked();
+        OFOxm<IpEcn> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpProto.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpProto.java
new file mode 100644
index 0000000..dc284d6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpProto.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpProto extends OFObject, OFOxm<IpProtocol> {
+    long getTypeLen();
+    IpProtocol getValue();
+    MatchField<IpProtocol> getMatchField();
+    boolean isMasked();
+    OFOxm<IpProtocol> getCanonical();
+    IpProtocol getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IpProtocol> {
+        OFOxmIpProto build();
+        long getTypeLen();
+        IpProtocol getValue();
+        Builder setValue(IpProtocol value);
+        MatchField<IpProtocol> getMatchField();
+        boolean isMasked();
+        OFOxm<IpProtocol> getCanonical();
+        IpProtocol getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpProtoMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpProtoMasked.java
new file mode 100644
index 0000000..906f742
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpProtoMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpProtoMasked extends OFObject, OFOxm<IpProtocol> {
+    long getTypeLen();
+    IpProtocol getValue();
+    IpProtocol getMask();
+    MatchField<IpProtocol> getMatchField();
+    boolean isMasked();
+    OFOxm<IpProtocol> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IpProtocol> {
+        OFOxmIpProtoMasked build();
+        long getTypeLen();
+        IpProtocol getValue();
+        Builder setValue(IpProtocol value);
+        IpProtocol getMask();
+        Builder setMask(IpProtocol mask);
+        MatchField<IpProtocol> getMatchField();
+        boolean isMasked();
+        OFOxm<IpProtocol> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4Dst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4Dst.java
new file mode 100644
index 0000000..6e97025
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4Dst.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv4Dst extends OFObject, OFOxm<IPv4Address> {
+    long getTypeLen();
+    IPv4Address getValue();
+    MatchField<IPv4Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv4Address> getCanonical();
+    IPv4Address getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv4Address> {
+        OFOxmIpv4Dst build();
+        long getTypeLen();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        MatchField<IPv4Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv4Address> getCanonical();
+        IPv4Address getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4DstMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4DstMasked.java
new file mode 100644
index 0000000..8a008c8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4DstMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv4DstMasked extends OFObject, OFOxm<IPv4Address> {
+    long getTypeLen();
+    IPv4Address getValue();
+    IPv4Address getMask();
+    MatchField<IPv4Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv4Address> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv4Address> {
+        OFOxmIpv4DstMasked build();
+        long getTypeLen();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        IPv4Address getMask();
+        Builder setMask(IPv4Address mask);
+        MatchField<IPv4Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv4Address> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4Src.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4Src.java
new file mode 100644
index 0000000..1cfbc04
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4Src.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv4Src extends OFObject, OFOxm<IPv4Address> {
+    long getTypeLen();
+    IPv4Address getValue();
+    MatchField<IPv4Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv4Address> getCanonical();
+    IPv4Address getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv4Address> {
+        OFOxmIpv4Src build();
+        long getTypeLen();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        MatchField<IPv4Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv4Address> getCanonical();
+        IPv4Address getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4SrcMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4SrcMasked.java
new file mode 100644
index 0000000..9fcd714
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv4SrcMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv4SrcMasked extends OFObject, OFOxm<IPv4Address> {
+    long getTypeLen();
+    IPv4Address getValue();
+    IPv4Address getMask();
+    MatchField<IPv4Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv4Address> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv4Address> {
+        OFOxmIpv4SrcMasked build();
+        long getTypeLen();
+        IPv4Address getValue();
+        Builder setValue(IPv4Address value);
+        IPv4Address getMask();
+        Builder setMask(IPv4Address mask);
+        MatchField<IPv4Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv4Address> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Dst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Dst.java
new file mode 100644
index 0000000..bb92e3b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Dst.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6Dst extends OFObject, OFOxm<IPv6Address> {
+    long getTypeLen();
+    IPv6Address getValue();
+    MatchField<IPv6Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv6Address> getCanonical();
+    IPv6Address getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv6Address> {
+        OFOxmIpv6Dst build();
+        long getTypeLen();
+        IPv6Address getValue();
+        Builder setValue(IPv6Address value);
+        MatchField<IPv6Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv6Address> getCanonical();
+        IPv6Address getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6DstMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6DstMasked.java
new file mode 100644
index 0000000..ca98060
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6DstMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6DstMasked extends OFObject, OFOxm<IPv6Address> {
+    long getTypeLen();
+    IPv6Address getValue();
+    IPv6Address getMask();
+    MatchField<IPv6Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv6Address> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv6Address> {
+        OFOxmIpv6DstMasked build();
+        long getTypeLen();
+        IPv6Address getValue();
+        Builder setValue(IPv6Address value);
+        IPv6Address getMask();
+        Builder setMask(IPv6Address mask);
+        MatchField<IPv6Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv6Address> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Flabel.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Flabel.java
new file mode 100644
index 0000000..fa28ec7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Flabel.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6Flabel extends OFObject, OFOxm<IPv6FlowLabel> {
+    long getTypeLen();
+    IPv6FlowLabel getValue();
+    MatchField<IPv6FlowLabel> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv6FlowLabel> getCanonical();
+    IPv6FlowLabel getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv6FlowLabel> {
+        OFOxmIpv6Flabel build();
+        long getTypeLen();
+        IPv6FlowLabel getValue();
+        Builder setValue(IPv6FlowLabel value);
+        MatchField<IPv6FlowLabel> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv6FlowLabel> getCanonical();
+        IPv6FlowLabel getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6FlabelMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6FlabelMasked.java
new file mode 100644
index 0000000..7e19baa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6FlabelMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6FlabelMasked extends OFObject, OFOxm<IPv6FlowLabel> {
+    long getTypeLen();
+    IPv6FlowLabel getValue();
+    IPv6FlowLabel getMask();
+    MatchField<IPv6FlowLabel> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv6FlowLabel> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv6FlowLabel> {
+        OFOxmIpv6FlabelMasked build();
+        long getTypeLen();
+        IPv6FlowLabel getValue();
+        Builder setValue(IPv6FlowLabel value);
+        IPv6FlowLabel getMask();
+        Builder setMask(IPv6FlowLabel mask);
+        MatchField<IPv6FlowLabel> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv6FlowLabel> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdSll.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdSll.java
new file mode 100644
index 0000000..5365c2f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdSll.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6NdSll extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    MacAddress getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmIpv6NdSll build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        MacAddress getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdSllMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdSllMasked.java
new file mode 100644
index 0000000..baf32e1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdSllMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6NdSllMasked extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MacAddress getMask();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmIpv6NdSllMasked build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MacAddress getMask();
+        Builder setMask(MacAddress mask);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTarget.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTarget.java
new file mode 100644
index 0000000..421f148
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTarget.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6NdTarget extends OFObject, OFOxm<IPv6Address> {
+    long getTypeLen();
+    IPv6Address getValue();
+    MatchField<IPv6Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv6Address> getCanonical();
+    IPv6Address getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv6Address> {
+        OFOxmIpv6NdTarget build();
+        long getTypeLen();
+        IPv6Address getValue();
+        Builder setValue(IPv6Address value);
+        MatchField<IPv6Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv6Address> getCanonical();
+        IPv6Address getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTargetMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTargetMasked.java
new file mode 100644
index 0000000..807affe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTargetMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6NdTargetMasked extends OFObject, OFOxm<IPv6Address> {
+    long getTypeLen();
+    IPv6Address getValue();
+    IPv6Address getMask();
+    MatchField<IPv6Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv6Address> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv6Address> {
+        OFOxmIpv6NdTargetMasked build();
+        long getTypeLen();
+        IPv6Address getValue();
+        Builder setValue(IPv6Address value);
+        IPv6Address getMask();
+        Builder setMask(IPv6Address mask);
+        MatchField<IPv6Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv6Address> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTll.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTll.java
new file mode 100644
index 0000000..ca9f1ad
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTll.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6NdTll extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    MacAddress getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmIpv6NdTll build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        MacAddress getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTllMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTllMasked.java
new file mode 100644
index 0000000..1e1a6e6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6NdTllMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6NdTllMasked extends OFObject, OFOxm<MacAddress> {
+    long getTypeLen();
+    MacAddress getValue();
+    MacAddress getMask();
+    MatchField<MacAddress> getMatchField();
+    boolean isMasked();
+    OFOxm<MacAddress> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<MacAddress> {
+        OFOxmIpv6NdTllMasked build();
+        long getTypeLen();
+        MacAddress getValue();
+        Builder setValue(MacAddress value);
+        MacAddress getMask();
+        Builder setMask(MacAddress mask);
+        MatchField<MacAddress> getMatchField();
+        boolean isMasked();
+        OFOxm<MacAddress> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Src.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Src.java
new file mode 100644
index 0000000..528c16c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6Src.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6Src extends OFObject, OFOxm<IPv6Address> {
+    long getTypeLen();
+    IPv6Address getValue();
+    MatchField<IPv6Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv6Address> getCanonical();
+    IPv6Address getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv6Address> {
+        OFOxmIpv6Src build();
+        long getTypeLen();
+        IPv6Address getValue();
+        Builder setValue(IPv6Address value);
+        MatchField<IPv6Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv6Address> getCanonical();
+        IPv6Address getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6SrcMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6SrcMasked.java
new file mode 100644
index 0000000..1fc4e20
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmIpv6SrcMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmIpv6SrcMasked extends OFObject, OFOxm<IPv6Address> {
+    long getTypeLen();
+    IPv6Address getValue();
+    IPv6Address getMask();
+    MatchField<IPv6Address> getMatchField();
+    boolean isMasked();
+    OFOxm<IPv6Address> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<IPv6Address> {
+        OFOxmIpv6SrcMasked build();
+        long getTypeLen();
+        IPv6Address getValue();
+        Builder setValue(IPv6Address value);
+        IPv6Address getMask();
+        Builder setMask(IPv6Address mask);
+        MatchField<IPv6Address> getMatchField();
+        boolean isMasked();
+        OFOxm<IPv6Address> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMetadata.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMetadata.java
new file mode 100644
index 0000000..92964e6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMetadata.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmMetadata extends OFObject, OFOxm<OFMetadata> {
+    long getTypeLen();
+    OFMetadata getValue();
+    MatchField<OFMetadata> getMatchField();
+    boolean isMasked();
+    OFOxm<OFMetadata> getCanonical();
+    OFMetadata getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFMetadata> {
+        OFOxmMetadata build();
+        long getTypeLen();
+        OFMetadata getValue();
+        Builder setValue(OFMetadata value);
+        MatchField<OFMetadata> getMatchField();
+        boolean isMasked();
+        OFOxm<OFMetadata> getCanonical();
+        OFMetadata getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMetadataMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMetadataMasked.java
new file mode 100644
index 0000000..58d0437
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMetadataMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmMetadataMasked extends OFObject, OFOxm<OFMetadata> {
+    long getTypeLen();
+    OFMetadata getValue();
+    OFMetadata getMask();
+    MatchField<OFMetadata> getMatchField();
+    boolean isMasked();
+    OFOxm<OFMetadata> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFMetadata> {
+        OFOxmMetadataMasked build();
+        long getTypeLen();
+        OFMetadata getValue();
+        Builder setValue(OFMetadata value);
+        OFMetadata getMask();
+        Builder setMask(OFMetadata mask);
+        MatchField<OFMetadata> getMatchField();
+        boolean isMasked();
+        OFOxm<OFMetadata> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsLabel.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsLabel.java
new file mode 100644
index 0000000..d64a878
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsLabel.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmMplsLabel extends OFObject, OFOxm<U32> {
+    long getTypeLen();
+    U32 getValue();
+    MatchField<U32> getMatchField();
+    boolean isMasked();
+    OFOxm<U32> getCanonical();
+    U32 getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U32> {
+        OFOxmMplsLabel build();
+        long getTypeLen();
+        U32 getValue();
+        Builder setValue(U32 value);
+        MatchField<U32> getMatchField();
+        boolean isMasked();
+        OFOxm<U32> getCanonical();
+        U32 getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsLabelMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsLabelMasked.java
new file mode 100644
index 0000000..21d94f4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsLabelMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmMplsLabelMasked extends OFObject, OFOxm<U32> {
+    long getTypeLen();
+    U32 getValue();
+    U32 getMask();
+    MatchField<U32> getMatchField();
+    boolean isMasked();
+    OFOxm<U32> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U32> {
+        OFOxmMplsLabelMasked build();
+        long getTypeLen();
+        U32 getValue();
+        Builder setValue(U32 value);
+        U32 getMask();
+        Builder setMask(U32 mask);
+        MatchField<U32> getMatchField();
+        boolean isMasked();
+        OFOxm<U32> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsTc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsTc.java
new file mode 100644
index 0000000..e7cf2e5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsTc.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmMplsTc extends OFObject, OFOxm<U8> {
+    long getTypeLen();
+    U8 getValue();
+    MatchField<U8> getMatchField();
+    boolean isMasked();
+    OFOxm<U8> getCanonical();
+    U8 getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U8> {
+        OFOxmMplsTc build();
+        long getTypeLen();
+        U8 getValue();
+        Builder setValue(U8 value);
+        MatchField<U8> getMatchField();
+        boolean isMasked();
+        OFOxm<U8> getCanonical();
+        U8 getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsTcMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsTcMasked.java
new file mode 100644
index 0000000..150ba6c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmMplsTcMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmMplsTcMasked extends OFObject, OFOxm<U8> {
+    long getTypeLen();
+    U8 getValue();
+    U8 getMask();
+    MatchField<U8> getMatchField();
+    boolean isMasked();
+    OFOxm<U8> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U8> {
+        OFOxmMplsTcMasked build();
+        long getTypeLen();
+        U8 getValue();
+        Builder setValue(U8 value);
+        U8 getMask();
+        Builder setMask(U8 mask);
+        MatchField<U8> getMatchField();
+        boolean isMasked();
+        OFOxm<U8> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpDst.java
new file mode 100644
index 0000000..16cf32d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpDst.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmSctpDst extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    TransportPort getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmSctpDst build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        TransportPort getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpDstMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpDstMasked.java
new file mode 100644
index 0000000..15df987
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpDstMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmSctpDstMasked extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    TransportPort getMask();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmSctpDstMasked build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        TransportPort getMask();
+        Builder setMask(TransportPort mask);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpSrc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpSrc.java
new file mode 100644
index 0000000..1953087
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpSrc.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmSctpSrc extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    TransportPort getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmSctpSrc build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        TransportPort getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpSrcMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpSrcMasked.java
new file mode 100644
index 0000000..4454c3c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmSctpSrcMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmSctpSrcMasked extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    TransportPort getMask();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmSctpSrcMasked build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        TransportPort getMask();
+        Builder setMask(TransportPort mask);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpDst.java
new file mode 100644
index 0000000..9bbedc2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpDst.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmTcpDst extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    TransportPort getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmTcpDst build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        TransportPort getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpDstMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpDstMasked.java
new file mode 100644
index 0000000..798dab2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpDstMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmTcpDstMasked extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    TransportPort getMask();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmTcpDstMasked build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        TransportPort getMask();
+        Builder setMask(TransportPort mask);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpSrc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpSrc.java
new file mode 100644
index 0000000..b4aa20e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpSrc.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmTcpSrc extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    TransportPort getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmTcpSrc build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        TransportPort getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpSrcMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpSrcMasked.java
new file mode 100644
index 0000000..4a39ded
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTcpSrcMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmTcpSrcMasked extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    TransportPort getMask();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmTcpSrcMasked build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        TransportPort getMask();
+        Builder setMask(TransportPort mask);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTunnelId.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTunnelId.java
new file mode 100644
index 0000000..63a7e7a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTunnelId.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmTunnelId extends OFObject, OFOxm<U64> {
+    long getTypeLen();
+    U64 getValue();
+    MatchField<U64> getMatchField();
+    boolean isMasked();
+    OFOxm<U64> getCanonical();
+    U64 getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U64> {
+        OFOxmTunnelId build();
+        long getTypeLen();
+        U64 getValue();
+        Builder setValue(U64 value);
+        MatchField<U64> getMatchField();
+        boolean isMasked();
+        OFOxm<U64> getCanonical();
+        U64 getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTunnelIdMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTunnelIdMasked.java
new file mode 100644
index 0000000..2f8b9b8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmTunnelIdMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmTunnelIdMasked extends OFObject, OFOxm<U64> {
+    long getTypeLen();
+    U64 getValue();
+    U64 getMask();
+    MatchField<U64> getMatchField();
+    boolean isMasked();
+    OFOxm<U64> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<U64> {
+        OFOxmTunnelIdMasked build();
+        long getTypeLen();
+        U64 getValue();
+        Builder setValue(U64 value);
+        U64 getMask();
+        Builder setMask(U64 mask);
+        MatchField<U64> getMatchField();
+        boolean isMasked();
+        OFOxm<U64> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpDst.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpDst.java
new file mode 100644
index 0000000..097db29
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpDst.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmUdpDst extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    TransportPort getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmUdpDst build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        TransportPort getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpDstMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpDstMasked.java
new file mode 100644
index 0000000..37fea56
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpDstMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmUdpDstMasked extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    TransportPort getMask();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmUdpDstMasked build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        TransportPort getMask();
+        Builder setMask(TransportPort mask);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpSrc.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpSrc.java
new file mode 100644
index 0000000..9f16f2d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpSrc.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmUdpSrc extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    TransportPort getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmUdpSrc build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        TransportPort getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpSrcMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpSrcMasked.java
new file mode 100644
index 0000000..623b6b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmUdpSrcMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmUdpSrcMasked extends OFObject, OFOxm<TransportPort> {
+    long getTypeLen();
+    TransportPort getValue();
+    TransportPort getMask();
+    MatchField<TransportPort> getMatchField();
+    boolean isMasked();
+    OFOxm<TransportPort> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<TransportPort> {
+        OFOxmUdpSrcMasked build();
+        long getTypeLen();
+        TransportPort getValue();
+        Builder setValue(TransportPort value);
+        TransportPort getMask();
+        Builder setMask(TransportPort mask);
+        MatchField<TransportPort> getMatchField();
+        boolean isMasked();
+        OFOxm<TransportPort> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanPcp.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanPcp.java
new file mode 100644
index 0000000..858e6a0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanPcp.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmVlanPcp extends OFObject, OFOxm<VlanPcp> {
+    long getTypeLen();
+    VlanPcp getValue();
+    MatchField<VlanPcp> getMatchField();
+    boolean isMasked();
+    OFOxm<VlanPcp> getCanonical();
+    VlanPcp getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<VlanPcp> {
+        OFOxmVlanPcp build();
+        long getTypeLen();
+        VlanPcp getValue();
+        Builder setValue(VlanPcp value);
+        MatchField<VlanPcp> getMatchField();
+        boolean isMasked();
+        OFOxm<VlanPcp> getCanonical();
+        VlanPcp getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanPcpMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanPcpMasked.java
new file mode 100644
index 0000000..62a34b2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanPcpMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmVlanPcpMasked extends OFObject, OFOxm<VlanPcp> {
+    long getTypeLen();
+    VlanPcp getValue();
+    VlanPcp getMask();
+    MatchField<VlanPcp> getMatchField();
+    boolean isMasked();
+    OFOxm<VlanPcp> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<VlanPcp> {
+        OFOxmVlanPcpMasked build();
+        long getTypeLen();
+        VlanPcp getValue();
+        Builder setValue(VlanPcp value);
+        VlanPcp getMask();
+        Builder setMask(VlanPcp mask);
+        MatchField<VlanPcp> getMatchField();
+        boolean isMasked();
+        OFOxm<VlanPcp> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanVid.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanVid.java
new file mode 100644
index 0000000..4b34b05
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanVid.java
@@ -0,0 +1,51 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmVlanVid extends OFObject, OFOxm<OFVlanVidMatch> {
+    long getTypeLen();
+    OFVlanVidMatch getValue();
+    MatchField<OFVlanVidMatch> getMatchField();
+    boolean isMasked();
+    OFOxm<OFVlanVidMatch> getCanonical();
+    OFVlanVidMatch getMask();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFVlanVidMatch> {
+        OFOxmVlanVid build();
+        long getTypeLen();
+        OFVlanVidMatch getValue();
+        Builder setValue(OFVlanVidMatch value);
+        MatchField<OFVlanVidMatch> getMatchField();
+        boolean isMasked();
+        OFOxm<OFVlanVidMatch> getCanonical();
+        OFVlanVidMatch getMask();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanVidMasked.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanVidMasked.java
new file mode 100644
index 0000000..36110a7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxmVlanVidMasked.java
@@ -0,0 +1,52 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFOxmVlanVidMasked extends OFObject, OFOxm<OFVlanVidMatch> {
+    long getTypeLen();
+    OFVlanVidMatch getValue();
+    OFVlanVidMatch getMask();
+    MatchField<OFVlanVidMatch> getMatchField();
+    boolean isMasked();
+    OFOxm<OFVlanVidMatch> getCanonical();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFOxm.Builder<OFVlanVidMatch> {
+        OFOxmVlanVidMasked build();
+        long getTypeLen();
+        OFVlanVidMatch getValue();
+        Builder setValue(OFVlanVidMatch value);
+        OFVlanVidMatch getMask();
+        Builder setMask(OFVlanVidMatch mask);
+        MatchField<OFVlanVidMatch> getMatchField();
+        boolean isMasked();
+        OFOxm<OFVlanVidMatch> getCanonical();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxms.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxms.java
new file mode 100644
index 0000000..9cc2bba
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/oxm/OFOxms.java
@@ -0,0 +1,257 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.oxm;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public interface OFOxms {
+    // Subfactories
+
+    OFOxmArpOp.Builder buildArpOp() throws UnsupportedOperationException;
+    OFOxmArpOp arpOp(ArpOpcode value);
+    OFOxmArpOpMasked.Builder buildArpOpMasked() throws UnsupportedOperationException;
+    OFOxmArpOpMasked arpOpMasked(ArpOpcode value, ArpOpcode mask);
+    OFOxmArpSha.Builder buildArpSha() throws UnsupportedOperationException;
+    OFOxmArpSha arpSha(MacAddress value);
+    OFOxmArpShaMasked.Builder buildArpShaMasked() throws UnsupportedOperationException;
+    OFOxmArpShaMasked arpShaMasked(MacAddress value, MacAddress mask);
+    OFOxmArpSpa.Builder buildArpSpa() throws UnsupportedOperationException;
+    OFOxmArpSpa arpSpa(IPv4Address value);
+    OFOxmArpSpaMasked.Builder buildArpSpaMasked() throws UnsupportedOperationException;
+    OFOxmArpSpaMasked arpSpaMasked(IPv4Address value, IPv4Address mask);
+    OFOxmArpTha.Builder buildArpTha() throws UnsupportedOperationException;
+    OFOxmArpTha arpTha(MacAddress value);
+    OFOxmArpThaMasked.Builder buildArpThaMasked() throws UnsupportedOperationException;
+    OFOxmArpThaMasked arpThaMasked(MacAddress value, MacAddress mask);
+    OFOxmArpTpa.Builder buildArpTpa() throws UnsupportedOperationException;
+    OFOxmArpTpa arpTpa(IPv4Address value);
+    OFOxmArpTpaMasked.Builder buildArpTpaMasked() throws UnsupportedOperationException;
+    OFOxmArpTpaMasked arpTpaMasked(IPv4Address value, IPv4Address mask);
+    OFOxmBsnEgrPortGroupId.Builder buildBsnEgrPortGroupId() throws UnsupportedOperationException;
+    OFOxmBsnEgrPortGroupId bsnEgrPortGroupId(ClassId value);
+    OFOxmBsnEgrPortGroupIdMasked.Builder buildBsnEgrPortGroupIdMasked() throws UnsupportedOperationException;
+    OFOxmBsnEgrPortGroupIdMasked bsnEgrPortGroupIdMasked(ClassId value, ClassId mask);
+    OFOxmBsnGlobalVrfAllowed.Builder buildBsnGlobalVrfAllowed() throws UnsupportedOperationException;
+    OFOxmBsnGlobalVrfAllowed bsnGlobalVrfAllowed(OFBooleanValue value);
+    OFOxmBsnGlobalVrfAllowedMasked.Builder buildBsnGlobalVrfAllowedMasked() throws UnsupportedOperationException;
+    OFOxmBsnGlobalVrfAllowedMasked bsnGlobalVrfAllowedMasked(OFBooleanValue value, OFBooleanValue mask);
+    OFOxmBsnInPorts128.Builder buildBsnInPorts128() throws UnsupportedOperationException;
+    OFOxmBsnInPorts128 bsnInPorts128(OFBitMask128 value);
+    OFOxmBsnInPorts128Masked.Builder buildBsnInPorts128Masked() throws UnsupportedOperationException;
+    OFOxmBsnInPorts128Masked bsnInPorts128Masked(OFBitMask128 value, OFBitMask128 mask);
+    OFOxmBsnL3DstClassId.Builder buildBsnL3DstClassId() throws UnsupportedOperationException;
+    OFOxmBsnL3DstClassId bsnL3DstClassId(ClassId value);
+    OFOxmBsnL3DstClassIdMasked.Builder buildBsnL3DstClassIdMasked() throws UnsupportedOperationException;
+    OFOxmBsnL3DstClassIdMasked bsnL3DstClassIdMasked(ClassId value, ClassId mask);
+    OFOxmBsnL3InterfaceClassId.Builder buildBsnL3InterfaceClassId() throws UnsupportedOperationException;
+    OFOxmBsnL3InterfaceClassId bsnL3InterfaceClassId(ClassId value);
+    OFOxmBsnL3InterfaceClassIdMasked.Builder buildBsnL3InterfaceClassIdMasked() throws UnsupportedOperationException;
+    OFOxmBsnL3InterfaceClassIdMasked bsnL3InterfaceClassIdMasked(ClassId value, ClassId mask);
+    OFOxmBsnL3SrcClassId.Builder buildBsnL3SrcClassId() throws UnsupportedOperationException;
+    OFOxmBsnL3SrcClassId bsnL3SrcClassId(ClassId value);
+    OFOxmBsnL3SrcClassIdMasked.Builder buildBsnL3SrcClassIdMasked() throws UnsupportedOperationException;
+    OFOxmBsnL3SrcClassIdMasked bsnL3SrcClassIdMasked(ClassId value, ClassId mask);
+    OFOxmBsnLagId.Builder buildBsnLagId() throws UnsupportedOperationException;
+    OFOxmBsnLagId bsnLagId(LagId value);
+    OFOxmBsnLagIdMasked.Builder buildBsnLagIdMasked() throws UnsupportedOperationException;
+    OFOxmBsnLagIdMasked bsnLagIdMasked(LagId value, LagId mask);
+    OFOxmBsnTcpFlags.Builder buildBsnTcpFlags() throws UnsupportedOperationException;
+    OFOxmBsnTcpFlags bsnTcpFlags(U16 value);
+    OFOxmBsnTcpFlagsMasked.Builder buildBsnTcpFlagsMasked() throws UnsupportedOperationException;
+    OFOxmBsnTcpFlagsMasked bsnTcpFlagsMasked(U16 value, U16 mask);
+    OFOxmBsnUdf0.Builder buildBsnUdf0() throws UnsupportedOperationException;
+    OFOxmBsnUdf0 bsnUdf0(UDF value);
+    OFOxmBsnUdf0Masked.Builder buildBsnUdf0Masked() throws UnsupportedOperationException;
+    OFOxmBsnUdf0Masked bsnUdf0Masked(UDF value, UDF mask);
+    OFOxmBsnUdf1.Builder buildBsnUdf1() throws UnsupportedOperationException;
+    OFOxmBsnUdf1 bsnUdf1(UDF value);
+    OFOxmBsnUdf1Masked.Builder buildBsnUdf1Masked() throws UnsupportedOperationException;
+    OFOxmBsnUdf1Masked bsnUdf1Masked(UDF value, UDF mask);
+    OFOxmBsnUdf2.Builder buildBsnUdf2() throws UnsupportedOperationException;
+    OFOxmBsnUdf2 bsnUdf2(UDF value);
+    OFOxmBsnUdf2Masked.Builder buildBsnUdf2Masked() throws UnsupportedOperationException;
+    OFOxmBsnUdf2Masked bsnUdf2Masked(UDF value, UDF mask);
+    OFOxmBsnUdf3.Builder buildBsnUdf3() throws UnsupportedOperationException;
+    OFOxmBsnUdf3 bsnUdf3(UDF value);
+    OFOxmBsnUdf3Masked.Builder buildBsnUdf3Masked() throws UnsupportedOperationException;
+    OFOxmBsnUdf3Masked bsnUdf3Masked(UDF value, UDF mask);
+    OFOxmBsnUdf4.Builder buildBsnUdf4() throws UnsupportedOperationException;
+    OFOxmBsnUdf4 bsnUdf4(UDF value);
+    OFOxmBsnUdf4Masked.Builder buildBsnUdf4Masked() throws UnsupportedOperationException;
+    OFOxmBsnUdf4Masked bsnUdf4Masked(UDF value, UDF mask);
+    OFOxmBsnUdf5.Builder buildBsnUdf5() throws UnsupportedOperationException;
+    OFOxmBsnUdf5 bsnUdf5(UDF value);
+    OFOxmBsnUdf5Masked.Builder buildBsnUdf5Masked() throws UnsupportedOperationException;
+    OFOxmBsnUdf5Masked bsnUdf5Masked(UDF value, UDF mask);
+    OFOxmBsnUdf6.Builder buildBsnUdf6() throws UnsupportedOperationException;
+    OFOxmBsnUdf6 bsnUdf6(UDF value);
+    OFOxmBsnUdf6Masked.Builder buildBsnUdf6Masked() throws UnsupportedOperationException;
+    OFOxmBsnUdf6Masked bsnUdf6Masked(UDF value, UDF mask);
+    OFOxmBsnUdf7.Builder buildBsnUdf7() throws UnsupportedOperationException;
+    OFOxmBsnUdf7 bsnUdf7(UDF value);
+    OFOxmBsnUdf7Masked.Builder buildBsnUdf7Masked() throws UnsupportedOperationException;
+    OFOxmBsnUdf7Masked bsnUdf7Masked(UDF value, UDF mask);
+    OFOxmBsnVlanXlatePortGroupId.Builder buildBsnVlanXlatePortGroupId() throws UnsupportedOperationException;
+    OFOxmBsnVlanXlatePortGroupId bsnVlanXlatePortGroupId(ClassId value);
+    OFOxmBsnVlanXlatePortGroupIdMasked.Builder buildBsnVlanXlatePortGroupIdMasked() throws UnsupportedOperationException;
+    OFOxmBsnVlanXlatePortGroupIdMasked bsnVlanXlatePortGroupIdMasked(ClassId value, ClassId mask);
+    OFOxmBsnVrf.Builder buildBsnVrf() throws UnsupportedOperationException;
+    OFOxmBsnVrf bsnVrf(VRF value);
+    OFOxmBsnVrfMasked.Builder buildBsnVrfMasked() throws UnsupportedOperationException;
+    OFOxmBsnVrfMasked bsnVrfMasked(VRF value, VRF mask);
+    OFOxmEthDst.Builder buildEthDst() throws UnsupportedOperationException;
+    OFOxmEthDst ethDst(MacAddress value);
+    OFOxmEthDstMasked.Builder buildEthDstMasked() throws UnsupportedOperationException;
+    OFOxmEthDstMasked ethDstMasked(MacAddress value, MacAddress mask);
+    OFOxmEthSrc.Builder buildEthSrc() throws UnsupportedOperationException;
+    OFOxmEthSrc ethSrc(MacAddress value);
+    OFOxmEthSrcMasked.Builder buildEthSrcMasked() throws UnsupportedOperationException;
+    OFOxmEthSrcMasked ethSrcMasked(MacAddress value, MacAddress mask);
+    OFOxmEthType.Builder buildEthType() throws UnsupportedOperationException;
+    OFOxmEthType ethType(EthType value);
+    OFOxmEthTypeMasked.Builder buildEthTypeMasked() throws UnsupportedOperationException;
+    OFOxmEthTypeMasked ethTypeMasked(EthType value, EthType mask);
+    OFOxmIcmpv4Code.Builder buildIcmpv4Code() throws UnsupportedOperationException;
+    OFOxmIcmpv4Code icmpv4Code(ICMPv4Code value);
+    OFOxmIcmpv4CodeMasked.Builder buildIcmpv4CodeMasked() throws UnsupportedOperationException;
+    OFOxmIcmpv4CodeMasked icmpv4CodeMasked(ICMPv4Code value, ICMPv4Code mask);
+    OFOxmIcmpv4Type.Builder buildIcmpv4Type() throws UnsupportedOperationException;
+    OFOxmIcmpv4Type icmpv4Type(ICMPv4Type value);
+    OFOxmIcmpv4TypeMasked.Builder buildIcmpv4TypeMasked() throws UnsupportedOperationException;
+    OFOxmIcmpv4TypeMasked icmpv4TypeMasked(ICMPv4Type value, ICMPv4Type mask);
+    OFOxmIcmpv6Code.Builder buildIcmpv6Code() throws UnsupportedOperationException;
+    OFOxmIcmpv6Code icmpv6Code(U8 value);
+    OFOxmIcmpv6CodeMasked.Builder buildIcmpv6CodeMasked() throws UnsupportedOperationException;
+    OFOxmIcmpv6CodeMasked icmpv6CodeMasked(U8 value, U8 mask);
+    OFOxmIcmpv6Type.Builder buildIcmpv6Type() throws UnsupportedOperationException;
+    OFOxmIcmpv6Type icmpv6Type(U8 value);
+    OFOxmIcmpv6TypeMasked.Builder buildIcmpv6TypeMasked() throws UnsupportedOperationException;
+    OFOxmIcmpv6TypeMasked icmpv6TypeMasked(U8 value, U8 mask);
+    OFOxmInPhyPort.Builder buildInPhyPort() throws UnsupportedOperationException;
+    OFOxmInPhyPort inPhyPort(OFPort value);
+    OFOxmInPhyPortMasked.Builder buildInPhyPortMasked() throws UnsupportedOperationException;
+    OFOxmInPhyPortMasked inPhyPortMasked(OFPort value, OFPort mask);
+    OFOxmInPort.Builder buildInPort() throws UnsupportedOperationException;
+    OFOxmInPort inPort(OFPort value);
+    OFOxmInPortMasked.Builder buildInPortMasked() throws UnsupportedOperationException;
+    OFOxmInPortMasked inPortMasked(OFPort value, OFPort mask);
+    OFOxmIpDscp.Builder buildIpDscp() throws UnsupportedOperationException;
+    OFOxmIpDscp ipDscp(IpDscp value);
+    OFOxmIpDscpMasked.Builder buildIpDscpMasked() throws UnsupportedOperationException;
+    OFOxmIpDscpMasked ipDscpMasked(IpDscp value, IpDscp mask);
+    OFOxmIpEcn.Builder buildIpEcn() throws UnsupportedOperationException;
+    OFOxmIpEcn ipEcn(IpEcn value);
+    OFOxmIpEcnMasked.Builder buildIpEcnMasked() throws UnsupportedOperationException;
+    OFOxmIpEcnMasked ipEcnMasked(IpEcn value, IpEcn mask);
+    OFOxmIpProto.Builder buildIpProto() throws UnsupportedOperationException;
+    OFOxmIpProto ipProto(IpProtocol value);
+    OFOxmIpProtoMasked.Builder buildIpProtoMasked() throws UnsupportedOperationException;
+    OFOxmIpProtoMasked ipProtoMasked(IpProtocol value, IpProtocol mask);
+    OFOxmIpv4Dst.Builder buildIpv4Dst() throws UnsupportedOperationException;
+    OFOxmIpv4Dst ipv4Dst(IPv4Address value);
+    OFOxmIpv4DstMasked.Builder buildIpv4DstMasked() throws UnsupportedOperationException;
+    OFOxmIpv4DstMasked ipv4DstMasked(IPv4Address value, IPv4Address mask);
+    OFOxmIpv4Src.Builder buildIpv4Src() throws UnsupportedOperationException;
+    OFOxmIpv4Src ipv4Src(IPv4Address value);
+    OFOxmIpv4SrcMasked.Builder buildIpv4SrcMasked() throws UnsupportedOperationException;
+    OFOxmIpv4SrcMasked ipv4SrcMasked(IPv4Address value, IPv4Address mask);
+    OFOxmIpv6Dst.Builder buildIpv6Dst() throws UnsupportedOperationException;
+    OFOxmIpv6Dst ipv6Dst(IPv6Address value);
+    OFOxmIpv6DstMasked.Builder buildIpv6DstMasked() throws UnsupportedOperationException;
+    OFOxmIpv6DstMasked ipv6DstMasked(IPv6Address value, IPv6Address mask);
+    OFOxmIpv6Flabel.Builder buildIpv6Flabel() throws UnsupportedOperationException;
+    OFOxmIpv6Flabel ipv6Flabel(IPv6FlowLabel value);
+    OFOxmIpv6FlabelMasked.Builder buildIpv6FlabelMasked() throws UnsupportedOperationException;
+    OFOxmIpv6FlabelMasked ipv6FlabelMasked(IPv6FlowLabel value, IPv6FlowLabel mask);
+    OFOxmIpv6NdSll.Builder buildIpv6NdSll() throws UnsupportedOperationException;
+    OFOxmIpv6NdSll ipv6NdSll(MacAddress value);
+    OFOxmIpv6NdSllMasked.Builder buildIpv6NdSllMasked() throws UnsupportedOperationException;
+    OFOxmIpv6NdSllMasked ipv6NdSllMasked(MacAddress value, MacAddress mask);
+    OFOxmIpv6NdTarget.Builder buildIpv6NdTarget() throws UnsupportedOperationException;
+    OFOxmIpv6NdTarget ipv6NdTarget(IPv6Address value);
+    OFOxmIpv6NdTargetMasked.Builder buildIpv6NdTargetMasked() throws UnsupportedOperationException;
+    OFOxmIpv6NdTargetMasked ipv6NdTargetMasked(IPv6Address value, IPv6Address mask);
+    OFOxmIpv6NdTll.Builder buildIpv6NdTll() throws UnsupportedOperationException;
+    OFOxmIpv6NdTll ipv6NdTll(MacAddress value);
+    OFOxmIpv6NdTllMasked.Builder buildIpv6NdTllMasked() throws UnsupportedOperationException;
+    OFOxmIpv6NdTllMasked ipv6NdTllMasked(MacAddress value, MacAddress mask);
+    OFOxmIpv6Src.Builder buildIpv6Src() throws UnsupportedOperationException;
+    OFOxmIpv6Src ipv6Src(IPv6Address value);
+    OFOxmIpv6SrcMasked.Builder buildIpv6SrcMasked() throws UnsupportedOperationException;
+    OFOxmIpv6SrcMasked ipv6SrcMasked(IPv6Address value, IPv6Address mask);
+    OFOxmMetadata.Builder buildMetadata() throws UnsupportedOperationException;
+    OFOxmMetadata metadata(OFMetadata value);
+    OFOxmMetadataMasked.Builder buildMetadataMasked() throws UnsupportedOperationException;
+    OFOxmMetadataMasked metadataMasked(OFMetadata value, OFMetadata mask);
+    OFOxmMplsLabel.Builder buildMplsLabel() throws UnsupportedOperationException;
+    OFOxmMplsLabel mplsLabel(U32 value);
+    OFOxmMplsLabelMasked.Builder buildMplsLabelMasked() throws UnsupportedOperationException;
+    OFOxmMplsLabelMasked mplsLabelMasked(U32 value, U32 mask);
+    OFOxmMplsTc.Builder buildMplsTc() throws UnsupportedOperationException;
+    OFOxmMplsTc mplsTc(U8 value);
+    OFOxmMplsTcMasked.Builder buildMplsTcMasked() throws UnsupportedOperationException;
+    OFOxmMplsTcMasked mplsTcMasked(U8 value, U8 mask);
+    OFOxmSctpDst.Builder buildSctpDst() throws UnsupportedOperationException;
+    OFOxmSctpDst sctpDst(TransportPort value);
+    OFOxmSctpDstMasked.Builder buildSctpDstMasked() throws UnsupportedOperationException;
+    OFOxmSctpDstMasked sctpDstMasked(TransportPort value, TransportPort mask);
+    OFOxmSctpSrc.Builder buildSctpSrc() throws UnsupportedOperationException;
+    OFOxmSctpSrc sctpSrc(TransportPort value);
+    OFOxmSctpSrcMasked.Builder buildSctpSrcMasked() throws UnsupportedOperationException;
+    OFOxmSctpSrcMasked sctpSrcMasked(TransportPort value, TransportPort mask);
+    OFOxmTcpDst.Builder buildTcpDst() throws UnsupportedOperationException;
+    OFOxmTcpDst tcpDst(TransportPort value);
+    OFOxmTcpDstMasked.Builder buildTcpDstMasked() throws UnsupportedOperationException;
+    OFOxmTcpDstMasked tcpDstMasked(TransportPort value, TransportPort mask);
+    OFOxmTcpSrc.Builder buildTcpSrc() throws UnsupportedOperationException;
+    OFOxmTcpSrc tcpSrc(TransportPort value);
+    OFOxmTcpSrcMasked.Builder buildTcpSrcMasked() throws UnsupportedOperationException;
+    OFOxmTcpSrcMasked tcpSrcMasked(TransportPort value, TransportPort mask);
+    OFOxmUdpDst.Builder buildUdpDst() throws UnsupportedOperationException;
+    OFOxmUdpDst udpDst(TransportPort value);
+    OFOxmUdpDstMasked.Builder buildUdpDstMasked() throws UnsupportedOperationException;
+    OFOxmUdpDstMasked udpDstMasked(TransportPort value, TransportPort mask);
+    OFOxmUdpSrc.Builder buildUdpSrc() throws UnsupportedOperationException;
+    OFOxmUdpSrc udpSrc(TransportPort value);
+    OFOxmUdpSrcMasked.Builder buildUdpSrcMasked() throws UnsupportedOperationException;
+    OFOxmUdpSrcMasked udpSrcMasked(TransportPort value, TransportPort mask);
+    OFOxmVlanPcp.Builder buildVlanPcp() throws UnsupportedOperationException;
+    OFOxmVlanPcp vlanPcp(VlanPcp value);
+    OFOxmVlanPcpMasked.Builder buildVlanPcpMasked() throws UnsupportedOperationException;
+    OFOxmVlanPcpMasked vlanPcpMasked(VlanPcp value, VlanPcp mask);
+    OFOxmVlanVid.Builder buildVlanVid() throws UnsupportedOperationException;
+    OFOxmVlanVid vlanVid(OFVlanVidMatch value);
+    OFOxmVlanVidMasked.Builder buildVlanVidMasked() throws UnsupportedOperationException;
+    OFOxmVlanVidMasked vlanVidMasked(OFVlanVidMatch value, OFVlanVidMatch mask);
+    OFOxmTunnelId.Builder buildTunnelId() throws UnsupportedOperationException;
+    OFOxmTunnelId tunnelId(U64 value);
+    OFOxmTunnelIdMasked.Builder buildTunnelIdMasked() throws UnsupportedOperationException;
+    OFOxmTunnelIdMasked tunnelIdMasked(U64 value, U64 mask);
+
+    OFMessageReader<OFOxm<?>> getReader();
+    OFVersion getVersion();
+
+    public <F extends OFValueType<F>> OFOxm<F> fromValue(F value, MatchField<F> field);
+    public <F extends OFValueType<F>> OFOxm<F> fromValueAndMask(F value, F mask, MatchField<F> field);
+    public <F extends OFValueType<F>> OFOxm<F> fromMasked(Masked<F> masked, MatchField<F> field);
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueueProp.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueueProp.java
new file mode 100644
index 0000000..d82da0a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueueProp.java
@@ -0,0 +1,40 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.queueprop;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueueProp extends OFObject {
+    int getType();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder  {
+        OFQueueProp build();
+        int getType();
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropExperimenter.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropExperimenter.java
new file mode 100644
index 0000000..50ed036
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropExperimenter.java
@@ -0,0 +1,45 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.queueprop;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueuePropExperimenter extends OFObject, OFQueueProp {
+    int getType();
+    long getExperimenter();
+    byte[] getData();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFQueueProp.Builder {
+        OFQueuePropExperimenter build();
+        int getType();
+        long getExperimenter();
+        byte[] getData();
+        Builder setData(byte[] data);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropMaxRate.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropMaxRate.java
new file mode 100644
index 0000000..44f3c24
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropMaxRate.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.queueprop;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueuePropMaxRate extends OFObject, OFQueueProp {
+    int getType();
+    int getRate();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFQueueProp.Builder {
+        OFQueuePropMaxRate build();
+        int getType();
+        int getRate();
+        Builder setRate(int rate);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropMinRate.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropMinRate.java
new file mode 100644
index 0000000..e6941f7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueuePropMinRate.java
@@ -0,0 +1,43 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.queueprop;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+public interface OFQueuePropMinRate extends OFObject, OFQueueProp {
+    int getType();
+    int getRate();
+    OFVersion getVersion();
+
+    void writeTo(ChannelBuffer channelBuffer);
+
+    Builder createBuilder();
+    public interface Builder extends OFQueueProp.Builder {
+        OFQueuePropMinRate build();
+        int getType();
+        int getRate();
+        Builder setRate(int rate);
+        OFVersion getVersion();
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueueProps.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueueProps.java
new file mode 100644
index 0000000..ba85e85
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/queueprop/OFQueueProps.java
@@ -0,0 +1,37 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_interface.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.queueprop;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+public interface OFQueueProps {
+    // Subfactories
+
+    OFQueuePropMinRate.Builder buildMinRate();
+    OFQueuePropMinRate minRate(int rate);
+    OFQueuePropMaxRate.Builder buildMaxRate() throws UnsupportedOperationException;
+    OFQueuePropMaxRate maxRate(int rate);
+
+    OFMessageReader<OFQueueProp> getReader();
+    OFVersion getVersion();
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnChecksumVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnChecksumVer10.java
new file mode 100644
index 0000000..3d3649b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnChecksumVer10.java
@@ -0,0 +1,313 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnChecksumVer10 implements OFActionBsnChecksum {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnChecksumVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 28;
+
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+
+    // OF message fields
+    private final U128 checksum;
+//
+    // Immutable default instance
+    final static OFActionBsnChecksumVer10 DEFAULT = new OFActionBsnChecksumVer10(
+        DEFAULT_CHECKSUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnChecksumVer10(U128 checksum) {
+        this.checksum = checksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionBsnChecksum.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnChecksum.Builder {
+        final OFActionBsnChecksumVer10 parentMessage;
+
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+        BuilderWithParent(OFActionBsnChecksumVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFActionBsnChecksum.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionBsnChecksum build() {
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+
+                //
+                return new OFActionBsnChecksumVer10(
+                    checksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnChecksum.Builder {
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFActionBsnChecksum.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionBsnChecksum build() {
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+
+
+            return new OFActionBsnChecksumVer10(
+                    checksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnChecksum> {
+        @Override
+        public OFActionBsnChecksum readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 28)
+                throw new OFParseError("Wrong length: Expected=28(28), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            U128 checksum = U128.read16Bytes(bb);
+
+            OFActionBsnChecksumVer10 actionBsnChecksumVer10 = new OFActionBsnChecksumVer10(
+                    checksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnChecksumVer10);
+            return actionBsnChecksumVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnChecksumVer10Funnel FUNNEL = new OFActionBsnChecksumVer10Funnel();
+    static class OFActionBsnChecksumVer10Funnel implements Funnel<OFActionBsnChecksumVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnChecksumVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 28
+            sink.putShort((short) 0x1c);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            message.checksum.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnChecksumVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnChecksumVer10 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 28
+            bb.writeShort((short) 0x1c);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            message.checksum.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnChecksumVer10(");
+        b.append("checksum=").append(checksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnChecksumVer10 other = (OFActionBsnChecksumVer10) obj;
+
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnMirrorVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnMirrorVer10.java
new file mode 100644
index 0000000..374feb9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnMirrorVer10.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnMirrorVer10 implements OFActionBsnMirror {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnMirrorVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static OFPort DEFAULT_DEST_PORT = OFPort.ANY;
+        private final static long DEFAULT_VLAN_TAG = 0x0L;
+        private final static short DEFAULT_COPY_STAGE = (short) 0x0;
+
+    // OF message fields
+    private final OFPort destPort;
+    private final long vlanTag;
+    private final short copyStage;
+//
+    // Immutable default instance
+    final static OFActionBsnMirrorVer10 DEFAULT = new OFActionBsnMirrorVer10(
+        DEFAULT_DEST_PORT, DEFAULT_VLAN_TAG, DEFAULT_COPY_STAGE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnMirrorVer10(OFPort destPort, long vlanTag, short copyStage) {
+        this.destPort = destPort;
+        this.vlanTag = vlanTag;
+        this.copyStage = copyStage;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionBsnMirror.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnMirror.Builder {
+        final OFActionBsnMirrorVer10 parentMessage;
+
+        // OF message fields
+        private boolean destPortSet;
+        private OFPort destPort;
+        private boolean vlanTagSet;
+        private long vlanTag;
+        private boolean copyStageSet;
+        private short copyStage;
+
+        BuilderWithParent(OFActionBsnMirrorVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setDestPort(OFPort destPort) {
+        this.destPort = destPort;
+        this.destPortSet = true;
+        return this;
+    }
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setVlanTag(long vlanTag) {
+        this.vlanTag = vlanTag;
+        this.vlanTagSet = true;
+        return this;
+    }
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setCopyStage(short copyStage) {
+        this.copyStage = copyStage;
+        this.copyStageSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionBsnMirror build() {
+                OFPort destPort = this.destPortSet ? this.destPort : parentMessage.destPort;
+                if(destPort == null)
+                    throw new NullPointerException("Property destPort must not be null");
+                long vlanTag = this.vlanTagSet ? this.vlanTag : parentMessage.vlanTag;
+                short copyStage = this.copyStageSet ? this.copyStage : parentMessage.copyStage;
+
+                //
+                return new OFActionBsnMirrorVer10(
+                    destPort,
+                    vlanTag,
+                    copyStage
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnMirror.Builder {
+        // OF message fields
+        private boolean destPortSet;
+        private OFPort destPort;
+        private boolean vlanTagSet;
+        private long vlanTag;
+        private boolean copyStageSet;
+        private short copyStage;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setDestPort(OFPort destPort) {
+        this.destPort = destPort;
+        this.destPortSet = true;
+        return this;
+    }
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setVlanTag(long vlanTag) {
+        this.vlanTag = vlanTag;
+        this.vlanTagSet = true;
+        return this;
+    }
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setCopyStage(short copyStage) {
+        this.copyStage = copyStage;
+        this.copyStageSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionBsnMirror build() {
+            OFPort destPort = this.destPortSet ? this.destPort : DEFAULT_DEST_PORT;
+            if(destPort == null)
+                throw new NullPointerException("Property destPort must not be null");
+            long vlanTag = this.vlanTagSet ? this.vlanTag : DEFAULT_VLAN_TAG;
+            short copyStage = this.copyStageSet ? this.copyStage : DEFAULT_COPY_STAGE;
+
+
+            return new OFActionBsnMirrorVer10(
+                    destPort,
+                    vlanTag,
+                    copyStage
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnMirror> {
+        @Override
+        public OFActionBsnMirror readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+            OFPort destPort = OFPort.read2Bytes(bb);
+            long vlanTag = U32.f(bb.readInt());
+            short copyStage = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionBsnMirrorVer10 actionBsnMirrorVer10 = new OFActionBsnMirrorVer10(
+                    destPort,
+                      vlanTag,
+                      copyStage
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnMirrorVer10);
+            return actionBsnMirrorVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnMirrorVer10Funnel FUNNEL = new OFActionBsnMirrorVer10Funnel();
+    static class OFActionBsnMirrorVer10Funnel implements Funnel<OFActionBsnMirrorVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnMirrorVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+            message.destPort.putTo(sink);
+            sink.putLong(message.vlanTag);
+            sink.putShort(message.copyStage);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnMirrorVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnMirrorVer10 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+            message.destPort.write2Bytes(bb);
+            bb.writeInt(U32.t(message.vlanTag));
+            bb.writeByte(U8.t(message.copyStage));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnMirrorVer10(");
+        b.append("destPort=").append(destPort);
+        b.append(", ");
+        b.append("vlanTag=").append(vlanTag);
+        b.append(", ");
+        b.append("copyStage=").append(copyStage);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnMirrorVer10 other = (OFActionBsnMirrorVer10) obj;
+
+        if (destPort == null) {
+            if (other.destPort != null)
+                return false;
+        } else if (!destPort.equals(other.destPort))
+            return false;
+        if( vlanTag != other.vlanTag)
+            return false;
+        if( copyStage != other.copyStage)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((destPort == null) ? 0 : destPort.hashCode());
+        result = prime *  (int) (vlanTag ^ (vlanTag >>> 32));
+        result = prime * result + copyStage;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnSetTunnelDstVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnSetTunnelDstVer10.java
new file mode 100644
index 0000000..add313c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnSetTunnelDstVer10.java
@@ -0,0 +1,306 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnSetTunnelDstVer10 implements OFActionBsnSetTunnelDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnSetTunnelDstVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_DST = 0x0L;
+
+    // OF message fields
+    private final long dst;
+//
+    // Immutable default instance
+    final static OFActionBsnSetTunnelDstVer10 DEFAULT = new OFActionBsnSetTunnelDstVer10(
+        DEFAULT_DST
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnSetTunnelDstVer10(long dst) {
+        this.dst = dst;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionBsnSetTunnelDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnSetTunnelDst.Builder {
+        final OFActionBsnSetTunnelDstVer10 parentMessage;
+
+        // OF message fields
+        private boolean dstSet;
+        private long dst;
+
+        BuilderWithParent(OFActionBsnSetTunnelDstVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFActionBsnSetTunnelDst.Builder setDst(long dst) {
+        this.dst = dst;
+        this.dstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionBsnSetTunnelDst build() {
+                long dst = this.dstSet ? this.dst : parentMessage.dst;
+
+                //
+                return new OFActionBsnSetTunnelDstVer10(
+                    dst
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnSetTunnelDst.Builder {
+        // OF message fields
+        private boolean dstSet;
+        private long dst;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFActionBsnSetTunnelDst.Builder setDst(long dst) {
+        this.dst = dst;
+        this.dstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionBsnSetTunnelDst build() {
+            long dst = this.dstSet ? this.dst : DEFAULT_DST;
+
+
+            return new OFActionBsnSetTunnelDstVer10(
+                    dst
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnSetTunnelDst> {
+        @Override
+        public OFActionBsnSetTunnelDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+            long dst = U32.f(bb.readInt());
+
+            OFActionBsnSetTunnelDstVer10 actionBsnSetTunnelDstVer10 = new OFActionBsnSetTunnelDstVer10(
+                    dst
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnSetTunnelDstVer10);
+            return actionBsnSetTunnelDstVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnSetTunnelDstVer10Funnel FUNNEL = new OFActionBsnSetTunnelDstVer10Funnel();
+    static class OFActionBsnSetTunnelDstVer10Funnel implements Funnel<OFActionBsnSetTunnelDstVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnSetTunnelDstVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+            sink.putLong(message.dst);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnSetTunnelDstVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnSetTunnelDstVer10 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+            bb.writeInt(U32.t(message.dst));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnSetTunnelDstVer10(");
+        b.append("dst=").append(dst);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnSetTunnelDstVer10 other = (OFActionBsnSetTunnelDstVer10) obj;
+
+        if( dst != other.dst)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (dst ^ (dst >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnVer10.java
new file mode 100644
index 0000000..14a7001
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnVer10.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionBsnVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFActionBsnVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionBsn> {
+        @Override
+        public OFActionBsn readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFActionBsnChecksumVer10
+                   return OFActionBsnChecksumVer10.READER.readFrom(bb);
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFActionBsnMirrorVer10
+                   return OFActionBsnMirrorVer10.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFActionBsnSetTunnelDstVer10
+                   return OFActionBsnSetTunnelDstVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionBsnVer10: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionEnqueueVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionEnqueueVer10.java
new file mode 100644
index 0000000..650f3ba
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionEnqueueVer10.java
@@ -0,0 +1,319 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionEnqueueVer10 implements OFActionEnqueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionEnqueueVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+
+    // OF message fields
+    private final OFPort port;
+    private final long queueId;
+//
+    // Immutable default instance
+    final static OFActionEnqueueVer10 DEFAULT = new OFActionEnqueueVer10(
+        DEFAULT_PORT, DEFAULT_QUEUE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionEnqueueVer10(OFPort port, long queueId) {
+        this.port = port;
+        this.queueId = queueId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.ENQUEUE;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionEnqueue.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionEnqueue.Builder {
+        final OFActionEnqueueVer10 parentMessage;
+
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean queueIdSet;
+        private long queueId;
+
+        BuilderWithParent(OFActionEnqueueVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.ENQUEUE;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionEnqueue.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFActionEnqueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionEnqueue build() {
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+
+                //
+                return new OFActionEnqueueVer10(
+                    port,
+                    queueId
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionEnqueue.Builder {
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean queueIdSet;
+        private long queueId;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.ENQUEUE;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionEnqueue.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFActionEnqueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionEnqueue build() {
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+
+
+            return new OFActionEnqueueVer10(
+                    port,
+                    queueId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionEnqueue> {
+        @Override
+        public OFActionEnqueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 11
+            short type = bb.readShort();
+            if(type != (short) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFActionType.ENQUEUE(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFPort port = OFPort.read2Bytes(bb);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            long queueId = U32.f(bb.readInt());
+
+            OFActionEnqueueVer10 actionEnqueueVer10 = new OFActionEnqueueVer10(
+                    port,
+                      queueId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionEnqueueVer10);
+            return actionEnqueueVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionEnqueueVer10Funnel FUNNEL = new OFActionEnqueueVer10Funnel();
+    static class OFActionEnqueueVer10Funnel implements Funnel<OFActionEnqueueVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionEnqueueVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 11
+            sink.putShort((short) 0xb);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            message.port.putTo(sink);
+            // skip pad (6 bytes)
+            sink.putLong(message.queueId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionEnqueueVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionEnqueueVer10 message) {
+            // fixed value property type = 11
+            bb.writeShort((short) 0xb);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            message.port.write2Bytes(bb);
+            // pad: 6 bytes
+            bb.writeZero(6);
+            bb.writeInt(U32.t(message.queueId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionEnqueueVer10(");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionEnqueueVer10 other = (OFActionEnqueueVer10) obj;
+
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionExperimenterVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionExperimenterVer10.java
new file mode 100644
index 0000000..e0b1bf2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionExperimenterVer10.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionExperimenterVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionExperimenterVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionExperimenter> {
+        @Override
+        public OFActionExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFActionBsnVer10
+                   return OFActionBsnVer10.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFActionNiciraVer10
+                   return OFActionNiciraVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFActionExperimenterVer10: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionIdsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionIdsVer10.java
new file mode 100644
index 0000000..cde6599
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionIdsVer10.java
@@ -0,0 +1,123 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+
+public class OFActionIdsVer10 implements OFActionIds {
+    public final static OFActionIdsVer10 INSTANCE = new OFActionIdsVer10();
+
+
+
+
+    public OFActionIdBsnChecksum bsnChecksum() {
+        throw new UnsupportedOperationException("OFActionIdBsnChecksum not supported in version 1.0");
+    }
+
+    public OFActionIdBsnMirror bsnMirror() {
+        throw new UnsupportedOperationException("OFActionIdBsnMirror not supported in version 1.0");
+    }
+
+    public OFActionIdBsnSetTunnelDst bsnSetTunnelDst() {
+        throw new UnsupportedOperationException("OFActionIdBsnSetTunnelDst not supported in version 1.0");
+    }
+
+    public OFActionIdCopyTtlIn copyTtlIn() {
+        throw new UnsupportedOperationException("OFActionIdCopyTtlIn not supported in version 1.0");
+    }
+
+    public OFActionIdCopyTtlOut copyTtlOut() {
+        throw new UnsupportedOperationException("OFActionIdCopyTtlOut not supported in version 1.0");
+    }
+
+    public OFActionIdDecMplsTtl decMplsTtl() {
+        throw new UnsupportedOperationException("OFActionIdDecMplsTtl not supported in version 1.0");
+    }
+
+    public OFActionIdDecNwTtl decNwTtl() {
+        throw new UnsupportedOperationException("OFActionIdDecNwTtl not supported in version 1.0");
+    }
+
+    public OFActionIdGroup group() {
+        throw new UnsupportedOperationException("OFActionIdGroup not supported in version 1.0");
+    }
+
+    public OFActionIdNiciraDecTtl niciraDecTtl() {
+        throw new UnsupportedOperationException("OFActionIdNiciraDecTtl not supported in version 1.0");
+    }
+
+    public OFActionIdOutput output() {
+        throw new UnsupportedOperationException("OFActionIdOutput not supported in version 1.0");
+    }
+
+    public OFActionIdPopMpls popMpls() {
+        throw new UnsupportedOperationException("OFActionIdPopMpls not supported in version 1.0");
+    }
+
+    public OFActionIdPopPbb popPbb() {
+        throw new UnsupportedOperationException("OFActionIdPopPbb not supported in version 1.0");
+    }
+
+    public OFActionIdPopVlan popVlan() {
+        throw new UnsupportedOperationException("OFActionIdPopVlan not supported in version 1.0");
+    }
+
+    public OFActionIdPushMpls pushMpls() {
+        throw new UnsupportedOperationException("OFActionIdPushMpls not supported in version 1.0");
+    }
+
+    public OFActionIdPushPbb pushPbb() {
+        throw new UnsupportedOperationException("OFActionIdPushPbb not supported in version 1.0");
+    }
+
+    public OFActionIdPushVlan pushVlan() {
+        throw new UnsupportedOperationException("OFActionIdPushVlan not supported in version 1.0");
+    }
+
+    public OFActionIdSetField setField() {
+        throw new UnsupportedOperationException("OFActionIdSetField not supported in version 1.0");
+    }
+
+    public OFActionIdSetMplsTtl setMplsTtl() {
+        throw new UnsupportedOperationException("OFActionIdSetMplsTtl not supported in version 1.0");
+    }
+
+    public OFActionIdSetNwTtl setNwTtl() {
+        throw new UnsupportedOperationException("OFActionIdSetNwTtl not supported in version 1.0");
+    }
+
+    public OFActionIdSetQueue setQueue() {
+        throw new UnsupportedOperationException("OFActionIdSetQueue not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFActionId> getReader() {
+        throw new UnsupportedOperationException("Reader<OFActionId> not supported in version 1.0");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionNiciraDecTtlVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionNiciraDecTtlVer10.java
new file mode 100644
index 0000000..c72dcc6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionNiciraDecTtlVer10.java
@@ -0,0 +1,192 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionNiciraDecTtlVer10 implements OFActionNiciraDecTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionNiciraDecTtlVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionNiciraDecTtlVer10 DEFAULT = new OFActionNiciraDecTtlVer10(
+
+    );
+
+    final static OFActionNiciraDecTtlVer10 INSTANCE = new OFActionNiciraDecTtlVer10();
+    // private empty constructor - use shared instance!
+    private OFActionNiciraDecTtlVer10() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public int getSubtype() {
+        return 0x12;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionNiciraDecTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionNiciraDecTtlVer10 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionNiciraDecTtl> {
+        @Override
+        public OFActionNiciraDecTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            // fixed value property subtype == 0x12
+            short subtype = bb.readShort();
+            if(subtype != (short) 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12(0x12), got="+subtype);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionNiciraDecTtlVer10Funnel FUNNEL = new OFActionNiciraDecTtlVer10Funnel();
+    static class OFActionNiciraDecTtlVer10Funnel implements Funnel<OFActionNiciraDecTtlVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionNiciraDecTtlVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x2320L
+            sink.putInt(0x2320);
+            // fixed value property subtype = 0x12
+            sink.putShort((short) 0x12);
+            // skip pad (2 bytes)
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionNiciraDecTtlVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionNiciraDecTtlVer10 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x2320L
+            bb.writeInt(0x2320);
+            // fixed value property subtype = 0x12
+            bb.writeShort((short) 0x12);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionNiciraDecTtlVer10(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionNiciraVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionNiciraVer10.java
new file mode 100644
index 0000000..2023afa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionNiciraVer10.java
@@ -0,0 +1,64 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionNiciraVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFActionNiciraVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionNicira> {
+        @Override
+        public OFActionNicira readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            short subtype = bb.readShort();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case (short) 0x12:
+                   // discriminator value 0x12=0x12 for class OFActionNiciraDecTtlVer10
+                   return OFActionNiciraDecTtlVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionNiciraVer10: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionOutputVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionOutputVer10.java
new file mode 100644
index 0000000..e224bc8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionOutputVer10.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionOutputVer10 implements OFActionOutput {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionOutputVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static int DEFAULT_MAX_LEN = 0x0;
+
+    // OF message fields
+    private final OFPort port;
+    private final int maxLen;
+//
+    // Immutable default instance
+    final static OFActionOutputVer10 DEFAULT = new OFActionOutputVer10(
+        DEFAULT_PORT, DEFAULT_MAX_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionOutputVer10(OFPort port, int maxLen) {
+        this.port = port;
+        this.maxLen = maxLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionOutput.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionOutput.Builder {
+        final OFActionOutputVer10 parentMessage;
+
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean maxLenSet;
+        private int maxLen;
+
+        BuilderWithParent(OFActionOutputVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionOutput.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFActionOutput.Builder setMaxLen(int maxLen) {
+        this.maxLen = maxLen;
+        this.maxLenSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionOutput build() {
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                int maxLen = this.maxLenSet ? this.maxLen : parentMessage.maxLen;
+
+                //
+                return new OFActionOutputVer10(
+                    port,
+                    maxLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionOutput.Builder {
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean maxLenSet;
+        private int maxLen;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionOutput.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFActionOutput.Builder setMaxLen(int maxLen) {
+        this.maxLen = maxLen;
+        this.maxLenSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionOutput build() {
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            int maxLen = this.maxLenSet ? this.maxLen : DEFAULT_MAX_LEN;
+
+
+            return new OFActionOutputVer10(
+                    port,
+                    maxLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionOutput> {
+        @Override
+        public OFActionOutput readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFActionType.OUTPUT(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFPort port = OFPort.read2Bytes(bb);
+            int maxLen = U16.f(bb.readShort());
+
+            OFActionOutputVer10 actionOutputVer10 = new OFActionOutputVer10(
+                    port,
+                      maxLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionOutputVer10);
+            return actionOutputVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionOutputVer10Funnel FUNNEL = new OFActionOutputVer10Funnel();
+    static class OFActionOutputVer10Funnel implements Funnel<OFActionOutputVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionOutputVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.port.putTo(sink);
+            sink.putInt(message.maxLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionOutputVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionOutputVer10 message) {
+            // fixed value property type = 0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.port.write2Bytes(bb);
+            bb.writeShort(U16.t(message.maxLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionOutputVer10(");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("maxLen=").append(maxLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionOutputVer10 other = (OFActionOutputVer10) obj;
+
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if( maxLen != other.maxLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + maxLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetDlDstVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetDlDstVer10.java
new file mode 100644
index 0000000..348da90
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetDlDstVer10.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetDlDstVer10 implements OFActionSetDlDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetDlDstVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_DL_ADDR = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress dlAddr;
+//
+    // Immutable default instance
+    final static OFActionSetDlDstVer10 DEFAULT = new OFActionSetDlDstVer10(
+        DEFAULT_DL_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetDlDstVer10(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_DST;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetDlDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetDlDst.Builder {
+        final OFActionSetDlDstVer10 parentMessage;
+
+        // OF message fields
+        private boolean dlAddrSet;
+        private MacAddress dlAddr;
+
+        BuilderWithParent(OFActionSetDlDstVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_DST;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFActionSetDlDst.Builder setDlAddr(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+        this.dlAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetDlDst build() {
+                MacAddress dlAddr = this.dlAddrSet ? this.dlAddr : parentMessage.dlAddr;
+                if(dlAddr == null)
+                    throw new NullPointerException("Property dlAddr must not be null");
+
+                //
+                return new OFActionSetDlDstVer10(
+                    dlAddr
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetDlDst.Builder {
+        // OF message fields
+        private boolean dlAddrSet;
+        private MacAddress dlAddr;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_DST;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFActionSetDlDst.Builder setDlAddr(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+        this.dlAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetDlDst build() {
+            MacAddress dlAddr = this.dlAddrSet ? this.dlAddr : DEFAULT_DL_ADDR;
+            if(dlAddr == null)
+                throw new NullPointerException("Property dlAddr must not be null");
+
+
+            return new OFActionSetDlDstVer10(
+                    dlAddr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetDlDst> {
+        @Override
+        public OFActionSetDlDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 5
+            short type = bb.readShort();
+            if(type != (short) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_DL_DST(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            MacAddress dlAddr = MacAddress.read6Bytes(bb);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFActionSetDlDstVer10 actionSetDlDstVer10 = new OFActionSetDlDstVer10(
+                    dlAddr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetDlDstVer10);
+            return actionSetDlDstVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetDlDstVer10Funnel FUNNEL = new OFActionSetDlDstVer10Funnel();
+    static class OFActionSetDlDstVer10Funnel implements Funnel<OFActionSetDlDstVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetDlDstVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 5
+            sink.putShort((short) 0x5);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            message.dlAddr.putTo(sink);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetDlDstVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetDlDstVer10 message) {
+            // fixed value property type = 5
+            bb.writeShort((short) 0x5);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            message.dlAddr.write6Bytes(bb);
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetDlDstVer10(");
+        b.append("dlAddr=").append(dlAddr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetDlDstVer10 other = (OFActionSetDlDstVer10) obj;
+
+        if (dlAddr == null) {
+            if (other.dlAddr != null)
+                return false;
+        } else if (!dlAddr.equals(other.dlAddr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((dlAddr == null) ? 0 : dlAddr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetDlSrcVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetDlSrcVer10.java
new file mode 100644
index 0000000..cc88013
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetDlSrcVer10.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetDlSrcVer10 implements OFActionSetDlSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetDlSrcVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_DL_ADDR = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress dlAddr;
+//
+    // Immutable default instance
+    final static OFActionSetDlSrcVer10 DEFAULT = new OFActionSetDlSrcVer10(
+        DEFAULT_DL_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetDlSrcVer10(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_SRC;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetDlSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetDlSrc.Builder {
+        final OFActionSetDlSrcVer10 parentMessage;
+
+        // OF message fields
+        private boolean dlAddrSet;
+        private MacAddress dlAddr;
+
+        BuilderWithParent(OFActionSetDlSrcVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_SRC;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFActionSetDlSrc.Builder setDlAddr(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+        this.dlAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetDlSrc build() {
+                MacAddress dlAddr = this.dlAddrSet ? this.dlAddr : parentMessage.dlAddr;
+                if(dlAddr == null)
+                    throw new NullPointerException("Property dlAddr must not be null");
+
+                //
+                return new OFActionSetDlSrcVer10(
+                    dlAddr
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetDlSrc.Builder {
+        // OF message fields
+        private boolean dlAddrSet;
+        private MacAddress dlAddr;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_SRC;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFActionSetDlSrc.Builder setDlAddr(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+        this.dlAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetDlSrc build() {
+            MacAddress dlAddr = this.dlAddrSet ? this.dlAddr : DEFAULT_DL_ADDR;
+            if(dlAddr == null)
+                throw new NullPointerException("Property dlAddr must not be null");
+
+
+            return new OFActionSetDlSrcVer10(
+                    dlAddr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetDlSrc> {
+        @Override
+        public OFActionSetDlSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 4
+            short type = bb.readShort();
+            if(type != (short) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_DL_SRC(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            MacAddress dlAddr = MacAddress.read6Bytes(bb);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFActionSetDlSrcVer10 actionSetDlSrcVer10 = new OFActionSetDlSrcVer10(
+                    dlAddr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetDlSrcVer10);
+            return actionSetDlSrcVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetDlSrcVer10Funnel FUNNEL = new OFActionSetDlSrcVer10Funnel();
+    static class OFActionSetDlSrcVer10Funnel implements Funnel<OFActionSetDlSrcVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetDlSrcVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 4
+            sink.putShort((short) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            message.dlAddr.putTo(sink);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetDlSrcVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetDlSrcVer10 message) {
+            // fixed value property type = 4
+            bb.writeShort((short) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            message.dlAddr.write6Bytes(bb);
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetDlSrcVer10(");
+        b.append("dlAddr=").append(dlAddr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetDlSrcVer10 other = (OFActionSetDlSrcVer10) obj;
+
+        if (dlAddr == null) {
+            if (other.dlAddr != null)
+                return false;
+        } else if (!dlAddr.equals(other.dlAddr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((dlAddr == null) ? 0 : dlAddr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwDstVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwDstVer10.java
new file mode 100644
index 0000000..f7a4d27
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwDstVer10.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwDstVer10 implements OFActionSetNwDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwDstVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_NW_ADDR = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address nwAddr;
+//
+    // Immutable default instance
+    final static OFActionSetNwDstVer10 DEFAULT = new OFActionSetNwDstVer10(
+        DEFAULT_NW_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwDstVer10(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_DST;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetNwDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwDst.Builder {
+        final OFActionSetNwDstVer10 parentMessage;
+
+        // OF message fields
+        private boolean nwAddrSet;
+        private IPv4Address nwAddr;
+
+        BuilderWithParent(OFActionSetNwDstVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_DST;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFActionSetNwDst.Builder setNwAddr(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+        this.nwAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetNwDst build() {
+                IPv4Address nwAddr = this.nwAddrSet ? this.nwAddr : parentMessage.nwAddr;
+                if(nwAddr == null)
+                    throw new NullPointerException("Property nwAddr must not be null");
+
+                //
+                return new OFActionSetNwDstVer10(
+                    nwAddr
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwDst.Builder {
+        // OF message fields
+        private boolean nwAddrSet;
+        private IPv4Address nwAddr;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_DST;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFActionSetNwDst.Builder setNwAddr(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+        this.nwAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetNwDst build() {
+            IPv4Address nwAddr = this.nwAddrSet ? this.nwAddr : DEFAULT_NW_ADDR;
+            if(nwAddr == null)
+                throw new NullPointerException("Property nwAddr must not be null");
+
+
+            return new OFActionSetNwDstVer10(
+                    nwAddr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwDst> {
+        @Override
+        public OFActionSetNwDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 7
+            short type = bb.readShort();
+            if(type != (short) 0x7)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_DST(7), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            IPv4Address nwAddr = IPv4Address.read4Bytes(bb);
+
+            OFActionSetNwDstVer10 actionSetNwDstVer10 = new OFActionSetNwDstVer10(
+                    nwAddr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwDstVer10);
+            return actionSetNwDstVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwDstVer10Funnel FUNNEL = new OFActionSetNwDstVer10Funnel();
+    static class OFActionSetNwDstVer10Funnel implements Funnel<OFActionSetNwDstVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwDstVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 7
+            sink.putShort((short) 0x7);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.nwAddr.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwDstVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwDstVer10 message) {
+            // fixed value property type = 7
+            bb.writeShort((short) 0x7);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.nwAddr.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwDstVer10(");
+        b.append("nwAddr=").append(nwAddr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwDstVer10 other = (OFActionSetNwDstVer10) obj;
+
+        if (nwAddr == null) {
+            if (other.nwAddr != null)
+                return false;
+        } else if (!nwAddr.equals(other.nwAddr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((nwAddr == null) ? 0 : nwAddr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwSrcVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwSrcVer10.java
new file mode 100644
index 0000000..4d30837
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwSrcVer10.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwSrcVer10 implements OFActionSetNwSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwSrcVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_NW_ADDR = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address nwAddr;
+//
+    // Immutable default instance
+    final static OFActionSetNwSrcVer10 DEFAULT = new OFActionSetNwSrcVer10(
+        DEFAULT_NW_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwSrcVer10(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_SRC;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetNwSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwSrc.Builder {
+        final OFActionSetNwSrcVer10 parentMessage;
+
+        // OF message fields
+        private boolean nwAddrSet;
+        private IPv4Address nwAddr;
+
+        BuilderWithParent(OFActionSetNwSrcVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_SRC;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFActionSetNwSrc.Builder setNwAddr(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+        this.nwAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetNwSrc build() {
+                IPv4Address nwAddr = this.nwAddrSet ? this.nwAddr : parentMessage.nwAddr;
+                if(nwAddr == null)
+                    throw new NullPointerException("Property nwAddr must not be null");
+
+                //
+                return new OFActionSetNwSrcVer10(
+                    nwAddr
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwSrc.Builder {
+        // OF message fields
+        private boolean nwAddrSet;
+        private IPv4Address nwAddr;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_SRC;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFActionSetNwSrc.Builder setNwAddr(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+        this.nwAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetNwSrc build() {
+            IPv4Address nwAddr = this.nwAddrSet ? this.nwAddr : DEFAULT_NW_ADDR;
+            if(nwAddr == null)
+                throw new NullPointerException("Property nwAddr must not be null");
+
+
+            return new OFActionSetNwSrcVer10(
+                    nwAddr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwSrc> {
+        @Override
+        public OFActionSetNwSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 6
+            short type = bb.readShort();
+            if(type != (short) 0x6)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_SRC(6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            IPv4Address nwAddr = IPv4Address.read4Bytes(bb);
+
+            OFActionSetNwSrcVer10 actionSetNwSrcVer10 = new OFActionSetNwSrcVer10(
+                    nwAddr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwSrcVer10);
+            return actionSetNwSrcVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwSrcVer10Funnel FUNNEL = new OFActionSetNwSrcVer10Funnel();
+    static class OFActionSetNwSrcVer10Funnel implements Funnel<OFActionSetNwSrcVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwSrcVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 6
+            sink.putShort((short) 0x6);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.nwAddr.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwSrcVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwSrcVer10 message) {
+            // fixed value property type = 6
+            bb.writeShort((short) 0x6);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.nwAddr.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwSrcVer10(");
+        b.append("nwAddr=").append(nwAddr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwSrcVer10 other = (OFActionSetNwSrcVer10) obj;
+
+        if (nwAddr == null) {
+            if (other.nwAddr != null)
+                return false;
+        } else if (!nwAddr.equals(other.nwAddr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((nwAddr == null) ? 0 : nwAddr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwTosVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwTosVer10.java
new file mode 100644
index 0000000..43493bb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetNwTosVer10.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwTosVer10 implements OFActionSetNwTos {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwTosVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_NW_TOS = (short) 0x0;
+
+    // OF message fields
+    private final short nwTos;
+//
+    // Immutable default instance
+    final static OFActionSetNwTosVer10 DEFAULT = new OFActionSetNwTosVer10(
+        DEFAULT_NW_TOS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwTosVer10(short nwTos) {
+        this.nwTos = nwTos;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TOS;
+    }
+
+    @Override
+    public short getNwTos() {
+        return nwTos;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetNwTos.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwTos.Builder {
+        final OFActionSetNwTosVer10 parentMessage;
+
+        // OF message fields
+        private boolean nwTosSet;
+        private short nwTos;
+
+        BuilderWithParent(OFActionSetNwTosVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TOS;
+    }
+
+    @Override
+    public short getNwTos() {
+        return nwTos;
+    }
+
+    @Override
+    public OFActionSetNwTos.Builder setNwTos(short nwTos) {
+        this.nwTos = nwTos;
+        this.nwTosSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetNwTos build() {
+                short nwTos = this.nwTosSet ? this.nwTos : parentMessage.nwTos;
+
+                //
+                return new OFActionSetNwTosVer10(
+                    nwTos
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwTos.Builder {
+        // OF message fields
+        private boolean nwTosSet;
+        private short nwTos;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TOS;
+    }
+
+    @Override
+    public short getNwTos() {
+        return nwTos;
+    }
+
+    @Override
+    public OFActionSetNwTos.Builder setNwTos(short nwTos) {
+        this.nwTos = nwTos;
+        this.nwTosSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetNwTos build() {
+            short nwTos = this.nwTosSet ? this.nwTos : DEFAULT_NW_TOS;
+
+
+            return new OFActionSetNwTosVer10(
+                    nwTos
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwTos> {
+        @Override
+        public OFActionSetNwTos readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 8
+            short type = bb.readShort();
+            if(type != (short) 0x8)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_TOS(8), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short nwTos = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetNwTosVer10 actionSetNwTosVer10 = new OFActionSetNwTosVer10(
+                    nwTos
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwTosVer10);
+            return actionSetNwTosVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwTosVer10Funnel FUNNEL = new OFActionSetNwTosVer10Funnel();
+    static class OFActionSetNwTosVer10Funnel implements Funnel<OFActionSetNwTosVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwTosVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 8
+            sink.putShort((short) 0x8);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.nwTos);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwTosVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwTosVer10 message) {
+            // fixed value property type = 8
+            bb.writeShort((short) 0x8);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.nwTos));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwTosVer10(");
+        b.append("nwTos=").append(nwTos);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwTosVer10 other = (OFActionSetNwTosVer10) obj;
+
+        if( nwTos != other.nwTos)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + nwTos;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetTpDstVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetTpDstVer10.java
new file mode 100644
index 0000000..822c484
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetTpDstVer10.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetTpDstVer10 implements OFActionSetTpDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetTpDstVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_TP_PORT = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort tpPort;
+//
+    // Immutable default instance
+    final static OFActionSetTpDstVer10 DEFAULT = new OFActionSetTpDstVer10(
+        DEFAULT_TP_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetTpDstVer10(TransportPort tpPort) {
+        this.tpPort = tpPort;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_DST;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetTpDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetTpDst.Builder {
+        final OFActionSetTpDstVer10 parentMessage;
+
+        // OF message fields
+        private boolean tpPortSet;
+        private TransportPort tpPort;
+
+        BuilderWithParent(OFActionSetTpDstVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_DST;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFActionSetTpDst.Builder setTpPort(TransportPort tpPort) {
+        this.tpPort = tpPort;
+        this.tpPortSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetTpDst build() {
+                TransportPort tpPort = this.tpPortSet ? this.tpPort : parentMessage.tpPort;
+                if(tpPort == null)
+                    throw new NullPointerException("Property tpPort must not be null");
+
+                //
+                return new OFActionSetTpDstVer10(
+                    tpPort
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetTpDst.Builder {
+        // OF message fields
+        private boolean tpPortSet;
+        private TransportPort tpPort;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_DST;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFActionSetTpDst.Builder setTpPort(TransportPort tpPort) {
+        this.tpPort = tpPort;
+        this.tpPortSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetTpDst build() {
+            TransportPort tpPort = this.tpPortSet ? this.tpPort : DEFAULT_TP_PORT;
+            if(tpPort == null)
+                throw new NullPointerException("Property tpPort must not be null");
+
+
+            return new OFActionSetTpDstVer10(
+                    tpPort
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetTpDst> {
+        @Override
+        public OFActionSetTpDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 10
+            short type = bb.readShort();
+            if(type != (short) 0xa)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_TP_DST(10), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TransportPort tpPort = TransportPort.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionSetTpDstVer10 actionSetTpDstVer10 = new OFActionSetTpDstVer10(
+                    tpPort
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetTpDstVer10);
+            return actionSetTpDstVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetTpDstVer10Funnel FUNNEL = new OFActionSetTpDstVer10Funnel();
+    static class OFActionSetTpDstVer10Funnel implements Funnel<OFActionSetTpDstVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetTpDstVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 10
+            sink.putShort((short) 0xa);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.tpPort.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetTpDstVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetTpDstVer10 message) {
+            // fixed value property type = 10
+            bb.writeShort((short) 0xa);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.tpPort.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetTpDstVer10(");
+        b.append("tpPort=").append(tpPort);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetTpDstVer10 other = (OFActionSetTpDstVer10) obj;
+
+        if (tpPort == null) {
+            if (other.tpPort != null)
+                return false;
+        } else if (!tpPort.equals(other.tpPort))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tpPort == null) ? 0 : tpPort.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetTpSrcVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetTpSrcVer10.java
new file mode 100644
index 0000000..d69dfb8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetTpSrcVer10.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetTpSrcVer10 implements OFActionSetTpSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetTpSrcVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_TP_PORT = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort tpPort;
+//
+    // Immutable default instance
+    final static OFActionSetTpSrcVer10 DEFAULT = new OFActionSetTpSrcVer10(
+        DEFAULT_TP_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetTpSrcVer10(TransportPort tpPort) {
+        this.tpPort = tpPort;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_SRC;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetTpSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetTpSrc.Builder {
+        final OFActionSetTpSrcVer10 parentMessage;
+
+        // OF message fields
+        private boolean tpPortSet;
+        private TransportPort tpPort;
+
+        BuilderWithParent(OFActionSetTpSrcVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_SRC;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFActionSetTpSrc.Builder setTpPort(TransportPort tpPort) {
+        this.tpPort = tpPort;
+        this.tpPortSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetTpSrc build() {
+                TransportPort tpPort = this.tpPortSet ? this.tpPort : parentMessage.tpPort;
+                if(tpPort == null)
+                    throw new NullPointerException("Property tpPort must not be null");
+
+                //
+                return new OFActionSetTpSrcVer10(
+                    tpPort
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetTpSrc.Builder {
+        // OF message fields
+        private boolean tpPortSet;
+        private TransportPort tpPort;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_SRC;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFActionSetTpSrc.Builder setTpPort(TransportPort tpPort) {
+        this.tpPort = tpPort;
+        this.tpPortSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetTpSrc build() {
+            TransportPort tpPort = this.tpPortSet ? this.tpPort : DEFAULT_TP_PORT;
+            if(tpPort == null)
+                throw new NullPointerException("Property tpPort must not be null");
+
+
+            return new OFActionSetTpSrcVer10(
+                    tpPort
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetTpSrc> {
+        @Override
+        public OFActionSetTpSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 9
+            short type = bb.readShort();
+            if(type != (short) 0x9)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_TP_SRC(9), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TransportPort tpPort = TransportPort.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionSetTpSrcVer10 actionSetTpSrcVer10 = new OFActionSetTpSrcVer10(
+                    tpPort
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetTpSrcVer10);
+            return actionSetTpSrcVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetTpSrcVer10Funnel FUNNEL = new OFActionSetTpSrcVer10Funnel();
+    static class OFActionSetTpSrcVer10Funnel implements Funnel<OFActionSetTpSrcVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetTpSrcVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 9
+            sink.putShort((short) 0x9);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.tpPort.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetTpSrcVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetTpSrcVer10 message) {
+            // fixed value property type = 9
+            bb.writeShort((short) 0x9);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.tpPort.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetTpSrcVer10(");
+        b.append("tpPort=").append(tpPort);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetTpSrcVer10 other = (OFActionSetTpSrcVer10) obj;
+
+        if (tpPort == null) {
+            if (other.tpPort != null)
+                return false;
+        } else if (!tpPort.equals(other.tpPort))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tpPort == null) ? 0 : tpPort.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetVlanPcpVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetVlanPcpVer10.java
new file mode 100644
index 0000000..b4005e0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetVlanPcpVer10.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetVlanPcpVer10 implements OFActionSetVlanPcp {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetVlanPcpVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static VlanPcp DEFAULT_VLAN_PCP = VlanPcp.NONE;
+
+    // OF message fields
+    private final VlanPcp vlanPcp;
+//
+    // Immutable default instance
+    final static OFActionSetVlanPcpVer10 DEFAULT = new OFActionSetVlanPcpVer10(
+        DEFAULT_VLAN_PCP
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetVlanPcpVer10(VlanPcp vlanPcp) {
+        this.vlanPcp = vlanPcp;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_PCP;
+    }
+
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetVlanPcp.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetVlanPcp.Builder {
+        final OFActionSetVlanPcpVer10 parentMessage;
+
+        // OF message fields
+        private boolean vlanPcpSet;
+        private VlanPcp vlanPcp;
+
+        BuilderWithParent(OFActionSetVlanPcpVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_PCP;
+    }
+
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFActionSetVlanPcp.Builder setVlanPcp(VlanPcp vlanPcp) {
+        this.vlanPcp = vlanPcp;
+        this.vlanPcpSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetVlanPcp build() {
+                VlanPcp vlanPcp = this.vlanPcpSet ? this.vlanPcp : parentMessage.vlanPcp;
+                if(vlanPcp == null)
+                    throw new NullPointerException("Property vlanPcp must not be null");
+
+                //
+                return new OFActionSetVlanPcpVer10(
+                    vlanPcp
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetVlanPcp.Builder {
+        // OF message fields
+        private boolean vlanPcpSet;
+        private VlanPcp vlanPcp;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_PCP;
+    }
+
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFActionSetVlanPcp.Builder setVlanPcp(VlanPcp vlanPcp) {
+        this.vlanPcp = vlanPcp;
+        this.vlanPcpSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetVlanPcp build() {
+            VlanPcp vlanPcp = this.vlanPcpSet ? this.vlanPcp : DEFAULT_VLAN_PCP;
+            if(vlanPcp == null)
+                throw new NullPointerException("Property vlanPcp must not be null");
+
+
+            return new OFActionSetVlanPcpVer10(
+                    vlanPcp
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetVlanPcp> {
+        @Override
+        public OFActionSetVlanPcp readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_VLAN_PCP(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            VlanPcp vlanPcp = VlanPcp.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetVlanPcpVer10 actionSetVlanPcpVer10 = new OFActionSetVlanPcpVer10(
+                    vlanPcp
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetVlanPcpVer10);
+            return actionSetVlanPcpVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetVlanPcpVer10Funnel FUNNEL = new OFActionSetVlanPcpVer10Funnel();
+    static class OFActionSetVlanPcpVer10Funnel implements Funnel<OFActionSetVlanPcpVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetVlanPcpVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.vlanPcp.putTo(sink);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetVlanPcpVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetVlanPcpVer10 message) {
+            // fixed value property type = 2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.vlanPcp.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetVlanPcpVer10(");
+        b.append("vlanPcp=").append(vlanPcp);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetVlanPcpVer10 other = (OFActionSetVlanPcpVer10) obj;
+
+        if (vlanPcp == null) {
+            if (other.vlanPcp != null)
+                return false;
+        } else if (!vlanPcp.equals(other.vlanPcp))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((vlanPcp == null) ? 0 : vlanPcp.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetVlanVidVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetVlanVidVer10.java
new file mode 100644
index 0000000..f63f283
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionSetVlanVidVer10.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetVlanVidVer10 implements OFActionSetVlanVid {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetVlanVidVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static VlanVid DEFAULT_VLAN_VID = VlanVid.ZERO;
+
+    // OF message fields
+    private final VlanVid vlanVid;
+//
+    // Immutable default instance
+    final static OFActionSetVlanVidVer10 DEFAULT = new OFActionSetVlanVidVer10(
+        DEFAULT_VLAN_VID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetVlanVidVer10(VlanVid vlanVid) {
+        this.vlanVid = vlanVid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_VID;
+    }
+
+    @Override
+    public VlanVid getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFActionSetVlanVid.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetVlanVid.Builder {
+        final OFActionSetVlanVidVer10 parentMessage;
+
+        // OF message fields
+        private boolean vlanVidSet;
+        private VlanVid vlanVid;
+
+        BuilderWithParent(OFActionSetVlanVidVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_VID;
+    }
+
+    @Override
+    public VlanVid getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFActionSetVlanVid.Builder setVlanVid(VlanVid vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFActionSetVlanVid build() {
+                VlanVid vlanVid = this.vlanVidSet ? this.vlanVid : parentMessage.vlanVid;
+                if(vlanVid == null)
+                    throw new NullPointerException("Property vlanVid must not be null");
+
+                //
+                return new OFActionSetVlanVidVer10(
+                    vlanVid
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetVlanVid.Builder {
+        // OF message fields
+        private boolean vlanVidSet;
+        private VlanVid vlanVid;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_VID;
+    }
+
+    @Override
+    public VlanVid getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFActionSetVlanVid.Builder setVlanVid(VlanVid vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFActionSetVlanVid build() {
+            VlanVid vlanVid = this.vlanVidSet ? this.vlanVid : DEFAULT_VLAN_VID;
+            if(vlanVid == null)
+                throw new NullPointerException("Property vlanVid must not be null");
+
+
+            return new OFActionSetVlanVidVer10(
+                    vlanVid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetVlanVid> {
+        @Override
+        public OFActionSetVlanVid readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_VLAN_VID(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            VlanVid vlanVid = VlanVid.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionSetVlanVidVer10 actionSetVlanVidVer10 = new OFActionSetVlanVidVer10(
+                    vlanVid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetVlanVidVer10);
+            return actionSetVlanVidVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetVlanVidVer10Funnel FUNNEL = new OFActionSetVlanVidVer10Funnel();
+    static class OFActionSetVlanVidVer10Funnel implements Funnel<OFActionSetVlanVidVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetVlanVidVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.vlanVid.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetVlanVidVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetVlanVidVer10 message) {
+            // fixed value property type = 1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.vlanVid.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetVlanVidVer10(");
+        b.append("vlanVid=").append(vlanVid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetVlanVidVer10 other = (OFActionSetVlanVidVer10) obj;
+
+        if (vlanVid == null) {
+            if (other.vlanVid != null)
+                return false;
+        } else if (!vlanVid.equals(other.vlanVid))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((vlanVid == null) ? 0 : vlanVid.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionStripVlanVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionStripVlanVer10.java
new file mode 100644
index 0000000..1314c1a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionStripVlanVer10.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionStripVlanVer10 implements OFActionStripVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionStripVlanVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionStripVlanVer10 DEFAULT = new OFActionStripVlanVer10(
+
+    );
+
+    final static OFActionStripVlanVer10 INSTANCE = new OFActionStripVlanVer10();
+    // private empty constructor - use shared instance!
+    private OFActionStripVlanVer10() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.STRIP_VLAN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionStripVlan.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionStripVlanVer10 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionStripVlan> {
+        @Override
+        public OFActionStripVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 3
+            short type = bb.readShort();
+            if(type != (short) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFActionType.STRIP_VLAN(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionStripVlanVer10Funnel FUNNEL = new OFActionStripVlanVer10Funnel();
+    static class OFActionStripVlanVer10Funnel implements Funnel<OFActionStripVlanVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionStripVlanVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 3
+            sink.putShort((short) 0x3);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionStripVlanVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionStripVlanVer10 message) {
+            // fixed value property type = 3
+            bb.writeShort((short) 0x3);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionStripVlanVer10(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionTypeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionTypeSerializerVer10.java
new file mode 100644
index 0000000..e094760
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionTypeSerializerVer10.java
@@ -0,0 +1,129 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFActionType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFActionTypeSerializerVer10 {
+
+    public final static short OUTPUT_VAL = (short) 0x0;
+    public final static short SET_VLAN_VID_VAL = (short) 0x1;
+    public final static short SET_VLAN_PCP_VAL = (short) 0x2;
+    public final static short STRIP_VLAN_VAL = (short) 0x3;
+    public final static short SET_DL_SRC_VAL = (short) 0x4;
+    public final static short SET_DL_DST_VAL = (short) 0x5;
+    public final static short SET_NW_SRC_VAL = (short) 0x6;
+    public final static short SET_NW_DST_VAL = (short) 0x7;
+    public final static short SET_NW_TOS_VAL = (short) 0x8;
+    public final static short SET_TP_SRC_VAL = (short) 0x9;
+    public final static short SET_TP_DST_VAL = (short) 0xa;
+    public final static short ENQUEUE_VAL = (short) 0xb;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFActionType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFActionType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFActionType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFActionType ofWireValue(short val) {
+        switch(val) {
+            case OUTPUT_VAL:
+                return OFActionType.OUTPUT;
+            case SET_VLAN_VID_VAL:
+                return OFActionType.SET_VLAN_VID;
+            case SET_VLAN_PCP_VAL:
+                return OFActionType.SET_VLAN_PCP;
+            case STRIP_VLAN_VAL:
+                return OFActionType.STRIP_VLAN;
+            case SET_DL_SRC_VAL:
+                return OFActionType.SET_DL_SRC;
+            case SET_DL_DST_VAL:
+                return OFActionType.SET_DL_DST;
+            case SET_NW_SRC_VAL:
+                return OFActionType.SET_NW_SRC;
+            case SET_NW_DST_VAL:
+                return OFActionType.SET_NW_DST;
+            case SET_NW_TOS_VAL:
+                return OFActionType.SET_NW_TOS;
+            case SET_TP_SRC_VAL:
+                return OFActionType.SET_TP_SRC;
+            case SET_TP_DST_VAL:
+                return OFActionType.SET_TP_DST;
+            case ENQUEUE_VAL:
+                return OFActionType.ENQUEUE;
+            case EXPERIMENTER_VAL:
+                return OFActionType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFActionType in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFActionType e) {
+        switch(e) {
+            case OUTPUT:
+                return OUTPUT_VAL;
+            case SET_VLAN_VID:
+                return SET_VLAN_VID_VAL;
+            case SET_VLAN_PCP:
+                return SET_VLAN_PCP_VAL;
+            case STRIP_VLAN:
+                return STRIP_VLAN_VAL;
+            case SET_DL_SRC:
+                return SET_DL_SRC_VAL;
+            case SET_DL_DST:
+                return SET_DL_DST_VAL;
+            case SET_NW_SRC:
+                return SET_NW_SRC_VAL;
+            case SET_NW_DST:
+                return SET_NW_DST_VAL;
+            case SET_NW_TOS:
+                return SET_NW_TOS_VAL;
+            case SET_TP_SRC:
+                return SET_TP_SRC_VAL;
+            case SET_TP_DST:
+                return SET_TP_DST_VAL;
+            case ENQUEUE:
+                return ENQUEUE_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFActionType in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionVer10.java
new file mode 100644
index 0000000..9917dcd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionVer10.java
@@ -0,0 +1,90 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFAction> {
+        @Override
+        public OFAction readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0xffff:
+                   // discriminator value OFActionType.EXPERIMENTER=65535 for class OFActionExperimenterVer10
+                   return OFActionExperimenterVer10.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFActionType.ENQUEUE=11 for class OFActionEnqueueVer10
+                   return OFActionEnqueueVer10.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFActionType.OUTPUT=0 for class OFActionOutputVer10
+                   return OFActionOutputVer10.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFActionType.SET_DL_DST=5 for class OFActionSetDlDstVer10
+                   return OFActionSetDlDstVer10.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFActionType.SET_DL_SRC=4 for class OFActionSetDlSrcVer10
+                   return OFActionSetDlSrcVer10.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFActionType.SET_NW_DST=7 for class OFActionSetNwDstVer10
+                   return OFActionSetNwDstVer10.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFActionType.SET_NW_SRC=6 for class OFActionSetNwSrcVer10
+                   return OFActionSetNwSrcVer10.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFActionType.SET_NW_TOS=8 for class OFActionSetNwTosVer10
+                   return OFActionSetNwTosVer10.READER.readFrom(bb);
+               case (short) 0xa:
+                   // discriminator value OFActionType.SET_TP_DST=10 for class OFActionSetTpDstVer10
+                   return OFActionSetTpDstVer10.READER.readFrom(bb);
+               case (short) 0x9:
+                   // discriminator value OFActionType.SET_TP_SRC=9 for class OFActionSetTpSrcVer10
+                   return OFActionSetTpSrcVer10.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFActionType.SET_VLAN_PCP=2 for class OFActionSetVlanPcpVer10
+                   return OFActionSetVlanPcpVer10.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFActionType.SET_VLAN_VID=1 for class OFActionSetVlanVidVer10
+                   return OFActionSetVlanVidVer10.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFActionType.STRIP_VLAN=3 for class OFActionStripVlanVer10
+                   return OFActionStripVlanVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFActionVer10: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionsVer10.java
new file mode 100644
index 0000000..7bb203b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFActionsVer10.java
@@ -0,0 +1,282 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+
+public class OFActionsVer10 implements OFActions {
+    public final static OFActionsVer10 INSTANCE = new OFActionsVer10();
+
+
+
+
+    public OFActionBsnChecksum.Builder buildBsnChecksum() {
+        return new OFActionBsnChecksumVer10.Builder();
+    }
+    public OFActionBsnChecksum bsnChecksum(U128 checksum) {
+        return new OFActionBsnChecksumVer10(
+                checksum
+                    );
+    }
+
+    public OFActionBsnMirror.Builder buildBsnMirror() {
+        return new OFActionBsnMirrorVer10.Builder();
+    }
+
+    public OFActionBsnSetTunnelDst.Builder buildBsnSetTunnelDst() {
+        return new OFActionBsnSetTunnelDstVer10.Builder();
+    }
+    public OFActionBsnSetTunnelDst bsnSetTunnelDst(long dst) {
+        return new OFActionBsnSetTunnelDstVer10(
+                dst
+                    );
+    }
+
+    public OFActionEnqueue.Builder buildEnqueue() {
+        return new OFActionEnqueueVer10.Builder();
+    }
+    public OFActionEnqueue enqueue(OFPort port, long queueId) {
+        return new OFActionEnqueueVer10(
+                port,
+                      queueId
+                    );
+    }
+
+    public OFActionNiciraDecTtl niciraDecTtl() {
+        return OFActionNiciraDecTtlVer10.INSTANCE;
+    }
+
+    public OFActionOutput.Builder buildOutput() {
+        return new OFActionOutputVer10.Builder();
+    }
+    public OFActionOutput output(OFPort port, int maxLen) {
+        return new OFActionOutputVer10(
+                port,
+                      maxLen
+                    );
+    }
+
+    public OFActionSetDlDst.Builder buildSetDlDst() {
+        return new OFActionSetDlDstVer10.Builder();
+    }
+    public OFActionSetDlDst setDlDst(MacAddress dlAddr) {
+        return new OFActionSetDlDstVer10(
+                dlAddr
+                    );
+    }
+
+    public OFActionSetDlSrc.Builder buildSetDlSrc() {
+        return new OFActionSetDlSrcVer10.Builder();
+    }
+    public OFActionSetDlSrc setDlSrc(MacAddress dlAddr) {
+        return new OFActionSetDlSrcVer10(
+                dlAddr
+                    );
+    }
+
+    public OFActionSetNwDst.Builder buildSetNwDst() {
+        return new OFActionSetNwDstVer10.Builder();
+    }
+    public OFActionSetNwDst setNwDst(IPv4Address nwAddr) {
+        return new OFActionSetNwDstVer10(
+                nwAddr
+                    );
+    }
+
+    public OFActionSetNwSrc.Builder buildSetNwSrc() {
+        return new OFActionSetNwSrcVer10.Builder();
+    }
+    public OFActionSetNwSrc setNwSrc(IPv4Address nwAddr) {
+        return new OFActionSetNwSrcVer10(
+                nwAddr
+                    );
+    }
+
+    public OFActionSetNwTos.Builder buildSetNwTos() {
+        return new OFActionSetNwTosVer10.Builder();
+    }
+    public OFActionSetNwTos setNwTos(short nwTos) {
+        return new OFActionSetNwTosVer10(
+                nwTos
+                    );
+    }
+
+    public OFActionSetTpDst.Builder buildSetTpDst() {
+        return new OFActionSetTpDstVer10.Builder();
+    }
+    public OFActionSetTpDst setTpDst(TransportPort tpPort) {
+        return new OFActionSetTpDstVer10(
+                tpPort
+                    );
+    }
+
+    public OFActionSetTpSrc.Builder buildSetTpSrc() {
+        return new OFActionSetTpSrcVer10.Builder();
+    }
+    public OFActionSetTpSrc setTpSrc(TransportPort tpPort) {
+        return new OFActionSetTpSrcVer10(
+                tpPort
+                    );
+    }
+
+    public OFActionSetVlanPcp.Builder buildSetVlanPcp() {
+        return new OFActionSetVlanPcpVer10.Builder();
+    }
+    public OFActionSetVlanPcp setVlanPcp(VlanPcp vlanPcp) {
+        return new OFActionSetVlanPcpVer10(
+                vlanPcp
+                    );
+    }
+
+    public OFActionSetVlanVid.Builder buildSetVlanVid() {
+        return new OFActionSetVlanVidVer10.Builder();
+    }
+    public OFActionSetVlanVid setVlanVid(VlanVid vlanVid) {
+        return new OFActionSetVlanVidVer10(
+                vlanVid
+                    );
+    }
+
+    public OFActionStripVlan stripVlan() {
+        return OFActionStripVlanVer10.INSTANCE;
+    }
+
+    public OFActionCopyTtlIn copyTtlIn() {
+        throw new UnsupportedOperationException("OFActionCopyTtlIn not supported in version 1.0");
+    }
+
+    public OFActionCopyTtlOut copyTtlOut() {
+        throw new UnsupportedOperationException("OFActionCopyTtlOut not supported in version 1.0");
+    }
+
+    public OFActionDecMplsTtl decMplsTtl() {
+        throw new UnsupportedOperationException("OFActionDecMplsTtl not supported in version 1.0");
+    }
+
+    public OFActionDecNwTtl decNwTtl() {
+        throw new UnsupportedOperationException("OFActionDecNwTtl not supported in version 1.0");
+    }
+
+    public OFActionGroup.Builder buildGroup() {
+        throw new UnsupportedOperationException("OFActionGroup not supported in version 1.0");
+    }
+    public OFActionGroup group(OFGroup group) {
+        throw new UnsupportedOperationException("OFActionGroup not supported in version 1.0");
+    }
+
+    public OFActionPopMpls.Builder buildPopMpls() {
+        throw new UnsupportedOperationException("OFActionPopMpls not supported in version 1.0");
+    }
+    public OFActionPopMpls popMpls(EthType ethertype) {
+        throw new UnsupportedOperationException("OFActionPopMpls not supported in version 1.0");
+    }
+
+    public OFActionPopVlan popVlan() {
+        throw new UnsupportedOperationException("OFActionPopVlan not supported in version 1.0");
+    }
+
+    public OFActionPushMpls.Builder buildPushMpls() {
+        throw new UnsupportedOperationException("OFActionPushMpls not supported in version 1.0");
+    }
+    public OFActionPushMpls pushMpls(EthType ethertype) {
+        throw new UnsupportedOperationException("OFActionPushMpls not supported in version 1.0");
+    }
+
+    public OFActionPushVlan.Builder buildPushVlan() {
+        throw new UnsupportedOperationException("OFActionPushVlan not supported in version 1.0");
+    }
+    public OFActionPushVlan pushVlan(EthType ethertype) {
+        throw new UnsupportedOperationException("OFActionPushVlan not supported in version 1.0");
+    }
+
+    public OFActionSetMplsLabel.Builder buildSetMplsLabel() {
+        throw new UnsupportedOperationException("OFActionSetMplsLabel not supported in version 1.0");
+    }
+    public OFActionSetMplsLabel setMplsLabel(long mplsLabel) {
+        throw new UnsupportedOperationException("OFActionSetMplsLabel not supported in version 1.0");
+    }
+
+    public OFActionSetMplsTc.Builder buildSetMplsTc() {
+        throw new UnsupportedOperationException("OFActionSetMplsTc not supported in version 1.0");
+    }
+    public OFActionSetMplsTc setMplsTc(short mplsTc) {
+        throw new UnsupportedOperationException("OFActionSetMplsTc not supported in version 1.0");
+    }
+
+    public OFActionSetMplsTtl.Builder buildSetMplsTtl() {
+        throw new UnsupportedOperationException("OFActionSetMplsTtl not supported in version 1.0");
+    }
+    public OFActionSetMplsTtl setMplsTtl(short mplsTtl) {
+        throw new UnsupportedOperationException("OFActionSetMplsTtl not supported in version 1.0");
+    }
+
+    public OFActionSetNwEcn.Builder buildSetNwEcn() {
+        throw new UnsupportedOperationException("OFActionSetNwEcn not supported in version 1.0");
+    }
+    public OFActionSetNwEcn setNwEcn(IpEcn nwEcn) {
+        throw new UnsupportedOperationException("OFActionSetNwEcn not supported in version 1.0");
+    }
+
+    public OFActionSetNwTtl.Builder buildSetNwTtl() {
+        throw new UnsupportedOperationException("OFActionSetNwTtl not supported in version 1.0");
+    }
+    public OFActionSetNwTtl setNwTtl(short nwTtl) {
+        throw new UnsupportedOperationException("OFActionSetNwTtl not supported in version 1.0");
+    }
+
+    public OFActionSetQueue.Builder buildSetQueue() {
+        throw new UnsupportedOperationException("OFActionSetQueue not supported in version 1.0");
+    }
+    public OFActionSetQueue setQueue(long queueId) {
+        throw new UnsupportedOperationException("OFActionSetQueue not supported in version 1.0");
+    }
+
+    public OFActionSetField.Builder buildSetField() {
+        throw new UnsupportedOperationException("OFActionSetField not supported in version 1.0");
+    }
+    public OFActionSetField setField(OFOxm<?> field) {
+        throw new UnsupportedOperationException("OFActionSetField not supported in version 1.0");
+    }
+
+    public OFActionPopPbb popPbb() {
+        throw new UnsupportedOperationException("OFActionPopPbb not supported in version 1.0");
+    }
+
+    public OFActionPushPbb.Builder buildPushPbb() {
+        throw new UnsupportedOperationException("OFActionPushPbb not supported in version 1.0");
+    }
+    public OFActionPushPbb pushPbb(EthType ethertype) {
+        throw new UnsupportedOperationException("OFActionPushPbb not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFAction> getReader() {
+        return OFActionVer10.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFAggregateStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFAggregateStatsReplyVer10.java
new file mode 100644
index 0000000..a30e829
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFAggregateStatsReplyVer10.java
@@ -0,0 +1,506 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAggregateStatsReplyVer10 implements OFAggregateStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 36;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static long DEFAULT_FLOW_COUNT = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final long flowCount;
+//
+    // Immutable default instance
+    final static OFAggregateStatsReplyVer10 DEFAULT = new OFAggregateStatsReplyVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_FLOW_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAggregateStatsReplyVer10(long xid, Set<OFStatsReplyFlags> flags, U64 packetCount, U64 byteCount, long flowCount) {
+        this.xid = xid;
+        this.flags = flags;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.flowCount = flowCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+
+
+    public OFAggregateStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAggregateStatsReply.Builder {
+        final OFAggregateStatsReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean flowCountSet;
+        private long flowCount;
+
+        BuilderWithParent(OFAggregateStatsReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAggregateStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                long flowCount = this.flowCountSet ? this.flowCount : parentMessage.flowCount;
+
+                //
+                return new OFAggregateStatsReplyVer10(
+                    xid,
+                    flags,
+                    packetCount,
+                    byteCount,
+                    flowCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFAggregateStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean flowCountSet;
+        private long flowCount;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAggregateStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            long flowCount = this.flowCountSet ? this.flowCount : DEFAULT_FLOW_COUNT;
+
+
+            return new OFAggregateStatsReplyVer10(
+                    xid,
+                    flags,
+                    packetCount,
+                    byteCount,
+                    flowCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAggregateStatsReply> {
+        @Override
+        public OFAggregateStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 36)
+                throw new OFParseError("Wrong length: Expected=36(36), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 2
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x2)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.AGGREGATE(2), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer10.readFrom(bb);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            long flowCount = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFAggregateStatsReplyVer10 aggregateStatsReplyVer10 = new OFAggregateStatsReplyVer10(
+                    xid,
+                      flags,
+                      packetCount,
+                      byteCount,
+                      flowCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", aggregateStatsReplyVer10);
+            return aggregateStatsReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAggregateStatsReplyVer10Funnel FUNNEL = new OFAggregateStatsReplyVer10Funnel();
+    static class OFAggregateStatsReplyVer10Funnel implements Funnel<OFAggregateStatsReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAggregateStatsReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // fixed value property length = 36
+            sink.putShort((short) 0x24);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 2
+            sink.putShort((short) 0x2);
+            OFStatsReplyFlagsSerializerVer10.putTo(message.flags, sink);
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            sink.putLong(message.flowCount);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAggregateStatsReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFAggregateStatsReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // fixed value property length = 36
+            bb.writeShort((short) 0x24);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 2
+            bb.writeShort((short) 0x2);
+            OFStatsReplyFlagsSerializerVer10.writeTo(bb, message.flags);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            bb.writeInt(U32.t(message.flowCount));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAggregateStatsReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("flowCount=").append(flowCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAggregateStatsReplyVer10 other = (OFAggregateStatsReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if( flowCount != other.flowCount)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime *  (int) (flowCount ^ (flowCount >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFAggregateStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFAggregateStatsRequestVer10.java
new file mode 100644
index 0000000..4b36011
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFAggregateStatsRequestVer10.java
@@ -0,0 +1,582 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAggregateStatsRequestVer10 implements OFAggregateStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final Match match;
+    private final TableId tableId;
+    private final OFPort outPort;
+//
+    // Immutable default instance
+    final static OFAggregateStatsRequestVer10 DEFAULT = new OFAggregateStatsRequestVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_TABLE_ID, DEFAULT_OUT_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAggregateStatsRequestVer10(long xid, Set<OFStatsRequestFlags> flags, Match match, TableId tableId, OFPort outPort) {
+        this.xid = xid;
+        this.flags = flags;
+        this.match = match;
+        this.tableId = tableId;
+        this.outPort = outPort;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFAggregateStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAggregateStatsRequest.Builder {
+        final OFAggregateStatsRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+
+        BuilderWithParent(OFAggregateStatsRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAggregateStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+
+                //
+                return new OFAggregateStatsRequestVer10(
+                    xid,
+                    flags,
+                    match,
+                    tableId,
+                    outPort
+                );
+        }
+
+    }
+
+    static class Builder implements OFAggregateStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAggregateStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+
+
+            return new OFAggregateStatsRequestVer10(
+                    xid,
+                    flags,
+                    match,
+                    tableId,
+                    outPort
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAggregateStatsRequest> {
+        @Override
+        public OFAggregateStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 56)
+                throw new OFParseError("Wrong length: Expected=56(56), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 2
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x2)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.AGGREGATE(2), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer10.readFrom(bb);
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFPort outPort = OFPort.read2Bytes(bb);
+
+            OFAggregateStatsRequestVer10 aggregateStatsRequestVer10 = new OFAggregateStatsRequestVer10(
+                    xid,
+                      flags,
+                      match,
+                      tableId,
+                      outPort
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", aggregateStatsRequestVer10);
+            return aggregateStatsRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAggregateStatsRequestVer10Funnel FUNNEL = new OFAggregateStatsRequestVer10Funnel();
+    static class OFAggregateStatsRequestVer10Funnel implements Funnel<OFAggregateStatsRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAggregateStatsRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 56
+            sink.putShort((short) 0x38);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 2
+            sink.putShort((short) 0x2);
+            OFStatsRequestFlagsSerializerVer10.putTo(message.flags, sink);
+            message.match.putTo(sink);
+            message.tableId.putTo(sink);
+            // skip pad (1 bytes)
+            message.outPort.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAggregateStatsRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFAggregateStatsRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 56
+            bb.writeShort((short) 0x38);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 2
+            bb.writeShort((short) 0x2);
+            OFStatsRequestFlagsSerializerVer10.writeTo(bb, message.flags);
+            message.match.writeTo(bb);
+            message.tableId.writeByte(bb);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.outPort.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAggregateStatsRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAggregateStatsRequestVer10 other = (OFAggregateStatsRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadActionCodeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadActionCodeSerializerVer10.java
new file mode 100644
index 0000000..b1f67c7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadActionCodeSerializerVer10.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadActionCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadActionCodeSerializerVer10 {
+
+    public final static short BAD_TYPE_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x2;
+    public final static short BAD_EXPERIMENTER_TYPE_VAL = (short) 0x3;
+    public final static short BAD_OUT_PORT_VAL = (short) 0x4;
+    public final static short BAD_ARGUMENT_VAL = (short) 0x5;
+    public final static short EPERM_VAL = (short) 0x6;
+    public final static short TOO_MANY_VAL = (short) 0x7;
+    public final static short BAD_QUEUE_VAL = (short) 0x8;
+
+    public static OFBadActionCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadActionCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadActionCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadActionCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TYPE_VAL:
+                return OFBadActionCode.BAD_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadActionCode.BAD_LEN;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadActionCode.BAD_EXPERIMENTER;
+            case BAD_EXPERIMENTER_TYPE_VAL:
+                return OFBadActionCode.BAD_EXPERIMENTER_TYPE;
+            case BAD_OUT_PORT_VAL:
+                return OFBadActionCode.BAD_OUT_PORT;
+            case BAD_ARGUMENT_VAL:
+                return OFBadActionCode.BAD_ARGUMENT;
+            case EPERM_VAL:
+                return OFBadActionCode.EPERM;
+            case TOO_MANY_VAL:
+                return OFBadActionCode.TOO_MANY;
+            case BAD_QUEUE_VAL:
+                return OFBadActionCode.BAD_QUEUE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadActionCode in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadActionCode e) {
+        switch(e) {
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_EXPERIMENTER_TYPE:
+                return BAD_EXPERIMENTER_TYPE_VAL;
+            case BAD_OUT_PORT:
+                return BAD_OUT_PORT_VAL;
+            case BAD_ARGUMENT:
+                return BAD_ARGUMENT_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case TOO_MANY:
+                return TOO_MANY_VAL;
+            case BAD_QUEUE:
+                return BAD_QUEUE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadActionCode in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadActionErrorMsgVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadActionErrorMsgVer10.java
new file mode 100644
index 0000000..aae9003
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadActionErrorMsgVer10.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadActionErrorMsgVer10 implements OFBadActionErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadActionErrorMsgVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadActionCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadActionErrorMsgVer10(long xid, OFBadActionCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadActionErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadActionErrorMsg.Builder {
+        final OFBadActionErrorMsgVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadActionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadActionErrorMsgVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setCode(OFBadActionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadActionErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadActionCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadActionErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadActionErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadActionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setCode(OFBadActionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadActionErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadActionErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadActionErrorMsg> {
+        @Override
+        public OFBadActionErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 2
+            short errType = bb.readShort();
+            if(errType != (short) 0x2)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_ACTION(2), got="+errType);
+            OFBadActionCode code = OFBadActionCodeSerializerVer10.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_10);
+
+            OFBadActionErrorMsgVer10 badActionErrorMsgVer10 = new OFBadActionErrorMsgVer10(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badActionErrorMsgVer10);
+            return badActionErrorMsgVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadActionErrorMsgVer10Funnel FUNNEL = new OFBadActionErrorMsgVer10Funnel();
+    static class OFBadActionErrorMsgVer10Funnel implements Funnel<OFBadActionErrorMsgVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadActionErrorMsgVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 2
+            sink.putShort((short) 0x2);
+            OFBadActionCodeSerializerVer10.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadActionErrorMsgVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadActionErrorMsgVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 2
+            bb.writeShort((short) 0x2);
+            OFBadActionCodeSerializerVer10.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadActionErrorMsgVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadActionErrorMsgVer10 other = (OFBadActionErrorMsgVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadRequestCodeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadRequestCodeSerializerVer10.java
new file mode 100644
index 0000000..fc11c91
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadRequestCodeSerializerVer10.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadRequestCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadRequestCodeSerializerVer10 {
+
+    public final static short BAD_VERSION_VAL = (short) 0x0;
+    public final static short BAD_TYPE_VAL = (short) 0x1;
+    public final static short BAD_STAT_VAL = (short) 0x2;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x3;
+    public final static short BAD_SUBTYPE_VAL = (short) 0x4;
+    public final static short EPERM_VAL = (short) 0x5;
+    public final static short BAD_LEN_VAL = (short) 0x6;
+    public final static short BUFFER_EMPTY_VAL = (short) 0x7;
+    public final static short BUFFER_UNKNOWN_VAL = (short) 0x8;
+
+    public static OFBadRequestCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadRequestCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadRequestCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadRequestCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_VERSION_VAL:
+                return OFBadRequestCode.BAD_VERSION;
+            case BAD_TYPE_VAL:
+                return OFBadRequestCode.BAD_TYPE;
+            case BAD_STAT_VAL:
+                return OFBadRequestCode.BAD_STAT;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadRequestCode.BAD_EXPERIMENTER;
+            case BAD_SUBTYPE_VAL:
+                return OFBadRequestCode.BAD_SUBTYPE;
+            case EPERM_VAL:
+                return OFBadRequestCode.EPERM;
+            case BAD_LEN_VAL:
+                return OFBadRequestCode.BAD_LEN;
+            case BUFFER_EMPTY_VAL:
+                return OFBadRequestCode.BUFFER_EMPTY;
+            case BUFFER_UNKNOWN_VAL:
+                return OFBadRequestCode.BUFFER_UNKNOWN;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadRequestCode in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadRequestCode e) {
+        switch(e) {
+            case BAD_VERSION:
+                return BAD_VERSION_VAL;
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_STAT:
+                return BAD_STAT_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_SUBTYPE:
+                return BAD_SUBTYPE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BUFFER_EMPTY:
+                return BUFFER_EMPTY_VAL;
+            case BUFFER_UNKNOWN:
+                return BUFFER_UNKNOWN_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadRequestCode in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadRequestErrorMsgVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadRequestErrorMsgVer10.java
new file mode 100644
index 0000000..3d0c19d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBadRequestErrorMsgVer10.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadRequestErrorMsgVer10 implements OFBadRequestErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadRequestErrorMsgVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadRequestCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadRequestErrorMsgVer10(long xid, OFBadRequestCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadRequestErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadRequestErrorMsg.Builder {
+        final OFBadRequestErrorMsgVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadRequestCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadRequestErrorMsgVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setCode(OFBadRequestCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadRequestErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadRequestCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadRequestErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadRequestErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadRequestCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setCode(OFBadRequestCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadRequestErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadRequestErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadRequestErrorMsg> {
+        @Override
+        public OFBadRequestErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 1
+            short errType = bb.readShort();
+            if(errType != (short) 0x1)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_REQUEST(1), got="+errType);
+            OFBadRequestCode code = OFBadRequestCodeSerializerVer10.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_10);
+
+            OFBadRequestErrorMsgVer10 badRequestErrorMsgVer10 = new OFBadRequestErrorMsgVer10(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badRequestErrorMsgVer10);
+            return badRequestErrorMsgVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadRequestErrorMsgVer10Funnel FUNNEL = new OFBadRequestErrorMsgVer10Funnel();
+    static class OFBadRequestErrorMsgVer10Funnel implements Funnel<OFBadRequestErrorMsgVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadRequestErrorMsgVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 1
+            sink.putShort((short) 0x1);
+            OFBadRequestCodeSerializerVer10.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadRequestErrorMsgVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadRequestErrorMsgVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 1
+            bb.writeShort((short) 0x1);
+            OFBadRequestCodeSerializerVer10.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadRequestErrorMsgVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadRequestErrorMsgVer10 other = (OFBadRequestErrorMsgVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBarrierReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBarrierReplyVer10.java
new file mode 100644
index 0000000..37e7356
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBarrierReplyVer10.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBarrierReplyVer10 implements OFBarrierReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBarrierReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBarrierReplyVer10 DEFAULT = new OFBarrierReplyVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBarrierReplyVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFBarrierReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBarrierReply.Builder {
+        final OFBarrierReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBarrierReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBarrierReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBarrierReplyVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBarrierReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBarrierReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBarrierReplyVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBarrierReply> {
+        @Override
+        public OFBarrierReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFBarrierReplyVer10 barrierReplyVer10 = new OFBarrierReplyVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", barrierReplyVer10);
+            return barrierReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBarrierReplyVer10Funnel FUNNEL = new OFBarrierReplyVer10Funnel();
+    static class OFBarrierReplyVer10Funnel implements Funnel<OFBarrierReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBarrierReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBarrierReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBarrierReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBarrierReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBarrierReplyVer10 other = (OFBarrierReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBarrierRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBarrierRequestVer10.java
new file mode 100644
index 0000000..e2def34
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBarrierRequestVer10.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBarrierRequestVer10 implements OFBarrierRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBarrierRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBarrierRequestVer10 DEFAULT = new OFBarrierRequestVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBarrierRequestVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFBarrierRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBarrierRequest.Builder {
+        final OFBarrierRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBarrierRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBarrierRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBarrierRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBarrierRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBarrierRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBarrierRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBarrierRequest> {
+        @Override
+        public OFBarrierRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFBarrierRequestVer10 barrierRequestVer10 = new OFBarrierRequestVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", barrierRequestVer10);
+            return barrierRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBarrierRequestVer10Funnel FUNNEL = new OFBarrierRequestVer10Funnel();
+    static class OFBarrierRequestVer10Funnel implements Funnel<OFBarrierRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBarrierRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBarrierRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBarrierRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBarrierRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBarrierRequestVer10 other = (OFBarrierRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwClearDataReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwClearDataReplyVer10.java
new file mode 100644
index 0000000..a1c1020
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwClearDataReplyVer10.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwClearDataReplyVer10 implements OFBsnBwClearDataReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwClearDataReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnBwClearDataReplyVer10 DEFAULT = new OFBsnBwClearDataReplyVer10(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwClearDataReplyVer10(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnBwClearDataReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwClearDataReply.Builder {
+        final OFBsnBwClearDataReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnBwClearDataReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwClearDataReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnBwClearDataReplyVer10(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwClearDataReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwClearDataReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnBwClearDataReplyVer10(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwClearDataReply> {
+        @Override
+        public OFBsnBwClearDataReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x16L
+            int subtype = bb.readInt();
+            if(subtype != 0x16)
+                throw new OFParseError("Wrong subtype: Expected=0x16L(0x16L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnBwClearDataReplyVer10 bsnBwClearDataReplyVer10 = new OFBsnBwClearDataReplyVer10(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwClearDataReplyVer10);
+            return bsnBwClearDataReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwClearDataReplyVer10Funnel FUNNEL = new OFBsnBwClearDataReplyVer10Funnel();
+    static class OFBsnBwClearDataReplyVer10Funnel implements Funnel<OFBsnBwClearDataReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwClearDataReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x16L
+            sink.putInt(0x16);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwClearDataReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwClearDataReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x16L
+            bb.writeInt(0x16);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwClearDataReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwClearDataReplyVer10 other = (OFBsnBwClearDataReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwClearDataRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwClearDataRequestVer10.java
new file mode 100644
index 0000000..763b7d6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwClearDataRequestVer10.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwClearDataRequestVer10 implements OFBsnBwClearDataRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwClearDataRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnBwClearDataRequestVer10 DEFAULT = new OFBsnBwClearDataRequestVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwClearDataRequestVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+
+
+    public OFBsnBwClearDataRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwClearDataRequest.Builder {
+        final OFBsnBwClearDataRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnBwClearDataRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+
+
+        @Override
+        public OFBsnBwClearDataRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnBwClearDataRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwClearDataRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+//
+        @Override
+        public OFBsnBwClearDataRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnBwClearDataRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwClearDataRequest> {
+        @Override
+        public OFBsnBwClearDataRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x15L
+            int subtype = bb.readInt();
+            if(subtype != 0x15)
+                throw new OFParseError("Wrong subtype: Expected=0x15L(0x15L), got="+subtype);
+
+            OFBsnBwClearDataRequestVer10 bsnBwClearDataRequestVer10 = new OFBsnBwClearDataRequestVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwClearDataRequestVer10);
+            return bsnBwClearDataRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwClearDataRequestVer10Funnel FUNNEL = new OFBsnBwClearDataRequestVer10Funnel();
+    static class OFBsnBwClearDataRequestVer10Funnel implements Funnel<OFBsnBwClearDataRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwClearDataRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x15L
+            sink.putInt(0x15);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwClearDataRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwClearDataRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x15L
+            bb.writeInt(0x15);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwClearDataRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwClearDataRequestVer10 other = (OFBsnBwClearDataRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableGetReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableGetReplyVer10.java
new file mode 100644
index 0000000..fd16755
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableGetReplyVer10.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableGetReplyVer10 implements OFBsnBwEnableGetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableGetReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLED = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enabled;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableGetReplyVer10 DEFAULT = new OFBsnBwEnableGetReplyVer10(
+        DEFAULT_XID, DEFAULT_ENABLED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableGetReplyVer10(long xid, long enabled) {
+        this.xid = xid;
+        this.enabled = enabled;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+
+
+    public OFBsnBwEnableGetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableGetReply.Builder {
+        final OFBsnBwEnableGetReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+        BuilderWithParent(OFBsnBwEnableGetReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableGetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+
+                //
+                return new OFBsnBwEnableGetReplyVer10(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableGetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableGetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+
+
+            return new OFBsnBwEnableGetReplyVer10(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableGetReply> {
+        @Override
+        public OFBsnBwEnableGetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x14L
+            int subtype = bb.readInt();
+            if(subtype != 0x14)
+                throw new OFParseError("Wrong subtype: Expected=0x14L(0x14L), got="+subtype);
+            long enabled = U32.f(bb.readInt());
+
+            OFBsnBwEnableGetReplyVer10 bsnBwEnableGetReplyVer10 = new OFBsnBwEnableGetReplyVer10(
+                    xid,
+                      enabled
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableGetReplyVer10);
+            return bsnBwEnableGetReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableGetReplyVer10Funnel FUNNEL = new OFBsnBwEnableGetReplyVer10Funnel();
+    static class OFBsnBwEnableGetReplyVer10Funnel implements Funnel<OFBsnBwEnableGetReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableGetReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x14L
+            sink.putInt(0x14);
+            sink.putLong(message.enabled);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableGetReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableGetReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x14L
+            bb.writeInt(0x14);
+            bb.writeInt(U32.t(message.enabled));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableGetReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableGetReplyVer10 other = (OFBsnBwEnableGetReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enabled ^ (enabled >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableGetRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableGetRequestVer10.java
new file mode 100644
index 0000000..f8ad0a0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableGetRequestVer10.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableGetRequestVer10 implements OFBsnBwEnableGetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableGetRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableGetRequestVer10 DEFAULT = new OFBsnBwEnableGetRequestVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableGetRequestVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+
+
+    public OFBsnBwEnableGetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableGetRequest.Builder {
+        final OFBsnBwEnableGetRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnBwEnableGetRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+
+
+        @Override
+        public OFBsnBwEnableGetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnBwEnableGetRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableGetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+//
+        @Override
+        public OFBsnBwEnableGetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnBwEnableGetRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableGetRequest> {
+        @Override
+        public OFBsnBwEnableGetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x13L
+            int subtype = bb.readInt();
+            if(subtype != 0x13)
+                throw new OFParseError("Wrong subtype: Expected=0x13L(0x13L), got="+subtype);
+
+            OFBsnBwEnableGetRequestVer10 bsnBwEnableGetRequestVer10 = new OFBsnBwEnableGetRequestVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableGetRequestVer10);
+            return bsnBwEnableGetRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableGetRequestVer10Funnel FUNNEL = new OFBsnBwEnableGetRequestVer10Funnel();
+    static class OFBsnBwEnableGetRequestVer10Funnel implements Funnel<OFBsnBwEnableGetRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableGetRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x13L
+            sink.putInt(0x13);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableGetRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableGetRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x13L
+            bb.writeInt(0x13);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableGetRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableGetRequestVer10 other = (OFBsnBwEnableGetRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableSetReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableSetReplyVer10.java
new file mode 100644
index 0000000..4370e74
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableSetReplyVer10.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableSetReplyVer10 implements OFBsnBwEnableSetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableSetReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableSetReplyVer10 DEFAULT = new OFBsnBwEnableSetReplyVer10(
+        DEFAULT_XID, DEFAULT_ENABLE, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableSetReplyVer10(long xid, long enable, long status) {
+        this.xid = xid;
+        this.enable = enable;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnBwEnableSetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableSetReply.Builder {
+        final OFBsnBwEnableSetReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnBwEnableSetReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableSetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnBwEnableSetReplyVer10(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableSetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableSetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnBwEnableSetReplyVer10(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableSetReply> {
+        @Override
+        public OFBsnBwEnableSetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x17L
+            int subtype = bb.readInt();
+            if(subtype != 0x17)
+                throw new OFParseError("Wrong subtype: Expected=0x17L(0x17L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+            long status = U32.f(bb.readInt());
+
+            OFBsnBwEnableSetReplyVer10 bsnBwEnableSetReplyVer10 = new OFBsnBwEnableSetReplyVer10(
+                    xid,
+                      enable,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableSetReplyVer10);
+            return bsnBwEnableSetReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableSetReplyVer10Funnel FUNNEL = new OFBsnBwEnableSetReplyVer10Funnel();
+    static class OFBsnBwEnableSetReplyVer10Funnel implements Funnel<OFBsnBwEnableSetReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableSetReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x17L
+            sink.putInt(0x17);
+            sink.putLong(message.enable);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableSetReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableSetReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x17L
+            bb.writeInt(0x17);
+            bb.writeInt(U32.t(message.enable));
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableSetReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableSetReplyVer10 other = (OFBsnBwEnableSetReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableSetRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableSetRequestVer10.java
new file mode 100644
index 0000000..5e765a0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnBwEnableSetRequestVer10.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableSetRequestVer10 implements OFBsnBwEnableSetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableSetRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableSetRequestVer10 DEFAULT = new OFBsnBwEnableSetRequestVer10(
+        DEFAULT_XID, DEFAULT_ENABLE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableSetRequestVer10(long xid, long enable) {
+        this.xid = xid;
+        this.enable = enable;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+
+
+    public OFBsnBwEnableSetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableSetRequest.Builder {
+        final OFBsnBwEnableSetRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+        BuilderWithParent(OFBsnBwEnableSetRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableSetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+
+                //
+                return new OFBsnBwEnableSetRequestVer10(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableSetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableSetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+
+
+            return new OFBsnBwEnableSetRequestVer10(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableSetRequest> {
+        @Override
+        public OFBsnBwEnableSetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x12L
+            int subtype = bb.readInt();
+            if(subtype != 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12L(0x12L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+
+            OFBsnBwEnableSetRequestVer10 bsnBwEnableSetRequestVer10 = new OFBsnBwEnableSetRequestVer10(
+                    xid,
+                      enable
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableSetRequestVer10);
+            return bsnBwEnableSetRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableSetRequestVer10Funnel FUNNEL = new OFBsnBwEnableSetRequestVer10Funnel();
+    static class OFBsnBwEnableSetRequestVer10Funnel implements Funnel<OFBsnBwEnableSetRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableSetRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x12L
+            sink.putInt(0x12);
+            sink.putLong(message.enable);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableSetRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableSetRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x12L
+            bb.writeInt(0x12);
+            bb.writeInt(U32.t(message.enable));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableSetRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableSetRequestVer10 other = (OFBsnBwEnableSetRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetInterfacesReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetInterfacesReplyVer10.java
new file mode 100644
index 0000000..e63c1f7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetInterfacesReplyVer10.java
@@ -0,0 +1,375 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetInterfacesReplyVer10 implements OFBsnGetInterfacesReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetInterfacesReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static List<OFBsnInterface> DEFAULT_INTERFACES = ImmutableList.<OFBsnInterface>of();
+
+    // OF message fields
+    private final long xid;
+    private final List<OFBsnInterface> interfaces;
+//
+    // Immutable default instance
+    final static OFBsnGetInterfacesReplyVer10 DEFAULT = new OFBsnGetInterfacesReplyVer10(
+        DEFAULT_XID, DEFAULT_INTERFACES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetInterfacesReplyVer10(long xid, List<OFBsnInterface> interfaces) {
+        this.xid = xid;
+        this.interfaces = interfaces;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+
+
+    public OFBsnGetInterfacesReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetInterfacesReply.Builder {
+        final OFBsnGetInterfacesReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean interfacesSet;
+        private List<OFBsnInterface> interfaces;
+
+        BuilderWithParent(OFBsnGetInterfacesReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setInterfaces(List<OFBsnInterface> interfaces) {
+        this.interfaces = interfaces;
+        this.interfacesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetInterfacesReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                List<OFBsnInterface> interfaces = this.interfacesSet ? this.interfaces : parentMessage.interfaces;
+                if(interfaces == null)
+                    throw new NullPointerException("Property interfaces must not be null");
+
+                //
+                return new OFBsnGetInterfacesReplyVer10(
+                    xid,
+                    interfaces
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetInterfacesReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean interfacesSet;
+        private List<OFBsnInterface> interfaces;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setInterfaces(List<OFBsnInterface> interfaces) {
+        this.interfaces = interfaces;
+        this.interfacesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetInterfacesReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            List<OFBsnInterface> interfaces = this.interfacesSet ? this.interfaces : DEFAULT_INTERFACES;
+            if(interfaces == null)
+                throw new NullPointerException("Property interfaces must not be null");
+
+
+            return new OFBsnGetInterfacesReplyVer10(
+                    xid,
+                    interfaces
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetInterfacesReply> {
+        @Override
+        public OFBsnGetInterfacesReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xaL
+            int subtype = bb.readInt();
+            if(subtype != 0xa)
+                throw new OFParseError("Wrong subtype: Expected=0xaL(0xaL), got="+subtype);
+            List<OFBsnInterface> interfaces = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnInterfaceVer10.READER);
+
+            OFBsnGetInterfacesReplyVer10 bsnGetInterfacesReplyVer10 = new OFBsnGetInterfacesReplyVer10(
+                    xid,
+                      interfaces
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetInterfacesReplyVer10);
+            return bsnGetInterfacesReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetInterfacesReplyVer10Funnel FUNNEL = new OFBsnGetInterfacesReplyVer10Funnel();
+    static class OFBsnGetInterfacesReplyVer10Funnel implements Funnel<OFBsnGetInterfacesReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetInterfacesReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            sink.putInt(0xa);
+            FunnelUtils.putList(message.interfaces, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetInterfacesReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetInterfacesReplyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            bb.writeInt(0xa);
+            ChannelUtils.writeList(bb, message.interfaces);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetInterfacesReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("interfaces=").append(interfaces);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetInterfacesReplyVer10 other = (OFBsnGetInterfacesReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (interfaces == null) {
+            if (other.interfaces != null)
+                return false;
+        } else if (!interfaces.equals(other.interfaces))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetInterfacesRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetInterfacesRequestVer10.java
new file mode 100644
index 0000000..f5ddab5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetInterfacesRequestVer10.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetInterfacesRequestVer10 implements OFBsnGetInterfacesRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetInterfacesRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnGetInterfacesRequestVer10 DEFAULT = new OFBsnGetInterfacesRequestVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetInterfacesRequestVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+
+
+    public OFBsnGetInterfacesRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetInterfacesRequest.Builder {
+        final OFBsnGetInterfacesRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnGetInterfacesRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+
+
+        @Override
+        public OFBsnGetInterfacesRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnGetInterfacesRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetInterfacesRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+//
+        @Override
+        public OFBsnGetInterfacesRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnGetInterfacesRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetInterfacesRequest> {
+        @Override
+        public OFBsnGetInterfacesRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x9L
+            int subtype = bb.readInt();
+            if(subtype != 0x9)
+                throw new OFParseError("Wrong subtype: Expected=0x9L(0x9L), got="+subtype);
+
+            OFBsnGetInterfacesRequestVer10 bsnGetInterfacesRequestVer10 = new OFBsnGetInterfacesRequestVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetInterfacesRequestVer10);
+            return bsnGetInterfacesRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetInterfacesRequestVer10Funnel FUNNEL = new OFBsnGetInterfacesRequestVer10Funnel();
+    static class OFBsnGetInterfacesRequestVer10Funnel implements Funnel<OFBsnGetInterfacesRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetInterfacesRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            sink.putInt(0x9);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetInterfacesRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetInterfacesRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            bb.writeInt(0x9);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetInterfacesRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetInterfacesRequestVer10 other = (OFBsnGetInterfacesRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetIpMaskReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetIpMaskReplyVer10.java
new file mode 100644
index 0000000..45fdba5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetIpMaskReplyVer10.java
@@ -0,0 +1,413 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetIpMaskReplyVer10 implements OFBsnGetIpMaskReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetIpMaskReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_INDEX = (short) 0x0;
+        private final static long DEFAULT_MASK = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final short index;
+    private final long mask;
+//
+    // Immutable default instance
+    final static OFBsnGetIpMaskReplyVer10 DEFAULT = new OFBsnGetIpMaskReplyVer10(
+        DEFAULT_XID, DEFAULT_INDEX, DEFAULT_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetIpMaskReplyVer10(long xid, short index, long mask) {
+        this.xid = xid;
+        this.index = index;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+
+
+    public OFBsnGetIpMaskReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetIpMaskReply.Builder {
+        final OFBsnGetIpMaskReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean indexSet;
+        private short index;
+        private boolean maskSet;
+        private long mask;
+
+        BuilderWithParent(OFBsnGetIpMaskReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetIpMaskReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+    @Override
+    public OFBsnGetIpMaskReply.Builder setIndex(short index) {
+        this.index = index;
+        this.indexSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFBsnGetIpMaskReply.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetIpMaskReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short index = this.indexSet ? this.index : parentMessage.index;
+                long mask = this.maskSet ? this.mask : parentMessage.mask;
+
+                //
+                return new OFBsnGetIpMaskReplyVer10(
+                    xid,
+                    index,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetIpMaskReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean indexSet;
+        private short index;
+        private boolean maskSet;
+        private long mask;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetIpMaskReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+    @Override
+    public OFBsnGetIpMaskReply.Builder setIndex(short index) {
+        this.index = index;
+        this.indexSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFBsnGetIpMaskReply.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetIpMaskReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short index = this.indexSet ? this.index : DEFAULT_INDEX;
+            long mask = this.maskSet ? this.mask : DEFAULT_MASK;
+
+
+            return new OFBsnGetIpMaskReplyVer10(
+                    xid,
+                    index,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetIpMaskReply> {
+        @Override
+        public OFBsnGetIpMaskReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+            short index = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            long mask = U32.f(bb.readInt());
+
+            OFBsnGetIpMaskReplyVer10 bsnGetIpMaskReplyVer10 = new OFBsnGetIpMaskReplyVer10(
+                    xid,
+                      index,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetIpMaskReplyVer10);
+            return bsnGetIpMaskReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetIpMaskReplyVer10Funnel FUNNEL = new OFBsnGetIpMaskReplyVer10Funnel();
+    static class OFBsnGetIpMaskReplyVer10Funnel implements Funnel<OFBsnGetIpMaskReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetIpMaskReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+            sink.putShort(message.index);
+            // skip pad (3 bytes)
+            sink.putLong(message.mask);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetIpMaskReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetIpMaskReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+            bb.writeByte(U8.t(message.index));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeInt(U32.t(message.mask));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetIpMaskReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("index=").append(index);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetIpMaskReplyVer10 other = (OFBsnGetIpMaskReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( index != other.index)
+            return false;
+        if( mask != other.mask)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + index;
+        result = prime *  (int) (mask ^ (mask >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetIpMaskRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetIpMaskRequestVer10.java
new file mode 100644
index 0000000..f35f0dc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetIpMaskRequestVer10.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetIpMaskRequestVer10 implements OFBsnGetIpMaskRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetIpMaskRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_INDEX = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short index;
+//
+    // Immutable default instance
+    final static OFBsnGetIpMaskRequestVer10 DEFAULT = new OFBsnGetIpMaskRequestVer10(
+        DEFAULT_XID, DEFAULT_INDEX
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetIpMaskRequestVer10(long xid, short index) {
+        this.xid = xid;
+        this.index = index;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+
+
+    public OFBsnGetIpMaskRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetIpMaskRequest.Builder {
+        final OFBsnGetIpMaskRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean indexSet;
+        private short index;
+
+        BuilderWithParent(OFBsnGetIpMaskRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetIpMaskRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+    @Override
+    public OFBsnGetIpMaskRequest.Builder setIndex(short index) {
+        this.index = index;
+        this.indexSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetIpMaskRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short index = this.indexSet ? this.index : parentMessage.index;
+
+                //
+                return new OFBsnGetIpMaskRequestVer10(
+                    xid,
+                    index
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetIpMaskRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean indexSet;
+        private short index;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetIpMaskRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+    @Override
+    public OFBsnGetIpMaskRequest.Builder setIndex(short index) {
+        this.index = index;
+        this.indexSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetIpMaskRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short index = this.indexSet ? this.index : DEFAULT_INDEX;
+
+
+            return new OFBsnGetIpMaskRequestVer10(
+                    xid,
+                    index
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetIpMaskRequest> {
+        @Override
+        public OFBsnGetIpMaskRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+            short index = U8.f(bb.readByte());
+            // pad: 7 bytes
+            bb.skipBytes(7);
+
+            OFBsnGetIpMaskRequestVer10 bsnGetIpMaskRequestVer10 = new OFBsnGetIpMaskRequestVer10(
+                    xid,
+                      index
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetIpMaskRequestVer10);
+            return bsnGetIpMaskRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetIpMaskRequestVer10Funnel FUNNEL = new OFBsnGetIpMaskRequestVer10Funnel();
+    static class OFBsnGetIpMaskRequestVer10Funnel implements Funnel<OFBsnGetIpMaskRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetIpMaskRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+            sink.putShort(message.index);
+            // skip pad (7 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetIpMaskRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetIpMaskRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+            bb.writeByte(U8.t(message.index));
+            // pad: 7 bytes
+            bb.writeZero(7);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetIpMaskRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("index=").append(index);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetIpMaskRequestVer10 other = (OFBsnGetIpMaskRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( index != other.index)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + index;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetL2TableReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetL2TableReplyVer10.java
new file mode 100644
index 0000000..852182c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetL2TableReplyVer10.java
@@ -0,0 +1,418 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetL2TableReplyVer10 implements OFBsnGetL2TableReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetL2TableReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_L2_TABLE_ENABLE = (short) 0x0;
+        private final static int DEFAULT_L2_TABLE_PRIORITY = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short l2TableEnable;
+    private final int l2TablePriority;
+//
+    // Immutable default instance
+    final static OFBsnGetL2TableReplyVer10 DEFAULT = new OFBsnGetL2TableReplyVer10(
+        DEFAULT_XID, DEFAULT_L2_TABLE_ENABLE, DEFAULT_L2_TABLE_PRIORITY
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetL2TableReplyVer10(long xid, short l2TableEnable, int l2TablePriority) {
+        this.xid = xid;
+        this.l2TableEnable = l2TableEnable;
+        this.l2TablePriority = l2TablePriority;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+    @Override
+    public short getL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+
+
+    public OFBsnGetL2TableReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetL2TableReply.Builder {
+        final OFBsnGetL2TableReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean l2TableEnableSet;
+        private short l2TableEnable;
+        private boolean l2TablePrioritySet;
+        private int l2TablePriority;
+
+        BuilderWithParent(OFBsnGetL2TableReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetL2TableReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+    @Override
+    public short getL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public OFBsnGetL2TableReply.Builder setL2TableEnable(short l2TableEnable) {
+        this.l2TableEnable = l2TableEnable;
+        this.l2TableEnableSet = true;
+        return this;
+    }
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+    @Override
+    public OFBsnGetL2TableReply.Builder setL2TablePriority(int l2TablePriority) {
+        this.l2TablePriority = l2TablePriority;
+        this.l2TablePrioritySet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetL2TableReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short l2TableEnable = this.l2TableEnableSet ? this.l2TableEnable : parentMessage.l2TableEnable;
+                int l2TablePriority = this.l2TablePrioritySet ? this.l2TablePriority : parentMessage.l2TablePriority;
+
+                //
+                return new OFBsnGetL2TableReplyVer10(
+                    xid,
+                    l2TableEnable,
+                    l2TablePriority
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetL2TableReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean l2TableEnableSet;
+        private short l2TableEnable;
+        private boolean l2TablePrioritySet;
+        private int l2TablePriority;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetL2TableReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+    @Override
+    public short getL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public OFBsnGetL2TableReply.Builder setL2TableEnable(short l2TableEnable) {
+        this.l2TableEnable = l2TableEnable;
+        this.l2TableEnableSet = true;
+        return this;
+    }
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+    @Override
+    public OFBsnGetL2TableReply.Builder setL2TablePriority(int l2TablePriority) {
+        this.l2TablePriority = l2TablePriority;
+        this.l2TablePrioritySet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetL2TableReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short l2TableEnable = this.l2TableEnableSet ? this.l2TableEnable : DEFAULT_L2_TABLE_ENABLE;
+            int l2TablePriority = this.l2TablePrioritySet ? this.l2TablePriority : DEFAULT_L2_TABLE_PRIORITY;
+
+
+            return new OFBsnGetL2TableReplyVer10(
+                    xid,
+                    l2TableEnable,
+                    l2TablePriority
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetL2TableReply> {
+        @Override
+        public OFBsnGetL2TableReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xeL
+            int subtype = bb.readInt();
+            if(subtype != 0xe)
+                throw new OFParseError("Wrong subtype: Expected=0xeL(0xeL), got="+subtype);
+            short l2TableEnable = U8.f(bb.readByte());
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int l2TablePriority = U16.f(bb.readShort());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFBsnGetL2TableReplyVer10 bsnGetL2TableReplyVer10 = new OFBsnGetL2TableReplyVer10(
+                    xid,
+                      l2TableEnable,
+                      l2TablePriority
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetL2TableReplyVer10);
+            return bsnGetL2TableReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetL2TableReplyVer10Funnel FUNNEL = new OFBsnGetL2TableReplyVer10Funnel();
+    static class OFBsnGetL2TableReplyVer10Funnel implements Funnel<OFBsnGetL2TableReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetL2TableReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xeL
+            sink.putInt(0xe);
+            sink.putShort(message.l2TableEnable);
+            // skip pad (1 bytes)
+            sink.putInt(message.l2TablePriority);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetL2TableReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetL2TableReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xeL
+            bb.writeInt(0xe);
+            bb.writeByte(U8.t(message.l2TableEnable));
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.l2TablePriority));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetL2TableReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("l2TableEnable=").append(l2TableEnable);
+        b.append(", ");
+        b.append("l2TablePriority=").append(l2TablePriority);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetL2TableReplyVer10 other = (OFBsnGetL2TableReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( l2TableEnable != other.l2TableEnable)
+            return false;
+        if( l2TablePriority != other.l2TablePriority)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + l2TableEnable;
+        result = prime * result + l2TablePriority;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetL2TableRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetL2TableRequestVer10.java
new file mode 100644
index 0000000..8d432c1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetL2TableRequestVer10.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetL2TableRequestVer10 implements OFBsnGetL2TableRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetL2TableRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnGetL2TableRequestVer10 DEFAULT = new OFBsnGetL2TableRequestVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetL2TableRequestVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+
+
+    public OFBsnGetL2TableRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetL2TableRequest.Builder {
+        final OFBsnGetL2TableRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnGetL2TableRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetL2TableRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+
+
+        @Override
+        public OFBsnGetL2TableRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnGetL2TableRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetL2TableRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetL2TableRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+//
+        @Override
+        public OFBsnGetL2TableRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnGetL2TableRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetL2TableRequest> {
+        @Override
+        public OFBsnGetL2TableRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xdL
+            int subtype = bb.readInt();
+            if(subtype != 0xd)
+                throw new OFParseError("Wrong subtype: Expected=0xdL(0xdL), got="+subtype);
+
+            OFBsnGetL2TableRequestVer10 bsnGetL2TableRequestVer10 = new OFBsnGetL2TableRequestVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetL2TableRequestVer10);
+            return bsnGetL2TableRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetL2TableRequestVer10Funnel FUNNEL = new OFBsnGetL2TableRequestVer10Funnel();
+    static class OFBsnGetL2TableRequestVer10Funnel implements Funnel<OFBsnGetL2TableRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetL2TableRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xdL
+            sink.putInt(0xd);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetL2TableRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetL2TableRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xdL
+            bb.writeInt(0xd);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetL2TableRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetL2TableRequestVer10 other = (OFBsnGetL2TableRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetMirroringReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetMirroringReplyVer10.java
new file mode 100644
index 0000000..080b04f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetMirroringReplyVer10.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetMirroringReplyVer10 implements OFBsnGetMirroringReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetMirroringReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnGetMirroringReplyVer10 DEFAULT = new OFBsnGetMirroringReplyVer10(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetMirroringReplyVer10(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnGetMirroringReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetMirroringReply.Builder {
+        final OFBsnGetMirroringReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnGetMirroringReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetMirroringReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnGetMirroringReplyVer10(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetMirroringReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetMirroringReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnGetMirroringReplyVer10(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetMirroringReply> {
+        @Override
+        public OFBsnGetMirroringReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x5L
+            int subtype = bb.readInt();
+            if(subtype != 0x5)
+                throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnGetMirroringReplyVer10 bsnGetMirroringReplyVer10 = new OFBsnGetMirroringReplyVer10(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetMirroringReplyVer10);
+            return bsnGetMirroringReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetMirroringReplyVer10Funnel FUNNEL = new OFBsnGetMirroringReplyVer10Funnel();
+    static class OFBsnGetMirroringReplyVer10Funnel implements Funnel<OFBsnGetMirroringReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetMirroringReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            sink.putInt(0x5);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetMirroringReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetMirroringReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            bb.writeInt(0x5);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetMirroringReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetMirroringReplyVer10 other = (OFBsnGetMirroringReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetMirroringRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetMirroringRequestVer10.java
new file mode 100644
index 0000000..e4422dd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnGetMirroringRequestVer10.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetMirroringRequestVer10 implements OFBsnGetMirroringRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetMirroringRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnGetMirroringRequestVer10 DEFAULT = new OFBsnGetMirroringRequestVer10(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetMirroringRequestVer10(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnGetMirroringRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetMirroringRequest.Builder {
+        final OFBsnGetMirroringRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnGetMirroringRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetMirroringRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnGetMirroringRequestVer10(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetMirroringRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetMirroringRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnGetMirroringRequestVer10(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetMirroringRequest> {
+        @Override
+        public OFBsnGetMirroringRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnGetMirroringRequestVer10 bsnGetMirroringRequestVer10 = new OFBsnGetMirroringRequestVer10(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetMirroringRequestVer10);
+            return bsnGetMirroringRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetMirroringRequestVer10Funnel FUNNEL = new OFBsnGetMirroringRequestVer10Funnel();
+    static class OFBsnGetMirroringRequestVer10Funnel implements Funnel<OFBsnGetMirroringRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetMirroringRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetMirroringRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetMirroringRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetMirroringRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetMirroringRequestVer10 other = (OFBsnGetMirroringRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHeaderVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHeaderVer10.java
new file mode 100644
index 0000000..e2d6efe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHeaderVer10.java
@@ -0,0 +1,169 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFBsnHeaderVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFBsnHeaderVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnHeader> {
+        @Override
+        public OFBsnHeader readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x16:
+                   // discriminator value 0x16L=0x16L for class OFBsnBwClearDataReplyVer10
+                   return OFBsnBwClearDataReplyVer10.READER.readFrom(bb);
+               case 0x15:
+                   // discriminator value 0x15L=0x15L for class OFBsnBwClearDataRequestVer10
+                   return OFBsnBwClearDataRequestVer10.READER.readFrom(bb);
+               case 0x14:
+                   // discriminator value 0x14L=0x14L for class OFBsnBwEnableGetReplyVer10
+                   return OFBsnBwEnableGetReplyVer10.READER.readFrom(bb);
+               case 0x13:
+                   // discriminator value 0x13L=0x13L for class OFBsnBwEnableGetRequestVer10
+                   return OFBsnBwEnableGetRequestVer10.READER.readFrom(bb);
+               case 0x17:
+                   // discriminator value 0x17L=0x17L for class OFBsnBwEnableSetReplyVer10
+                   return OFBsnBwEnableSetReplyVer10.READER.readFrom(bb);
+               case 0x12:
+                   // discriminator value 0x12L=0x12L for class OFBsnBwEnableSetRequestVer10
+                   return OFBsnBwEnableSetRequestVer10.READER.readFrom(bb);
+               case 0xa:
+                   // discriminator value 0xaL=0xaL for class OFBsnGetInterfacesReplyVer10
+                   return OFBsnGetInterfacesReplyVer10.READER.readFrom(bb);
+               case 0x9:
+                   // discriminator value 0x9L=0x9L for class OFBsnGetInterfacesRequestVer10
+                   return OFBsnGetInterfacesRequestVer10.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFBsnGetIpMaskReplyVer10
+                   return OFBsnGetIpMaskReplyVer10.READER.readFrom(bb);
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFBsnGetIpMaskRequestVer10
+                   return OFBsnGetIpMaskRequestVer10.READER.readFrom(bb);
+               case 0xe:
+                   // discriminator value 0xeL=0xeL for class OFBsnGetL2TableReplyVer10
+                   return OFBsnGetL2TableReplyVer10.READER.readFrom(bb);
+               case 0xd:
+                   // discriminator value 0xdL=0xdL for class OFBsnGetL2TableRequestVer10
+                   return OFBsnGetL2TableRequestVer10.READER.readFrom(bb);
+               case 0x5:
+                   // discriminator value 0x5L=0x5L for class OFBsnGetMirroringReplyVer10
+                   return OFBsnGetMirroringReplyVer10.READER.readFrom(bb);
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFBsnGetMirroringRequestVer10
+                   return OFBsnGetMirroringRequestVer10.READER.readFrom(bb);
+               case 0x1c:
+                   // discriminator value 0x1cL=0x1cL for class OFBsnHybridGetReplyVer10
+                   return OFBsnHybridGetReplyVer10.READER.readFrom(bb);
+               case 0x1b:
+                   // discriminator value 0x1bL=0x1bL for class OFBsnHybridGetRequestVer10
+                   return OFBsnHybridGetRequestVer10.READER.readFrom(bb);
+               case 0x22:
+                   // discriminator value 0x22L=0x22L for class OFBsnPduRxReplyVer10
+                   return OFBsnPduRxReplyVer10.READER.readFrom(bb);
+               case 0x21:
+                   // discriminator value 0x21L=0x21L for class OFBsnPduRxRequestVer10
+                   return OFBsnPduRxRequestVer10.READER.readFrom(bb);
+               case 0x23:
+                   // discriminator value 0x23L=0x23L for class OFBsnPduRxTimeoutVer10
+                   return OFBsnPduRxTimeoutVer10.READER.readFrom(bb);
+               case 0x20:
+                   // discriminator value 0x20L=0x20L for class OFBsnPduTxReplyVer10
+                   return OFBsnPduTxReplyVer10.READER.readFrom(bb);
+               case 0x1f:
+                   // discriminator value 0x1fL=0x1fL for class OFBsnPduTxRequestVer10
+                   return OFBsnPduTxRequestVer10.READER.readFrom(bb);
+               case 0x0:
+                   // discriminator value 0x0L=0x0L for class OFBsnSetIpMaskVer10
+                   return OFBsnSetIpMaskVer10.READER.readFrom(bb);
+               case 0x18:
+                   // discriminator value 0x18L=0x18L for class OFBsnSetL2TableReplyVer10
+                   return OFBsnSetL2TableReplyVer10.READER.readFrom(bb);
+               case 0xc:
+                   // discriminator value 0xcL=0xcL for class OFBsnSetL2TableRequestVer10
+                   return OFBsnSetL2TableRequestVer10.READER.readFrom(bb);
+               case 0x3:
+                   // discriminator value 0x3L=0x3L for class OFBsnSetMirroringVer10
+                   return OFBsnSetMirroringVer10.READER.readFrom(bb);
+               case 0x19:
+                   // discriminator value 0x19L=0x19L for class OFBsnSetPktinSuppressionReplyVer10
+                   return OFBsnSetPktinSuppressionReplyVer10.READER.readFrom(bb);
+               case 0xb:
+                   // discriminator value 0xbL=0xbL for class OFBsnSetPktinSuppressionRequestVer10
+                   return OFBsnSetPktinSuppressionRequestVer10.READER.readFrom(bb);
+               case 0x6:
+                   // discriminator value 0x6L=0x6L for class OFBsnShellCommandVer10
+                   return OFBsnShellCommandVer10.READER.readFrom(bb);
+               case 0x7:
+                   // discriminator value 0x7L=0x7L for class OFBsnShellOutputVer10
+                   return OFBsnShellOutputVer10.READER.readFrom(bb);
+               case 0x8:
+                   // discriminator value 0x8L=0x8L for class OFBsnShellStatusVer10
+                   return OFBsnShellStatusVer10.READER.readFrom(bb);
+               case 0x10:
+                   // discriminator value 0x10L=0x10L for class OFBsnVirtualPortCreateReplyVer10
+                   return OFBsnVirtualPortCreateReplyVer10.READER.readFrom(bb);
+               case 0xf:
+                   // discriminator value 0xfL=0xfL for class OFBsnVirtualPortCreateRequestVer10
+                   return OFBsnVirtualPortCreateRequestVer10.READER.readFrom(bb);
+               case 0x1a:
+                   // discriminator value 0x1aL=0x1aL for class OFBsnVirtualPortRemoveReplyVer10
+                   return OFBsnVirtualPortRemoveReplyVer10.READER.readFrom(bb);
+               case 0x11:
+                   // discriminator value 0x11L=0x11L for class OFBsnVirtualPortRemoveRequestVer10
+                   return OFBsnVirtualPortRemoveRequestVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnHeaderVer10: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHybridGetReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHybridGetReplyVer10.java
new file mode 100644
index 0000000..afe00bd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHybridGetReplyVer10.java
@@ -0,0 +1,418 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnHybridGetReplyVer10 implements OFBsnHybridGetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnHybridGetReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_HYBRID_ENABLE = (short) 0x0;
+        private final static int DEFAULT_HYBRID_VERSION = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short hybridEnable;
+    private final int hybridVersion;
+//
+    // Immutable default instance
+    final static OFBsnHybridGetReplyVer10 DEFAULT = new OFBsnHybridGetReplyVer10(
+        DEFAULT_XID, DEFAULT_HYBRID_ENABLE, DEFAULT_HYBRID_VERSION
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnHybridGetReplyVer10(long xid, short hybridEnable, int hybridVersion) {
+        this.xid = xid;
+        this.hybridEnable = hybridEnable;
+        this.hybridVersion = hybridVersion;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1cL;
+    }
+
+    @Override
+    public short getHybridEnable() {
+        return hybridEnable;
+    }
+
+    @Override
+    public int getHybridVersion() {
+        return hybridVersion;
+    }
+
+
+
+    public OFBsnHybridGetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnHybridGetReply.Builder {
+        final OFBsnHybridGetReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean hybridEnableSet;
+        private short hybridEnable;
+        private boolean hybridVersionSet;
+        private int hybridVersion;
+
+        BuilderWithParent(OFBsnHybridGetReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnHybridGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1cL;
+    }
+
+    @Override
+    public short getHybridEnable() {
+        return hybridEnable;
+    }
+
+    @Override
+    public OFBsnHybridGetReply.Builder setHybridEnable(short hybridEnable) {
+        this.hybridEnable = hybridEnable;
+        this.hybridEnableSet = true;
+        return this;
+    }
+    @Override
+    public int getHybridVersion() {
+        return hybridVersion;
+    }
+
+    @Override
+    public OFBsnHybridGetReply.Builder setHybridVersion(int hybridVersion) {
+        this.hybridVersion = hybridVersion;
+        this.hybridVersionSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnHybridGetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short hybridEnable = this.hybridEnableSet ? this.hybridEnable : parentMessage.hybridEnable;
+                int hybridVersion = this.hybridVersionSet ? this.hybridVersion : parentMessage.hybridVersion;
+
+                //
+                return new OFBsnHybridGetReplyVer10(
+                    xid,
+                    hybridEnable,
+                    hybridVersion
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnHybridGetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean hybridEnableSet;
+        private short hybridEnable;
+        private boolean hybridVersionSet;
+        private int hybridVersion;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnHybridGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1cL;
+    }
+
+    @Override
+    public short getHybridEnable() {
+        return hybridEnable;
+    }
+
+    @Override
+    public OFBsnHybridGetReply.Builder setHybridEnable(short hybridEnable) {
+        this.hybridEnable = hybridEnable;
+        this.hybridEnableSet = true;
+        return this;
+    }
+    @Override
+    public int getHybridVersion() {
+        return hybridVersion;
+    }
+
+    @Override
+    public OFBsnHybridGetReply.Builder setHybridVersion(int hybridVersion) {
+        this.hybridVersion = hybridVersion;
+        this.hybridVersionSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnHybridGetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short hybridEnable = this.hybridEnableSet ? this.hybridEnable : DEFAULT_HYBRID_ENABLE;
+            int hybridVersion = this.hybridVersionSet ? this.hybridVersion : DEFAULT_HYBRID_VERSION;
+
+
+            return new OFBsnHybridGetReplyVer10(
+                    xid,
+                    hybridEnable,
+                    hybridVersion
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnHybridGetReply> {
+        @Override
+        public OFBsnHybridGetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1cL
+            int subtype = bb.readInt();
+            if(subtype != 0x1c)
+                throw new OFParseError("Wrong subtype: Expected=0x1cL(0x1cL), got="+subtype);
+            short hybridEnable = U8.f(bb.readByte());
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int hybridVersion = U16.f(bb.readShort());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFBsnHybridGetReplyVer10 bsnHybridGetReplyVer10 = new OFBsnHybridGetReplyVer10(
+                    xid,
+                      hybridEnable,
+                      hybridVersion
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnHybridGetReplyVer10);
+            return bsnHybridGetReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnHybridGetReplyVer10Funnel FUNNEL = new OFBsnHybridGetReplyVer10Funnel();
+    static class OFBsnHybridGetReplyVer10Funnel implements Funnel<OFBsnHybridGetReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnHybridGetReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1cL
+            sink.putInt(0x1c);
+            sink.putShort(message.hybridEnable);
+            // skip pad (1 bytes)
+            sink.putInt(message.hybridVersion);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnHybridGetReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnHybridGetReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1cL
+            bb.writeInt(0x1c);
+            bb.writeByte(U8.t(message.hybridEnable));
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.hybridVersion));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnHybridGetReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("hybridEnable=").append(hybridEnable);
+        b.append(", ");
+        b.append("hybridVersion=").append(hybridVersion);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnHybridGetReplyVer10 other = (OFBsnHybridGetReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( hybridEnable != other.hybridEnable)
+            return false;
+        if( hybridVersion != other.hybridVersion)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + hybridEnable;
+        result = prime * result + hybridVersion;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHybridGetRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHybridGetRequestVer10.java
new file mode 100644
index 0000000..3282c8d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnHybridGetRequestVer10.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnHybridGetRequestVer10 implements OFBsnHybridGetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnHybridGetRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnHybridGetRequestVer10 DEFAULT = new OFBsnHybridGetRequestVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnHybridGetRequestVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1bL;
+    }
+
+
+
+    public OFBsnHybridGetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnHybridGetRequest.Builder {
+        final OFBsnHybridGetRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnHybridGetRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnHybridGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1bL;
+    }
+
+
+
+        @Override
+        public OFBsnHybridGetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnHybridGetRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnHybridGetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnHybridGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1bL;
+    }
+
+//
+        @Override
+        public OFBsnHybridGetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnHybridGetRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnHybridGetRequest> {
+        @Override
+        public OFBsnHybridGetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1bL
+            int subtype = bb.readInt();
+            if(subtype != 0x1b)
+                throw new OFParseError("Wrong subtype: Expected=0x1bL(0x1bL), got="+subtype);
+
+            OFBsnHybridGetRequestVer10 bsnHybridGetRequestVer10 = new OFBsnHybridGetRequestVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnHybridGetRequestVer10);
+            return bsnHybridGetRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnHybridGetRequestVer10Funnel FUNNEL = new OFBsnHybridGetRequestVer10Funnel();
+    static class OFBsnHybridGetRequestVer10Funnel implements Funnel<OFBsnHybridGetRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnHybridGetRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1bL
+            sink.putInt(0x1b);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnHybridGetRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnHybridGetRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1bL
+            bb.writeInt(0x1b);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnHybridGetRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnHybridGetRequestVer10 other = (OFBsnHybridGetRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnInterfaceVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnInterfaceVer10.java
new file mode 100644
index 0000000..19db624
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnInterfaceVer10.java
@@ -0,0 +1,396 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnInterfaceVer10 implements OFBsnInterface {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnInterfaceVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 32;
+
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static String DEFAULT_NAME = "";
+        private final static IPv4Address DEFAULT_IPV4_ADDR = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_IPV4_NETMASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final MacAddress hwAddr;
+    private final String name;
+    private final IPv4Address ipv4Addr;
+    private final IPv4Address ipv4Netmask;
+//
+    // Immutable default instance
+    final static OFBsnInterfaceVer10 DEFAULT = new OFBsnInterfaceVer10(
+        DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_IPV4_ADDR, DEFAULT_IPV4_NETMASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnInterfaceVer10(MacAddress hwAddr, String name, IPv4Address ipv4Addr, IPv4Address ipv4Netmask) {
+        this.hwAddr = hwAddr;
+        this.name = name;
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4Netmask = ipv4Netmask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFBsnInterface.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnInterface.Builder {
+        final OFBsnInterfaceVer10 parentMessage;
+
+        // OF message fields
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+        private boolean ipv4NetmaskSet;
+        private IPv4Address ipv4Netmask;
+
+        BuilderWithParent(OFBsnInterfaceVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) {
+        this.ipv4Netmask = ipv4Netmask;
+        this.ipv4NetmaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFBsnInterface build() {
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : parentMessage.ipv4Addr;
+                if(ipv4Addr == null)
+                    throw new NullPointerException("Property ipv4Addr must not be null");
+                IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : parentMessage.ipv4Netmask;
+                if(ipv4Netmask == null)
+                    throw new NullPointerException("Property ipv4Netmask must not be null");
+
+                //
+                return new OFBsnInterfaceVer10(
+                    hwAddr,
+                    name,
+                    ipv4Addr,
+                    ipv4Netmask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnInterface.Builder {
+        // OF message fields
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+        private boolean ipv4NetmaskSet;
+        private IPv4Address ipv4Netmask;
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) {
+        this.ipv4Netmask = ipv4Netmask;
+        this.ipv4NetmaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFBsnInterface build() {
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : DEFAULT_IPV4_ADDR;
+            if(ipv4Addr == null)
+                throw new NullPointerException("Property ipv4Addr must not be null");
+            IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : DEFAULT_IPV4_NETMASK;
+            if(ipv4Netmask == null)
+                throw new NullPointerException("Property ipv4Netmask must not be null");
+
+
+            return new OFBsnInterfaceVer10(
+                    hwAddr,
+                    name,
+                    ipv4Addr,
+                    ipv4Netmask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnInterface> {
+        @Override
+        public OFBsnInterface readFrom(ChannelBuffer bb) throws OFParseError {
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            String name = ChannelUtils.readFixedLengthString(bb, 16);
+            IPv4Address ipv4Addr = IPv4Address.read4Bytes(bb);
+            IPv4Address ipv4Netmask = IPv4Address.read4Bytes(bb);
+
+            OFBsnInterfaceVer10 bsnInterfaceVer10 = new OFBsnInterfaceVer10(
+                    hwAddr,
+                      name,
+                      ipv4Addr,
+                      ipv4Netmask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnInterfaceVer10);
+            return bsnInterfaceVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnInterfaceVer10Funnel FUNNEL = new OFBsnInterfaceVer10Funnel();
+    static class OFBsnInterfaceVer10Funnel implements Funnel<OFBsnInterfaceVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnInterfaceVer10 message, PrimitiveSink sink) {
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putUnencodedChars(message.name);
+            message.ipv4Addr.putTo(sink);
+            message.ipv4Netmask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnInterfaceVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnInterfaceVer10 message) {
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 16);
+            message.ipv4Addr.write4Bytes(bb);
+            message.ipv4Netmask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnInterfaceVer10(");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("ipv4Addr=").append(ipv4Addr);
+        b.append(", ");
+        b.append("ipv4Netmask=").append(ipv4Netmask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnInterfaceVer10 other = (OFBsnInterfaceVer10) obj;
+
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (ipv4Addr == null) {
+            if (other.ipv4Addr != null)
+                return false;
+        } else if (!ipv4Addr.equals(other.ipv4Addr))
+            return false;
+        if (ipv4Netmask == null) {
+            if (other.ipv4Netmask != null)
+                return false;
+        } else if (!ipv4Netmask.equals(other.ipv4Netmask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((ipv4Addr == null) ? 0 : ipv4Addr.hashCode());
+        result = prime * result + ((ipv4Netmask == null) ? 0 : ipv4Netmask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxReplyVer10.java
new file mode 100644
index 0000000..9d16d85
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxReplyVer10.java
@@ -0,0 +1,462 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduRxReplyVer10 implements OFBsnPduRxReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 23;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduRxReplyVer10 DEFAULT = new OFBsnPduRxReplyVer10(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxReplyVer10(long xid, long status, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduRxReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxReply.Builder {
+        final OFBsnPduRxReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduRxReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduRxReplyVer10(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduRxReplyVer10(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxReply> {
+        @Override
+        public OFBsnPduRxReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 23)
+                throw new OFParseError("Wrong length: Expected=23(23), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x22L
+            int subtype = bb.readInt();
+            if(subtype != 0x22)
+                throw new OFParseError("Wrong subtype: Expected=0x22L(0x22L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read2Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduRxReplyVer10 bsnPduRxReplyVer10 = new OFBsnPduRxReplyVer10(
+                    xid,
+                      status,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxReplyVer10);
+            return bsnPduRxReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxReplyVer10Funnel FUNNEL = new OFBsnPduRxReplyVer10Funnel();
+    static class OFBsnPduRxReplyVer10Funnel implements Funnel<OFBsnPduRxReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 23
+            sink.putShort((short) 0x17);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x22L
+            sink.putInt(0x22);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 23
+            bb.writeShort((short) 0x17);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x22L
+            bb.writeInt(0x22);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write2Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxReplyVer10 other = (OFBsnPduRxReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxRequestVer10.java
new file mode 100644
index 0000000..5f6a942
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxRequestVer10.java
@@ -0,0 +1,524 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnPduRxRequestVer10 implements OFBsnPduRxRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 26;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_TIMEOUT_MS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long timeoutMs;
+    private final OFPort portNo;
+    private final short slotNum;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnPduRxRequestVer10 DEFAULT = new OFBsnPduRxRequestVer10(
+        DEFAULT_XID, DEFAULT_TIMEOUT_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxRequestVer10(long xid, long timeoutMs, OFPort portNo, short slotNum, byte[] data) {
+        this.xid = xid;
+        this.timeoutMs = timeoutMs;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnPduRxRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxRequest.Builder {
+        final OFBsnPduRxRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeoutMsSet;
+        private long timeoutMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnPduRxRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setTimeoutMs(long timeoutMs) {
+        this.timeoutMs = timeoutMs;
+        this.timeoutMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long timeoutMs = this.timeoutMsSet ? this.timeoutMs : parentMessage.timeoutMs;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnPduRxRequestVer10(
+                    xid,
+                    timeoutMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeoutMsSet;
+        private long timeoutMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setTimeoutMs(long timeoutMs) {
+        this.timeoutMs = timeoutMs;
+        this.timeoutMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long timeoutMs = this.timeoutMsSet ? this.timeoutMs : DEFAULT_TIMEOUT_MS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnPduRxRequestVer10(
+                    xid,
+                    timeoutMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxRequest> {
+        @Override
+        public OFBsnPduRxRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x21L
+            int subtype = bb.readInt();
+            if(subtype != 0x21)
+                throw new OFParseError("Wrong subtype: Expected=0x21L(0x21L), got="+subtype);
+            long timeoutMs = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read2Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnPduRxRequestVer10 bsnPduRxRequestVer10 = new OFBsnPduRxRequestVer10(
+                    xid,
+                      timeoutMs,
+                      portNo,
+                      slotNum,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxRequestVer10);
+            return bsnPduRxRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxRequestVer10Funnel FUNNEL = new OFBsnPduRxRequestVer10Funnel();
+    static class OFBsnPduRxRequestVer10Funnel implements Funnel<OFBsnPduRxRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x21L
+            sink.putInt(0x21);
+            sink.putLong(message.timeoutMs);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+            // skip pad (3 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxRequestVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x21L
+            bb.writeInt(0x21);
+            bb.writeInt(U32.t(message.timeoutMs));
+            message.portNo.write2Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("timeoutMs=").append(timeoutMs);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxRequestVer10 other = (OFBsnPduRxRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( timeoutMs != other.timeoutMs)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (timeoutMs ^ (timeoutMs >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxTimeoutVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxTimeoutVer10.java
new file mode 100644
index 0000000..129b62a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduRxTimeoutVer10.java
@@ -0,0 +1,415 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduRxTimeoutVer10 implements OFBsnPduRxTimeout {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxTimeoutVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 19;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduRxTimeoutVer10 DEFAULT = new OFBsnPduRxTimeoutVer10(
+        DEFAULT_XID, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxTimeoutVer10(long xid, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduRxTimeout.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxTimeout.Builder {
+        final OFBsnPduRxTimeoutVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduRxTimeoutVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxTimeout build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduRxTimeoutVer10(
+                    xid,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxTimeout.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxTimeout build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduRxTimeoutVer10(
+                    xid,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxTimeout> {
+        @Override
+        public OFBsnPduRxTimeout readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 19)
+                throw new OFParseError("Wrong length: Expected=19(19), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x23L
+            int subtype = bb.readInt();
+            if(subtype != 0x23)
+                throw new OFParseError("Wrong subtype: Expected=0x23L(0x23L), got="+subtype);
+            OFPort portNo = OFPort.read2Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduRxTimeoutVer10 bsnPduRxTimeoutVer10 = new OFBsnPduRxTimeoutVer10(
+                    xid,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxTimeoutVer10);
+            return bsnPduRxTimeoutVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxTimeoutVer10Funnel FUNNEL = new OFBsnPduRxTimeoutVer10Funnel();
+    static class OFBsnPduRxTimeoutVer10Funnel implements Funnel<OFBsnPduRxTimeoutVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxTimeoutVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 19
+            sink.putShort((short) 0x13);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x23L
+            sink.putInt(0x23);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxTimeoutVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxTimeoutVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 19
+            bb.writeShort((short) 0x13);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x23L
+            bb.writeInt(0x23);
+            message.portNo.write2Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxTimeoutVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxTimeoutVer10 other = (OFBsnPduRxTimeoutVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduSlotNumTSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduSlotNumTSerializerVer10.java
new file mode 100644
index 0000000..3faf113
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduSlotNumTSerializerVer10.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnPduSlotNumT;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnPduSlotNumTSerializerVer10 {
+
+    public final static byte PDU_SLOT_NUM_ANY_VAL = (byte) 0xff;
+
+    public static OFBsnPduSlotNumT readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnPduSlotNumT e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnPduSlotNumT e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnPduSlotNumT ofWireValue(byte val) {
+        switch(val) {
+            case PDU_SLOT_NUM_ANY_VAL:
+                return OFBsnPduSlotNumT.PDU_SLOT_NUM_ANY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnPduSlotNumT in version 1.0: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnPduSlotNumT e) {
+        switch(e) {
+            case PDU_SLOT_NUM_ANY:
+                return PDU_SLOT_NUM_ANY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnPduSlotNumT in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduTxReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduTxReplyVer10.java
new file mode 100644
index 0000000..5bbf0da
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduTxReplyVer10.java
@@ -0,0 +1,462 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduTxReplyVer10 implements OFBsnPduTxReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 23;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduTxReplyVer10 DEFAULT = new OFBsnPduTxReplyVer10(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduTxReplyVer10(long xid, long status, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduTxReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduTxReply.Builder {
+        final OFBsnPduTxReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduTxReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduTxReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduTxReplyVer10(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduTxReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduTxReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduTxReplyVer10(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduTxReply> {
+        @Override
+        public OFBsnPduTxReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 23)
+                throw new OFParseError("Wrong length: Expected=23(23), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x20L
+            int subtype = bb.readInt();
+            if(subtype != 0x20)
+                throw new OFParseError("Wrong subtype: Expected=0x20L(0x20L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read2Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduTxReplyVer10 bsnPduTxReplyVer10 = new OFBsnPduTxReplyVer10(
+                    xid,
+                      status,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduTxReplyVer10);
+            return bsnPduTxReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduTxReplyVer10Funnel FUNNEL = new OFBsnPduTxReplyVer10Funnel();
+    static class OFBsnPduTxReplyVer10Funnel implements Funnel<OFBsnPduTxReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduTxReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 23
+            sink.putShort((short) 0x17);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x20L
+            sink.putInt(0x20);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduTxReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduTxReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 23
+            bb.writeShort((short) 0x17);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x20L
+            bb.writeInt(0x20);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write2Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduTxReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduTxReplyVer10 other = (OFBsnPduTxReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduTxRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduTxRequestVer10.java
new file mode 100644
index 0000000..2f85edb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnPduTxRequestVer10.java
@@ -0,0 +1,524 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnPduTxRequestVer10 implements OFBsnPduTxRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 26;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_TX_INTERVAL_MS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long txIntervalMs;
+    private final OFPort portNo;
+    private final short slotNum;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnPduTxRequestVer10 DEFAULT = new OFBsnPduTxRequestVer10(
+        DEFAULT_XID, DEFAULT_TX_INTERVAL_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduTxRequestVer10(long xid, long txIntervalMs, OFPort portNo, short slotNum, byte[] data) {
+        this.xid = xid;
+        this.txIntervalMs = txIntervalMs;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnPduTxRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduTxRequest.Builder {
+        final OFBsnPduTxRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean txIntervalMsSet;
+        private long txIntervalMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnPduTxRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) {
+        this.txIntervalMs = txIntervalMs;
+        this.txIntervalMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduTxRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : parentMessage.txIntervalMs;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnPduTxRequestVer10(
+                    xid,
+                    txIntervalMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduTxRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean txIntervalMsSet;
+        private long txIntervalMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) {
+        this.txIntervalMs = txIntervalMs;
+        this.txIntervalMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduTxRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : DEFAULT_TX_INTERVAL_MS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnPduTxRequestVer10(
+                    xid,
+                    txIntervalMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduTxRequest> {
+        @Override
+        public OFBsnPduTxRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1fL
+            int subtype = bb.readInt();
+            if(subtype != 0x1f)
+                throw new OFParseError("Wrong subtype: Expected=0x1fL(0x1fL), got="+subtype);
+            long txIntervalMs = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read2Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnPduTxRequestVer10 bsnPduTxRequestVer10 = new OFBsnPduTxRequestVer10(
+                    xid,
+                      txIntervalMs,
+                      portNo,
+                      slotNum,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduTxRequestVer10);
+            return bsnPduTxRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduTxRequestVer10Funnel FUNNEL = new OFBsnPduTxRequestVer10Funnel();
+    static class OFBsnPduTxRequestVer10Funnel implements Funnel<OFBsnPduTxRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduTxRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1fL
+            sink.putInt(0x1f);
+            sink.putLong(message.txIntervalMs);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+            // skip pad (3 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduTxRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduTxRequestVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1fL
+            bb.writeInt(0x1f);
+            bb.writeInt(U32.t(message.txIntervalMs));
+            message.portNo.write2Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduTxRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("txIntervalMs=").append(txIntervalMs);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduTxRequestVer10 other = (OFBsnPduTxRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( txIntervalMs != other.txIntervalMs)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (txIntervalMs ^ (txIntervalMs >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetIpMaskVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetIpMaskVer10.java
new file mode 100644
index 0000000..46ccc66
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetIpMaskVer10.java
@@ -0,0 +1,413 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetIpMaskVer10 implements OFBsnSetIpMask {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetIpMaskVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_INDEX = (short) 0x0;
+        private final static long DEFAULT_MASK = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final short index;
+    private final long mask;
+//
+    // Immutable default instance
+    final static OFBsnSetIpMaskVer10 DEFAULT = new OFBsnSetIpMaskVer10(
+        DEFAULT_XID, DEFAULT_INDEX, DEFAULT_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetIpMaskVer10(long xid, short index, long mask) {
+        this.xid = xid;
+        this.index = index;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x0L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+
+
+    public OFBsnSetIpMask.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetIpMask.Builder {
+        final OFBsnSetIpMaskVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean indexSet;
+        private short index;
+        private boolean maskSet;
+        private long mask;
+
+        BuilderWithParent(OFBsnSetIpMaskVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetIpMask.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x0L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+    @Override
+    public OFBsnSetIpMask.Builder setIndex(short index) {
+        this.index = index;
+        this.indexSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFBsnSetIpMask.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetIpMask build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short index = this.indexSet ? this.index : parentMessage.index;
+                long mask = this.maskSet ? this.mask : parentMessage.mask;
+
+                //
+                return new OFBsnSetIpMaskVer10(
+                    xid,
+                    index,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetIpMask.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean indexSet;
+        private short index;
+        private boolean maskSet;
+        private long mask;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetIpMask.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x0L;
+    }
+
+    @Override
+    public short getIndex() {
+        return index;
+    }
+
+    @Override
+    public OFBsnSetIpMask.Builder setIndex(short index) {
+        this.index = index;
+        this.indexSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFBsnSetIpMask.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetIpMask build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short index = this.indexSet ? this.index : DEFAULT_INDEX;
+            long mask = this.maskSet ? this.mask : DEFAULT_MASK;
+
+
+            return new OFBsnSetIpMaskVer10(
+                    xid,
+                    index,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetIpMask> {
+        @Override
+        public OFBsnSetIpMask readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x0L
+            int subtype = bb.readInt();
+            if(subtype != 0x0)
+                throw new OFParseError("Wrong subtype: Expected=0x0L(0x0L), got="+subtype);
+            short index = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            long mask = U32.f(bb.readInt());
+
+            OFBsnSetIpMaskVer10 bsnSetIpMaskVer10 = new OFBsnSetIpMaskVer10(
+                    xid,
+                      index,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetIpMaskVer10);
+            return bsnSetIpMaskVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetIpMaskVer10Funnel FUNNEL = new OFBsnSetIpMaskVer10Funnel();
+    static class OFBsnSetIpMaskVer10Funnel implements Funnel<OFBsnSetIpMaskVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetIpMaskVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x0L
+            sink.putInt(0x0);
+            sink.putShort(message.index);
+            // skip pad (3 bytes)
+            sink.putLong(message.mask);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetIpMaskVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetIpMaskVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x0L
+            bb.writeInt(0x0);
+            bb.writeByte(U8.t(message.index));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeInt(U32.t(message.mask));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetIpMaskVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("index=").append(index);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetIpMaskVer10 other = (OFBsnSetIpMaskVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( index != other.index)
+            return false;
+        if( mask != other.mask)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + index;
+        result = prime *  (int) (mask ^ (mask >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetL2TableReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetL2TableReplyVer10.java
new file mode 100644
index 0000000..2f93768
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetL2TableReplyVer10.java
@@ -0,0 +1,460 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetL2TableReplyVer10 implements OFBsnSetL2TableReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetL2TableReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static boolean DEFAULT_L2_TABLE_ENABLE = false;
+        private final static int DEFAULT_L2_TABLE_PRIORITY = 0x0;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final boolean l2TableEnable;
+    private final int l2TablePriority;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnSetL2TableReplyVer10 DEFAULT = new OFBsnSetL2TableReplyVer10(
+        DEFAULT_XID, DEFAULT_L2_TABLE_ENABLE, DEFAULT_L2_TABLE_PRIORITY, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetL2TableReplyVer10(long xid, boolean l2TableEnable, int l2TablePriority, long status) {
+        this.xid = xid;
+        this.l2TableEnable = l2TableEnable;
+        this.l2TablePriority = l2TablePriority;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x18L;
+    }
+
+    @Override
+    public boolean isL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnSetL2TableReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetL2TableReply.Builder {
+        final OFBsnSetL2TableReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean l2TableEnableSet;
+        private boolean l2TableEnable;
+        private boolean l2TablePrioritySet;
+        private int l2TablePriority;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnSetL2TableReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetL2TableReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x18L;
+    }
+
+    @Override
+    public boolean isL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public OFBsnSetL2TableReply.Builder setL2TableEnable(boolean l2TableEnable) {
+        this.l2TableEnable = l2TableEnable;
+        this.l2TableEnableSet = true;
+        return this;
+    }
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+    @Override
+    public OFBsnSetL2TableReply.Builder setL2TablePriority(int l2TablePriority) {
+        this.l2TablePriority = l2TablePriority;
+        this.l2TablePrioritySet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetL2TableReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetL2TableReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                boolean l2TableEnable = this.l2TableEnableSet ? this.l2TableEnable : parentMessage.l2TableEnable;
+                int l2TablePriority = this.l2TablePrioritySet ? this.l2TablePriority : parentMessage.l2TablePriority;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnSetL2TableReplyVer10(
+                    xid,
+                    l2TableEnable,
+                    l2TablePriority,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetL2TableReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean l2TableEnableSet;
+        private boolean l2TableEnable;
+        private boolean l2TablePrioritySet;
+        private int l2TablePriority;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetL2TableReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x18L;
+    }
+
+    @Override
+    public boolean isL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public OFBsnSetL2TableReply.Builder setL2TableEnable(boolean l2TableEnable) {
+        this.l2TableEnable = l2TableEnable;
+        this.l2TableEnableSet = true;
+        return this;
+    }
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+    @Override
+    public OFBsnSetL2TableReply.Builder setL2TablePriority(int l2TablePriority) {
+        this.l2TablePriority = l2TablePriority;
+        this.l2TablePrioritySet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetL2TableReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetL2TableReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            boolean l2TableEnable = this.l2TableEnableSet ? this.l2TableEnable : DEFAULT_L2_TABLE_ENABLE;
+            int l2TablePriority = this.l2TablePrioritySet ? this.l2TablePriority : DEFAULT_L2_TABLE_PRIORITY;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnSetL2TableReplyVer10(
+                    xid,
+                    l2TableEnable,
+                    l2TablePriority,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetL2TableReply> {
+        @Override
+        public OFBsnSetL2TableReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x18L
+            int subtype = bb.readInt();
+            if(subtype != 0x18)
+                throw new OFParseError("Wrong subtype: Expected=0x18L(0x18L), got="+subtype);
+            boolean l2TableEnable = (bb.readByte() != 0);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int l2TablePriority = U16.f(bb.readShort());
+            long status = U32.f(bb.readInt());
+
+            OFBsnSetL2TableReplyVer10 bsnSetL2TableReplyVer10 = new OFBsnSetL2TableReplyVer10(
+                    xid,
+                      l2TableEnable,
+                      l2TablePriority,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetL2TableReplyVer10);
+            return bsnSetL2TableReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetL2TableReplyVer10Funnel FUNNEL = new OFBsnSetL2TableReplyVer10Funnel();
+    static class OFBsnSetL2TableReplyVer10Funnel implements Funnel<OFBsnSetL2TableReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetL2TableReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x18L
+            sink.putInt(0x18);
+            sink.putBoolean(message.l2TableEnable);
+            // skip pad (1 bytes)
+            sink.putInt(message.l2TablePriority);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetL2TableReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetL2TableReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x18L
+            bb.writeInt(0x18);
+            bb.writeByte(message.l2TableEnable ? 1 : 0);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.l2TablePriority));
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetL2TableReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("l2TableEnable=").append(l2TableEnable);
+        b.append(", ");
+        b.append("l2TablePriority=").append(l2TablePriority);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetL2TableReplyVer10 other = (OFBsnSetL2TableReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( l2TableEnable != other.l2TableEnable)
+            return false;
+        if( l2TablePriority != other.l2TablePriority)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + (l2TableEnable ? 1231 : 1237);
+        result = prime * result + l2TablePriority;
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetL2TableRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetL2TableRequestVer10.java
new file mode 100644
index 0000000..dbc6dea
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetL2TableRequestVer10.java
@@ -0,0 +1,418 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetL2TableRequestVer10 implements OFBsnSetL2TableRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetL2TableRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static boolean DEFAULT_L2_TABLE_ENABLE = false;
+        private final static int DEFAULT_L2_TABLE_PRIORITY = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final boolean l2TableEnable;
+    private final int l2TablePriority;
+//
+    // Immutable default instance
+    final static OFBsnSetL2TableRequestVer10 DEFAULT = new OFBsnSetL2TableRequestVer10(
+        DEFAULT_XID, DEFAULT_L2_TABLE_ENABLE, DEFAULT_L2_TABLE_PRIORITY
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetL2TableRequestVer10(long xid, boolean l2TableEnable, int l2TablePriority) {
+        this.xid = xid;
+        this.l2TableEnable = l2TableEnable;
+        this.l2TablePriority = l2TablePriority;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+    @Override
+    public boolean isL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+
+
+    public OFBsnSetL2TableRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetL2TableRequest.Builder {
+        final OFBsnSetL2TableRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean l2TableEnableSet;
+        private boolean l2TableEnable;
+        private boolean l2TablePrioritySet;
+        private int l2TablePriority;
+
+        BuilderWithParent(OFBsnSetL2TableRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetL2TableRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+    @Override
+    public boolean isL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public OFBsnSetL2TableRequest.Builder setL2TableEnable(boolean l2TableEnable) {
+        this.l2TableEnable = l2TableEnable;
+        this.l2TableEnableSet = true;
+        return this;
+    }
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+    @Override
+    public OFBsnSetL2TableRequest.Builder setL2TablePriority(int l2TablePriority) {
+        this.l2TablePriority = l2TablePriority;
+        this.l2TablePrioritySet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetL2TableRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                boolean l2TableEnable = this.l2TableEnableSet ? this.l2TableEnable : parentMessage.l2TableEnable;
+                int l2TablePriority = this.l2TablePrioritySet ? this.l2TablePriority : parentMessage.l2TablePriority;
+
+                //
+                return new OFBsnSetL2TableRequestVer10(
+                    xid,
+                    l2TableEnable,
+                    l2TablePriority
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetL2TableRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean l2TableEnableSet;
+        private boolean l2TableEnable;
+        private boolean l2TablePrioritySet;
+        private int l2TablePriority;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetL2TableRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+    @Override
+    public boolean isL2TableEnable() {
+        return l2TableEnable;
+    }
+
+    @Override
+    public OFBsnSetL2TableRequest.Builder setL2TableEnable(boolean l2TableEnable) {
+        this.l2TableEnable = l2TableEnable;
+        this.l2TableEnableSet = true;
+        return this;
+    }
+    @Override
+    public int getL2TablePriority() {
+        return l2TablePriority;
+    }
+
+    @Override
+    public OFBsnSetL2TableRequest.Builder setL2TablePriority(int l2TablePriority) {
+        this.l2TablePriority = l2TablePriority;
+        this.l2TablePrioritySet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetL2TableRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            boolean l2TableEnable = this.l2TableEnableSet ? this.l2TableEnable : DEFAULT_L2_TABLE_ENABLE;
+            int l2TablePriority = this.l2TablePrioritySet ? this.l2TablePriority : DEFAULT_L2_TABLE_PRIORITY;
+
+
+            return new OFBsnSetL2TableRequestVer10(
+                    xid,
+                    l2TableEnable,
+                    l2TablePriority
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetL2TableRequest> {
+        @Override
+        public OFBsnSetL2TableRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xcL
+            int subtype = bb.readInt();
+            if(subtype != 0xc)
+                throw new OFParseError("Wrong subtype: Expected=0xcL(0xcL), got="+subtype);
+            boolean l2TableEnable = (bb.readByte() != 0);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int l2TablePriority = U16.f(bb.readShort());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFBsnSetL2TableRequestVer10 bsnSetL2TableRequestVer10 = new OFBsnSetL2TableRequestVer10(
+                    xid,
+                      l2TableEnable,
+                      l2TablePriority
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetL2TableRequestVer10);
+            return bsnSetL2TableRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetL2TableRequestVer10Funnel FUNNEL = new OFBsnSetL2TableRequestVer10Funnel();
+    static class OFBsnSetL2TableRequestVer10Funnel implements Funnel<OFBsnSetL2TableRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetL2TableRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xcL
+            sink.putInt(0xc);
+            sink.putBoolean(message.l2TableEnable);
+            // skip pad (1 bytes)
+            sink.putInt(message.l2TablePriority);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetL2TableRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetL2TableRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xcL
+            bb.writeInt(0xc);
+            bb.writeByte(message.l2TableEnable ? 1 : 0);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.l2TablePriority));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetL2TableRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("l2TableEnable=").append(l2TableEnable);
+        b.append(", ");
+        b.append("l2TablePriority=").append(l2TablePriority);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetL2TableRequestVer10 other = (OFBsnSetL2TableRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( l2TableEnable != other.l2TableEnable)
+            return false;
+        if( l2TablePriority != other.l2TablePriority)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + (l2TableEnable ? 1231 : 1237);
+        result = prime * result + l2TablePriority;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetMirroringVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetMirroringVer10.java
new file mode 100644
index 0000000..cb71dd5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetMirroringVer10.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetMirroringVer10 implements OFBsnSetMirroring {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetMirroringVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnSetMirroringVer10 DEFAULT = new OFBsnSetMirroringVer10(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetMirroringVer10(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnSetMirroring.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetMirroring.Builder {
+        final OFBsnSetMirroringVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnSetMirroringVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetMirroring build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnSetMirroringVer10(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetMirroring.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetMirroring build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnSetMirroringVer10(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetMirroring> {
+        @Override
+        public OFBsnSetMirroring readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3L
+            int subtype = bb.readInt();
+            if(subtype != 0x3)
+                throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnSetMirroringVer10 bsnSetMirroringVer10 = new OFBsnSetMirroringVer10(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetMirroringVer10);
+            return bsnSetMirroringVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetMirroringVer10Funnel FUNNEL = new OFBsnSetMirroringVer10Funnel();
+    static class OFBsnSetMirroringVer10Funnel implements Funnel<OFBsnSetMirroringVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetMirroringVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            sink.putInt(0x3);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetMirroringVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetMirroringVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            bb.writeInt(0x3);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetMirroringVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetMirroringVer10 other = (OFBsnSetMirroringVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetPktinSuppressionReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetPktinSuppressionReplyVer10.java
new file mode 100644
index 0000000..7791761
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetPktinSuppressionReplyVer10.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetPktinSuppressionReplyVer10 implements OFBsnSetPktinSuppressionReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetPktinSuppressionReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnSetPktinSuppressionReplyVer10 DEFAULT = new OFBsnSetPktinSuppressionReplyVer10(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetPktinSuppressionReplyVer10(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnSetPktinSuppressionReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetPktinSuppressionReply.Builder {
+        final OFBsnSetPktinSuppressionReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnSetPktinSuppressionReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetPktinSuppressionReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnSetPktinSuppressionReplyVer10(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetPktinSuppressionReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetPktinSuppressionReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnSetPktinSuppressionReplyVer10(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetPktinSuppressionReply> {
+        @Override
+        public OFBsnSetPktinSuppressionReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x19L
+            int subtype = bb.readInt();
+            if(subtype != 0x19)
+                throw new OFParseError("Wrong subtype: Expected=0x19L(0x19L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnSetPktinSuppressionReplyVer10 bsnSetPktinSuppressionReplyVer10 = new OFBsnSetPktinSuppressionReplyVer10(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetPktinSuppressionReplyVer10);
+            return bsnSetPktinSuppressionReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetPktinSuppressionReplyVer10Funnel FUNNEL = new OFBsnSetPktinSuppressionReplyVer10Funnel();
+    static class OFBsnSetPktinSuppressionReplyVer10Funnel implements Funnel<OFBsnSetPktinSuppressionReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetPktinSuppressionReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x19L
+            sink.putInt(0x19);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetPktinSuppressionReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetPktinSuppressionReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x19L
+            bb.writeInt(0x19);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetPktinSuppressionReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetPktinSuppressionReplyVer10 other = (OFBsnSetPktinSuppressionReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetPktinSuppressionRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetPktinSuppressionRequestVer10.java
new file mode 100644
index 0000000..758af8d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnSetPktinSuppressionRequestVer10.java
@@ -0,0 +1,561 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetPktinSuppressionRequestVer10 implements OFBsnSetPktinSuppressionRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetPktinSuppressionRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static boolean DEFAULT_ENABLED = false;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final boolean enabled;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final U64 cookie;
+//
+    // Immutable default instance
+    final static OFBsnSetPktinSuppressionRequestVer10 DEFAULT = new OFBsnSetPktinSuppressionRequestVer10(
+        DEFAULT_XID, DEFAULT_ENABLED, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_COOKIE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetPktinSuppressionRequestVer10(long xid, boolean enabled, int idleTimeout, int hardTimeout, int priority, U64 cookie) {
+        this.xid = xid;
+        this.enabled = enabled;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.cookie = cookie;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+
+
+    public OFBsnSetPktinSuppressionRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetPktinSuppressionRequest.Builder {
+        final OFBsnSetPktinSuppressionRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private boolean enabled;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean cookieSet;
+        private U64 cookie;
+
+        BuilderWithParent(OFBsnSetPktinSuppressionRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setEnabled(boolean enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetPktinSuppressionRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                boolean enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+
+                //
+                return new OFBsnSetPktinSuppressionRequestVer10(
+                    xid,
+                    enabled,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    cookie
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetPktinSuppressionRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private boolean enabled;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean cookieSet;
+        private U64 cookie;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setEnabled(boolean enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetPktinSuppressionRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            boolean enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+
+
+            return new OFBsnSetPktinSuppressionRequestVer10(
+                    xid,
+                    enabled,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    cookie
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetPktinSuppressionRequest> {
+        @Override
+        public OFBsnSetPktinSuppressionRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xbL
+            int subtype = bb.readInt();
+            if(subtype != 0xb)
+                throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got="+subtype);
+            boolean enabled = (bb.readByte() != 0);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            U64 cookie = U64.ofRaw(bb.readLong());
+
+            OFBsnSetPktinSuppressionRequestVer10 bsnSetPktinSuppressionRequestVer10 = new OFBsnSetPktinSuppressionRequestVer10(
+                    xid,
+                      enabled,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      cookie
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetPktinSuppressionRequestVer10);
+            return bsnSetPktinSuppressionRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetPktinSuppressionRequestVer10Funnel FUNNEL = new OFBsnSetPktinSuppressionRequestVer10Funnel();
+    static class OFBsnSetPktinSuppressionRequestVer10Funnel implements Funnel<OFBsnSetPktinSuppressionRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetPktinSuppressionRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            sink.putInt(0xb);
+            sink.putBoolean(message.enabled);
+            // skip pad (1 bytes)
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.cookie.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetPktinSuppressionRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetPktinSuppressionRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            bb.writeInt(0xb);
+            bb.writeByte(message.enabled ? 1 : 0);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeLong(message.cookie.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetPktinSuppressionRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetPktinSuppressionRequestVer10 other = (OFBsnSetPktinSuppressionRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + (enabled ? 1231 : 1237);
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellCommandVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellCommandVer10.java
new file mode 100644
index 0000000..a6a04cb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellCommandVer10.java
@@ -0,0 +1,418 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnShellCommandVer10 implements OFBsnShellCommand {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnShellCommandVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_SERVICE = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long service;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnShellCommandVer10 DEFAULT = new OFBsnShellCommandVer10(
+        DEFAULT_XID, DEFAULT_SERVICE, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnShellCommandVer10(long xid, long service, byte[] data) {
+        this.xid = xid;
+        this.service = service;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+    @Override
+    public long getService() {
+        return service;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnShellCommand.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnShellCommand.Builder {
+        final OFBsnShellCommandVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean serviceSet;
+        private long service;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnShellCommandVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnShellCommand.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+    @Override
+    public long getService() {
+        return service;
+    }
+
+    @Override
+    public OFBsnShellCommand.Builder setService(long service) {
+        this.service = service;
+        this.serviceSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnShellCommand.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnShellCommand build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long service = this.serviceSet ? this.service : parentMessage.service;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnShellCommandVer10(
+                    xid,
+                    service,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnShellCommand.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean serviceSet;
+        private long service;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnShellCommand.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+    @Override
+    public long getService() {
+        return service;
+    }
+
+    @Override
+    public OFBsnShellCommand.Builder setService(long service) {
+        this.service = service;
+        this.serviceSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnShellCommand.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnShellCommand build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long service = this.serviceSet ? this.service : DEFAULT_SERVICE;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnShellCommandVer10(
+                    xid,
+                    service,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnShellCommand> {
+        @Override
+        public OFBsnShellCommand readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x6L
+            int subtype = bb.readInt();
+            if(subtype != 0x6)
+                throw new OFParseError("Wrong subtype: Expected=0x6L(0x6L), got="+subtype);
+            long service = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnShellCommandVer10 bsnShellCommandVer10 = new OFBsnShellCommandVer10(
+                    xid,
+                      service,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnShellCommandVer10);
+            return bsnShellCommandVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnShellCommandVer10Funnel FUNNEL = new OFBsnShellCommandVer10Funnel();
+    static class OFBsnShellCommandVer10Funnel implements Funnel<OFBsnShellCommandVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnShellCommandVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            sink.putInt(0x6);
+            sink.putLong(message.service);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnShellCommandVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnShellCommandVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            bb.writeInt(0x6);
+            bb.writeInt(U32.t(message.service));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnShellCommandVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("service=").append(service);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnShellCommandVer10 other = (OFBsnShellCommandVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( service != other.service)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (service ^ (service >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellOutputVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellOutputVer10.java
new file mode 100644
index 0000000..54e7951
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellOutputVer10.java
@@ -0,0 +1,371 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnShellOutputVer10 implements OFBsnShellOutput {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnShellOutputVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnShellOutputVer10 DEFAULT = new OFBsnShellOutputVer10(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnShellOutputVer10(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnShellOutput.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnShellOutput.Builder {
+        final OFBsnShellOutputVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnShellOutputVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnShellOutput.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnShellOutput.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnShellOutput build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnShellOutputVer10(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnShellOutput.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnShellOutput.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnShellOutput.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnShellOutput build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnShellOutputVer10(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnShellOutput> {
+        @Override
+        public OFBsnShellOutput readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x7L
+            int subtype = bb.readInt();
+            if(subtype != 0x7)
+                throw new OFParseError("Wrong subtype: Expected=0x7L(0x7L), got="+subtype);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnShellOutputVer10 bsnShellOutputVer10 = new OFBsnShellOutputVer10(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnShellOutputVer10);
+            return bsnShellOutputVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnShellOutputVer10Funnel FUNNEL = new OFBsnShellOutputVer10Funnel();
+    static class OFBsnShellOutputVer10Funnel implements Funnel<OFBsnShellOutputVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnShellOutputVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            sink.putInt(0x7);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnShellOutputVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnShellOutputVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            bb.writeInt(0x7);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnShellOutputVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnShellOutputVer10 other = (OFBsnShellOutputVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellStatusVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellStatusVer10.java
new file mode 100644
index 0000000..13189de
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnShellStatusVer10.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnShellStatusVer10 implements OFBsnShellStatus {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnShellStatusVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnShellStatusVer10 DEFAULT = new OFBsnShellStatusVer10(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnShellStatusVer10(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnShellStatus.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnShellStatus.Builder {
+        final OFBsnShellStatusVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnShellStatusVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnShellStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnShellStatus.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnShellStatus build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnShellStatusVer10(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnShellStatus.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnShellStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnShellStatus.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnShellStatus build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnShellStatusVer10(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnShellStatus> {
+        @Override
+        public OFBsnShellStatus readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x8L
+            int subtype = bb.readInt();
+            if(subtype != 0x8)
+                throw new OFParseError("Wrong subtype: Expected=0x8L(0x8L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnShellStatusVer10 bsnShellStatusVer10 = new OFBsnShellStatusVer10(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnShellStatusVer10);
+            return bsnShellStatusVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnShellStatusVer10Funnel FUNNEL = new OFBsnShellStatusVer10Funnel();
+    static class OFBsnShellStatusVer10Funnel implements Funnel<OFBsnShellStatusVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnShellStatusVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            sink.putInt(0x8);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnShellStatusVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnShellStatusVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            bb.writeInt(0x8);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnShellStatusVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnShellStatusVer10 other = (OFBsnShellStatusVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnStatsReplyVer10.java
new file mode 100644
index 0000000..5dc77e8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnStatsReplyVer10.java
@@ -0,0 +1,73 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnStatsReplyVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFBsnStatsReplyVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnStatsReply> {
+        @Override
+        public OFBsnStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsReplyFlagsSerializerVer10.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnStatsReplyVer10: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnStatsRequestVer10.java
new file mode 100644
index 0000000..197a732
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnStatsRequestVer10.java
@@ -0,0 +1,73 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnStatsRequestVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFBsnStatsRequestVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnStatsRequest<?>> {
+        @Override
+        public OFBsnStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsRequestFlagsSerializerVer10.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnStatsRequestVer10: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnTlvsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnTlvsVer10.java
new file mode 100644
index 0000000..7375e41
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnTlvsVer10.java
@@ -0,0 +1,200 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFBsnTlvsVer10 implements OFBsnTlvs {
+    public final static OFBsnTlvsVer10 INSTANCE = new OFBsnTlvsVer10();
+
+
+
+
+    public OFBsnTlvBroadcastQueryTimeout.Builder buildBroadcastQueryTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvBroadcastQueryTimeout not supported in version 1.0");
+    }
+    public OFBsnTlvBroadcastQueryTimeout broadcastQueryTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvBroadcastQueryTimeout not supported in version 1.0");
+    }
+
+    public OFBsnTlvCircuitId.Builder buildCircuitId() {
+        throw new UnsupportedOperationException("OFBsnTlvCircuitId not supported in version 1.0");
+    }
+    public OFBsnTlvCircuitId circuitId(byte[] value) {
+        throw new UnsupportedOperationException("OFBsnTlvCircuitId not supported in version 1.0");
+    }
+
+    public OFBsnTlvCrcEnabled.Builder buildCrcEnabled() {
+        throw new UnsupportedOperationException("OFBsnTlvCrcEnabled not supported in version 1.0");
+    }
+    public OFBsnTlvCrcEnabled crcEnabled(short value) {
+        throw new UnsupportedOperationException("OFBsnTlvCrcEnabled not supported in version 1.0");
+    }
+
+    public OFBsnTlvIdleNotification idleNotification() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleNotification not supported in version 1.0");
+    }
+
+    public OFBsnTlvIdleTime.Builder buildIdleTime() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTime not supported in version 1.0");
+    }
+    public OFBsnTlvIdleTime idleTime(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTime not supported in version 1.0");
+    }
+
+    public OFBsnTlvIdleTimeout.Builder buildIdleTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTimeout not supported in version 1.0");
+    }
+    public OFBsnTlvIdleTimeout idleTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTimeout not supported in version 1.0");
+    }
+
+    public OFBsnTlvIpv4.Builder buildIpv4() {
+        throw new UnsupportedOperationException("OFBsnTlvIpv4 not supported in version 1.0");
+    }
+    public OFBsnTlvIpv4 ipv4(IPv4Address value) {
+        throw new UnsupportedOperationException("OFBsnTlvIpv4 not supported in version 1.0");
+    }
+
+    public OFBsnTlvMac.Builder buildMac() {
+        throw new UnsupportedOperationException("OFBsnTlvMac not supported in version 1.0");
+    }
+    public OFBsnTlvMac mac(MacAddress value) {
+        throw new UnsupportedOperationException("OFBsnTlvMac not supported in version 1.0");
+    }
+
+    public OFBsnTlvMissPackets.Builder buildMissPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvMissPackets not supported in version 1.0");
+    }
+    public OFBsnTlvMissPackets missPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvMissPackets not supported in version 1.0");
+    }
+
+    public OFBsnTlvPort.Builder buildPort() {
+        throw new UnsupportedOperationException("OFBsnTlvPort not supported in version 1.0");
+    }
+    public OFBsnTlvPort port(OFPort value) {
+        throw new UnsupportedOperationException("OFBsnTlvPort not supported in version 1.0");
+    }
+
+    public OFBsnTlvQueueId.Builder buildQueueId() {
+        throw new UnsupportedOperationException("OFBsnTlvQueueId not supported in version 1.0");
+    }
+    public OFBsnTlvQueueId queueId(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvQueueId not supported in version 1.0");
+    }
+
+    public OFBsnTlvQueueWeight.Builder buildQueueWeight() {
+        throw new UnsupportedOperationException("OFBsnTlvQueueWeight not supported in version 1.0");
+    }
+    public OFBsnTlvQueueWeight queueWeight(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvQueueWeight not supported in version 1.0");
+    }
+
+    public OFBsnTlvReplyPackets.Builder buildReplyPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvReplyPackets not supported in version 1.0");
+    }
+    public OFBsnTlvReplyPackets replyPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvReplyPackets not supported in version 1.0");
+    }
+
+    public OFBsnTlvRequestPackets.Builder buildRequestPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvRequestPackets not supported in version 1.0");
+    }
+    public OFBsnTlvRequestPackets requestPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvRequestPackets not supported in version 1.0");
+    }
+
+    public OFBsnTlvRxPackets.Builder buildRxPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvRxPackets not supported in version 1.0");
+    }
+    public OFBsnTlvRxPackets rxPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvRxPackets not supported in version 1.0");
+    }
+
+    public OFBsnTlvTxPackets.Builder buildTxPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvTxPackets not supported in version 1.0");
+    }
+    public OFBsnTlvTxPackets txPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvTxPackets not supported in version 1.0");
+    }
+
+    public OFBsnTlvUdfAnchor.Builder buildUdfAnchor() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfAnchor not supported in version 1.0");
+    }
+    public OFBsnTlvUdfAnchor udfAnchor(OFBsnUdfAnchor value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfAnchor not supported in version 1.0");
+    }
+
+    public OFBsnTlvUdfId.Builder buildUdfId() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfId not supported in version 1.0");
+    }
+    public OFBsnTlvUdfId udfId(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfId not supported in version 1.0");
+    }
+
+    public OFBsnTlvUdfLength.Builder buildUdfLength() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfLength not supported in version 1.0");
+    }
+    public OFBsnTlvUdfLength udfLength(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfLength not supported in version 1.0");
+    }
+
+    public OFBsnTlvUdfOffset.Builder buildUdfOffset() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfOffset not supported in version 1.0");
+    }
+    public OFBsnTlvUdfOffset udfOffset(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfOffset not supported in version 1.0");
+    }
+
+    public OFBsnTlvUnicastQueryTimeout.Builder buildUnicastQueryTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvUnicastQueryTimeout not supported in version 1.0");
+    }
+    public OFBsnTlvUnicastQueryTimeout unicastQueryTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvUnicastQueryTimeout not supported in version 1.0");
+    }
+
+    public OFBsnTlvVlanVid.Builder buildVlanVid() {
+        throw new UnsupportedOperationException("OFBsnTlvVlanVid not supported in version 1.0");
+    }
+    public OFBsnTlvVlanVid vlanVid(VlanVid value) {
+        throw new UnsupportedOperationException("OFBsnTlvVlanVid not supported in version 1.0");
+    }
+
+    public OFBsnTlvVrf.Builder buildVrf() {
+        throw new UnsupportedOperationException("OFBsnTlvVrf not supported in version 1.0");
+    }
+    public OFBsnTlvVrf vrf(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvVrf not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFBsnTlv> getReader() {
+        throw new UnsupportedOperationException("Reader<OFBsnTlv> not supported in version 1.0");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortCreateReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortCreateReplyVer10.java
new file mode 100644
index 0000000..1256b9c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortCreateReplyVer10.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortCreateReplyVer10 implements OFBsnVirtualPortCreateReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortCreateReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static long DEFAULT_VPORT_NO = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final long vportNo;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortCreateReplyVer10 DEFAULT = new OFBsnVirtualPortCreateReplyVer10(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_VPORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortCreateReplyVer10(long xid, long status, long vportNo) {
+        this.xid = xid;
+        this.status = status;
+        this.vportNo = vportNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+
+
+    public OFBsnVirtualPortCreateReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortCreateReply.Builder {
+        final OFBsnVirtualPortCreateReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean vportNoSet;
+        private long vportNo;
+
+        BuilderWithParent(OFBsnVirtualPortCreateReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortCreateReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                long vportNo = this.vportNoSet ? this.vportNo : parentMessage.vportNo;
+
+                //
+                return new OFBsnVirtualPortCreateReplyVer10(
+                    xid,
+                    status,
+                    vportNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortCreateReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean vportNoSet;
+        private long vportNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortCreateReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            long vportNo = this.vportNoSet ? this.vportNo : DEFAULT_VPORT_NO;
+
+
+            return new OFBsnVirtualPortCreateReplyVer10(
+                    xid,
+                    status,
+                    vportNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortCreateReply> {
+        @Override
+        public OFBsnVirtualPortCreateReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x10L
+            int subtype = bb.readInt();
+            if(subtype != 0x10)
+                throw new OFParseError("Wrong subtype: Expected=0x10L(0x10L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            long vportNo = U32.f(bb.readInt());
+
+            OFBsnVirtualPortCreateReplyVer10 bsnVirtualPortCreateReplyVer10 = new OFBsnVirtualPortCreateReplyVer10(
+                    xid,
+                      status,
+                      vportNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortCreateReplyVer10);
+            return bsnVirtualPortCreateReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortCreateReplyVer10Funnel FUNNEL = new OFBsnVirtualPortCreateReplyVer10Funnel();
+    static class OFBsnVirtualPortCreateReplyVer10Funnel implements Funnel<OFBsnVirtualPortCreateReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortCreateReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x10L
+            sink.putInt(0x10);
+            sink.putLong(message.status);
+            sink.putLong(message.vportNo);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortCreateReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortCreateReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x10L
+            bb.writeInt(0x10);
+            bb.writeInt(U32.t(message.status));
+            bb.writeInt(U32.t(message.vportNo));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortCreateReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("vportNo=").append(vportNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortCreateReplyVer10 other = (OFBsnVirtualPortCreateReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if( vportNo != other.vportNo)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime *  (int) (vportNo ^ (vportNo >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortCreateRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortCreateRequestVer10.java
new file mode 100644
index 0000000..69741e9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortCreateRequestVer10.java
@@ -0,0 +1,369 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortCreateRequestVer10 implements OFBsnVirtualPortCreateRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortCreateRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFBsnVport vport;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortCreateRequestVer10(long xid, OFBsnVport vport) {
+        this.xid = xid;
+        this.vport = vport;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+
+
+    public OFBsnVirtualPortCreateRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortCreateRequest.Builder {
+        final OFBsnVirtualPortCreateRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportSet;
+        private OFBsnVport vport;
+
+        BuilderWithParent(OFBsnVirtualPortCreateRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setVport(OFBsnVport vport) {
+        this.vport = vport;
+        this.vportSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortCreateRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBsnVport vport = this.vportSet ? this.vport : parentMessage.vport;
+                if(vport == null)
+                    throw new NullPointerException("Property vport must not be null");
+
+                //
+                return new OFBsnVirtualPortCreateRequestVer10(
+                    xid,
+                    vport
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortCreateRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportSet;
+        private OFBsnVport vport;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setVport(OFBsnVport vport) {
+        this.vport = vport;
+        this.vportSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortCreateRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.vportSet)
+                throw new IllegalStateException("Property vport doesn't have default value -- must be set");
+            if(vport == null)
+                throw new NullPointerException("Property vport must not be null");
+
+
+            return new OFBsnVirtualPortCreateRequestVer10(
+                    xid,
+                    vport
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortCreateRequest> {
+        @Override
+        public OFBsnVirtualPortCreateRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xfL
+            int subtype = bb.readInt();
+            if(subtype != 0xf)
+                throw new OFParseError("Wrong subtype: Expected=0xfL(0xfL), got="+subtype);
+            OFBsnVport vport = OFBsnVportVer10.READER.readFrom(bb);
+
+            OFBsnVirtualPortCreateRequestVer10 bsnVirtualPortCreateRequestVer10 = new OFBsnVirtualPortCreateRequestVer10(
+                    xid,
+                      vport
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortCreateRequestVer10);
+            return bsnVirtualPortCreateRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortCreateRequestVer10Funnel FUNNEL = new OFBsnVirtualPortCreateRequestVer10Funnel();
+    static class OFBsnVirtualPortCreateRequestVer10Funnel implements Funnel<OFBsnVirtualPortCreateRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortCreateRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            sink.putInt(0xf);
+            message.vport.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortCreateRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortCreateRequestVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            bb.writeInt(0xf);
+            message.vport.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortCreateRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vport=").append(vport);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortCreateRequestVer10 other = (OFBsnVirtualPortCreateRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (vport == null) {
+            if (other.vport != null)
+                return false;
+        } else if (!vport.equals(other.vport))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((vport == null) ? 0 : vport.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortRemoveReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortRemoveReplyVer10.java
new file mode 100644
index 0000000..440624f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortRemoveReplyVer10.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortRemoveReplyVer10 implements OFBsnVirtualPortRemoveReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortRemoveReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortRemoveReplyVer10 DEFAULT = new OFBsnVirtualPortRemoveReplyVer10(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortRemoveReplyVer10(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnVirtualPortRemoveReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortRemoveReply.Builder {
+        final OFBsnVirtualPortRemoveReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnVirtualPortRemoveReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortRemoveReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnVirtualPortRemoveReplyVer10(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortRemoveReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortRemoveReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnVirtualPortRemoveReplyVer10(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortRemoveReply> {
+        @Override
+        public OFBsnVirtualPortRemoveReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1aL
+            int subtype = bb.readInt();
+            if(subtype != 0x1a)
+                throw new OFParseError("Wrong subtype: Expected=0x1aL(0x1aL), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnVirtualPortRemoveReplyVer10 bsnVirtualPortRemoveReplyVer10 = new OFBsnVirtualPortRemoveReplyVer10(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortRemoveReplyVer10);
+            return bsnVirtualPortRemoveReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortRemoveReplyVer10Funnel FUNNEL = new OFBsnVirtualPortRemoveReplyVer10Funnel();
+    static class OFBsnVirtualPortRemoveReplyVer10Funnel implements Funnel<OFBsnVirtualPortRemoveReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortRemoveReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1aL
+            sink.putInt(0x1a);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortRemoveReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortRemoveReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1aL
+            bb.writeInt(0x1a);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortRemoveReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortRemoveReplyVer10 other = (OFBsnVirtualPortRemoveReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortRemoveRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortRemoveRequestVer10.java
new file mode 100644
index 0000000..f178056
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVirtualPortRemoveRequestVer10.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortRemoveRequestVer10 implements OFBsnVirtualPortRemoveRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortRemoveRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_VPORT_NO = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long vportNo;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortRemoveRequestVer10 DEFAULT = new OFBsnVirtualPortRemoveRequestVer10(
+        DEFAULT_XID, DEFAULT_VPORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortRemoveRequestVer10(long xid, long vportNo) {
+        this.xid = xid;
+        this.vportNo = vportNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+
+
+    public OFBsnVirtualPortRemoveRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortRemoveRequest.Builder {
+        final OFBsnVirtualPortRemoveRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportNoSet;
+        private long vportNo;
+
+        BuilderWithParent(OFBsnVirtualPortRemoveRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortRemoveRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long vportNo = this.vportNoSet ? this.vportNo : parentMessage.vportNo;
+
+                //
+                return new OFBsnVirtualPortRemoveRequestVer10(
+                    xid,
+                    vportNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortRemoveRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportNoSet;
+        private long vportNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortRemoveRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long vportNo = this.vportNoSet ? this.vportNo : DEFAULT_VPORT_NO;
+
+
+            return new OFBsnVirtualPortRemoveRequestVer10(
+                    xid,
+                    vportNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortRemoveRequest> {
+        @Override
+        public OFBsnVirtualPortRemoveRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x11L
+            int subtype = bb.readInt();
+            if(subtype != 0x11)
+                throw new OFParseError("Wrong subtype: Expected=0x11L(0x11L), got="+subtype);
+            long vportNo = U32.f(bb.readInt());
+
+            OFBsnVirtualPortRemoveRequestVer10 bsnVirtualPortRemoveRequestVer10 = new OFBsnVirtualPortRemoveRequestVer10(
+                    xid,
+                      vportNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortRemoveRequestVer10);
+            return bsnVirtualPortRemoveRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortRemoveRequestVer10Funnel FUNNEL = new OFBsnVirtualPortRemoveRequestVer10Funnel();
+    static class OFBsnVirtualPortRemoveRequestVer10Funnel implements Funnel<OFBsnVirtualPortRemoveRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortRemoveRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x11L
+            sink.putInt(0x11);
+            sink.putLong(message.vportNo);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortRemoveRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortRemoveRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x11L
+            bb.writeInt(0x11);
+            bb.writeInt(U32.t(message.vportNo));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortRemoveRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vportNo=").append(vportNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortRemoveRequestVer10 other = (OFBsnVirtualPortRemoveRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( vportNo != other.vportNo)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (vportNo ^ (vportNo >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportL2GreFlagsSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportL2GreFlagsSerializerVer10.java
new file mode 100644
index 0000000..4c2111d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportL2GreFlagsSerializerVer10.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportL2GreFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFBsnVportL2GreFlagsSerializerVer10 {
+
+    public final static int BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL = 0x1;
+    public final static int BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL = 0x2;
+    public final static int BSN_VPORT_L2GRE_DSCP_COPY_VAL = 0x4;
+    public final static int BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL = 0x8;
+    public final static int BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL = 0x10;
+
+    public static Set<OFBsnVportL2GreFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFBsnVportL2GreFlags> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFBsnVportL2GreFlags> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFBsnVportL2GreFlags> ofWireValue(int val) {
+        EnumSet<OFBsnVportL2GreFlags> set = EnumSet.noneOf(OFBsnVportL2GreFlags.class);
+
+        if((val & BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID);
+        if((val & BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN);
+        if((val & BSN_VPORT_L2GRE_DSCP_COPY_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_COPY);
+        if((val & BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID);
+        if((val & BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFBsnVportL2GreFlags> set) {
+        int wireValue = 0;
+
+        for(OFBsnVportL2GreFlags e: set) {
+            switch(e) {
+                case BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_DSCP_ASSIGN:
+                    wireValue |= BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_DSCP_COPY:
+                    wireValue |= BSN_VPORT_L2GRE_DSCP_COPY_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_LOOPBACK_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFBsnVportL2GreFlags in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportL2GreVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportL2GreVer10.java
new file mode 100644
index 0000000..32af98d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportL2GreVer10.java
@@ -0,0 +1,839 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVportL2GreVer10 implements OFBsnVportL2Gre {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVportL2GreVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 60;
+
+        private final static Set<OFBsnVportL2GreFlags> DEFAULT_FLAGS = ImmutableSet.<OFBsnVportL2GreFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static OFPort DEFAULT_LOOPBACK_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_LOCAL_MAC = MacAddress.NONE;
+        private final static MacAddress DEFAULT_NH_MAC = MacAddress.NONE;
+        private final static IPv4Address DEFAULT_SRC_IP = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_DST_IP = IPv4Address.NONE;
+        private final static short DEFAULT_DSCP = (short) 0x0;
+        private final static short DEFAULT_TTL = (short) 0x0;
+        private final static long DEFAULT_VPN = 0x0L;
+        private final static long DEFAULT_RATE_LIMIT = 0x0L;
+        private final static String DEFAULT_IF_NAME = "";
+
+    // OF message fields
+    private final Set<OFBsnVportL2GreFlags> flags;
+    private final OFPort portNo;
+    private final OFPort loopbackPortNo;
+    private final MacAddress localMac;
+    private final MacAddress nhMac;
+    private final IPv4Address srcIp;
+    private final IPv4Address dstIp;
+    private final short dscp;
+    private final short ttl;
+    private final long vpn;
+    private final long rateLimit;
+    private final String ifName;
+//
+    // Immutable default instance
+    final static OFBsnVportL2GreVer10 DEFAULT = new OFBsnVportL2GreVer10(
+        DEFAULT_FLAGS, DEFAULT_PORT_NO, DEFAULT_LOOPBACK_PORT_NO, DEFAULT_LOCAL_MAC, DEFAULT_NH_MAC, DEFAULT_SRC_IP, DEFAULT_DST_IP, DEFAULT_DSCP, DEFAULT_TTL, DEFAULT_VPN, DEFAULT_RATE_LIMIT, DEFAULT_IF_NAME
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVportL2GreVer10(Set<OFBsnVportL2GreFlags> flags, OFPort portNo, OFPort loopbackPortNo, MacAddress localMac, MacAddress nhMac, IPv4Address srcIp, IPv4Address dstIp, short dscp, short ttl, long vpn, long rateLimit, String ifName) {
+        this.flags = flags;
+        this.portNo = portNo;
+        this.loopbackPortNo = loopbackPortNo;
+        this.localMac = localMac;
+        this.nhMac = nhMac;
+        this.srcIp = srcIp;
+        this.dstIp = dstIp;
+        this.dscp = dscp;
+        this.ttl = ttl;
+        this.vpn = vpn;
+        this.rateLimit = rateLimit;
+        this.ifName = ifName;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFBsnVportL2Gre.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVportL2Gre.Builder {
+        final OFBsnVportL2GreVer10 parentMessage;
+
+        // OF message fields
+        private boolean flagsSet;
+        private Set<OFBsnVportL2GreFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean loopbackPortNoSet;
+        private OFPort loopbackPortNo;
+        private boolean localMacSet;
+        private MacAddress localMac;
+        private boolean nhMacSet;
+        private MacAddress nhMac;
+        private boolean srcIpSet;
+        private IPv4Address srcIp;
+        private boolean dstIpSet;
+        private IPv4Address dstIp;
+        private boolean dscpSet;
+        private short dscp;
+        private boolean ttlSet;
+        private short ttl;
+        private boolean vpnSet;
+        private long vpn;
+        private boolean rateLimitSet;
+        private long rateLimit;
+        private boolean ifNameSet;
+        private String ifName;
+
+        BuilderWithParent(OFBsnVportL2GreVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setFlags(Set<OFBsnVportL2GreFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLoopbackPortNo(OFPort loopbackPortNo) {
+        this.loopbackPortNo = loopbackPortNo;
+        this.loopbackPortNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLocalMac(MacAddress localMac) {
+        this.localMac = localMac;
+        this.localMacSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setNhMac(MacAddress nhMac) {
+        this.nhMac = nhMac;
+        this.nhMacSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setSrcIp(IPv4Address srcIp) {
+        this.srcIp = srcIp;
+        this.srcIpSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDstIp(IPv4Address dstIp) {
+        this.dstIp = dstIp;
+        this.dstIpSet = true;
+        return this;
+    }
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDscp(short dscp) {
+        this.dscp = dscp;
+        this.dscpSet = true;
+        return this;
+    }
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setTtl(short ttl) {
+        this.ttl = ttl;
+        this.ttlSet = true;
+        return this;
+    }
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setVpn(long vpn) {
+        this.vpn = vpn;
+        this.vpnSet = true;
+        return this;
+    }
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setRateLimit(long rateLimit) {
+        this.rateLimit = rateLimit;
+        this.rateLimitSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFBsnVportL2Gre build() {
+                Set<OFBsnVportL2GreFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                OFPort loopbackPortNo = this.loopbackPortNoSet ? this.loopbackPortNo : parentMessage.loopbackPortNo;
+                if(loopbackPortNo == null)
+                    throw new NullPointerException("Property loopbackPortNo must not be null");
+                MacAddress localMac = this.localMacSet ? this.localMac : parentMessage.localMac;
+                if(localMac == null)
+                    throw new NullPointerException("Property localMac must not be null");
+                MacAddress nhMac = this.nhMacSet ? this.nhMac : parentMessage.nhMac;
+                if(nhMac == null)
+                    throw new NullPointerException("Property nhMac must not be null");
+                IPv4Address srcIp = this.srcIpSet ? this.srcIp : parentMessage.srcIp;
+                if(srcIp == null)
+                    throw new NullPointerException("Property srcIp must not be null");
+                IPv4Address dstIp = this.dstIpSet ? this.dstIp : parentMessage.dstIp;
+                if(dstIp == null)
+                    throw new NullPointerException("Property dstIp must not be null");
+                short dscp = this.dscpSet ? this.dscp : parentMessage.dscp;
+                short ttl = this.ttlSet ? this.ttl : parentMessage.ttl;
+                long vpn = this.vpnSet ? this.vpn : parentMessage.vpn;
+                long rateLimit = this.rateLimitSet ? this.rateLimit : parentMessage.rateLimit;
+                String ifName = this.ifNameSet ? this.ifName : parentMessage.ifName;
+                if(ifName == null)
+                    throw new NullPointerException("Property ifName must not be null");
+
+                //
+                return new OFBsnVportL2GreVer10(
+                    flags,
+                    portNo,
+                    loopbackPortNo,
+                    localMac,
+                    nhMac,
+                    srcIp,
+                    dstIp,
+                    dscp,
+                    ttl,
+                    vpn,
+                    rateLimit,
+                    ifName
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVportL2Gre.Builder {
+        // OF message fields
+        private boolean flagsSet;
+        private Set<OFBsnVportL2GreFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean loopbackPortNoSet;
+        private OFPort loopbackPortNo;
+        private boolean localMacSet;
+        private MacAddress localMac;
+        private boolean nhMacSet;
+        private MacAddress nhMac;
+        private boolean srcIpSet;
+        private IPv4Address srcIp;
+        private boolean dstIpSet;
+        private IPv4Address dstIp;
+        private boolean dscpSet;
+        private short dscp;
+        private boolean ttlSet;
+        private short ttl;
+        private boolean vpnSet;
+        private long vpn;
+        private boolean rateLimitSet;
+        private long rateLimit;
+        private boolean ifNameSet;
+        private String ifName;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setFlags(Set<OFBsnVportL2GreFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLoopbackPortNo(OFPort loopbackPortNo) {
+        this.loopbackPortNo = loopbackPortNo;
+        this.loopbackPortNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLocalMac(MacAddress localMac) {
+        this.localMac = localMac;
+        this.localMacSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setNhMac(MacAddress nhMac) {
+        this.nhMac = nhMac;
+        this.nhMacSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setSrcIp(IPv4Address srcIp) {
+        this.srcIp = srcIp;
+        this.srcIpSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDstIp(IPv4Address dstIp) {
+        this.dstIp = dstIp;
+        this.dstIpSet = true;
+        return this;
+    }
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDscp(short dscp) {
+        this.dscp = dscp;
+        this.dscpSet = true;
+        return this;
+    }
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setTtl(short ttl) {
+        this.ttl = ttl;
+        this.ttlSet = true;
+        return this;
+    }
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setVpn(long vpn) {
+        this.vpn = vpn;
+        this.vpnSet = true;
+        return this;
+    }
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setRateLimit(long rateLimit) {
+        this.rateLimit = rateLimit;
+        this.rateLimitSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFBsnVportL2Gre build() {
+            Set<OFBsnVportL2GreFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            OFPort loopbackPortNo = this.loopbackPortNoSet ? this.loopbackPortNo : DEFAULT_LOOPBACK_PORT_NO;
+            if(loopbackPortNo == null)
+                throw new NullPointerException("Property loopbackPortNo must not be null");
+            MacAddress localMac = this.localMacSet ? this.localMac : DEFAULT_LOCAL_MAC;
+            if(localMac == null)
+                throw new NullPointerException("Property localMac must not be null");
+            MacAddress nhMac = this.nhMacSet ? this.nhMac : DEFAULT_NH_MAC;
+            if(nhMac == null)
+                throw new NullPointerException("Property nhMac must not be null");
+            IPv4Address srcIp = this.srcIpSet ? this.srcIp : DEFAULT_SRC_IP;
+            if(srcIp == null)
+                throw new NullPointerException("Property srcIp must not be null");
+            IPv4Address dstIp = this.dstIpSet ? this.dstIp : DEFAULT_DST_IP;
+            if(dstIp == null)
+                throw new NullPointerException("Property dstIp must not be null");
+            short dscp = this.dscpSet ? this.dscp : DEFAULT_DSCP;
+            short ttl = this.ttlSet ? this.ttl : DEFAULT_TTL;
+            long vpn = this.vpnSet ? this.vpn : DEFAULT_VPN;
+            long rateLimit = this.rateLimitSet ? this.rateLimit : DEFAULT_RATE_LIMIT;
+            String ifName = this.ifNameSet ? this.ifName : DEFAULT_IF_NAME;
+            if(ifName == null)
+                throw new NullPointerException("Property ifName must not be null");
+
+
+            return new OFBsnVportL2GreVer10(
+                    flags,
+                    portNo,
+                    loopbackPortNo,
+                    localMac,
+                    nhMac,
+                    srcIp,
+                    dstIp,
+                    dscp,
+                    ttl,
+                    vpn,
+                    rateLimit,
+                    ifName
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVportL2Gre> {
+        @Override
+        public OFBsnVportL2Gre readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 60)
+                throw new OFParseError("Wrong length: Expected=60(60), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            Set<OFBsnVportL2GreFlags> flags = OFBsnVportL2GreFlagsSerializerVer10.readFrom(bb);
+            OFPort portNo = OFPort.read2Bytes(bb);
+            OFPort loopbackPortNo = OFPort.read2Bytes(bb);
+            MacAddress localMac = MacAddress.read6Bytes(bb);
+            MacAddress nhMac = MacAddress.read6Bytes(bb);
+            IPv4Address srcIp = IPv4Address.read4Bytes(bb);
+            IPv4Address dstIp = IPv4Address.read4Bytes(bb);
+            short dscp = U8.f(bb.readByte());
+            short ttl = U8.f(bb.readByte());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long vpn = U32.f(bb.readInt());
+            long rateLimit = U32.f(bb.readInt());
+            String ifName = ChannelUtils.readFixedLengthString(bb, 16);
+
+            OFBsnVportL2GreVer10 bsnVportL2GreVer10 = new OFBsnVportL2GreVer10(
+                    flags,
+                      portNo,
+                      loopbackPortNo,
+                      localMac,
+                      nhMac,
+                      srcIp,
+                      dstIp,
+                      dscp,
+                      ttl,
+                      vpn,
+                      rateLimit,
+                      ifName
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVportL2GreVer10);
+            return bsnVportL2GreVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVportL2GreVer10Funnel FUNNEL = new OFBsnVportL2GreVer10Funnel();
+    static class OFBsnVportL2GreVer10Funnel implements Funnel<OFBsnVportL2GreVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVportL2GreVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 60
+            sink.putShort((short) 0x3c);
+            OFBsnVportL2GreFlagsSerializerVer10.putTo(message.flags, sink);
+            message.portNo.putTo(sink);
+            message.loopbackPortNo.putTo(sink);
+            message.localMac.putTo(sink);
+            message.nhMac.putTo(sink);
+            message.srcIp.putTo(sink);
+            message.dstIp.putTo(sink);
+            sink.putShort(message.dscp);
+            sink.putShort(message.ttl);
+            // skip pad (2 bytes)
+            sink.putLong(message.vpn);
+            sink.putLong(message.rateLimit);
+            sink.putUnencodedChars(message.ifName);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVportL2GreVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVportL2GreVer10 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 60
+            bb.writeShort((short) 0x3c);
+            OFBsnVportL2GreFlagsSerializerVer10.writeTo(bb, message.flags);
+            message.portNo.write2Bytes(bb);
+            message.loopbackPortNo.write2Bytes(bb);
+            message.localMac.write6Bytes(bb);
+            message.nhMac.write6Bytes(bb);
+            message.srcIp.write4Bytes(bb);
+            message.dstIp.write4Bytes(bb);
+            bb.writeByte(U8.t(message.dscp));
+            bb.writeByte(U8.t(message.ttl));
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.vpn));
+            bb.writeInt(U32.t(message.rateLimit));
+            ChannelUtils.writeFixedLengthString(bb, message.ifName, 16);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVportL2GreVer10(");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("loopbackPortNo=").append(loopbackPortNo);
+        b.append(", ");
+        b.append("localMac=").append(localMac);
+        b.append(", ");
+        b.append("nhMac=").append(nhMac);
+        b.append(", ");
+        b.append("srcIp=").append(srcIp);
+        b.append(", ");
+        b.append("dstIp=").append(dstIp);
+        b.append(", ");
+        b.append("dscp=").append(dscp);
+        b.append(", ");
+        b.append("ttl=").append(ttl);
+        b.append(", ");
+        b.append("vpn=").append(vpn);
+        b.append(", ");
+        b.append("rateLimit=").append(rateLimit);
+        b.append(", ");
+        b.append("ifName=").append(ifName);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVportL2GreVer10 other = (OFBsnVportL2GreVer10) obj;
+
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (loopbackPortNo == null) {
+            if (other.loopbackPortNo != null)
+                return false;
+        } else if (!loopbackPortNo.equals(other.loopbackPortNo))
+            return false;
+        if (localMac == null) {
+            if (other.localMac != null)
+                return false;
+        } else if (!localMac.equals(other.localMac))
+            return false;
+        if (nhMac == null) {
+            if (other.nhMac != null)
+                return false;
+        } else if (!nhMac.equals(other.nhMac))
+            return false;
+        if (srcIp == null) {
+            if (other.srcIp != null)
+                return false;
+        } else if (!srcIp.equals(other.srcIp))
+            return false;
+        if (dstIp == null) {
+            if (other.dstIp != null)
+                return false;
+        } else if (!dstIp.equals(other.dstIp))
+            return false;
+        if( dscp != other.dscp)
+            return false;
+        if( ttl != other.ttl)
+            return false;
+        if( vpn != other.vpn)
+            return false;
+        if( rateLimit != other.rateLimit)
+            return false;
+        if (ifName == null) {
+            if (other.ifName != null)
+                return false;
+        } else if (!ifName.equals(other.ifName))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((loopbackPortNo == null) ? 0 : loopbackPortNo.hashCode());
+        result = prime * result + ((localMac == null) ? 0 : localMac.hashCode());
+        result = prime * result + ((nhMac == null) ? 0 : nhMac.hashCode());
+        result = prime * result + ((srcIp == null) ? 0 : srcIp.hashCode());
+        result = prime * result + ((dstIp == null) ? 0 : dstIp.hashCode());
+        result = prime * result + dscp;
+        result = prime * result + ttl;
+        result = prime *  (int) (vpn ^ (vpn >>> 32));
+        result = prime *  (int) (rateLimit ^ (rateLimit >>> 32));
+        result = prime * result + ((ifName == null) ? 0 : ifName.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportQInQUntaggedSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportQInQUntaggedSerializerVer10.java
new file mode 100644
index 0000000..e3f79b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportQInQUntaggedSerializerVer10.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportQInQUntagged;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVportQInQUntaggedSerializerVer10 {
+
+    public final static short BSN_VPORT_Q_IN_Q_UNTAGGED_VAL = (short) 0xffff;
+
+    public static OFBsnVportQInQUntagged readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVportQInQUntagged e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnVportQInQUntagged e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVportQInQUntagged ofWireValue(short val) {
+        switch(val) {
+            case BSN_VPORT_Q_IN_Q_UNTAGGED_VAL:
+                return OFBsnVportQInQUntagged.BSN_VPORT_Q_IN_Q_UNTAGGED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVportQInQUntagged in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVportQInQUntagged e) {
+        switch(e) {
+            case BSN_VPORT_Q_IN_Q_UNTAGGED:
+                return BSN_VPORT_Q_IN_Q_UNTAGGED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVportQInQUntagged in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportQInQVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportQInQVer10.java
new file mode 100644
index 0000000..7f5b0a3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportQInQVer10.java
@@ -0,0 +1,502 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVportQInQVer10 implements OFBsnVportQInQ {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVportQInQVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_PORT_NO = 0x0L;
+        private final static int DEFAULT_INGRESS_TPID = 0x0;
+        private final static int DEFAULT_INGRESS_VLAN_ID = 0x0;
+        private final static int DEFAULT_EGRESS_TPID = 0x0;
+        private final static int DEFAULT_EGRESS_VLAN_ID = 0x0;
+        private final static String DEFAULT_IF_NAME = "";
+
+    // OF message fields
+    private final long portNo;
+    private final int ingressTpid;
+    private final int ingressVlanId;
+    private final int egressTpid;
+    private final int egressVlanId;
+    private final String ifName;
+//
+    // Immutable default instance
+    final static OFBsnVportQInQVer10 DEFAULT = new OFBsnVportQInQVer10(
+        DEFAULT_PORT_NO, DEFAULT_INGRESS_TPID, DEFAULT_INGRESS_VLAN_ID, DEFAULT_EGRESS_TPID, DEFAULT_EGRESS_VLAN_ID, DEFAULT_IF_NAME
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVportQInQVer10(long portNo, int ingressTpid, int ingressVlanId, int egressTpid, int egressVlanId, String ifName) {
+        this.portNo = portNo;
+        this.ingressTpid = ingressTpid;
+        this.ingressVlanId = ingressVlanId;
+        this.egressTpid = egressTpid;
+        this.egressVlanId = egressVlanId;
+        this.ifName = ifName;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFBsnVportQInQ.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVportQInQ.Builder {
+        final OFBsnVportQInQVer10 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private long portNo;
+        private boolean ingressTpidSet;
+        private int ingressTpid;
+        private boolean ingressVlanIdSet;
+        private int ingressVlanId;
+        private boolean egressTpidSet;
+        private int egressTpid;
+        private boolean egressVlanIdSet;
+        private int egressVlanId;
+        private boolean ifNameSet;
+        private String ifName;
+
+        BuilderWithParent(OFBsnVportQInQVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setPortNo(long portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressTpid(int ingressTpid) {
+        this.ingressTpid = ingressTpid;
+        this.ingressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressVlanId(int ingressVlanId) {
+        this.ingressVlanId = ingressVlanId;
+        this.ingressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressTpid(int egressTpid) {
+        this.egressTpid = egressTpid;
+        this.egressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressVlanId(int egressVlanId) {
+        this.egressVlanId = egressVlanId;
+        this.egressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFBsnVportQInQ build() {
+                long portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                int ingressTpid = this.ingressTpidSet ? this.ingressTpid : parentMessage.ingressTpid;
+                int ingressVlanId = this.ingressVlanIdSet ? this.ingressVlanId : parentMessage.ingressVlanId;
+                int egressTpid = this.egressTpidSet ? this.egressTpid : parentMessage.egressTpid;
+                int egressVlanId = this.egressVlanIdSet ? this.egressVlanId : parentMessage.egressVlanId;
+                String ifName = this.ifNameSet ? this.ifName : parentMessage.ifName;
+                if(ifName == null)
+                    throw new NullPointerException("Property ifName must not be null");
+
+                //
+                return new OFBsnVportQInQVer10(
+                    portNo,
+                    ingressTpid,
+                    ingressVlanId,
+                    egressTpid,
+                    egressVlanId,
+                    ifName
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVportQInQ.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private long portNo;
+        private boolean ingressTpidSet;
+        private int ingressTpid;
+        private boolean ingressVlanIdSet;
+        private int ingressVlanId;
+        private boolean egressTpidSet;
+        private int egressTpid;
+        private boolean egressVlanIdSet;
+        private int egressVlanId;
+        private boolean ifNameSet;
+        private String ifName;
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setPortNo(long portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressTpid(int ingressTpid) {
+        this.ingressTpid = ingressTpid;
+        this.ingressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressVlanId(int ingressVlanId) {
+        this.ingressVlanId = ingressVlanId;
+        this.ingressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressTpid(int egressTpid) {
+        this.egressTpid = egressTpid;
+        this.egressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressVlanId(int egressVlanId) {
+        this.egressVlanId = egressVlanId;
+        this.egressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFBsnVportQInQ build() {
+            long portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            int ingressTpid = this.ingressTpidSet ? this.ingressTpid : DEFAULT_INGRESS_TPID;
+            int ingressVlanId = this.ingressVlanIdSet ? this.ingressVlanId : DEFAULT_INGRESS_VLAN_ID;
+            int egressTpid = this.egressTpidSet ? this.egressTpid : DEFAULT_EGRESS_TPID;
+            int egressVlanId = this.egressVlanIdSet ? this.egressVlanId : DEFAULT_EGRESS_VLAN_ID;
+            String ifName = this.ifNameSet ? this.ifName : DEFAULT_IF_NAME;
+            if(ifName == null)
+                throw new NullPointerException("Property ifName must not be null");
+
+
+            return new OFBsnVportQInQVer10(
+                    portNo,
+                    ingressTpid,
+                    ingressVlanId,
+                    egressTpid,
+                    egressVlanId,
+                    ifName
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVportQInQ> {
+        @Override
+        public OFBsnVportQInQ readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=0x0(0x0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long portNo = U32.f(bb.readInt());
+            int ingressTpid = U16.f(bb.readShort());
+            int ingressVlanId = U16.f(bb.readShort());
+            int egressTpid = U16.f(bb.readShort());
+            int egressVlanId = U16.f(bb.readShort());
+            String ifName = ChannelUtils.readFixedLengthString(bb, 16);
+
+            OFBsnVportQInQVer10 bsnVportQInQVer10 = new OFBsnVportQInQVer10(
+                    portNo,
+                      ingressTpid,
+                      ingressVlanId,
+                      egressTpid,
+                      egressVlanId,
+                      ifName
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVportQInQVer10);
+            return bsnVportQInQVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVportQInQVer10Funnel FUNNEL = new OFBsnVportQInQVer10Funnel();
+    static class OFBsnVportQInQVer10Funnel implements Funnel<OFBsnVportQInQVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVportQInQVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 0x0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.portNo);
+            sink.putInt(message.ingressTpid);
+            sink.putInt(message.ingressVlanId);
+            sink.putInt(message.egressTpid);
+            sink.putInt(message.egressVlanId);
+            sink.putUnencodedChars(message.ifName);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVportQInQVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVportQInQVer10 message) {
+            // fixed value property type = 0x0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.portNo));
+            bb.writeShort(U16.t(message.ingressTpid));
+            bb.writeShort(U16.t(message.ingressVlanId));
+            bb.writeShort(U16.t(message.egressTpid));
+            bb.writeShort(U16.t(message.egressVlanId));
+            ChannelUtils.writeFixedLengthString(bb, message.ifName, 16);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVportQInQVer10(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("ingressTpid=").append(ingressTpid);
+        b.append(", ");
+        b.append("ingressVlanId=").append(ingressVlanId);
+        b.append(", ");
+        b.append("egressTpid=").append(egressTpid);
+        b.append(", ");
+        b.append("egressVlanId=").append(egressVlanId);
+        b.append(", ");
+        b.append("ifName=").append(ifName);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVportQInQVer10 other = (OFBsnVportQInQVer10) obj;
+
+        if( portNo != other.portNo)
+            return false;
+        if( ingressTpid != other.ingressTpid)
+            return false;
+        if( ingressVlanId != other.ingressVlanId)
+            return false;
+        if( egressTpid != other.egressTpid)
+            return false;
+        if( egressVlanId != other.egressVlanId)
+            return false;
+        if (ifName == null) {
+            if (other.ifName != null)
+                return false;
+        } else if (!ifName.equals(other.ifName))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (portNo ^ (portNo >>> 32));
+        result = prime * result + ingressTpid;
+        result = prime * result + ingressVlanId;
+        result = prime * result + egressTpid;
+        result = prime * result + egressVlanId;
+        result = prime * result + ((ifName == null) ? 0 : ifName.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportStatusSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportStatusSerializerVer10.java
new file mode 100644
index 0000000..c4aa654
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportStatusSerializerVer10.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportStatus;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVportStatusSerializerVer10 {
+
+    public final static short BSN_VPORT_STATUS_OK_VAL = (short) 0x0;
+    public final static short BSN_VPORT_STATUS_FAILED_VAL = (short) 0x1;
+
+    public static OFBsnVportStatus readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(U8.f(bb.readByte()));
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVportStatus e) {
+        bb.writeByte(U8.t(toWireValue(e)));
+    }
+
+    public static void putTo(OFBsnVportStatus e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVportStatus ofWireValue(short val) {
+        switch(val) {
+            case BSN_VPORT_STATUS_OK_VAL:
+                return OFBsnVportStatus.BSN_VPORT_STATUS_OK;
+            case BSN_VPORT_STATUS_FAILED_VAL:
+                return OFBsnVportStatus.BSN_VPORT_STATUS_FAILED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVportStatus in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVportStatus e) {
+        switch(e) {
+            case BSN_VPORT_STATUS_OK:
+                return BSN_VPORT_STATUS_OK_VAL;
+            case BSN_VPORT_STATUS_FAILED:
+                return BSN_VPORT_STATUS_FAILED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVportStatus in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportVer10.java
new file mode 100644
index 0000000..95e9682
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFBsnVportVer10.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnVportVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFBsnVportVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnVport> {
+        @Override
+        public OFBsnVport readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFBsnVportL2GreVer10
+                   return OFBsnVportL2GreVer10.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value 0x0=0x0 for class OFBsnVportQInQVer10
+                   return OFBsnVportQInQVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFBsnVportVer10: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFCapabilitiesSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFCapabilitiesSerializerVer10.java
new file mode 100644
index 0000000..6bac973
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFCapabilitiesSerializerVer10.java
@@ -0,0 +1,120 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFCapabilities;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFCapabilitiesSerializerVer10 {
+
+    public final static int FLOW_STATS_VAL = 0x1;
+    public final static int TABLE_STATS_VAL = 0x2;
+    public final static int PORT_STATS_VAL = 0x4;
+    public final static int STP_VAL = 0x8;
+    public final static int RESERVED_VAL = 0x10;
+    public final static int IP_REASM_VAL = 0x20;
+    public final static int QUEUE_STATS_VAL = 0x40;
+    public final static int ARP_MATCH_IP_VAL = 0x80;
+
+    public static Set<OFCapabilities> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFCapabilities> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFCapabilities> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFCapabilities> ofWireValue(int val) {
+        EnumSet<OFCapabilities> set = EnumSet.noneOf(OFCapabilities.class);
+
+        if((val & FLOW_STATS_VAL) != 0)
+            set.add(OFCapabilities.FLOW_STATS);
+        if((val & TABLE_STATS_VAL) != 0)
+            set.add(OFCapabilities.TABLE_STATS);
+        if((val & PORT_STATS_VAL) != 0)
+            set.add(OFCapabilities.PORT_STATS);
+        if((val & STP_VAL) != 0)
+            set.add(OFCapabilities.STP);
+        if((val & RESERVED_VAL) != 0)
+            set.add(OFCapabilities.RESERVED);
+        if((val & IP_REASM_VAL) != 0)
+            set.add(OFCapabilities.IP_REASM);
+        if((val & QUEUE_STATS_VAL) != 0)
+            set.add(OFCapabilities.QUEUE_STATS);
+        if((val & ARP_MATCH_IP_VAL) != 0)
+            set.add(OFCapabilities.ARP_MATCH_IP);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFCapabilities> set) {
+        int wireValue = 0;
+
+        for(OFCapabilities e: set) {
+            switch(e) {
+                case FLOW_STATS:
+                    wireValue |= FLOW_STATS_VAL;
+                    break;
+                case TABLE_STATS:
+                    wireValue |= TABLE_STATS_VAL;
+                    break;
+                case PORT_STATS:
+                    wireValue |= PORT_STATS_VAL;
+                    break;
+                case STP:
+                    wireValue |= STP_VAL;
+                    break;
+                case RESERVED:
+                    wireValue |= RESERVED_VAL;
+                    break;
+                case IP_REASM:
+                    wireValue |= IP_REASM_VAL;
+                    break;
+                case QUEUE_STATS:
+                    wireValue |= QUEUE_STATS_VAL;
+                    break;
+                case ARP_MATCH_IP:
+                    wireValue |= ARP_MATCH_IP_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFCapabilities in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFConfigFlagsSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFConfigFlagsSerializerVer10.java
new file mode 100644
index 0000000..bd45beb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFConfigFlagsSerializerVer10.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFConfigFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFConfigFlagsSerializerVer10 {
+
+    public final static short FRAG_NORMAL_VAL = (short) 0x0;
+    public final static short FRAG_DROP_VAL = (short) 0x1;
+    public final static short FRAG_REASM_VAL = (short) 0x2;
+    public final static short FRAG_MASK_VAL = (short) 0x3;
+
+    public static Set<OFConfigFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFConfigFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFConfigFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFConfigFlags> ofWireValue(short val) {
+        EnumSet<OFConfigFlags> set = EnumSet.noneOf(OFConfigFlags.class);
+
+        if((val & FRAG_MASK_VAL) == FRAG_NORMAL_VAL)
+            set.add(OFConfigFlags.FRAG_NORMAL);
+        else if((val & FRAG_MASK_VAL) == FRAG_DROP_VAL)
+            set.add(OFConfigFlags.FRAG_DROP);
+        else if((val & FRAG_MASK_VAL) == FRAG_REASM_VAL)
+            set.add(OFConfigFlags.FRAG_REASM);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFConfigFlags> set) {
+        short wireValue = 0;
+
+        for(OFConfigFlags e: set) {
+            switch(e) {
+                case FRAG_NORMAL:
+                    wireValue |= FRAG_NORMAL_VAL;
+                    break;
+                case FRAG_DROP:
+                    wireValue |= FRAG_DROP_VAL;
+                    break;
+                case FRAG_REASM:
+                    wireValue |= FRAG_REASM_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFConfigFlags in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsReplyVer10.java
new file mode 100644
index 0000000..ed1bf76
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsReplyVer10.java
@@ -0,0 +1,616 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFDescStatsReplyVer10 implements OFDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFDescStatsReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 1068;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static String DEFAULT_MFR_DESC = "";
+        private final static String DEFAULT_HW_DESC = "";
+        private final static String DEFAULT_SW_DESC = "";
+        private final static String DEFAULT_SERIAL_NUM = "";
+        private final static String DEFAULT_DP_DESC = "";
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final String mfrDesc;
+    private final String hwDesc;
+    private final String swDesc;
+    private final String serialNum;
+    private final String dpDesc;
+//
+    // Immutable default instance
+    final static OFDescStatsReplyVer10 DEFAULT = new OFDescStatsReplyVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MFR_DESC, DEFAULT_HW_DESC, DEFAULT_SW_DESC, DEFAULT_SERIAL_NUM, DEFAULT_DP_DESC
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFDescStatsReplyVer10(long xid, Set<OFStatsReplyFlags> flags, String mfrDesc, String hwDesc, String swDesc, String serialNum, String dpDesc) {
+        this.xid = xid;
+        this.flags = flags;
+        this.mfrDesc = mfrDesc;
+        this.hwDesc = hwDesc;
+        this.swDesc = swDesc;
+        this.serialNum = serialNum;
+        this.dpDesc = dpDesc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+
+
+    public OFDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFDescStatsReply.Builder {
+        final OFDescStatsReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean mfrDescSet;
+        private String mfrDesc;
+        private boolean hwDescSet;
+        private String hwDesc;
+        private boolean swDescSet;
+        private String swDesc;
+        private boolean serialNumSet;
+        private String serialNum;
+        private boolean dpDescSet;
+        private String dpDesc;
+
+        BuilderWithParent(OFDescStatsReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
+        this.mfrDesc = mfrDesc;
+        this.mfrDescSet = true;
+        return this;
+    }
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
+        this.hwDesc = hwDesc;
+        this.hwDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSwDesc(String swDesc) {
+        this.swDesc = swDesc;
+        this.swDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSerialNum(String serialNum) {
+        this.serialNum = serialNum;
+        this.serialNumSet = true;
+        return this;
+    }
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
+        this.dpDesc = dpDesc;
+        this.dpDescSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                String mfrDesc = this.mfrDescSet ? this.mfrDesc : parentMessage.mfrDesc;
+                if(mfrDesc == null)
+                    throw new NullPointerException("Property mfrDesc must not be null");
+                String hwDesc = this.hwDescSet ? this.hwDesc : parentMessage.hwDesc;
+                if(hwDesc == null)
+                    throw new NullPointerException("Property hwDesc must not be null");
+                String swDesc = this.swDescSet ? this.swDesc : parentMessage.swDesc;
+                if(swDesc == null)
+                    throw new NullPointerException("Property swDesc must not be null");
+                String serialNum = this.serialNumSet ? this.serialNum : parentMessage.serialNum;
+                if(serialNum == null)
+                    throw new NullPointerException("Property serialNum must not be null");
+                String dpDesc = this.dpDescSet ? this.dpDesc : parentMessage.dpDesc;
+                if(dpDesc == null)
+                    throw new NullPointerException("Property dpDesc must not be null");
+
+                //
+                return new OFDescStatsReplyVer10(
+                    xid,
+                    flags,
+                    mfrDesc,
+                    hwDesc,
+                    swDesc,
+                    serialNum,
+                    dpDesc
+                );
+        }
+
+    }
+
+    static class Builder implements OFDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean mfrDescSet;
+        private String mfrDesc;
+        private boolean hwDescSet;
+        private String hwDesc;
+        private boolean swDescSet;
+        private String swDesc;
+        private boolean serialNumSet;
+        private String serialNum;
+        private boolean dpDescSet;
+        private String dpDesc;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
+        this.mfrDesc = mfrDesc;
+        this.mfrDescSet = true;
+        return this;
+    }
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
+        this.hwDesc = hwDesc;
+        this.hwDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSwDesc(String swDesc) {
+        this.swDesc = swDesc;
+        this.swDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSerialNum(String serialNum) {
+        this.serialNum = serialNum;
+        this.serialNumSet = true;
+        return this;
+    }
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
+        this.dpDesc = dpDesc;
+        this.dpDescSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            String mfrDesc = this.mfrDescSet ? this.mfrDesc : DEFAULT_MFR_DESC;
+            if(mfrDesc == null)
+                throw new NullPointerException("Property mfrDesc must not be null");
+            String hwDesc = this.hwDescSet ? this.hwDesc : DEFAULT_HW_DESC;
+            if(hwDesc == null)
+                throw new NullPointerException("Property hwDesc must not be null");
+            String swDesc = this.swDescSet ? this.swDesc : DEFAULT_SW_DESC;
+            if(swDesc == null)
+                throw new NullPointerException("Property swDesc must not be null");
+            String serialNum = this.serialNumSet ? this.serialNum : DEFAULT_SERIAL_NUM;
+            if(serialNum == null)
+                throw new NullPointerException("Property serialNum must not be null");
+            String dpDesc = this.dpDescSet ? this.dpDesc : DEFAULT_DP_DESC;
+            if(dpDesc == null)
+                throw new NullPointerException("Property dpDesc must not be null");
+
+
+            return new OFDescStatsReplyVer10(
+                    xid,
+                    flags,
+                    mfrDesc,
+                    hwDesc,
+                    swDesc,
+                    serialNum,
+                    dpDesc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFDescStatsReply> {
+        @Override
+        public OFDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 1068)
+                throw new OFParseError("Wrong length: Expected=1068(1068), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 0
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x0)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer10.readFrom(bb);
+            String mfrDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String hwDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String swDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String serialNum = ChannelUtils.readFixedLengthString(bb, 32);
+            String dpDesc = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFDescStatsReplyVer10 descStatsReplyVer10 = new OFDescStatsReplyVer10(
+                    xid,
+                      flags,
+                      mfrDesc,
+                      hwDesc,
+                      swDesc,
+                      serialNum,
+                      dpDesc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", descStatsReplyVer10);
+            return descStatsReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFDescStatsReplyVer10Funnel FUNNEL = new OFDescStatsReplyVer10Funnel();
+    static class OFDescStatsReplyVer10Funnel implements Funnel<OFDescStatsReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFDescStatsReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // fixed value property length = 1068
+            sink.putShort((short) 0x42c);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 0
+            sink.putShort((short) 0x0);
+            OFStatsReplyFlagsSerializerVer10.putTo(message.flags, sink);
+            sink.putUnencodedChars(message.mfrDesc);
+            sink.putUnencodedChars(message.hwDesc);
+            sink.putUnencodedChars(message.swDesc);
+            sink.putUnencodedChars(message.serialNum);
+            sink.putUnencodedChars(message.dpDesc);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFDescStatsReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFDescStatsReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // fixed value property length = 1068
+            bb.writeShort((short) 0x42c);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 0
+            bb.writeShort((short) 0x0);
+            OFStatsReplyFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeFixedLengthString(bb, message.mfrDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.hwDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.swDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.serialNum, 32);
+            ChannelUtils.writeFixedLengthString(bb, message.dpDesc, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFDescStatsReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("mfrDesc=").append(mfrDesc);
+        b.append(", ");
+        b.append("hwDesc=").append(hwDesc);
+        b.append(", ");
+        b.append("swDesc=").append(swDesc);
+        b.append(", ");
+        b.append("serialNum=").append(serialNum);
+        b.append(", ");
+        b.append("dpDesc=").append(dpDesc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFDescStatsReplyVer10 other = (OFDescStatsReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (mfrDesc == null) {
+            if (other.mfrDesc != null)
+                return false;
+        } else if (!mfrDesc.equals(other.mfrDesc))
+            return false;
+        if (hwDesc == null) {
+            if (other.hwDesc != null)
+                return false;
+        } else if (!hwDesc.equals(other.hwDesc))
+            return false;
+        if (swDesc == null) {
+            if (other.swDesc != null)
+                return false;
+        } else if (!swDesc.equals(other.swDesc))
+            return false;
+        if (serialNum == null) {
+            if (other.serialNum != null)
+                return false;
+        } else if (!serialNum.equals(other.serialNum))
+            return false;
+        if (dpDesc == null) {
+            if (other.dpDesc != null)
+                return false;
+        } else if (!dpDesc.equals(other.dpDesc))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((mfrDesc == null) ? 0 : mfrDesc.hashCode());
+        result = prime * result + ((hwDesc == null) ? 0 : hwDesc.hashCode());
+        result = prime * result + ((swDesc == null) ? 0 : swDesc.hashCode());
+        result = prime * result + ((serialNum == null) ? 0 : serialNum.hashCode());
+        result = prime * result + ((dpDesc == null) ? 0 : dpDesc.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsRequestVer10.java
new file mode 100644
index 0000000..71ac331
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsRequestVer10.java
@@ -0,0 +1,346 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFDescStatsRequestVer10 implements OFDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFDescStatsRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFDescStatsRequestVer10 DEFAULT = new OFDescStatsRequestVer10(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFDescStatsRequestVer10(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFDescStatsRequest.Builder {
+        final OFDescStatsRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFDescStatsRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFDescStatsRequestVer10(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFDescStatsRequestVer10(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFDescStatsRequest> {
+        @Override
+        public OFDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 0
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x0)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer10.readFrom(bb);
+
+            OFDescStatsRequestVer10 descStatsRequestVer10 = new OFDescStatsRequestVer10(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", descStatsRequestVer10);
+            return descStatsRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFDescStatsRequestVer10Funnel FUNNEL = new OFDescStatsRequestVer10Funnel();
+    static class OFDescStatsRequestVer10Funnel implements Funnel<OFDescStatsRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFDescStatsRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 0
+            sink.putShort((short) 0x0);
+            OFStatsRequestFlagsSerializerVer10.putTo(message.flags, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFDescStatsRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFDescStatsRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 0
+            bb.writeShort((short) 0x0);
+            OFStatsRequestFlagsSerializerVer10.writeTo(bb, message.flags);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFDescStatsRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFDescStatsRequestVer10 other = (OFDescStatsRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoReplyVer10.java
new file mode 100644
index 0000000..260030c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoReplyVer10.java
@@ -0,0 +1,325 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFEchoReplyVer10 implements OFEchoReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFEchoReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFEchoReplyVer10 DEFAULT = new OFEchoReplyVer10(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFEchoReplyVer10(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFEchoReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFEchoReply.Builder {
+        final OFEchoReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFEchoReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoReply.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFEchoReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFEchoReplyVer10(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFEchoReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoReply.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFEchoReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFEchoReplyVer10(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFEchoReply> {
+        @Override
+        public OFEchoReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 3
+            byte type = bb.readByte();
+            if(type != (byte) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFType.ECHO_REPLY(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFEchoReplyVer10 echoReplyVer10 = new OFEchoReplyVer10(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", echoReplyVer10);
+            return echoReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFEchoReplyVer10Funnel FUNNEL = new OFEchoReplyVer10Funnel();
+    static class OFEchoReplyVer10Funnel implements Funnel<OFEchoReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFEchoReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 3
+            sink.putByte((byte) 0x3);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFEchoReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFEchoReplyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 3
+            bb.writeByte((byte) 0x3);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFEchoReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFEchoReplyVer10 other = (OFEchoReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoRequestVer10.java
new file mode 100644
index 0000000..ee34d40
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoRequestVer10.java
@@ -0,0 +1,325 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFEchoRequestVer10 implements OFEchoRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFEchoRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFEchoRequestVer10 DEFAULT = new OFEchoRequestVer10(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFEchoRequestVer10(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFEchoRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFEchoRequest.Builder {
+        final OFEchoRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFEchoRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFEchoRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFEchoRequestVer10(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFEchoRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFEchoRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFEchoRequestVer10(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFEchoRequest> {
+        @Override
+        public OFEchoRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 2
+            byte type = bb.readByte();
+            if(type != (byte) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFType.ECHO_REQUEST(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFEchoRequestVer10 echoRequestVer10 = new OFEchoRequestVer10(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", echoRequestVer10);
+            return echoRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFEchoRequestVer10Funnel FUNNEL = new OFEchoRequestVer10Funnel();
+    static class OFEchoRequestVer10Funnel implements Funnel<OFEchoRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFEchoRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 2
+            sink.putByte((byte) 0x2);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFEchoRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFEchoRequestVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 2
+            bb.writeByte((byte) 0x2);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFEchoRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFEchoRequestVer10 other = (OFEchoRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorMsgVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorMsgVer10.java
new file mode 100644
index 0000000..03ecc4b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorMsgVer10.java
@@ -0,0 +1,80 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFErrorMsgVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 10;
+
+
+    public final static OFErrorMsgVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFErrorMsg> {
+        @Override
+        public OFErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short errType = bb.readShort();
+            bb.readerIndex(start);
+            switch(errType) {
+               case (short) 0x2:
+                   // discriminator value OFErrorType.BAD_ACTION=2 for class OFBadActionErrorMsgVer10
+                   return OFBadActionErrorMsgVer10.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFErrorType.BAD_REQUEST=1 for class OFBadRequestErrorMsgVer10
+                   return OFBadRequestErrorMsgVer10.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFErrorType.FLOW_MOD_FAILED=3 for class OFFlowModFailedErrorMsgVer10
+                   return OFFlowModFailedErrorMsgVer10.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFErrorType.HELLO_FAILED=0 for class OFHelloFailedErrorMsgVer10
+                   return OFHelloFailedErrorMsgVer10.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFErrorType.PORT_MOD_FAILED=4 for class OFPortModFailedErrorMsgVer10
+                   return OFPortModFailedErrorMsgVer10.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFErrorType.QUEUE_OP_FAILED=5 for class OFQueueOpFailedErrorMsgVer10
+                   return OFQueueOpFailedErrorMsgVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator errType of class OFErrorMsgVer10: " + errType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorMsgsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorMsgsVer10.java
new file mode 100644
index 0000000..bd921e9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorMsgsVer10.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFErrorMsgsVer10 implements OFErrorMsgs {
+    public final static OFErrorMsgsVer10 INSTANCE = new OFErrorMsgsVer10();
+
+    private final XidGenerator xidGenerator = XidGenerators.global();
+
+
+
+    public OFBadActionErrorMsg.Builder buildBadActionErrorMsg() {
+        return new OFBadActionErrorMsgVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBadRequestErrorMsg.Builder buildBadRequestErrorMsg() {
+        return new OFBadRequestErrorMsgVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModFailedErrorMsg.Builder buildFlowModFailedErrorMsg() {
+        return new OFFlowModFailedErrorMsgVer10.Builder().setXid(nextXid());
+    }
+
+    public OFHelloFailedErrorMsg.Builder buildHelloFailedErrorMsg() {
+        return new OFHelloFailedErrorMsgVer10.Builder().setXid(nextXid());
+    }
+
+    public OFPortModFailedErrorMsg.Builder buildPortModFailedErrorMsg() {
+        return new OFPortModFailedErrorMsgVer10.Builder().setXid(nextXid());
+    }
+
+    public OFQueueOpFailedErrorMsg.Builder buildQueueOpFailedErrorMsg() {
+        return new OFQueueOpFailedErrorMsgVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBadInstructionErrorMsg.Builder buildBadInstructionErrorMsg() {
+        throw new UnsupportedOperationException("OFBadInstructionErrorMsg not supported in version 1.0");
+    }
+
+    public OFBadMatchErrorMsg.Builder buildBadMatchErrorMsg() {
+        throw new UnsupportedOperationException("OFBadMatchErrorMsg not supported in version 1.0");
+    }
+
+    public OFGroupModFailedErrorMsg.Builder buildGroupModFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFGroupModFailedErrorMsg not supported in version 1.0");
+    }
+
+    public OFSwitchConfigFailedErrorMsg.Builder buildSwitchConfigFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFSwitchConfigFailedErrorMsg not supported in version 1.0");
+    }
+
+    public OFTableModFailedErrorMsg.Builder buildTableModFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFTableModFailedErrorMsg not supported in version 1.0");
+    }
+
+    public OFExperimenterErrorMsg.Builder buildExperimenterErrorMsg() {
+        throw new UnsupportedOperationException("OFExperimenterErrorMsg not supported in version 1.0");
+    }
+
+    public OFRoleRequestFailedErrorMsg.Builder buildRoleRequestFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFRoleRequestFailedErrorMsg not supported in version 1.0");
+    }
+
+    public OFMeterModFailedErrorMsg.Builder buildMeterModFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFMeterModFailedErrorMsg not supported in version 1.0");
+    }
+
+    public OFTableFeaturesFailedErrorMsg.Builder buildTableFeaturesFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFTableFeaturesFailedErrorMsg not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFErrorMsg> getReader() {
+        return OFErrorMsgVer10.READER;
+    }
+
+    public long nextXid() {
+        return xidGenerator.nextXid();
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorTypeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorTypeSerializerVer10.java
new file mode 100644
index 0000000..14e4696
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFErrorTypeSerializerVer10.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFErrorType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFErrorTypeSerializerVer10 {
+
+    public final static short HELLO_FAILED_VAL = (short) 0x0;
+    public final static short BAD_REQUEST_VAL = (short) 0x1;
+    public final static short BAD_ACTION_VAL = (short) 0x2;
+    public final static short FLOW_MOD_FAILED_VAL = (short) 0x3;
+    public final static short PORT_MOD_FAILED_VAL = (short) 0x4;
+    public final static short QUEUE_OP_FAILED_VAL = (short) 0x5;
+
+    public static OFErrorType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFErrorType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFErrorType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFErrorType ofWireValue(short val) {
+        switch(val) {
+            case HELLO_FAILED_VAL:
+                return OFErrorType.HELLO_FAILED;
+            case BAD_REQUEST_VAL:
+                return OFErrorType.BAD_REQUEST;
+            case BAD_ACTION_VAL:
+                return OFErrorType.BAD_ACTION;
+            case FLOW_MOD_FAILED_VAL:
+                return OFErrorType.FLOW_MOD_FAILED;
+            case PORT_MOD_FAILED_VAL:
+                return OFErrorType.PORT_MOD_FAILED;
+            case QUEUE_OP_FAILED_VAL:
+                return OFErrorType.QUEUE_OP_FAILED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFErrorType in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFErrorType e) {
+        switch(e) {
+            case HELLO_FAILED:
+                return HELLO_FAILED_VAL;
+            case BAD_REQUEST:
+                return BAD_REQUEST_VAL;
+            case BAD_ACTION:
+                return BAD_ACTION_VAL;
+            case FLOW_MOD_FAILED:
+                return FLOW_MOD_FAILED_VAL;
+            case PORT_MOD_FAILED:
+                return PORT_MOD_FAILED_VAL;
+            case QUEUE_OP_FAILED:
+                return QUEUE_OP_FAILED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFErrorType in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterStatsReplyVer10.java
new file mode 100644
index 0000000..f97c13c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterStatsReplyVer10.java
@@ -0,0 +1,70 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterStatsReplyVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFExperimenterStatsReplyVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenterStatsReply> {
+        @Override
+        public OFExperimenterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsReplyFlagsSerializerVer10.readFrom(bb);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsReplyVer10
+                   return OFBsnStatsReplyVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterStatsReplyVer10: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterStatsRequestVer10.java
new file mode 100644
index 0000000..fbe9855
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterStatsRequestVer10.java
@@ -0,0 +1,70 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterStatsRequestVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFExperimenterStatsRequestVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenterStatsRequest<?>> {
+        @Override
+        public OFExperimenterStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsRequestFlagsSerializerVer10.readFrom(bb);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsRequestVer10
+                   return OFBsnStatsRequestVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterStatsRequestVer10: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterVer10.java
new file mode 100644
index 0000000..37b7c26
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFExperimenterVer10.java
@@ -0,0 +1,68 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+
+    public final static OFExperimenterVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenter> {
+        @Override
+        public OFExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnHeaderVer10
+                   return OFBsnHeaderVer10.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFNiciraHeaderVer10
+                   return OFNiciraHeaderVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterVer10: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFactoryVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFactoryVer10.java
new file mode 100644
index 0000000..7ef1b32
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFactoryVer10.java
@@ -0,0 +1,1245 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.projectfloodlight.openflow.protocol.OFOxmList;
+
+
+public class OFFactoryVer10 implements OFFactory {
+    public final static OFFactoryVer10 INSTANCE = new OFFactoryVer10();
+
+    private final XidGenerator xidGenerator = XidGenerators.global();
+
+    public OFActions actions() {
+        return OFActionsVer10.INSTANCE;
+    }
+    public OFInstructions instructions() {
+        return OFInstructionsVer10.INSTANCE;
+    }
+    public OFMeterBands meterBands() {
+        return OFMeterBandsVer10.INSTANCE;
+    }
+    public OFOxms oxms() {
+        return OFOxmsVer10.INSTANCE;
+    }
+    public OFQueueProps queueProps() {
+        return OFQueuePropsVer10.INSTANCE;
+    }
+    public OFErrorMsgs errorMsgs() {
+        return OFErrorMsgsVer10.INSTANCE;
+    }
+    public OFActionIds actionIds() {
+        return OFActionIdsVer10.INSTANCE;
+    }
+    public OFInstructionIds instructionIds() {
+        return OFInstructionIdsVer10.INSTANCE;
+    }
+    public OFBsnTlvs bsnTlvs() {
+        return OFBsnTlvsVer10.INSTANCE;
+    }
+
+
+    public OFAggregateStatsReply.Builder buildAggregateStatsReply() {
+        return new OFAggregateStatsReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFAggregateStatsRequest.Builder buildAggregateStatsRequest() {
+        return new OFAggregateStatsRequestVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBarrierReply.Builder buildBarrierReply() {
+        return new OFBarrierReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFBarrierReply barrierReply() {
+        return new OFBarrierReplyVer10(
+                nextXid()
+                    );
+    }
+
+    public OFBarrierRequest.Builder buildBarrierRequest() {
+        return new OFBarrierRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBarrierRequest barrierRequest() {
+        return new OFBarrierRequestVer10(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwClearDataReply.Builder buildBsnBwClearDataReply() {
+        return new OFBsnBwClearDataReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnBwClearDataReply bsnBwClearDataReply(long status) {
+        return new OFBsnBwClearDataReplyVer10(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnBwClearDataRequest.Builder buildBsnBwClearDataRequest() {
+        return new OFBsnBwClearDataRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnBwClearDataRequest bsnBwClearDataRequest() {
+        return new OFBsnBwClearDataRequestVer10(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwEnableGetReply.Builder buildBsnBwEnableGetReply() {
+        return new OFBsnBwEnableGetReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableGetReply bsnBwEnableGetReply(long enabled) {
+        return new OFBsnBwEnableGetReplyVer10(
+                nextXid(),
+                      enabled
+                    );
+    }
+
+    public OFBsnBwEnableGetRequest.Builder buildBsnBwEnableGetRequest() {
+        return new OFBsnBwEnableGetRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableGetRequest bsnBwEnableGetRequest() {
+        return new OFBsnBwEnableGetRequestVer10(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwEnableSetReply.Builder buildBsnBwEnableSetReply() {
+        return new OFBsnBwEnableSetReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnBwEnableSetRequest.Builder buildBsnBwEnableSetRequest() {
+        return new OFBsnBwEnableSetRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableSetRequest bsnBwEnableSetRequest(long enable) {
+        return new OFBsnBwEnableSetRequestVer10(
+                nextXid(),
+                      enable
+                    );
+    }
+
+    public OFBsnGetInterfacesReply.Builder buildBsnGetInterfacesReply() {
+        return new OFBsnGetInterfacesReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnGetInterfacesReply bsnGetInterfacesReply(List<OFBsnInterface> interfaces) {
+        return new OFBsnGetInterfacesReplyVer10(
+                nextXid(),
+                      interfaces
+                    );
+    }
+
+    public OFBsnGetInterfacesRequest.Builder buildBsnGetInterfacesRequest() {
+        return new OFBsnGetInterfacesRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnGetInterfacesRequest bsnGetInterfacesRequest() {
+        return new OFBsnGetInterfacesRequestVer10(
+                nextXid()
+                    );
+    }
+
+    public OFBsnGetIpMaskReply.Builder buildBsnGetIpMaskReply() {
+        return new OFBsnGetIpMaskReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGetIpMaskRequest.Builder buildBsnGetIpMaskRequest() {
+        return new OFBsnGetIpMaskRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnGetIpMaskRequest bsnGetIpMaskRequest(short index) {
+        return new OFBsnGetIpMaskRequestVer10(
+                nextXid(),
+                      index
+                    );
+    }
+
+    public OFBsnGetL2TableReply.Builder buildBsnGetL2TableReply() {
+        return new OFBsnGetL2TableReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGetL2TableRequest.Builder buildBsnGetL2TableRequest() {
+        return new OFBsnGetL2TableRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnGetL2TableRequest bsnGetL2TableRequest() {
+        return new OFBsnGetL2TableRequestVer10(
+                nextXid()
+                    );
+    }
+
+    public OFBsnGetMirroringReply.Builder buildBsnGetMirroringReply() {
+        return new OFBsnGetMirroringReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnGetMirroringReply bsnGetMirroringReply(short reportMirrorPorts) {
+        return new OFBsnGetMirroringReplyVer10(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnGetMirroringRequest.Builder buildBsnGetMirroringRequest() {
+        return new OFBsnGetMirroringRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnGetMirroringRequest bsnGetMirroringRequest(short reportMirrorPorts) {
+        return new OFBsnGetMirroringRequestVer10(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnHybridGetReply.Builder buildBsnHybridGetReply() {
+        return new OFBsnHybridGetReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnHybridGetRequest.Builder buildBsnHybridGetRequest() {
+        return new OFBsnHybridGetRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnHybridGetRequest bsnHybridGetRequest() {
+        return new OFBsnHybridGetRequestVer10(
+                nextXid()
+                    );
+    }
+
+    public OFBsnInterface.Builder buildBsnInterface() {
+        return new OFBsnInterfaceVer10.Builder();
+    }
+
+    public OFBsnPduRxReply.Builder buildBsnPduRxReply() {
+        return new OFBsnPduRxReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduRxRequest.Builder buildBsnPduRxRequest() {
+        return new OFBsnPduRxRequestVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduRxTimeout.Builder buildBsnPduRxTimeout() {
+        return new OFBsnPduRxTimeoutVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduTxReply.Builder buildBsnPduTxReply() {
+        return new OFBsnPduTxReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduTxRequest.Builder buildBsnPduTxRequest() {
+        return new OFBsnPduTxRequestVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetIpMask.Builder buildBsnSetIpMask() {
+        return new OFBsnSetIpMaskVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetL2TableReply.Builder buildBsnSetL2TableReply() {
+        return new OFBsnSetL2TableReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetL2TableRequest.Builder buildBsnSetL2TableRequest() {
+        return new OFBsnSetL2TableRequestVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetMirroring.Builder buildBsnSetMirroring() {
+        return new OFBsnSetMirroringVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnSetMirroring bsnSetMirroring(short reportMirrorPorts) {
+        return new OFBsnSetMirroringVer10(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnSetPktinSuppressionReply.Builder buildBsnSetPktinSuppressionReply() {
+        return new OFBsnSetPktinSuppressionReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnSetPktinSuppressionReply bsnSetPktinSuppressionReply(long status) {
+        return new OFBsnSetPktinSuppressionReplyVer10(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnSetPktinSuppressionRequest.Builder buildBsnSetPktinSuppressionRequest() {
+        return new OFBsnSetPktinSuppressionRequestVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnShellCommand.Builder buildBsnShellCommand() {
+        return new OFBsnShellCommandVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnShellOutput.Builder buildBsnShellOutput() {
+        return new OFBsnShellOutputVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnShellOutput bsnShellOutput(byte[] data) {
+        return new OFBsnShellOutputVer10(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFBsnShellStatus.Builder buildBsnShellStatus() {
+        return new OFBsnShellStatusVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnShellStatus bsnShellStatus(long status) {
+        return new OFBsnShellStatusVer10(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnVirtualPortCreateReply.Builder buildBsnVirtualPortCreateReply() {
+        return new OFBsnVirtualPortCreateReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFBsnVirtualPortCreateRequest.Builder buildBsnVirtualPortCreateRequest() {
+        return new OFBsnVirtualPortCreateRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest(OFBsnVport vport) {
+        return new OFBsnVirtualPortCreateRequestVer10(
+                nextXid(),
+                      vport
+                    );
+    }
+
+    public OFBsnVirtualPortRemoveReply.Builder buildBsnVirtualPortRemoveReply() {
+        return new OFBsnVirtualPortRemoveReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortRemoveReply bsnVirtualPortRemoveReply(long status) {
+        return new OFBsnVirtualPortRemoveReplyVer10(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnVirtualPortRemoveRequest.Builder buildBsnVirtualPortRemoveRequest() {
+        return new OFBsnVirtualPortRemoveRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortRemoveRequest bsnVirtualPortRemoveRequest(long vportNo) {
+        return new OFBsnVirtualPortRemoveRequestVer10(
+                nextXid(),
+                      vportNo
+                    );
+    }
+
+    public OFBsnVportL2Gre.Builder buildBsnVportL2Gre() {
+        return new OFBsnVportL2GreVer10.Builder();
+    }
+
+    public OFBsnVportQInQ.Builder buildBsnVportQInQ() {
+        return new OFBsnVportQInQVer10.Builder();
+    }
+
+    public OFDescStatsReply.Builder buildDescStatsReply() {
+        return new OFDescStatsReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFDescStatsRequest.Builder buildDescStatsRequest() {
+        return new OFDescStatsRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFDescStatsRequest descStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFDescStatsRequestVer10(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFEchoReply.Builder buildEchoReply() {
+        return new OFEchoReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFEchoReply echoReply(byte[] data) {
+        return new OFEchoReplyVer10(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFEchoRequest.Builder buildEchoRequest() {
+        return new OFEchoRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFEchoRequest echoRequest(byte[] data) {
+        return new OFEchoRequestVer10(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFFeaturesReply.Builder buildFeaturesReply() {
+        return new OFFeaturesReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFeaturesRequest.Builder buildFeaturesRequest() {
+        return new OFFeaturesRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFFeaturesRequest featuresRequest() {
+        return new OFFeaturesRequestVer10(
+                nextXid()
+                    );
+    }
+
+    public OFFlowAdd.Builder buildFlowAdd() {
+        return new OFFlowAddVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFlowDelete.Builder buildFlowDelete() {
+        return new OFFlowDeleteVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFlowDeleteStrict.Builder buildFlowDeleteStrict() {
+        return new OFFlowDeleteStrictVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModify.Builder buildFlowModify() {
+        return new OFFlowModifyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModifyStrict.Builder buildFlowModifyStrict() {
+        return new OFFlowModifyStrictVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFlowRemoved.Builder buildFlowRemoved() {
+        return new OFFlowRemovedVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFlowStatsEntry.Builder buildFlowStatsEntry() {
+        return new OFFlowStatsEntryVer10.Builder();
+    }
+
+    public OFFlowStatsReply.Builder buildFlowStatsReply() {
+        return new OFFlowStatsReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFFlowStatsRequest.Builder buildFlowStatsRequest() {
+        return new OFFlowStatsRequestVer10.Builder().setXid(nextXid());
+    }
+
+    public OFGetConfigReply.Builder buildGetConfigReply() {
+        return new OFGetConfigReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFGetConfigRequest.Builder buildGetConfigRequest() {
+        return new OFGetConfigRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFGetConfigRequest getConfigRequest() {
+        return new OFGetConfigRequestVer10(
+                nextXid()
+                    );
+    }
+
+    public OFHello.Builder buildHello() {
+        return new OFHelloVer10.Builder().setXid(nextXid());
+    }
+    public OFHello hello(List<OFHelloElem> elements) {
+        return new OFHelloVer10(
+                nextXid()
+                    );
+    }
+
+    public OFMatchV1.Builder buildMatchV1() {
+        return new OFMatchV1Ver10.Builder();
+    }
+    public Match.Builder buildMatch() {
+        return new OFMatchV1Ver10.Builder();
+    }
+
+    final static Match MATCH_WILDCARD_ALL = OFMatchV1Ver10.DEFAULT;
+
+    public Match matchWildcardAll() {
+        return MATCH_WILDCARD_ALL;
+    }
+
+    public OFNiciraControllerRoleReply.Builder buildNiciraControllerRoleReply() {
+        return new OFNiciraControllerRoleReplyVer10.Builder().setXid(nextXid());
+    }
+    public OFNiciraControllerRoleReply niciraControllerRoleReply(OFNiciraControllerRole role) {
+        return new OFNiciraControllerRoleReplyVer10(
+                nextXid(),
+                      role
+                    );
+    }
+
+    public OFNiciraControllerRoleRequest.Builder buildNiciraControllerRoleRequest() {
+        return new OFNiciraControllerRoleRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFNiciraControllerRoleRequest niciraControllerRoleRequest(OFNiciraControllerRole role) {
+        return new OFNiciraControllerRoleRequestVer10(
+                nextXid(),
+                      role
+                    );
+    }
+
+    public OFPacketIn.Builder buildPacketIn() {
+        return new OFPacketInVer10.Builder().setXid(nextXid());
+    }
+
+    public OFPacketOut.Builder buildPacketOut() {
+        return new OFPacketOutVer10.Builder().setXid(nextXid());
+    }
+
+    public OFPacketQueue.Builder buildPacketQueue() {
+        return new OFPacketQueueVer10.Builder();
+    }
+
+    public OFPortDesc.Builder buildPortDesc() {
+        return new OFPortDescVer10.Builder();
+    }
+
+    public OFPortMod.Builder buildPortMod() {
+        return new OFPortModVer10.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatsEntry.Builder buildPortStatsEntry() {
+        return new OFPortStatsEntryVer10.Builder();
+    }
+
+    public OFPortStatsReply.Builder buildPortStatsReply() {
+        return new OFPortStatsReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatsRequest.Builder buildPortStatsRequest() {
+        return new OFPortStatsRequestVer10.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatus.Builder buildPortStatus() {
+        return new OFPortStatusVer10.Builder().setXid(nextXid());
+    }
+
+    public OFQueueGetConfigReply.Builder buildQueueGetConfigReply() {
+        return new OFQueueGetConfigReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFQueueGetConfigRequest.Builder buildQueueGetConfigRequest() {
+        return new OFQueueGetConfigRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFQueueGetConfigRequest queueGetConfigRequest(OFPort port) {
+        return new OFQueueGetConfigRequestVer10(
+                nextXid(),
+                      port
+                    );
+    }
+
+    public OFQueueStatsEntry.Builder buildQueueStatsEntry() {
+        return new OFQueueStatsEntryVer10.Builder();
+    }
+
+    public OFQueueStatsReply.Builder buildQueueStatsReply() {
+        return new OFQueueStatsReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFQueueStatsRequest.Builder buildQueueStatsRequest() {
+        return new OFQueueStatsRequestVer10.Builder().setXid(nextXid());
+    }
+
+    public OFSetConfig.Builder buildSetConfig() {
+        return new OFSetConfigVer10.Builder().setXid(nextXid());
+    }
+
+    public OFTableMod.Builder buildTableMod() {
+        throw new UnsupportedOperationException("OFTableMod not supported in version 1.0");
+    }
+
+    public OFTableStatsEntry.Builder buildTableStatsEntry() {
+        return new OFTableStatsEntryVer10.Builder();
+    }
+
+    public OFTableStatsReply.Builder buildTableStatsReply() {
+        return new OFTableStatsReplyVer10.Builder().setXid(nextXid());
+    }
+
+    public OFTableStatsRequest.Builder buildTableStatsRequest() {
+        return new OFTableStatsRequestVer10.Builder().setXid(nextXid());
+    }
+    public OFTableStatsRequest tableStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFTableStatsRequestVer10(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBucket.Builder buildBucket() {
+        throw new UnsupportedOperationException("OFBucket not supported in version 1.0");
+    }
+
+    public OFBucketCounter.Builder buildBucketCounter() {
+        throw new UnsupportedOperationException("OFBucketCounter not supported in version 1.0");
+    }
+    public OFBucketCounter bucketCounter(U64 packetCount, U64 byteCount) {
+        throw new UnsupportedOperationException("OFBucketCounter not supported in version 1.0");
+    }
+
+    public OFGroupAdd.Builder buildGroupAdd() {
+        throw new UnsupportedOperationException("OFGroupAdd not supported in version 1.0");
+    }
+
+    public OFGroupDelete.Builder buildGroupDelete() {
+        throw new UnsupportedOperationException("OFGroupDelete not supported in version 1.0");
+    }
+
+    public OFGroupDescStatsEntry.Builder buildGroupDescStatsEntry() {
+        throw new UnsupportedOperationException("OFGroupDescStatsEntry not supported in version 1.0");
+    }
+
+    public OFGroupDescStatsReply.Builder buildGroupDescStatsReply() {
+        throw new UnsupportedOperationException("OFGroupDescStatsReply not supported in version 1.0");
+    }
+
+    public OFGroupDescStatsRequest.Builder buildGroupDescStatsRequest() {
+        throw new UnsupportedOperationException("OFGroupDescStatsRequest not supported in version 1.0");
+    }
+    public OFGroupDescStatsRequest groupDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFGroupDescStatsRequest not supported in version 1.0");
+    }
+
+    public OFGroupModify.Builder buildGroupModify() {
+        throw new UnsupportedOperationException("OFGroupModify not supported in version 1.0");
+    }
+
+    public OFGroupStatsEntry.Builder buildGroupStatsEntry() {
+        throw new UnsupportedOperationException("OFGroupStatsEntry not supported in version 1.0");
+    }
+
+    public OFGroupStatsReply.Builder buildGroupStatsReply() {
+        throw new UnsupportedOperationException("OFGroupStatsReply not supported in version 1.0");
+    }
+
+    public OFGroupStatsRequest.Builder buildGroupStatsRequest() {
+        throw new UnsupportedOperationException("OFGroupStatsRequest not supported in version 1.0");
+    }
+
+    public OFMatchV2.Builder buildMatchV2() {
+        throw new UnsupportedOperationException("OFMatchV2 not supported in version 1.0");
+    }
+
+    public OFGroupFeaturesStatsReply.Builder buildGroupFeaturesStatsReply() {
+        throw new UnsupportedOperationException("OFGroupFeaturesStatsReply not supported in version 1.0");
+    }
+
+    public OFGroupFeaturesStatsRequest.Builder buildGroupFeaturesStatsRequest() {
+        throw new UnsupportedOperationException("OFGroupFeaturesStatsRequest not supported in version 1.0");
+    }
+    public OFGroupFeaturesStatsRequest groupFeaturesStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFGroupFeaturesStatsRequest not supported in version 1.0");
+    }
+
+    public OFMatchV3.Builder buildMatchV3() {
+        throw new UnsupportedOperationException("OFMatchV3 not supported in version 1.0");
+    }
+    public OFMatchV3 matchV3(OFOxmList oxmList) {
+        throw new UnsupportedOperationException("OFMatchV3 not supported in version 1.0");
+    }
+
+    public OFRoleReply.Builder buildRoleReply() {
+        throw new UnsupportedOperationException("OFRoleReply not supported in version 1.0");
+    }
+
+    public OFRoleRequest.Builder buildRoleRequest() {
+        throw new UnsupportedOperationException("OFRoleRequest not supported in version 1.0");
+    }
+
+    public OFAsyncGetReply.Builder buildAsyncGetReply() {
+        throw new UnsupportedOperationException("OFAsyncGetReply not supported in version 1.0");
+    }
+
+    public OFAsyncGetRequest.Builder buildAsyncGetRequest() {
+        throw new UnsupportedOperationException("OFAsyncGetRequest not supported in version 1.0");
+    }
+
+    public OFAsyncSet.Builder buildAsyncSet() {
+        throw new UnsupportedOperationException("OFAsyncSet not supported in version 1.0");
+    }
+
+    public OFBsnArpIdle.Builder buildBsnArpIdle() {
+        throw new UnsupportedOperationException("OFBsnArpIdle not supported in version 1.0");
+    }
+
+    public OFBsnControllerConnection.Builder buildBsnControllerConnection() {
+        throw new UnsupportedOperationException("OFBsnControllerConnection not supported in version 1.0");
+    }
+
+    public OFBsnControllerConnectionsReply.Builder buildBsnControllerConnectionsReply() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsReply not supported in version 1.0");
+    }
+    public OFBsnControllerConnectionsReply bsnControllerConnectionsReply(List<OFBsnControllerConnection> connections) {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsReply not supported in version 1.0");
+    }
+
+    public OFBsnControllerConnectionsRequest.Builder buildBsnControllerConnectionsRequest() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsRequest not supported in version 1.0");
+    }
+    public OFBsnControllerConnectionsRequest bsnControllerConnectionsRequest() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsRequest not supported in version 1.0");
+    }
+
+    public OFBsnDebugCounterDescStatsEntry.Builder buildBsnDebugCounterDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnDebugCounterDescStatsReply.Builder buildBsnDebugCounterDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnDebugCounterDescStatsRequest.Builder buildBsnDebugCounterDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsRequest not supported in version 1.0");
+    }
+    public OFBsnDebugCounterDescStatsRequest bsnDebugCounterDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnDebugCounterStatsEntry.Builder buildBsnDebugCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsEntry not supported in version 1.0");
+    }
+    public OFBsnDebugCounterStatsEntry bsnDebugCounterStatsEntry(U64 counterId, U64 value) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnDebugCounterStatsReply.Builder buildBsnDebugCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnDebugCounterStatsRequest.Builder buildBsnDebugCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsRequest not supported in version 1.0");
+    }
+    public OFBsnDebugCounterStatsRequest bsnDebugCounterStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnFlowChecksumBucketStatsEntry.Builder buildBsnFlowChecksumBucketStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsEntry not supported in version 1.0");
+    }
+    public OFBsnFlowChecksumBucketStatsEntry bsnFlowChecksumBucketStatsEntry(U64 checksum) {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnFlowChecksumBucketStatsReply.Builder buildBsnFlowChecksumBucketStatsReply() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnFlowChecksumBucketStatsRequest.Builder buildBsnFlowChecksumBucketStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnFlowIdle.Builder buildBsnFlowIdle() {
+        throw new UnsupportedOperationException("OFBsnFlowIdle not supported in version 1.0");
+    }
+
+    public OFBsnFlowIdleEnableGetReply.Builder buildBsnFlowIdleEnableGetReply() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetReply not supported in version 1.0");
+    }
+    public OFBsnFlowIdleEnableGetReply bsnFlowIdleEnableGetReply(long enabled) {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetReply not supported in version 1.0");
+    }
+
+    public OFBsnFlowIdleEnableGetRequest.Builder buildBsnFlowIdleEnableGetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetRequest not supported in version 1.0");
+    }
+    public OFBsnFlowIdleEnableGetRequest bsnFlowIdleEnableGetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetRequest not supported in version 1.0");
+    }
+
+    public OFBsnFlowIdleEnableSetReply.Builder buildBsnFlowIdleEnableSetReply() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetReply not supported in version 1.0");
+    }
+
+    public OFBsnFlowIdleEnableSetRequest.Builder buildBsnFlowIdleEnableSetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetRequest not supported in version 1.0");
+    }
+    public OFBsnFlowIdleEnableSetRequest bsnFlowIdleEnableSetRequest(long enable) {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetRequest not supported in version 1.0");
+    }
+
+    public OFBsnGentableBucketStatsEntry.Builder buildBsnGentableBucketStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsEntry not supported in version 1.0");
+    }
+    public OFBsnGentableBucketStatsEntry bsnGentableBucketStatsEntry(U128 checksum) {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnGentableBucketStatsReply.Builder buildBsnGentableBucketStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnGentableBucketStatsRequest.Builder buildBsnGentableBucketStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnGentableClearReply.Builder buildBsnGentableClearReply() {
+        throw new UnsupportedOperationException("OFBsnGentableClearReply not supported in version 1.0");
+    }
+
+    public OFBsnGentableClearRequest.Builder buildBsnGentableClearRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableClearRequest not supported in version 1.0");
+    }
+
+    public OFBsnGentableDescStatsEntry.Builder buildBsnGentableDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnGentableDescStatsReply.Builder buildBsnGentableDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnGentableDescStatsRequest.Builder buildBsnGentableDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsRequest not supported in version 1.0");
+    }
+    public OFBsnGentableDescStatsRequest bsnGentableDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnGentableEntryAdd.Builder buildBsnGentableEntryAdd() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryAdd not supported in version 1.0");
+    }
+
+    public OFBsnGentableEntryDelete.Builder buildBsnGentableEntryDelete() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDelete not supported in version 1.0");
+    }
+
+    public OFBsnGentableEntryDescStatsEntry.Builder buildBsnGentableEntryDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnGentableEntryDescStatsReply.Builder buildBsnGentableEntryDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnGentableEntryDescStatsRequest.Builder buildBsnGentableEntryDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnGentableEntryStatsEntry.Builder buildBsnGentableEntryStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsEntry not supported in version 1.0");
+    }
+    public OFBsnGentableEntryStatsEntry bsnGentableEntryStatsEntry(List<OFBsnTlv> key, List<OFBsnTlv> stats) {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnGentableEntryStatsReply.Builder buildBsnGentableEntryStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnGentableEntryStatsRequest.Builder buildBsnGentableEntryStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnGentableSetBucketsSize.Builder buildBsnGentableSetBucketsSize() {
+        throw new UnsupportedOperationException("OFBsnGentableSetBucketsSize not supported in version 1.0");
+    }
+
+    public OFBsnGentableStatsEntry.Builder buildBsnGentableStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnGentableStatsReply.Builder buildBsnGentableStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnGentableStatsRequest.Builder buildBsnGentableStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsRequest not supported in version 1.0");
+    }
+    public OFBsnGentableStatsRequest bsnGentableStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnGentableStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnGetSwitchPipelineReply.Builder buildBsnGetSwitchPipelineReply() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineReply not supported in version 1.0");
+    }
+    public OFBsnGetSwitchPipelineReply bsnGetSwitchPipelineReply(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineReply not supported in version 1.0");
+    }
+
+    public OFBsnGetSwitchPipelineRequest.Builder buildBsnGetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineRequest not supported in version 1.0");
+    }
+    public OFBsnGetSwitchPipelineRequest bsnGetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineRequest not supported in version 1.0");
+    }
+
+    public OFBsnImageDescStatsReply.Builder buildBsnImageDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnImageDescStatsRequest.Builder buildBsnImageDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsRequest not supported in version 1.0");
+    }
+    public OFBsnImageDescStatsRequest bsnImageDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnLacpConvergenceNotif.Builder buildBsnLacpConvergenceNotif() {
+        throw new UnsupportedOperationException("OFBsnLacpConvergenceNotif not supported in version 1.0");
+    }
+
+    public OFBsnLacpStatsEntry.Builder buildBsnLacpStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnLacpStatsReply.Builder buildBsnLacpStatsReply() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnLacpStatsRequest.Builder buildBsnLacpStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsRequest not supported in version 1.0");
+    }
+    public OFBsnLacpStatsRequest bsnLacpStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnLacpStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnLog.Builder buildBsnLog() {
+        throw new UnsupportedOperationException("OFBsnLog not supported in version 1.0");
+    }
+
+    public OFBsnPortCounterStatsEntry.Builder buildBsnPortCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsEntry not supported in version 1.0");
+    }
+    public OFBsnPortCounterStatsEntry bsnPortCounterStatsEntry(OFPort portNo, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnPortCounterStatsReply.Builder buildBsnPortCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnPortCounterStatsRequest.Builder buildBsnPortCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnRoleStatus.Builder buildBsnRoleStatus() {
+        throw new UnsupportedOperationException("OFBsnRoleStatus not supported in version 1.0");
+    }
+
+    public OFBsnSetAuxCxnsReply.Builder buildBsnSetAuxCxnsReply() {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsReply not supported in version 1.0");
+    }
+
+    public OFBsnSetAuxCxnsRequest.Builder buildBsnSetAuxCxnsRequest() {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsRequest not supported in version 1.0");
+    }
+    public OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest(long numAux) {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsRequest not supported in version 1.0");
+    }
+
+    public OFBsnSetLacpReply.Builder buildBsnSetLacpReply() {
+        throw new UnsupportedOperationException("OFBsnSetLacpReply not supported in version 1.0");
+    }
+
+    public OFBsnSetLacpRequest.Builder buildBsnSetLacpRequest() {
+        throw new UnsupportedOperationException("OFBsnSetLacpRequest not supported in version 1.0");
+    }
+
+    public OFBsnSetSwitchPipelineReply.Builder buildBsnSetSwitchPipelineReply() {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineReply not supported in version 1.0");
+    }
+    public OFBsnSetSwitchPipelineReply bsnSetSwitchPipelineReply(long status) {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineReply not supported in version 1.0");
+    }
+
+    public OFBsnSetSwitchPipelineRequest.Builder buildBsnSetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineRequest not supported in version 1.0");
+    }
+    public OFBsnSetSwitchPipelineRequest bsnSetSwitchPipelineRequest(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineRequest not supported in version 1.0");
+    }
+
+    public OFBsnSwitchPipelineStatsEntry.Builder buildBsnSwitchPipelineStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsEntry not supported in version 1.0");
+    }
+    public OFBsnSwitchPipelineStatsEntry bsnSwitchPipelineStatsEntry(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnSwitchPipelineStatsReply.Builder buildBsnSwitchPipelineStatsReply() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnSwitchPipelineStatsRequest.Builder buildBsnSwitchPipelineStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsRequest not supported in version 1.0");
+    }
+    public OFBsnSwitchPipelineStatsRequest bsnSwitchPipelineStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnTableChecksumStatsEntry.Builder buildBsnTableChecksumStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsEntry not supported in version 1.0");
+    }
+    public OFBsnTableChecksumStatsEntry bsnTableChecksumStatsEntry(TableId tableId, U64 checksum) {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnTableChecksumStatsReply.Builder buildBsnTableChecksumStatsReply() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnTableChecksumStatsRequest.Builder buildBsnTableChecksumStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsRequest not supported in version 1.0");
+    }
+    public OFBsnTableChecksumStatsRequest bsnTableChecksumStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnTableSetBucketsSize.Builder buildBsnTableSetBucketsSize() {
+        throw new UnsupportedOperationException("OFBsnTableSetBucketsSize not supported in version 1.0");
+    }
+
+    public OFBsnTimeReply.Builder buildBsnTimeReply() {
+        throw new UnsupportedOperationException("OFBsnTimeReply not supported in version 1.0");
+    }
+    public OFBsnTimeReply bsnTimeReply(U64 timeMs) {
+        throw new UnsupportedOperationException("OFBsnTimeReply not supported in version 1.0");
+    }
+
+    public OFBsnTimeRequest.Builder buildBsnTimeRequest() {
+        throw new UnsupportedOperationException("OFBsnTimeRequest not supported in version 1.0");
+    }
+    public OFBsnTimeRequest bsnTimeRequest() {
+        throw new UnsupportedOperationException("OFBsnTimeRequest not supported in version 1.0");
+    }
+
+    public OFBsnVlanCounterStatsEntry.Builder buildBsnVlanCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsEntry not supported in version 1.0");
+    }
+    public OFBsnVlanCounterStatsEntry bsnVlanCounterStatsEntry(int vlanVid, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnVlanCounterStatsReply.Builder buildBsnVlanCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnVlanCounterStatsRequest.Builder buildBsnVlanCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsRequest not supported in version 1.0");
+    }
+
+    public OFBsnVrfCounterStatsEntry.Builder buildBsnVrfCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsEntry not supported in version 1.0");
+    }
+    public OFBsnVrfCounterStatsEntry bsnVrfCounterStatsEntry(long vrf, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsEntry not supported in version 1.0");
+    }
+
+    public OFBsnVrfCounterStatsReply.Builder buildBsnVrfCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsReply not supported in version 1.0");
+    }
+
+    public OFBsnVrfCounterStatsRequest.Builder buildBsnVrfCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsRequest not supported in version 1.0");
+    }
+
+    public OFHelloElemVersionbitmap.Builder buildHelloElemVersionbitmap() {
+        throw new UnsupportedOperationException("OFHelloElemVersionbitmap not supported in version 1.0");
+    }
+    public OFHelloElemVersionbitmap helloElemVersionbitmap(List<U32> bitmaps) {
+        throw new UnsupportedOperationException("OFHelloElemVersionbitmap not supported in version 1.0");
+    }
+
+    public OFMeterBandStats.Builder buildMeterBandStats() {
+        throw new UnsupportedOperationException("OFMeterBandStats not supported in version 1.0");
+    }
+    public OFMeterBandStats meterBandStats(U64 packetBandCount, U64 byteBandCount) {
+        throw new UnsupportedOperationException("OFMeterBandStats not supported in version 1.0");
+    }
+
+    public OFMeterConfig.Builder buildMeterConfig() {
+        throw new UnsupportedOperationException("OFMeterConfig not supported in version 1.0");
+    }
+
+    public OFMeterConfigStatsReply.Builder buildMeterConfigStatsReply() {
+        throw new UnsupportedOperationException("OFMeterConfigStatsReply not supported in version 1.0");
+    }
+
+    public OFMeterConfigStatsRequest.Builder buildMeterConfigStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterConfigStatsRequest not supported in version 1.0");
+    }
+
+    public OFMeterFeatures.Builder buildMeterFeatures() {
+        throw new UnsupportedOperationException("OFMeterFeatures not supported in version 1.0");
+    }
+
+    public OFMeterFeaturesStatsReply.Builder buildMeterFeaturesStatsReply() {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsReply not supported in version 1.0");
+    }
+
+    public OFMeterFeaturesStatsRequest.Builder buildMeterFeaturesStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsRequest not supported in version 1.0");
+    }
+    public OFMeterFeaturesStatsRequest meterFeaturesStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsRequest not supported in version 1.0");
+    }
+
+    public OFMeterMod.Builder buildMeterMod() {
+        throw new UnsupportedOperationException("OFMeterMod not supported in version 1.0");
+    }
+
+    public OFMeterStats.Builder buildMeterStats() {
+        throw new UnsupportedOperationException("OFMeterStats not supported in version 1.0");
+    }
+
+    public OFMeterStatsReply.Builder buildMeterStatsReply() {
+        throw new UnsupportedOperationException("OFMeterStatsReply not supported in version 1.0");
+    }
+
+    public OFMeterStatsRequest.Builder buildMeterStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterStatsRequest not supported in version 1.0");
+    }
+
+    public OFPortDescStatsReply.Builder buildPortDescStatsReply() {
+        throw new UnsupportedOperationException("OFPortDescStatsReply not supported in version 1.0");
+    }
+
+    public OFPortDescStatsRequest.Builder buildPortDescStatsRequest() {
+        throw new UnsupportedOperationException("OFPortDescStatsRequest not supported in version 1.0");
+    }
+    public OFPortDescStatsRequest portDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFPortDescStatsRequest not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropApplyActions.Builder buildTableFeaturePropApplyActions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActions not supported in version 1.0");
+    }
+    public OFTableFeaturePropApplyActions tableFeaturePropApplyActions(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActions not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropApplyActionsMiss.Builder buildTableFeaturePropApplyActionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActionsMiss not supported in version 1.0");
+    }
+    public OFTableFeaturePropApplyActionsMiss tableFeaturePropApplyActionsMiss(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActionsMiss not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropApplySetfield.Builder buildTableFeaturePropApplySetfield() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfield not supported in version 1.0");
+    }
+    public OFTableFeaturePropApplySetfield tableFeaturePropApplySetfield(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfield not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropApplySetfieldMiss.Builder buildTableFeaturePropApplySetfieldMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfieldMiss not supported in version 1.0");
+    }
+    public OFTableFeaturePropApplySetfieldMiss tableFeaturePropApplySetfieldMiss(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfieldMiss not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropExperimenter.Builder buildTableFeaturePropExperimenter() {
+        throw new UnsupportedOperationException("OFTableFeaturePropExperimenter not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropExperimenterMiss.Builder buildTableFeaturePropExperimenterMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropExperimenterMiss not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropInstructions.Builder buildTableFeaturePropInstructions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructions not supported in version 1.0");
+    }
+    public OFTableFeaturePropInstructions tableFeaturePropInstructions(List<OFInstructionId> instructionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructions not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropInstructionsMiss.Builder buildTableFeaturePropInstructionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructionsMiss not supported in version 1.0");
+    }
+    public OFTableFeaturePropInstructionsMiss tableFeaturePropInstructionsMiss(List<OFInstructionId> instructionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructionsMiss not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropMatch.Builder buildTableFeaturePropMatch() {
+        throw new UnsupportedOperationException("OFTableFeaturePropMatch not supported in version 1.0");
+    }
+    public OFTableFeaturePropMatch tableFeaturePropMatch(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropMatch not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropNextTables.Builder buildTableFeaturePropNextTables() {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTables not supported in version 1.0");
+    }
+    public OFTableFeaturePropNextTables tableFeaturePropNextTables(List<U8> nextTableIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTables not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropNextTablesMiss.Builder buildTableFeaturePropNextTablesMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTablesMiss not supported in version 1.0");
+    }
+    public OFTableFeaturePropNextTablesMiss tableFeaturePropNextTablesMiss(List<U8> nextTableIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTablesMiss not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropWildcards.Builder buildTableFeaturePropWildcards() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWildcards not supported in version 1.0");
+    }
+    public OFTableFeaturePropWildcards tableFeaturePropWildcards(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWildcards not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropWriteActions.Builder buildTableFeaturePropWriteActions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActions not supported in version 1.0");
+    }
+    public OFTableFeaturePropWriteActions tableFeaturePropWriteActions(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActions not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropWriteActionsMiss.Builder buildTableFeaturePropWriteActionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActionsMiss not supported in version 1.0");
+    }
+    public OFTableFeaturePropWriteActionsMiss tableFeaturePropWriteActionsMiss(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActionsMiss not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropWriteSetfield.Builder buildTableFeaturePropWriteSetfield() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfield not supported in version 1.0");
+    }
+    public OFTableFeaturePropWriteSetfield tableFeaturePropWriteSetfield(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfield not supported in version 1.0");
+    }
+
+    public OFTableFeaturePropWriteSetfieldMiss.Builder buildTableFeaturePropWriteSetfieldMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfieldMiss not supported in version 1.0");
+    }
+    public OFTableFeaturePropWriteSetfieldMiss tableFeaturePropWriteSetfieldMiss(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfieldMiss not supported in version 1.0");
+    }
+
+    public OFTableFeatures.Builder buildTableFeatures() {
+        throw new UnsupportedOperationException("OFTableFeatures not supported in version 1.0");
+    }
+
+    public OFTableFeaturesStatsReply.Builder buildTableFeaturesStatsReply() {
+        throw new UnsupportedOperationException("OFTableFeaturesStatsReply not supported in version 1.0");
+    }
+
+    public OFTableFeaturesStatsRequest.Builder buildTableFeaturesStatsRequest() {
+        throw new UnsupportedOperationException("OFTableFeaturesStatsRequest not supported in version 1.0");
+    }
+
+    public OFUint64.Builder buildUint64() {
+        throw new UnsupportedOperationException("OFUint64 not supported in version 1.0");
+    }
+    public OFUint64 uint64(U64 value) {
+        throw new UnsupportedOperationException("OFUint64 not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFMessage> getReader() {
+        return OFMessageVer10.READER;
+    }
+
+    public long nextXid() {
+        return xidGenerator.nextXid();
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFeaturesReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFeaturesReplyVer10.java
new file mode 100644
index 0000000..2c0d797
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFeaturesReplyVer10.java
@@ -0,0 +1,637 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFeaturesReplyVer10 implements OFFeaturesReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFFeaturesReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static DatapathId DEFAULT_DATAPATH_ID = DatapathId.NONE;
+        private final static long DEFAULT_N_BUFFERS = 0x0L;
+        private final static short DEFAULT_N_TABLES = (short) 0x0;
+        private final static Set<OFCapabilities> DEFAULT_CAPABILITIES = ImmutableSet.<OFCapabilities>of();
+        private final static Set<OFActionType> DEFAULT_ACTIONS = ImmutableSet.<OFActionType>of();
+        private final static List<OFPortDesc> DEFAULT_PORTS = ImmutableList.<OFPortDesc>of();
+
+    // OF message fields
+    private final long xid;
+    private final DatapathId datapathId;
+    private final long nBuffers;
+    private final short nTables;
+    private final Set<OFCapabilities> capabilities;
+    private final Set<OFActionType> actions;
+    private final List<OFPortDesc> ports;
+//
+    // Immutable default instance
+    final static OFFeaturesReplyVer10 DEFAULT = new OFFeaturesReplyVer10(
+        DEFAULT_XID, DEFAULT_DATAPATH_ID, DEFAULT_N_BUFFERS, DEFAULT_N_TABLES, DEFAULT_CAPABILITIES, DEFAULT_ACTIONS, DEFAULT_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFeaturesReplyVer10(long xid, DatapathId datapathId, long nBuffers, short nTables, Set<OFCapabilities> capabilities, Set<OFActionType> actions, List<OFPortDesc> ports) {
+        this.xid = xid;
+        this.datapathId = datapathId;
+        this.nBuffers = nBuffers;
+        this.nTables = nTables;
+        this.capabilities = capabilities;
+        this.actions = actions;
+        this.ports = ports;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public long getReserved()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property reserved not supported in version 1.0");
+    }
+
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public Set<OFActionType> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.0");
+    }
+
+
+
+    public OFFeaturesReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFeaturesReply.Builder {
+        final OFFeaturesReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean datapathIdSet;
+        private DatapathId datapathId;
+        private boolean nBuffersSet;
+        private long nBuffers;
+        private boolean nTablesSet;
+        private short nTables;
+        private boolean capabilitiesSet;
+        private Set<OFCapabilities> capabilities;
+        private boolean actionsSet;
+        private Set<OFActionType> actions;
+        private boolean portsSet;
+        private List<OFPortDesc> ports;
+
+        BuilderWithParent(OFFeaturesReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setDatapathId(DatapathId datapathId) {
+        this.datapathId = datapathId;
+        this.datapathIdSet = true;
+        return this;
+    }
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNBuffers(long nBuffers) {
+        this.nBuffers = nBuffers;
+        this.nBuffersSet = true;
+        return this;
+    }
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNTables(short nTables) {
+        this.nTables = nTables;
+        this.nTablesSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setCapabilities(Set<OFCapabilities> capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getReserved()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property reserved not supported in version 1.0");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setReserved(long reserved) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property reserved not supported in version 1.0");
+    }
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setPorts(List<OFPortDesc> ports) {
+        this.ports = ports;
+        this.portsSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFActionType> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setActions(Set<OFActionType> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setAuxiliaryId(OFAuxId auxiliaryId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.0");
+    }
+
+
+        @Override
+        public OFFeaturesReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                DatapathId datapathId = this.datapathIdSet ? this.datapathId : parentMessage.datapathId;
+                if(datapathId == null)
+                    throw new NullPointerException("Property datapathId must not be null");
+                long nBuffers = this.nBuffersSet ? this.nBuffers : parentMessage.nBuffers;
+                short nTables = this.nTablesSet ? this.nTables : parentMessage.nTables;
+                Set<OFCapabilities> capabilities = this.capabilitiesSet ? this.capabilities : parentMessage.capabilities;
+                if(capabilities == null)
+                    throw new NullPointerException("Property capabilities must not be null");
+                Set<OFActionType> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+                List<OFPortDesc> ports = this.portsSet ? this.ports : parentMessage.ports;
+                if(ports == null)
+                    throw new NullPointerException("Property ports must not be null");
+
+                //
+                return new OFFeaturesReplyVer10(
+                    xid,
+                    datapathId,
+                    nBuffers,
+                    nTables,
+                    capabilities,
+                    actions,
+                    ports
+                );
+        }
+
+    }
+
+    static class Builder implements OFFeaturesReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean datapathIdSet;
+        private DatapathId datapathId;
+        private boolean nBuffersSet;
+        private long nBuffers;
+        private boolean nTablesSet;
+        private short nTables;
+        private boolean capabilitiesSet;
+        private Set<OFCapabilities> capabilities;
+        private boolean actionsSet;
+        private Set<OFActionType> actions;
+        private boolean portsSet;
+        private List<OFPortDesc> ports;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setDatapathId(DatapathId datapathId) {
+        this.datapathId = datapathId;
+        this.datapathIdSet = true;
+        return this;
+    }
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNBuffers(long nBuffers) {
+        this.nBuffers = nBuffers;
+        this.nBuffersSet = true;
+        return this;
+    }
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNTables(short nTables) {
+        this.nTables = nTables;
+        this.nTablesSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setCapabilities(Set<OFCapabilities> capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getReserved()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property reserved not supported in version 1.0");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setReserved(long reserved) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property reserved not supported in version 1.0");
+    }
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setPorts(List<OFPortDesc> ports) {
+        this.ports = ports;
+        this.portsSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFActionType> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setActions(Set<OFActionType> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setAuxiliaryId(OFAuxId auxiliaryId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.0");
+    }
+//
+        @Override
+        public OFFeaturesReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            DatapathId datapathId = this.datapathIdSet ? this.datapathId : DEFAULT_DATAPATH_ID;
+            if(datapathId == null)
+                throw new NullPointerException("Property datapathId must not be null");
+            long nBuffers = this.nBuffersSet ? this.nBuffers : DEFAULT_N_BUFFERS;
+            short nTables = this.nTablesSet ? this.nTables : DEFAULT_N_TABLES;
+            Set<OFCapabilities> capabilities = this.capabilitiesSet ? this.capabilities : DEFAULT_CAPABILITIES;
+            if(capabilities == null)
+                throw new NullPointerException("Property capabilities must not be null");
+            Set<OFActionType> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+            List<OFPortDesc> ports = this.portsSet ? this.ports : DEFAULT_PORTS;
+            if(ports == null)
+                throw new NullPointerException("Property ports must not be null");
+
+
+            return new OFFeaturesReplyVer10(
+                    xid,
+                    datapathId,
+                    nBuffers,
+                    nTables,
+                    capabilities,
+                    actions,
+                    ports
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFeaturesReply> {
+        @Override
+        public OFFeaturesReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 6
+            byte type = bb.readByte();
+            if(type != (byte) 0x6)
+                throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REPLY(6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            DatapathId datapathId = DatapathId.of(bb.readLong());
+            long nBuffers = U32.f(bb.readInt());
+            short nTables = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            Set<OFCapabilities> capabilities = OFCapabilitiesSerializerVer10.readFrom(bb);
+            Set<OFActionType> actions = ChannelUtilsVer10.readSupportedActions(bb);
+            List<OFPortDesc> ports = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPortDescVer10.READER);
+
+            OFFeaturesReplyVer10 featuresReplyVer10 = new OFFeaturesReplyVer10(
+                    xid,
+                      datapathId,
+                      nBuffers,
+                      nTables,
+                      capabilities,
+                      actions,
+                      ports
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", featuresReplyVer10);
+            return featuresReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFeaturesReplyVer10Funnel FUNNEL = new OFFeaturesReplyVer10Funnel();
+    static class OFFeaturesReplyVer10Funnel implements Funnel<OFFeaturesReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFeaturesReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 6
+            sink.putByte((byte) 0x6);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.datapathId.putTo(sink);
+            sink.putLong(message.nBuffers);
+            sink.putShort(message.nTables);
+            // skip pad (3 bytes)
+            OFCapabilitiesSerializerVer10.putTo(message.capabilities, sink);
+            ChannelUtilsVer10.putSupportedActionsTo(message.actions, sink);
+            FunnelUtils.putList(message.ports, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFeaturesReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFeaturesReplyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 6
+            bb.writeByte((byte) 0x6);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.datapathId.getLong());
+            bb.writeInt(U32.t(message.nBuffers));
+            bb.writeByte(U8.t(message.nTables));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            OFCapabilitiesSerializerVer10.writeTo(bb, message.capabilities);
+            ChannelUtilsVer10.writeSupportedActions(bb, message.actions);
+            ChannelUtils.writeList(bb, message.ports);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFeaturesReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("datapathId=").append(datapathId);
+        b.append(", ");
+        b.append("nBuffers=").append(nBuffers);
+        b.append(", ");
+        b.append("nTables=").append(nTables);
+        b.append(", ");
+        b.append("capabilities=").append(capabilities);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(", ");
+        b.append("ports=").append(ports);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFeaturesReplyVer10 other = (OFFeaturesReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (datapathId == null) {
+            if (other.datapathId != null)
+                return false;
+        } else if (!datapathId.equals(other.datapathId))
+            return false;
+        if( nBuffers != other.nBuffers)
+            return false;
+        if( nTables != other.nTables)
+            return false;
+        if (capabilities == null) {
+            if (other.capabilities != null)
+                return false;
+        } else if (!capabilities.equals(other.capabilities))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        if (ports == null) {
+            if (other.ports != null)
+                return false;
+        } else if (!ports.equals(other.ports))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((datapathId == null) ? 0 : datapathId.hashCode());
+        result = prime *  (int) (nBuffers ^ (nBuffers >>> 32));
+        result = prime * result + nTables;
+        result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        result = prime * result + ((ports == null) ? 0 : ports.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFeaturesRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFeaturesRequestVer10.java
new file mode 100644
index 0000000..284e1e9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFeaturesRequestVer10.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFeaturesRequestVer10 implements OFFeaturesRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFFeaturesRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFFeaturesRequestVer10 DEFAULT = new OFFeaturesRequestVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFeaturesRequestVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFFeaturesRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFeaturesRequest.Builder {
+        final OFFeaturesRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFFeaturesRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFeaturesRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFFeaturesRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFFeaturesRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFeaturesRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFFeaturesRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFeaturesRequest> {
+        @Override
+        public OFFeaturesRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 5
+            byte type = bb.readByte();
+            if(type != (byte) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REQUEST(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFFeaturesRequestVer10 featuresRequestVer10 = new OFFeaturesRequestVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", featuresRequestVer10);
+            return featuresRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFeaturesRequestVer10Funnel FUNNEL = new OFFeaturesRequestVer10Funnel();
+    static class OFFeaturesRequestVer10Funnel implements Funnel<OFFeaturesRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFeaturesRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 5
+            sink.putByte((byte) 0x5);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFeaturesRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFeaturesRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 5
+            bb.writeByte((byte) 0x5);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFeaturesRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFeaturesRequestVer10 other = (OFFeaturesRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowAddVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowAddVer10.java
new file mode 100644
index 0000000..e7ef2c9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowAddVer10.java
@@ -0,0 +1,856 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowAddVer10 implements OFFlowAdd {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowAddVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 72;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final long xid;
+    private final Match match;
+    private final U64 cookie;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final Set<OFFlowModFlags> flags;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFFlowAddVer10 DEFAULT = new OFFlowAddVer10(
+        DEFAULT_XID, DEFAULT_MATCH, DEFAULT_COOKIE, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_FLAGS, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowAddVer10(long xid, Match match, U64 cookie, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, Set<OFFlowModFlags> flags, List<OFAction> actions) {
+        this.xid = xid;
+        this.match = match;
+        this.cookie = cookie;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.flags = flags;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+
+
+    public OFFlowAdd.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowAdd.Builder {
+        final OFFlowAddVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFFlowAddVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowAdd build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFFlowAddVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowAdd.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowAdd build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFFlowAddVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowAdd> {
+        @Override
+        public OFFlowAdd readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            // fixed value property command == 0
+            short command = bb.readShort();
+            if(command != (short) 0x0)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.ADD(0), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read2Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer10.readFrom(bb);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer10.READER);
+
+            OFFlowAddVer10 flowAddVer10 = new OFFlowAddVer10(
+                    xid,
+                      match,
+                      cookie,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      flags,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowAddVer10);
+            return flowAddVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowAddVer10Funnel FUNNEL = new OFFlowAddVer10Funnel();
+    static class OFFlowAddVer10Funnel implements Funnel<OFFlowAddVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowAddVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.match.putTo(sink);
+            message.cookie.putTo(sink);
+            // fixed value property command = 0
+            sink.putShort((short) 0x0);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            OFFlowModFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowAddVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowAddVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.match.writeTo(bb);
+            bb.writeLong(message.cookie.getValue());
+            // fixed value property command = 0
+            bb.writeShort((short) 0x0);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write2Bytes(bb);
+            OFFlowModFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowAddVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowAddVer10 other = (OFFlowAddVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowDeleteStrictVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowDeleteStrictVer10.java
new file mode 100644
index 0000000..95a76c5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowDeleteStrictVer10.java
@@ -0,0 +1,856 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowDeleteStrictVer10 implements OFFlowDeleteStrict {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteStrictVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 72;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final long xid;
+    private final Match match;
+    private final U64 cookie;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final Set<OFFlowModFlags> flags;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFFlowDeleteStrictVer10 DEFAULT = new OFFlowDeleteStrictVer10(
+        DEFAULT_XID, DEFAULT_MATCH, DEFAULT_COOKIE, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_FLAGS, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowDeleteStrictVer10(long xid, Match match, U64 cookie, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, Set<OFFlowModFlags> flags, List<OFAction> actions) {
+        this.xid = xid;
+        this.match = match;
+        this.cookie = cookie;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.flags = flags;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+
+
+    public OFFlowDeleteStrict.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowDeleteStrict.Builder {
+        final OFFlowDeleteStrictVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFFlowDeleteStrictVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowDeleteStrict build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFFlowDeleteStrictVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowDeleteStrict.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowDeleteStrict build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFFlowDeleteStrictVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowDeleteStrict> {
+        @Override
+        public OFFlowDeleteStrict readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            // fixed value property command == 4
+            short command = bb.readShort();
+            if(command != (short) 0x4)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE_STRICT(4), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read2Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer10.readFrom(bb);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer10.READER);
+
+            OFFlowDeleteStrictVer10 flowDeleteStrictVer10 = new OFFlowDeleteStrictVer10(
+                    xid,
+                      match,
+                      cookie,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      flags,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowDeleteStrictVer10);
+            return flowDeleteStrictVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowDeleteStrictVer10Funnel FUNNEL = new OFFlowDeleteStrictVer10Funnel();
+    static class OFFlowDeleteStrictVer10Funnel implements Funnel<OFFlowDeleteStrictVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowDeleteStrictVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.match.putTo(sink);
+            message.cookie.putTo(sink);
+            // fixed value property command = 4
+            sink.putShort((short) 0x4);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            OFFlowModFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowDeleteStrictVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowDeleteStrictVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.match.writeTo(bb);
+            bb.writeLong(message.cookie.getValue());
+            // fixed value property command = 4
+            bb.writeShort((short) 0x4);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write2Bytes(bb);
+            OFFlowModFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowDeleteStrictVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowDeleteStrictVer10 other = (OFFlowDeleteStrictVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowDeleteVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowDeleteVer10.java
new file mode 100644
index 0000000..0be8dd8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowDeleteVer10.java
@@ -0,0 +1,856 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowDeleteVer10 implements OFFlowDelete {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 72;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final long xid;
+    private final Match match;
+    private final U64 cookie;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final Set<OFFlowModFlags> flags;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFFlowDeleteVer10 DEFAULT = new OFFlowDeleteVer10(
+        DEFAULT_XID, DEFAULT_MATCH, DEFAULT_COOKIE, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_FLAGS, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowDeleteVer10(long xid, Match match, U64 cookie, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, Set<OFFlowModFlags> flags, List<OFAction> actions) {
+        this.xid = xid;
+        this.match = match;
+        this.cookie = cookie;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.flags = flags;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+
+
+    public OFFlowDelete.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowDelete.Builder {
+        final OFFlowDeleteVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFFlowDeleteVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowDelete build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFFlowDeleteVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowDelete.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowDelete build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFFlowDeleteVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowDelete> {
+        @Override
+        public OFFlowDelete readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            // fixed value property command == 3
+            short command = bb.readShort();
+            if(command != (short) 0x3)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE(3), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read2Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer10.readFrom(bb);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer10.READER);
+
+            OFFlowDeleteVer10 flowDeleteVer10 = new OFFlowDeleteVer10(
+                    xid,
+                      match,
+                      cookie,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      flags,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowDeleteVer10);
+            return flowDeleteVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowDeleteVer10Funnel FUNNEL = new OFFlowDeleteVer10Funnel();
+    static class OFFlowDeleteVer10Funnel implements Funnel<OFFlowDeleteVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowDeleteVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.match.putTo(sink);
+            message.cookie.putTo(sink);
+            // fixed value property command = 3
+            sink.putShort((short) 0x3);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            OFFlowModFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowDeleteVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowDeleteVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.match.writeTo(bb);
+            bb.writeLong(message.cookie.getValue());
+            // fixed value property command = 3
+            bb.writeShort((short) 0x3);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write2Bytes(bb);
+            OFFlowModFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowDeleteVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowDeleteVer10 other = (OFFlowDeleteVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModCommandSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModCommandSerializerVer10.java
new file mode 100644
index 0000000..304389c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModCommandSerializerVer10.java
@@ -0,0 +1,89 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModCommand;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowModCommandSerializerVer10 {
+
+    public final static short ADD_VAL = (short) 0x0;
+    public final static short MODIFY_VAL = (short) 0x1;
+    public final static short MODIFY_STRICT_VAL = (short) 0x2;
+    public final static short DELETE_VAL = (short) 0x3;
+    public final static short DELETE_STRICT_VAL = (short) 0x4;
+
+    public static OFFlowModCommand readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowModCommand e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowModCommand e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFFlowModCommand ofWireValue(short val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFFlowModCommand.ADD;
+            case MODIFY_VAL:
+                return OFFlowModCommand.MODIFY;
+            case MODIFY_STRICT_VAL:
+                return OFFlowModCommand.MODIFY_STRICT;
+            case DELETE_VAL:
+                return OFFlowModCommand.DELETE;
+            case DELETE_STRICT_VAL:
+                return OFFlowModCommand.DELETE_STRICT;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowModCommand in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFFlowModCommand e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            case MODIFY_STRICT:
+                return MODIFY_STRICT_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case DELETE_STRICT:
+                return DELETE_STRICT_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowModCommand in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFailedCodeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFailedCodeSerializerVer10.java
new file mode 100644
index 0000000..cebce13
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFailedCodeSerializerVer10.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowModFailedCodeSerializerVer10 {
+
+    public final static short ALL_TABLES_FULL_VAL = (short) 0x0;
+    public final static short OVERLAP_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+    public final static short BAD_EMERG_TIMEOUT_VAL = (short) 0x3;
+    public final static short BAD_COMMAND_VAL = (short) 0x4;
+    public final static short UNSUPPORTED_VAL = (short) 0x5;
+
+    public static OFFlowModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFFlowModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case ALL_TABLES_FULL_VAL:
+                return OFFlowModFailedCode.ALL_TABLES_FULL;
+            case OVERLAP_VAL:
+                return OFFlowModFailedCode.OVERLAP;
+            case EPERM_VAL:
+                return OFFlowModFailedCode.EPERM;
+            case BAD_EMERG_TIMEOUT_VAL:
+                return OFFlowModFailedCode.BAD_EMERG_TIMEOUT;
+            case BAD_COMMAND_VAL:
+                return OFFlowModFailedCode.BAD_COMMAND;
+            case UNSUPPORTED_VAL:
+                return OFFlowModFailedCode.UNSUPPORTED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowModFailedCode in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFFlowModFailedCode e) {
+        switch(e) {
+            case ALL_TABLES_FULL:
+                return ALL_TABLES_FULL_VAL;
+            case OVERLAP:
+                return OVERLAP_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case BAD_EMERG_TIMEOUT:
+                return BAD_EMERG_TIMEOUT_VAL;
+            case BAD_COMMAND:
+                return BAD_COMMAND_VAL;
+            case UNSUPPORTED:
+                return UNSUPPORTED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowModFailedCode in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFailedErrorMsgVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFailedErrorMsgVer10.java
new file mode 100644
index 0000000..d9a8fe5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFailedErrorMsgVer10.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModFailedErrorMsgVer10 implements OFFlowModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModFailedErrorMsgVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFFlowModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModFailedErrorMsgVer10(long xid, OFFlowModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFFlowModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModFailedErrorMsg.Builder {
+        final OFFlowModFailedErrorMsgVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFFlowModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFFlowModFailedErrorMsgVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setCode(OFFlowModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFFlowModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFFlowModFailedErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFFlowModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setCode(OFFlowModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFFlowModFailedErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModFailedErrorMsg> {
+        @Override
+        public OFFlowModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 3
+            short errType = bb.readShort();
+            if(errType != (short) 0x3)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.FLOW_MOD_FAILED(3), got="+errType);
+            OFFlowModFailedCode code = OFFlowModFailedCodeSerializerVer10.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_10);
+
+            OFFlowModFailedErrorMsgVer10 flowModFailedErrorMsgVer10 = new OFFlowModFailedErrorMsgVer10(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModFailedErrorMsgVer10);
+            return flowModFailedErrorMsgVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModFailedErrorMsgVer10Funnel FUNNEL = new OFFlowModFailedErrorMsgVer10Funnel();
+    static class OFFlowModFailedErrorMsgVer10Funnel implements Funnel<OFFlowModFailedErrorMsgVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModFailedErrorMsgVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 3
+            sink.putShort((short) 0x3);
+            OFFlowModFailedCodeSerializerVer10.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModFailedErrorMsgVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModFailedErrorMsgVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 3
+            bb.writeShort((short) 0x3);
+            OFFlowModFailedCodeSerializerVer10.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModFailedErrorMsgVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModFailedErrorMsgVer10 other = (OFFlowModFailedErrorMsgVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFlagsSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFlagsSerializerVer10.java
new file mode 100644
index 0000000..a3bab3e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModFlagsSerializerVer10.java
@@ -0,0 +1,90 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFFlowModFlagsSerializerVer10 {
+
+    public final static short SEND_FLOW_REM_VAL = (short) 0x1;
+    public final static short CHECK_OVERLAP_VAL = (short) 0x2;
+    public final static short EMERG_VAL = (short) 0x4;
+
+    public static Set<OFFlowModFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFFlowModFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFFlowModFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFFlowModFlags> ofWireValue(short val) {
+        EnumSet<OFFlowModFlags> set = EnumSet.noneOf(OFFlowModFlags.class);
+
+        if((val & SEND_FLOW_REM_VAL) != 0)
+            set.add(OFFlowModFlags.SEND_FLOW_REM);
+        if((val & CHECK_OVERLAP_VAL) != 0)
+            set.add(OFFlowModFlags.CHECK_OVERLAP);
+        if((val & EMERG_VAL) != 0)
+            set.add(OFFlowModFlags.EMERG);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFFlowModFlags> set) {
+        short wireValue = 0;
+
+        for(OFFlowModFlags e: set) {
+            switch(e) {
+                case SEND_FLOW_REM:
+                    wireValue |= SEND_FLOW_REM_VAL;
+                    break;
+                case CHECK_OVERLAP:
+                    wireValue |= CHECK_OVERLAP_VAL;
+                    break;
+                case EMERG:
+                    wireValue |= EMERG_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFFlowModFlags in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModVer10.java
new file mode 100644
index 0000000..b434dec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModVer10.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFFlowModVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 72;
+
+
+    public final static OFFlowModVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFFlowMod> {
+        @Override
+        public OFFlowMod readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            ChannelUtilsVer10.readOFMatch(bb);
+            U64.ofRaw(bb.readLong());
+            short command = bb.readShort();
+            bb.readerIndex(start);
+            switch(command) {
+               case (short) 0x0:
+                   // discriminator value OFFlowModCommand.ADD=0 for class OFFlowAddVer10
+                   return OFFlowAddVer10.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFFlowModCommand.DELETE=3 for class OFFlowDeleteVer10
+                   return OFFlowDeleteVer10.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFFlowModCommand.DELETE_STRICT=4 for class OFFlowDeleteStrictVer10
+                   return OFFlowDeleteStrictVer10.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFFlowModCommand.MODIFY=1 for class OFFlowModifyVer10
+                   return OFFlowModifyVer10.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFFlowModCommand.MODIFY_STRICT=2 for class OFFlowModifyStrictVer10
+                   return OFFlowModifyStrictVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator command of class OFFlowModVer10: " + command);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModifyStrictVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModifyStrictVer10.java
new file mode 100644
index 0000000..2b72508
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModifyStrictVer10.java
@@ -0,0 +1,856 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModifyStrictVer10 implements OFFlowModifyStrict {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModifyStrictVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 72;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final long xid;
+    private final Match match;
+    private final U64 cookie;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final Set<OFFlowModFlags> flags;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFFlowModifyStrictVer10 DEFAULT = new OFFlowModifyStrictVer10(
+        DEFAULT_XID, DEFAULT_MATCH, DEFAULT_COOKIE, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_FLAGS, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModifyStrictVer10(long xid, Match match, U64 cookie, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, Set<OFFlowModFlags> flags, List<OFAction> actions) {
+        this.xid = xid;
+        this.match = match;
+        this.cookie = cookie;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.flags = flags;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+
+
+    public OFFlowModifyStrict.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModifyStrict.Builder {
+        final OFFlowModifyStrictVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFFlowModifyStrictVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowModifyStrict build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFFlowModifyStrictVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModifyStrict.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowModifyStrict build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFFlowModifyStrictVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModifyStrict> {
+        @Override
+        public OFFlowModifyStrict readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            // fixed value property command == 2
+            short command = bb.readShort();
+            if(command != (short) 0x2)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.MODIFY_STRICT(2), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read2Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer10.readFrom(bb);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer10.READER);
+
+            OFFlowModifyStrictVer10 flowModifyStrictVer10 = new OFFlowModifyStrictVer10(
+                    xid,
+                      match,
+                      cookie,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      flags,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModifyStrictVer10);
+            return flowModifyStrictVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModifyStrictVer10Funnel FUNNEL = new OFFlowModifyStrictVer10Funnel();
+    static class OFFlowModifyStrictVer10Funnel implements Funnel<OFFlowModifyStrictVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModifyStrictVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.match.putTo(sink);
+            message.cookie.putTo(sink);
+            // fixed value property command = 2
+            sink.putShort((short) 0x2);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            OFFlowModFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModifyStrictVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModifyStrictVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.match.writeTo(bb);
+            bb.writeLong(message.cookie.getValue());
+            // fixed value property command = 2
+            bb.writeShort((short) 0x2);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write2Bytes(bb);
+            OFFlowModFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModifyStrictVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModifyStrictVer10 other = (OFFlowModifyStrictVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModifyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModifyVer10.java
new file mode 100644
index 0000000..86b1f14
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowModifyVer10.java
@@ -0,0 +1,856 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModifyVer10 implements OFFlowModify {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModifyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 72;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final long xid;
+    private final Match match;
+    private final U64 cookie;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final Set<OFFlowModFlags> flags;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFFlowModifyVer10 DEFAULT = new OFFlowModifyVer10(
+        DEFAULT_XID, DEFAULT_MATCH, DEFAULT_COOKIE, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_FLAGS, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModifyVer10(long xid, Match match, U64 cookie, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, Set<OFFlowModFlags> flags, List<OFAction> actions) {
+        this.xid = xid;
+        this.match = match;
+        this.cookie = cookie;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.flags = flags;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+
+
+    public OFFlowModify.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModify.Builder {
+        final OFFlowModifyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFFlowModifyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModify.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModify.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModify.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModify.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModify.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowModify.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowModify build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFFlowModifyVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModify.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModify.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModify.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModify.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModify.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowModify.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowModify.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowModify build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFFlowModifyVer10(
+                    xid,
+                    match,
+                    cookie,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    flags,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModify> {
+        @Override
+        public OFFlowModify readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            // fixed value property command == 1
+            short command = bb.readShort();
+            if(command != (short) 0x1)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.MODIFY(1), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read2Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer10.readFrom(bb);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer10.READER);
+
+            OFFlowModifyVer10 flowModifyVer10 = new OFFlowModifyVer10(
+                    xid,
+                      match,
+                      cookie,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      flags,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModifyVer10);
+            return flowModifyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModifyVer10Funnel FUNNEL = new OFFlowModifyVer10Funnel();
+    static class OFFlowModifyVer10Funnel implements Funnel<OFFlowModifyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModifyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.match.putTo(sink);
+            message.cookie.putTo(sink);
+            // fixed value property command = 1
+            sink.putShort((short) 0x1);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            OFFlowModFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModifyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModifyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.match.writeTo(bb);
+            bb.writeLong(message.cookie.getValue());
+            // fixed value property command = 1
+            bb.writeShort((short) 0x1);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write2Bytes(bb);
+            OFFlowModFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModifyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModifyVer10 other = (OFFlowModifyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowRemovedReasonSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowRemovedReasonSerializerVer10.java
new file mode 100644
index 0000000..13eb0b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowRemovedReasonSerializerVer10.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowRemovedReasonSerializerVer10 {
+
+    public final static byte IDLE_TIMEOUT_VAL = (byte) 0x0;
+    public final static byte HARD_TIMEOUT_VAL = (byte) 0x1;
+    public final static byte DELETE_VAL = (byte) 0x2;
+
+    public static OFFlowRemovedReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowRemovedReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowRemovedReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFFlowRemovedReason ofWireValue(byte val) {
+        switch(val) {
+            case IDLE_TIMEOUT_VAL:
+                return OFFlowRemovedReason.IDLE_TIMEOUT;
+            case HARD_TIMEOUT_VAL:
+                return OFFlowRemovedReason.HARD_TIMEOUT;
+            case DELETE_VAL:
+                return OFFlowRemovedReason.DELETE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowRemovedReason in version 1.0: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFFlowRemovedReason e) {
+        switch(e) {
+            case IDLE_TIMEOUT:
+                return IDLE_TIMEOUT_VAL;
+            case HARD_TIMEOUT:
+                return HARD_TIMEOUT_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowRemovedReason in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowRemovedVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowRemovedVer10.java
new file mode 100644
index 0000000..a9f2d0d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowRemovedVer10.java
@@ -0,0 +1,775 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowRemovedVer10 implements OFFlowRemoved {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowRemovedVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 88;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static short DEFAULT_REASON = (short) 0x0;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final Match match;
+    private final U64 cookie;
+    private final int priority;
+    private final short reason;
+    private final long durationSec;
+    private final long durationNsec;
+    private final int idleTimeout;
+    private final U64 packetCount;
+    private final U64 byteCount;
+//
+    // Immutable default instance
+    final static OFFlowRemovedVer10 DEFAULT = new OFFlowRemovedVer10(
+        DEFAULT_XID, DEFAULT_MATCH, DEFAULT_COOKIE, DEFAULT_PRIORITY, DEFAULT_REASON, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_IDLE_TIMEOUT, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowRemovedVer10(long xid, Match match, U64 cookie, int priority, short reason, long durationSec, long durationNsec, int idleTimeout, U64 packetCount, U64 byteCount) {
+        this.xid = xid;
+        this.match = match;
+        this.cookie = cookie;
+        this.priority = priority;
+        this.reason = reason;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.idleTimeout = idleTimeout;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFFlowRemoved.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowRemoved.Builder {
+        final OFFlowRemovedVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean reasonSet;
+        private short reason;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+
+        BuilderWithParent(OFFlowRemovedVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setReason(short reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setHardTimeout(int hardTimeout) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.0");
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowRemoved build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                short reason = this.reasonSet ? this.reason : parentMessage.reason;
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+
+                //
+                return new OFFlowRemovedVer10(
+                    xid,
+                    match,
+                    cookie,
+                    priority,
+                    reason,
+                    durationSec,
+                    durationNsec,
+                    idleTimeout,
+                    packetCount,
+                    byteCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowRemoved.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean matchSet;
+        private Match match;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean reasonSet;
+        private short reason;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setReason(short reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setHardTimeout(int hardTimeout) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.0");
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowRemoved build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            short reason = this.reasonSet ? this.reason : DEFAULT_REASON;
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+
+
+            return new OFFlowRemovedVer10(
+                    xid,
+                    match,
+                    cookie,
+                    priority,
+                    reason,
+                    durationSec,
+                    durationNsec,
+                    idleTimeout,
+                    packetCount,
+                    byteCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowRemoved> {
+        @Override
+        public OFFlowRemoved readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 11
+            byte type = bb.readByte();
+            if(type != (byte) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_REMOVED(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 88)
+                throw new OFParseError("Wrong length: Expected=88(88), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            int priority = U16.f(bb.readShort());
+            short reason = U8.f(bb.readByte());
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            int idleTimeout = U16.f(bb.readShort());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+
+            OFFlowRemovedVer10 flowRemovedVer10 = new OFFlowRemovedVer10(
+                    xid,
+                      match,
+                      cookie,
+                      priority,
+                      reason,
+                      durationSec,
+                      durationNsec,
+                      idleTimeout,
+                      packetCount,
+                      byteCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowRemovedVer10);
+            return flowRemovedVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowRemovedVer10Funnel FUNNEL = new OFFlowRemovedVer10Funnel();
+    static class OFFlowRemovedVer10Funnel implements Funnel<OFFlowRemovedVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowRemovedVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 11
+            sink.putByte((byte) 0xb);
+            // fixed value property length = 88
+            sink.putShort((short) 0x58);
+            sink.putLong(message.xid);
+            message.match.putTo(sink);
+            message.cookie.putTo(sink);
+            sink.putInt(message.priority);
+            sink.putShort(message.reason);
+            // skip pad (1 bytes)
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            sink.putInt(message.idleTimeout);
+            // skip pad (2 bytes)
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowRemovedVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowRemovedVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 11
+            bb.writeByte((byte) 0xb);
+            // fixed value property length = 88
+            bb.writeShort((short) 0x58);
+            bb.writeInt(U32.t(message.xid));
+            message.match.writeTo(bb);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeShort(U16.t(message.priority));
+            bb.writeByte(U8.t(message.reason));
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            bb.writeShort(U16.t(message.idleTimeout));
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowRemovedVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowRemovedVer10 other = (OFFlowRemovedVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( priority != other.priority)
+            return false;
+        if( reason != other.reason)
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + priority;
+        result = prime * result + reason;
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + idleTimeout;
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsEntryVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsEntryVer10.java
new file mode 100644
index 0000000..d3f5ff9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsEntryVer10.java
@@ -0,0 +1,812 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsEntryVer10 implements OFFlowStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsEntryVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 88;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final TableId tableId;
+    private final Match match;
+    private final long durationSec;
+    private final long durationNsec;
+    private final int priority;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final U64 cookie;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFFlowStatsEntryVer10 DEFAULT = new OFFlowStatsEntryVer10(
+        DEFAULT_TABLE_ID, DEFAULT_MATCH, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_PRIORITY, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_COOKIE, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsEntryVer10(TableId tableId, Match match, long durationSec, long durationNsec, int priority, int idleTimeout, int hardTimeout, U64 cookie, U64 packetCount, U64 byteCount, List<OFAction> actions) {
+        this.tableId = tableId;
+        this.match = match;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.priority = priority;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.cookie = cookie;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.0");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFFlowStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsEntry.Builder {
+        final OFFlowStatsEntryVer10 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean matchSet;
+        private Match match;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean prioritySet;
+        private int priority;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFFlowStatsEntryVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property flags not supported in version 1.0");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFFlowStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFFlowStatsEntryVer10(
+                    tableId,
+                    match,
+                    durationSec,
+                    durationNsec,
+                    priority,
+                    idleTimeout,
+                    hardTimeout,
+                    cookie,
+                    packetCount,
+                    byteCount,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean matchSet;
+        private Match match;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean prioritySet;
+        private int priority;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property flags not supported in version 1.0");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFFlowStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFFlowStatsEntryVer10(
+                    tableId,
+                    match,
+                    durationSec,
+                    durationNsec,
+                    priority,
+                    idleTimeout,
+                    hardTimeout,
+                    cookie,
+                    packetCount,
+                    byteCount,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsEntry> {
+        @Override
+        public OFFlowStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            int priority = U16.f(bb.readShort());
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer10.READER);
+
+            OFFlowStatsEntryVer10 flowStatsEntryVer10 = new OFFlowStatsEntryVer10(
+                    tableId,
+                      match,
+                      durationSec,
+                      durationNsec,
+                      priority,
+                      idleTimeout,
+                      hardTimeout,
+                      cookie,
+                      packetCount,
+                      byteCount,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsEntryVer10);
+            return flowStatsEntryVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsEntryVer10Funnel FUNNEL = new OFFlowStatsEntryVer10Funnel();
+    static class OFFlowStatsEntryVer10Funnel implements Funnel<OFFlowStatsEntryVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsEntryVer10 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            message.tableId.putTo(sink);
+            // skip pad (1 bytes)
+            message.match.putTo(sink);
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            sink.putInt(message.priority);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            // skip pad (6 bytes)
+            message.cookie.putTo(sink);
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsEntryVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsEntryVer10 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.tableId.writeByte(bb);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.match.writeTo(bb);
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            // pad: 6 bytes
+            bb.writeZero(6);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsEntryVer10(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsEntryVer10 other = (OFFlowStatsEntryVer10) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + priority;
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsReplyVer10.java
new file mode 100644
index 0000000..2b33174
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsReplyVer10.java
@@ -0,0 +1,407 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsReplyVer10 implements OFFlowStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFFlowStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFFlowStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFFlowStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFFlowStatsReplyVer10 DEFAULT = new OFFlowStatsReplyVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsReplyVer10(long xid, Set<OFStatsReplyFlags> flags, List<OFFlowStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFFlowStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsReply.Builder {
+        final OFFlowStatsReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFFlowStatsEntry> entries;
+
+        BuilderWithParent(OFFlowStatsReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setEntries(List<OFFlowStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFFlowStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFFlowStatsReplyVer10(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFFlowStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setEntries(List<OFFlowStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFFlowStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFFlowStatsReplyVer10(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsReply> {
+        @Override
+        public OFFlowStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 1
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x1)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.FLOW(1), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer10.readFrom(bb);
+            List<OFFlowStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFFlowStatsEntryVer10.READER);
+
+            OFFlowStatsReplyVer10 flowStatsReplyVer10 = new OFFlowStatsReplyVer10(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsReplyVer10);
+            return flowStatsReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsReplyVer10Funnel FUNNEL = new OFFlowStatsReplyVer10Funnel();
+    static class OFFlowStatsReplyVer10Funnel implements Funnel<OFFlowStatsReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 1
+            sink.putShort((short) 0x1);
+            OFStatsReplyFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsReplyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 1
+            bb.writeShort((short) 0x1);
+            OFStatsReplyFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsReplyVer10 other = (OFFlowStatsReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsRequestVer10.java
new file mode 100644
index 0000000..6672997
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsRequestVer10.java
@@ -0,0 +1,582 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsRequestVer10 implements OFFlowStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer10.MATCH_WILDCARD_ALL;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final Match match;
+    private final TableId tableId;
+    private final OFPort outPort;
+//
+    // Immutable default instance
+    final static OFFlowStatsRequestVer10 DEFAULT = new OFFlowStatsRequestVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_TABLE_ID, DEFAULT_OUT_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsRequestVer10(long xid, Set<OFStatsRequestFlags> flags, Match match, TableId tableId, OFPort outPort) {
+        this.xid = xid;
+        this.flags = flags;
+        this.match = match;
+        this.tableId = tableId;
+        this.outPort = outPort;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFFlowStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsRequest.Builder {
+        final OFFlowStatsRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+
+        BuilderWithParent(OFFlowStatsRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+
+                //
+                return new OFFlowStatsRequestVer10(
+                    xid,
+                    flags,
+                    match,
+                    tableId,
+                    outPort
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutGroup(OFGroup outGroup) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property outGroup not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookieMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookieMask(U64 cookieMask) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookieMask not supported in version 1.0");
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+
+
+            return new OFFlowStatsRequestVer10(
+                    xid,
+                    flags,
+                    match,
+                    tableId,
+                    outPort
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsRequest> {
+        @Override
+        public OFFlowStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 56)
+                throw new OFParseError("Wrong length: Expected=56(56), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 1
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x1)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.FLOW(1), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer10.readFrom(bb);
+            Match match = ChannelUtilsVer10.readOFMatch(bb);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFPort outPort = OFPort.read2Bytes(bb);
+
+            OFFlowStatsRequestVer10 flowStatsRequestVer10 = new OFFlowStatsRequestVer10(
+                    xid,
+                      flags,
+                      match,
+                      tableId,
+                      outPort
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsRequestVer10);
+            return flowStatsRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsRequestVer10Funnel FUNNEL = new OFFlowStatsRequestVer10Funnel();
+    static class OFFlowStatsRequestVer10Funnel implements Funnel<OFFlowStatsRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 56
+            sink.putShort((short) 0x38);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 1
+            sink.putShort((short) 0x1);
+            OFStatsRequestFlagsSerializerVer10.putTo(message.flags, sink);
+            message.match.putTo(sink);
+            message.tableId.putTo(sink);
+            // skip pad (1 bytes)
+            message.outPort.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 56
+            bb.writeShort((short) 0x38);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 1
+            bb.writeShort((short) 0x1);
+            OFStatsRequestFlagsSerializerVer10.writeTo(bb, message.flags);
+            message.match.writeTo(bb);
+            message.tableId.writeByte(bb);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.outPort.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsRequestVer10 other = (OFFlowStatsRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowWildcardsSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowWildcardsSerializerVer10.java
new file mode 100644
index 0000000..f512fe7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowWildcardsSerializerVer10.java
@@ -0,0 +1,162 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowWildcards;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFFlowWildcardsSerializerVer10 {
+
+    public final static int IN_PORT_VAL = 0x1;
+    public final static int DL_VLAN_VAL = 0x2;
+    public final static int DL_SRC_VAL = 0x4;
+    public final static int DL_DST_VAL = 0x8;
+    public final static int DL_TYPE_VAL = 0x10;
+    public final static int NW_PROTO_VAL = 0x20;
+    public final static int TP_SRC_VAL = 0x40;
+    public final static int TP_DST_VAL = 0x80;
+    public final static int NW_SRC_ALL_VAL = 0x2000;
+    public final static int NW_SRC_MASK_VAL = 0x3f00;
+    public final static int NW_DST_ALL_VAL = 0x80000;
+    public final static int NW_DST_MASK_VAL = 0xfc000;
+    public final static int DL_VLAN_PCP_VAL = 0x100000;
+    public final static int NW_TOS_VAL = 0x200000;
+    public final static int ALL_VAL = 0x3fffff;
+
+    public static Set<OFFlowWildcards> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFFlowWildcards> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFFlowWildcards> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFFlowWildcards> ofWireValue(int val) {
+        EnumSet<OFFlowWildcards> set = EnumSet.noneOf(OFFlowWildcards.class);
+
+        if((val & IN_PORT_VAL) != 0)
+            set.add(OFFlowWildcards.IN_PORT);
+        if((val & DL_VLAN_VAL) != 0)
+            set.add(OFFlowWildcards.DL_VLAN);
+        if((val & DL_SRC_VAL) != 0)
+            set.add(OFFlowWildcards.DL_SRC);
+        if((val & DL_DST_VAL) != 0)
+            set.add(OFFlowWildcards.DL_DST);
+        if((val & DL_TYPE_VAL) != 0)
+            set.add(OFFlowWildcards.DL_TYPE);
+        if((val & NW_PROTO_VAL) != 0)
+            set.add(OFFlowWildcards.NW_PROTO);
+        if((val & TP_SRC_VAL) != 0)
+            set.add(OFFlowWildcards.TP_SRC);
+        if((val & TP_DST_VAL) != 0)
+            set.add(OFFlowWildcards.TP_DST);
+        if((val & NW_SRC_ALL_VAL) != 0)
+            set.add(OFFlowWildcards.NW_SRC_ALL);
+        if((val & NW_SRC_MASK_VAL) != 0)
+            set.add(OFFlowWildcards.NW_SRC_MASK);
+        if((val & NW_DST_ALL_VAL) != 0)
+            set.add(OFFlowWildcards.NW_DST_ALL);
+        if((val & NW_DST_MASK_VAL) != 0)
+            set.add(OFFlowWildcards.NW_DST_MASK);
+        if((val & DL_VLAN_PCP_VAL) != 0)
+            set.add(OFFlowWildcards.DL_VLAN_PCP);
+        if((val & NW_TOS_VAL) != 0)
+            set.add(OFFlowWildcards.NW_TOS);
+        if((val & ALL_VAL) != 0)
+            set.add(OFFlowWildcards.ALL);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFFlowWildcards> set) {
+        int wireValue = 0;
+
+        for(OFFlowWildcards e: set) {
+            switch(e) {
+                case IN_PORT:
+                    wireValue |= IN_PORT_VAL;
+                    break;
+                case DL_VLAN:
+                    wireValue |= DL_VLAN_VAL;
+                    break;
+                case DL_SRC:
+                    wireValue |= DL_SRC_VAL;
+                    break;
+                case DL_DST:
+                    wireValue |= DL_DST_VAL;
+                    break;
+                case DL_TYPE:
+                    wireValue |= DL_TYPE_VAL;
+                    break;
+                case NW_PROTO:
+                    wireValue |= NW_PROTO_VAL;
+                    break;
+                case TP_SRC:
+                    wireValue |= TP_SRC_VAL;
+                    break;
+                case TP_DST:
+                    wireValue |= TP_DST_VAL;
+                    break;
+                case NW_SRC_ALL:
+                    wireValue |= NW_SRC_ALL_VAL;
+                    break;
+                case NW_SRC_MASK:
+                    wireValue |= NW_SRC_MASK_VAL;
+                    break;
+                case NW_DST_ALL:
+                    wireValue |= NW_DST_ALL_VAL;
+                    break;
+                case NW_DST_MASK:
+                    wireValue |= NW_DST_MASK_VAL;
+                    break;
+                case DL_VLAN_PCP:
+                    wireValue |= DL_VLAN_PCP_VAL;
+                    break;
+                case NW_TOS:
+                    wireValue |= NW_TOS_VAL;
+                    break;
+                case ALL:
+                    wireValue |= ALL_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFFlowWildcards in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFGetConfigReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFGetConfigReplyVer10.java
new file mode 100644
index 0000000..5b744c6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFGetConfigReplyVer10.java
@@ -0,0 +1,370 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGetConfigReplyVer10 implements OFGetConfigReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGetConfigReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFConfigFlags> DEFAULT_FLAGS = ImmutableSet.<OFConfigFlags>of();
+        private final static int DEFAULT_MISS_SEND_LEN = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFConfigFlags> flags;
+    private final int missSendLen;
+//
+    // Immutable default instance
+    final static OFGetConfigReplyVer10 DEFAULT = new OFGetConfigReplyVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MISS_SEND_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGetConfigReplyVer10(long xid, Set<OFConfigFlags> flags, int missSendLen) {
+        this.xid = xid;
+        this.flags = flags;
+        this.missSendLen = missSendLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+
+
+    public OFGetConfigReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGetConfigReply.Builder {
+        final OFGetConfigReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+        BuilderWithParent(OFGetConfigReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGetConfigReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFConfigFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int missSendLen = this.missSendLenSet ? this.missSendLen : parentMessage.missSendLen;
+
+                //
+                return new OFGetConfigReplyVer10(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFGetConfigReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGetConfigReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFConfigFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int missSendLen = this.missSendLenSet ? this.missSendLen : DEFAULT_MISS_SEND_LEN;
+
+
+            return new OFGetConfigReplyVer10(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGetConfigReply> {
+        @Override
+        public OFGetConfigReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 8
+            byte type = bb.readByte();
+            if(type != (byte) 0x8)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REPLY(8), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Set<OFConfigFlags> flags = OFConfigFlagsSerializerVer10.readFrom(bb);
+            int missSendLen = U16.f(bb.readShort());
+
+            OFGetConfigReplyVer10 getConfigReplyVer10 = new OFGetConfigReplyVer10(
+                    xid,
+                      flags,
+                      missSendLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", getConfigReplyVer10);
+            return getConfigReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGetConfigReplyVer10Funnel FUNNEL = new OFGetConfigReplyVer10Funnel();
+    static class OFGetConfigReplyVer10Funnel implements Funnel<OFGetConfigReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGetConfigReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 8
+            sink.putByte((byte) 0x8);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            OFConfigFlagsSerializerVer10.putTo(message.flags, sink);
+            sink.putInt(message.missSendLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGetConfigReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFGetConfigReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 8
+            bb.writeByte((byte) 0x8);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            OFConfigFlagsSerializerVer10.writeTo(bb, message.flags);
+            bb.writeShort(U16.t(message.missSendLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGetConfigReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("missSendLen=").append(missSendLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGetConfigReplyVer10 other = (OFGetConfigReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( missSendLen != other.missSendLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + missSendLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFGetConfigRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFGetConfigRequestVer10.java
new file mode 100644
index 0000000..d34ecd2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFGetConfigRequestVer10.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGetConfigRequestVer10 implements OFGetConfigRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGetConfigRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFGetConfigRequestVer10 DEFAULT = new OFGetConfigRequestVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGetConfigRequestVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFGetConfigRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGetConfigRequest.Builder {
+        final OFGetConfigRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFGetConfigRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGetConfigRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFGetConfigRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFGetConfigRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGetConfigRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFGetConfigRequestVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGetConfigRequest> {
+        @Override
+        public OFGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 7
+            byte type = bb.readByte();
+            if(type != (byte) 0x7)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REQUEST(7), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFGetConfigRequestVer10 getConfigRequestVer10 = new OFGetConfigRequestVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", getConfigRequestVer10);
+            return getConfigRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGetConfigRequestVer10Funnel FUNNEL = new OFGetConfigRequestVer10Funnel();
+    static class OFGetConfigRequestVer10Funnel implements Funnel<OFGetConfigRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGetConfigRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 7
+            sink.putByte((byte) 0x7);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGetConfigRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFGetConfigRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 7
+            bb.writeByte((byte) 0x7);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGetConfigRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGetConfigRequestVer10 other = (OFGetConfigRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloFailedCodeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloFailedCodeSerializerVer10.java
new file mode 100644
index 0000000..05611bb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloFailedCodeSerializerVer10.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFHelloFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFHelloFailedCodeSerializerVer10 {
+
+    public final static short INCOMPATIBLE_VAL = (short) 0x0;
+    public final static short EPERM_VAL = (short) 0x1;
+
+    public static OFHelloFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFHelloFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFHelloFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFHelloFailedCode ofWireValue(short val) {
+        switch(val) {
+            case INCOMPATIBLE_VAL:
+                return OFHelloFailedCode.INCOMPATIBLE;
+            case EPERM_VAL:
+                return OFHelloFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFHelloFailedCode in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFHelloFailedCode e) {
+        switch(e) {
+            case INCOMPATIBLE:
+                return INCOMPATIBLE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFHelloFailedCode in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloFailedErrorMsgVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloFailedErrorMsgVer10.java
new file mode 100644
index 0000000..b24d497
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloFailedErrorMsgVer10.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloFailedErrorMsgVer10 implements OFHelloFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloFailedErrorMsgVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFHelloFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloFailedErrorMsgVer10(long xid, OFHelloFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFHelloFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHelloFailedErrorMsg.Builder {
+        final OFHelloFailedErrorMsgVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFHelloFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFHelloFailedErrorMsgVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setCode(OFHelloFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFHelloFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFHelloFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFHelloFailedErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFHelloFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFHelloFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setCode(OFHelloFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFHelloFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFHelloFailedErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHelloFailedErrorMsg> {
+        @Override
+        public OFHelloFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 0
+            short errType = bb.readShort();
+            if(errType != (short) 0x0)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.HELLO_FAILED(0), got="+errType);
+            OFHelloFailedCode code = OFHelloFailedCodeSerializerVer10.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_10);
+
+            OFHelloFailedErrorMsgVer10 helloFailedErrorMsgVer10 = new OFHelloFailedErrorMsgVer10(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloFailedErrorMsgVer10);
+            return helloFailedErrorMsgVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloFailedErrorMsgVer10Funnel FUNNEL = new OFHelloFailedErrorMsgVer10Funnel();
+    static class OFHelloFailedErrorMsgVer10Funnel implements Funnel<OFHelloFailedErrorMsgVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloFailedErrorMsgVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 0
+            sink.putShort((short) 0x0);
+            OFHelloFailedCodeSerializerVer10.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloFailedErrorMsgVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloFailedErrorMsgVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 0
+            bb.writeShort((short) 0x0);
+            OFHelloFailedCodeSerializerVer10.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloFailedErrorMsgVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloFailedErrorMsgVer10 other = (OFHelloFailedErrorMsgVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloVer10.java
new file mode 100644
index 0000000..d61e3b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloVer10.java
@@ -0,0 +1,292 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloVer10 implements OFHello {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFHelloVer10 DEFAULT = new OFHelloVer10(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloVer10(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.0");
+    }
+
+
+
+    public OFHello.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHello.Builder {
+        final OFHelloVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFHelloVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHello.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.0");
+    }
+
+    @Override
+    public OFHello.Builder setElements(List<OFHelloElem> elements) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property elements not supported in version 1.0");
+    }
+
+
+        @Override
+        public OFHello build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFHelloVer10(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFHello.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHello.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.0");
+    }
+
+    @Override
+    public OFHello.Builder setElements(List<OFHelloElem> elements) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property elements not supported in version 1.0");
+    }
+//
+        @Override
+        public OFHello build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFHelloVer10(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHello> {
+        @Override
+        public OFHello readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 0
+            byte type = bb.readByte();
+            if(type != (byte) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFType.HELLO(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFHelloVer10 helloVer10 = new OFHelloVer10(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloVer10);
+            return helloVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloVer10Funnel FUNNEL = new OFHelloVer10Funnel();
+    static class OFHelloVer10Funnel implements Funnel<OFHelloVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 0
+            sink.putByte((byte) 0x0);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 0
+            bb.writeByte((byte) 0x0);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloVer10(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloVer10 other = (OFHelloVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFInstructionIdsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFInstructionIdsVer10.java
new file mode 100644
index 0000000..1eb5109
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFInstructionIdsVer10.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFInstructionIdsVer10 implements OFInstructionIds {
+    public final static OFInstructionIdsVer10 INSTANCE = new OFInstructionIdsVer10();
+
+
+
+
+    public OFInstructionIdApplyActions applyActions() {
+        throw new UnsupportedOperationException("OFInstructionIdApplyActions not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnArpOffload bsnArpOffload() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnArpOffload not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnDeny bsnDeny() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDeny not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnDhcpOffload bsnDhcpOffload() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDhcpOffload not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableSplitHorizonCheck not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnDisableSrcMacCheck bsnDisableSrcMacCheck() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableSrcMacCheck not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnDisableVlanCounters bsnDisableVlanCounters() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableVlanCounters not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnPacketOfDeath bsnPacketOfDeath() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPacketOfDeath not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnPermit bsnPermit() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPermit not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnPrioritizePdus bsnPrioritizePdus() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPrioritizePdus not supported in version 1.0");
+    }
+
+    public OFInstructionIdBsnRequireVlanXlate bsnRequireVlanXlate() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnRequireVlanXlate not supported in version 1.0");
+    }
+
+    public OFInstructionIdClearActions clearActions() {
+        throw new UnsupportedOperationException("OFInstructionIdClearActions not supported in version 1.0");
+    }
+
+    public OFInstructionIdGotoTable gotoTable() {
+        throw new UnsupportedOperationException("OFInstructionIdGotoTable not supported in version 1.0");
+    }
+
+    public OFInstructionIdMeter meter() {
+        throw new UnsupportedOperationException("OFInstructionIdMeter not supported in version 1.0");
+    }
+
+    public OFInstructionIdWriteActions writeActions() {
+        throw new UnsupportedOperationException("OFInstructionIdWriteActions not supported in version 1.0");
+    }
+
+    public OFInstructionIdWriteMetadata writeMetadata() {
+        throw new UnsupportedOperationException("OFInstructionIdWriteMetadata not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFInstructionId> getReader() {
+        throw new UnsupportedOperationException("Reader<OFInstructionId> not supported in version 1.0");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFInstructionsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFInstructionsVer10.java
new file mode 100644
index 0000000..b1ea65d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFInstructionsVer10.java
@@ -0,0 +1,122 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+
+
+public class OFInstructionsVer10 implements OFInstructions {
+    public final static OFInstructionsVer10 INSTANCE = new OFInstructionsVer10();
+
+
+
+
+    public OFInstructionApplyActions.Builder buildApplyActions() {
+        throw new UnsupportedOperationException("OFInstructionApplyActions not supported in version 1.0");
+    }
+    public OFInstructionApplyActions applyActions(List<OFAction> actions) {
+        throw new UnsupportedOperationException("OFInstructionApplyActions not supported in version 1.0");
+    }
+
+    public OFInstructionClearActions clearActions() {
+        throw new UnsupportedOperationException("OFInstructionClearActions not supported in version 1.0");
+    }
+
+    public OFInstructionGotoTable.Builder buildGotoTable() {
+        throw new UnsupportedOperationException("OFInstructionGotoTable not supported in version 1.0");
+    }
+    public OFInstructionGotoTable gotoTable(TableId tableId) {
+        throw new UnsupportedOperationException("OFInstructionGotoTable not supported in version 1.0");
+    }
+
+    public OFInstructionWriteActions.Builder buildWriteActions() {
+        throw new UnsupportedOperationException("OFInstructionWriteActions not supported in version 1.0");
+    }
+    public OFInstructionWriteActions writeActions(List<OFAction> actions) {
+        throw new UnsupportedOperationException("OFInstructionWriteActions not supported in version 1.0");
+    }
+
+    public OFInstructionWriteMetadata.Builder buildWriteMetadata() {
+        throw new UnsupportedOperationException("OFInstructionWriteMetadata not supported in version 1.0");
+    }
+    public OFInstructionWriteMetadata writeMetadata(U64 metadata, U64 metadataMask) {
+        throw new UnsupportedOperationException("OFInstructionWriteMetadata not supported in version 1.0");
+    }
+
+    public OFInstructionBsnArpOffload bsnArpOffload() {
+        throw new UnsupportedOperationException("OFInstructionBsnArpOffload not supported in version 1.0");
+    }
+
+    public OFInstructionBsnDeny bsnDeny() {
+        throw new UnsupportedOperationException("OFInstructionBsnDeny not supported in version 1.0");
+    }
+
+    public OFInstructionBsnDhcpOffload bsnDhcpOffload() {
+        throw new UnsupportedOperationException("OFInstructionBsnDhcpOffload not supported in version 1.0");
+    }
+
+    public OFInstructionBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableSplitHorizonCheck not supported in version 1.0");
+    }
+
+    public OFInstructionBsnDisableSrcMacCheck bsnDisableSrcMacCheck() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableSrcMacCheck not supported in version 1.0");
+    }
+
+    public OFInstructionBsnDisableVlanCounters bsnDisableVlanCounters() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableVlanCounters not supported in version 1.0");
+    }
+
+    public OFInstructionBsnPacketOfDeath bsnPacketOfDeath() {
+        throw new UnsupportedOperationException("OFInstructionBsnPacketOfDeath not supported in version 1.0");
+    }
+
+    public OFInstructionBsnPermit bsnPermit() {
+        throw new UnsupportedOperationException("OFInstructionBsnPermit not supported in version 1.0");
+    }
+
+    public OFInstructionBsnPrioritizePdus bsnPrioritizePdus() {
+        throw new UnsupportedOperationException("OFInstructionBsnPrioritizePdus not supported in version 1.0");
+    }
+
+    public OFInstructionBsnRequireVlanXlate bsnRequireVlanXlate() {
+        throw new UnsupportedOperationException("OFInstructionBsnRequireVlanXlate not supported in version 1.0");
+    }
+
+    public OFInstructionMeter.Builder buildMeter() {
+        throw new UnsupportedOperationException("OFInstructionMeter not supported in version 1.0");
+    }
+    public OFInstructionMeter meter(long meterId) {
+        throw new UnsupportedOperationException("OFInstructionMeter not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFInstruction> getReader() {
+        throw new UnsupportedOperationException("Reader<OFInstruction> not supported in version 1.0");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMatchV1Ver10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMatchV1Ver10.java
new file mode 100644
index 0000000..14e829c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMatchV1Ver10.java
@@ -0,0 +1,2434 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMatchV1Ver10 implements OFMatchV1 {
+    private static final Logger logger = LoggerFactory.getLogger(OFMatchV1Ver10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 40;
+
+        private final static int DEFAULT_WILDCARDS = OFFlowWildcardsSerializerVer10.ALL_VAL;
+        private final static OFPort DEFAULT_IN_PORT = OFPort.ZERO;
+        private final static MacAddress DEFAULT_ETH_SRC = MacAddress.NONE;
+        private final static MacAddress DEFAULT_ETH_DST = MacAddress.NONE;
+        private final static OFVlanVidMatch DEFAULT_VLAN_VID = OFVlanVidMatch.NONE;
+        private final static VlanPcp DEFAULT_VLAN_PCP = VlanPcp.NONE;
+        private final static EthType DEFAULT_ETH_TYPE = EthType.NONE;
+        private final static IpDscp DEFAULT_IP_DSCP = IpDscp.NONE;
+        private final static IpProtocol DEFAULT_IP_PROTO = IpProtocol.NONE;
+        private final static IPv4Address DEFAULT_IPV4_SRC = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_IPV4_DST = IPv4Address.NONE;
+        private final static TransportPort DEFAULT_TCP_SRC = TransportPort.NONE;
+        private final static TransportPort DEFAULT_TCP_DST = TransportPort.NONE;
+
+    // OF message fields
+    private final int wildcards;
+    private final OFPort inPort;
+    private final MacAddress ethSrc;
+    private final MacAddress ethDst;
+    private final OFVlanVidMatch vlanVid;
+    private final VlanPcp vlanPcp;
+    private final EthType ethType;
+    private final IpDscp ipDscp;
+    private final IpProtocol ipProto;
+    private final IPv4Address ipv4Src;
+    private final IPv4Address ipv4Dst;
+    private final TransportPort tcpSrc;
+    private final TransportPort tcpDst;
+//
+    // Immutable default instance
+    final static OFMatchV1Ver10 DEFAULT = new OFMatchV1Ver10(
+        DEFAULT_WILDCARDS, DEFAULT_IN_PORT, DEFAULT_ETH_SRC, DEFAULT_ETH_DST, DEFAULT_VLAN_VID, DEFAULT_VLAN_PCP, DEFAULT_ETH_TYPE, DEFAULT_IP_DSCP, DEFAULT_IP_PROTO, DEFAULT_IPV4_SRC, DEFAULT_IPV4_DST, DEFAULT_TCP_SRC, DEFAULT_TCP_DST
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMatchV1Ver10(int wildcards, OFPort inPort, MacAddress ethSrc, MacAddress ethDst, OFVlanVidMatch vlanVid, VlanPcp vlanPcp, EthType ethType, IpDscp ipDscp, IpProtocol ipProto, IPv4Address ipv4Src, IPv4Address ipv4Dst, TransportPort tcpSrc, TransportPort tcpDst) {
+        this.wildcards = wildcards;
+        this.inPort = inPort;
+        this.ethSrc = ethSrc;
+        this.ethDst = ethDst;
+        this.vlanVid = vlanVid;
+        this.vlanPcp = vlanPcp;
+        this.ethType = ethType;
+        this.ipDscp = ipDscp;
+        this.ipProto = ipProto;
+        this.ipv4Src = ipv4Src;
+        this.ipv4Dst = ipv4Dst;
+        this.tcpSrc = tcpSrc;
+        this.tcpDst = tcpDst;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public MacAddress getEthSrc() {
+        return ethSrc;
+    }
+
+    @Override
+    public MacAddress getEthDst() {
+        return ethDst;
+    }
+
+    @Override
+    public OFVlanVidMatch getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public EthType getEthType() {
+        return ethType;
+    }
+
+    @Override
+    public IpDscp getIpDscp() {
+        return ipDscp;
+    }
+
+    @Override
+    public IpProtocol getIpProto() {
+        return ipProto;
+    }
+
+    @Override
+    public IPv4Address getIpv4Src() {
+        return ipv4Src;
+    }
+
+    @Override
+    public IPv4Address getIpv4Dst() {
+        return ipv4Dst;
+    }
+
+    @Override
+    public TransportPort getTcpSrc() {
+        return tcpSrc;
+    }
+
+    @Override
+    public TransportPort getTcpDst() {
+        return tcpDst;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+    final public static int OFPFW_ALL = ((1 << 22) - 1);
+
+    final public static int OFPFW_IN_PORT = 1 << 0; /* Switch input port. */
+    final public static int OFPFW_DL_VLAN = 1 << 1; /* VLAN id. */
+    final public static int OFPFW_DL_SRC = 1 << 2; /* Ethernet source address. */
+    final public static int OFPFW_DL_DST = 1 << 3; /*
+                                                    * Ethernet destination
+                                                    * address.
+                                                    */
+    final public static int OFPFW_DL_TYPE = 1 << 4; /* Ethernet frame type. */
+    final public static int OFPFW_NW_PROTO = 1 << 5; /* IP protocol. */
+    final public static int OFPFW_TP_SRC = 1 << 6; /* TCP/UDP source port. */
+    final public static int OFPFW_TP_DST = 1 << 7; /* TCP/UDP destination port. */
+
+    /*
+     * IP source address wildcard bit count. 0 is exact match, 1 ignores the
+     * LSB, 2 ignores the 2 least-significant bits, ..., 32 and higher wildcard
+     * the entire field. This is the *opposite* of the usual convention where
+     * e.g. /24 indicates that 8 bits (not 24 bits) are wildcarded.
+     */
+    final public static int OFPFW_NW_SRC_SHIFT = 8;
+    final public static int OFPFW_NW_SRC_BITS = 6;
+    final public static int OFPFW_NW_SRC_MASK = ((1 << OFPFW_NW_SRC_BITS) - 1) << OFPFW_NW_SRC_SHIFT;
+    final public static int OFPFW_NW_SRC_ALL = 32 << OFPFW_NW_SRC_SHIFT;
+
+    /* IP destination address wildcard bit count. Same format as source. */
+    final public static int OFPFW_NW_DST_SHIFT = 14;
+    final public static int OFPFW_NW_DST_BITS = 6;
+    final public static int OFPFW_NW_DST_MASK = ((1 << OFPFW_NW_DST_BITS) - 1) << OFPFW_NW_DST_SHIFT;
+    final public static int OFPFW_NW_DST_ALL = 32 << OFPFW_NW_DST_SHIFT;
+
+    final public static int OFPFW_DL_VLAN_PCP = 1 << 20; /* VLAN priority. */
+    final public static int OFPFW_NW_TOS = 1 << 21; /* IP ToS (DSCP field, 6bits) */
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        if (isFullyWildcarded(field))
+            return null;
+        if (!field.arePrerequisitesOK(this))
+            return null;
+
+        Object result;
+        switch (field.id) {
+            case IN_PORT:
+                result = inPort;
+                break;
+            case ETH_DST:
+                result = ethDst;
+                break;
+            case ETH_SRC:
+                result = ethSrc;
+                break;
+            case ETH_TYPE:
+                result = ethType;
+                break;
+            case VLAN_VID:
+                result = vlanVid;
+                break;
+            case VLAN_PCP:
+                result = vlanPcp;
+                break;
+            case ARP_OP:
+                result = ArpOpcode.of(ipProto.getIpProtocolNumber());
+                break;
+            case ARP_SPA:
+                result = ipv4Src;
+                break;
+            case ARP_TPA:
+                result = ipv4Dst;
+                break;
+            case IP_DSCP:
+                result = ipDscp;
+                break;
+            case IP_PROTO:
+                result = ipProto;
+                break;
+            case IPV4_SRC:
+                result = ipv4Src;
+                break;
+            case IPV4_DST:
+                result = ipv4Dst;
+                break;
+            case TCP_SRC:
+                result = tcpSrc;
+                break;
+            case TCP_DST:
+                result = tcpDst;
+                break;
+            case UDP_SRC:
+                result = tcpSrc;
+                break;
+            case UDP_DST:
+                result = tcpDst;
+                break;
+            case SCTP_SRC:
+                result = tcpSrc;
+                break;
+            case SCTP_DST:
+                result = tcpDst;
+                break;
+            case ICMPV4_TYPE:
+                result = tcpSrc;
+                break;
+            case ICMPV4_CODE:
+                result = tcpDst;
+                break;
+            // NOT SUPPORTED:
+            default:
+                throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+        }
+        return (F)result;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        if (!isPartiallyMasked(field))
+            return null;
+        if (!field.arePrerequisitesOK(this))
+            return null;
+        Object result;
+        switch (field.id) {
+            case ARP_SPA:
+            case IPV4_SRC:
+                int srcBitMask = (-1) << (32 - getIpv4SrcCidrMaskLen());
+                result = IPv4AddressWithMask.of(ipv4Src, IPv4Address.of(srcBitMask));
+                break;
+            case ARP_TPA:
+            case IPV4_DST:
+                int dstBitMask = (-1) << (32 - getIpv4DstCidrMaskLen());
+
+                result = IPv4AddressWithMask.of(ipv4Dst, IPv4Address.of(dstBitMask));
+                break;
+            default:
+                throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+        }
+        return (Masked<F>)result;
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        switch (field.id) {
+            case IN_PORT:
+            case ETH_DST:
+            case ETH_SRC:
+            case ETH_TYPE:
+            case VLAN_VID:
+            case VLAN_PCP:
+            case ARP_OP:
+            case ARP_SPA:
+            case ARP_TPA:
+            case IP_DSCP:
+            case IP_PROTO:
+            case IPV4_SRC:
+            case IPV4_DST:
+            case TCP_SRC:
+            case TCP_DST:
+            case UDP_SRC:
+            case UDP_DST:
+            case SCTP_SRC:
+            case SCTP_DST:
+            case ICMPV4_TYPE:
+            case ICMPV4_CODE:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        switch (field.id) {
+            case ARP_SPA:
+            case ARP_TPA:
+            case IPV4_SRC:
+            case IPV4_DST:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    @Override
+    public boolean isExact(MatchField<?> field) {
+        if (!field.arePrerequisitesOK(this))
+            return false;
+
+        switch (field.id) {
+            case IN_PORT:
+                return (this.wildcards & OFPFW_IN_PORT) == 0;
+            case ETH_DST:
+                return (this.wildcards & OFPFW_DL_DST) == 0;
+            case ETH_SRC:
+                return (this.wildcards & OFPFW_DL_SRC) == 0;
+            case ETH_TYPE:
+                return (this.wildcards & OFPFW_DL_TYPE) == 0;
+            case VLAN_VID:
+                return (this.wildcards & OFPFW_DL_VLAN) == 0;
+            case VLAN_PCP:
+                return (this.wildcards & OFPFW_DL_VLAN_PCP) == 0;
+            case ARP_OP:
+                return (this.wildcards & OFPFW_NW_PROTO) == 0;
+            case ARP_SPA:
+                return this.getIpv4SrcCidrMaskLen() >= 32;
+            case ARP_TPA:
+                return this.getIpv4DstCidrMaskLen() >= 32;
+            case IP_DSCP:
+                return (this.wildcards & OFPFW_NW_TOS) == 0;
+            case IP_PROTO:
+                return (this.wildcards & OFPFW_NW_PROTO) == 0;
+            case IPV4_SRC:
+                return this.getIpv4SrcCidrMaskLen() >= 32;
+            case IPV4_DST:
+                return this.getIpv4DstCidrMaskLen() >= 32;
+            case TCP_SRC:
+                return (this.wildcards & OFPFW_TP_SRC) == 0;
+            case TCP_DST:
+                return (this.wildcards & OFPFW_TP_DST) == 0;
+            case UDP_SRC:
+                return (this.wildcards & OFPFW_TP_SRC) == 0;
+            case UDP_DST:
+                return (this.wildcards & OFPFW_TP_DST) == 0;
+            case SCTP_SRC:
+                return (this.wildcards & OFPFW_TP_SRC) == 0;
+            case SCTP_DST:
+                return (this.wildcards & OFPFW_TP_DST) == 0;
+            case ICMPV4_TYPE:
+                return (this.wildcards & OFPFW_TP_SRC) == 0;
+            case ICMPV4_CODE:
+                return (this.wildcards & OFPFW_TP_DST) == 0;
+            default:
+                throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+        }
+    }
+
+    /**
+     * Parse this match's wildcard fields and return the number of significant
+     * bits in the IP destination field. NOTE: this returns the number of bits
+     * that are fixed, i.e., like CIDR, not the number of bits that are free
+     * like OpenFlow encodes.
+     *
+     * @return A number between 0 (matches all IPs) and 32 (exact match)
+     */
+    public int getIpv4DstCidrMaskLen() {
+        return Math.max(32 - ((wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT),
+                        0);
+    }
+
+    /**
+     * Parse this match's wildcard fields and return the number of significant
+     * bits in the IP destination field. NOTE: this returns the number of bits
+     * that are fixed, i.e., like CIDR, not the number of bits that are free
+     * like OpenFlow encodes.
+     *
+     * @return A number between 0 (matches all IPs) and 32 (exact match)
+     */
+    public int getIpv4SrcCidrMaskLen() {
+        return Math.max(32 - ((wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT),
+                        0);
+    }
+
+
+    @Override
+    public boolean isFullyWildcarded(MatchField<?> field) {
+        if (!field.arePrerequisitesOK(this))
+            return true;
+
+        switch (field.id) {
+            case IN_PORT:
+                return (this.wildcards & OFPFW_IN_PORT) != 0;
+            case ETH_DST:
+                return (this.wildcards & OFPFW_DL_DST) != 0;
+            case ETH_SRC:
+                return (this.wildcards & OFPFW_DL_SRC) != 0;
+            case ETH_TYPE:
+                return (this.wildcards & OFPFW_DL_TYPE) != 0;
+            case VLAN_VID:
+                return (this.wildcards & OFPFW_DL_VLAN) != 0;
+            case VLAN_PCP:
+                return (this.wildcards & OFPFW_DL_VLAN_PCP) != 0;
+            case ARP_OP:
+                return (this.wildcards & OFPFW_NW_PROTO) != 0;
+            case ARP_SPA:
+                return this.getIpv4SrcCidrMaskLen() <= 0;
+            case ARP_TPA:
+                return this.getIpv4DstCidrMaskLen() <= 0;
+            case IP_DSCP:
+                return (this.wildcards & OFPFW_NW_TOS) != 0;
+            case IP_PROTO:
+                return (this.wildcards & OFPFW_NW_PROTO) != 0;
+            case TCP_SRC:
+                return (this.wildcards & OFPFW_TP_SRC) != 0;
+            case TCP_DST:
+                return (this.wildcards & OFPFW_TP_DST) != 0;
+            case UDP_SRC:
+                return (this.wildcards & OFPFW_TP_SRC) != 0;
+            case UDP_DST:
+                return (this.wildcards & OFPFW_TP_DST) != 0;
+            case SCTP_SRC:
+                return (this.wildcards & OFPFW_TP_SRC) != 0;
+            case SCTP_DST:
+                return (this.wildcards & OFPFW_TP_DST) != 0;
+            case ICMPV4_TYPE:
+                return (this.wildcards & OFPFW_TP_SRC) != 0;
+            case ICMPV4_CODE:
+                return (this.wildcards & OFPFW_TP_DST) != 0;
+            case IPV4_SRC:
+                return this.getIpv4SrcCidrMaskLen() <= 0;
+            case IPV4_DST:
+                return this.getIpv4DstCidrMaskLen() <= 0;
+            default:
+                throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+        }
+    }
+
+    @Override
+    public boolean isPartiallyMasked(MatchField<?> field) {
+        if (!field.arePrerequisitesOK(this))
+            return false;
+
+        switch (field.id) {
+            case ARP_SPA:
+            case IPV4_SRC:
+                int srcCidrLen = getIpv4SrcCidrMaskLen();
+                return srcCidrLen > 0 && srcCidrLen < 32;
+            case ARP_TPA:
+            case IPV4_DST:
+                int dstCidrLen = getIpv4DstCidrMaskLen();
+                return dstCidrLen > 0 && dstCidrLen < 32;
+            default:
+                return false;
+        }
+    }
+
+    @Override
+    public Iterable<MatchField<?>> getMatchFields() {
+        ImmutableList.Builder<MatchField<?>> builder = ImmutableList.builder();
+        if ((wildcards & OFPFW_IN_PORT) == 0)
+            builder.add(MatchField.IN_PORT);
+        if ((wildcards & OFPFW_DL_VLAN) == 0)
+            builder.add(MatchField.VLAN_VID);
+        if ((wildcards & OFPFW_DL_SRC) == 0)
+            builder.add(MatchField.ETH_SRC);
+        if ((wildcards & OFPFW_DL_DST) == 0)
+            builder.add(MatchField.ETH_DST);
+        if ((wildcards & OFPFW_DL_TYPE) == 0)
+            builder.add(MatchField.ETH_TYPE);
+        if ((wildcards & OFPFW_NW_PROTO) == 0) {
+            if (ethType == EthType.ARP) {
+                builder.add(MatchField.ARP_OP);
+            } else if (ethType == EthType.IPv4) {
+                builder.add(MatchField.IP_PROTO);
+            } else {
+                throw new UnsupportedOperationException(
+                        "Unsupported Ethertype for matching on network protocol " + ethType);
+            }
+        }
+        if ((wildcards & OFPFW_TP_SRC) == 0) {
+            if (ipProto == IpProtocol.UDP) {
+                builder.add(MatchField.UDP_SRC);
+            } else if (ipProto == IpProtocol.TCP) {
+                builder.add(MatchField.TCP_SRC);
+            } else if (ipProto == IpProtocol.SCTP) {
+                builder.add(MatchField.SCTP_SRC);
+            } else {
+                throw new UnsupportedOperationException(
+                        "Unsupported IP protocol for matching on source port " + ipProto);
+            }
+        }
+        if ((wildcards & OFPFW_TP_DST) == 0) {
+            if (ipProto == IpProtocol.UDP) {
+                builder.add(MatchField.UDP_DST);
+            } else if (ipProto == IpProtocol.TCP) {
+                builder.add(MatchField.TCP_DST);
+            } else if (ipProto == IpProtocol.SCTP) {
+                builder.add(MatchField.SCTP_DST);
+            } else {
+                throw new UnsupportedOperationException(
+                        "Unsupported IP protocol for matching on destination port " + ipProto);
+            }
+        }
+        if (((wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT) < 32) {
+            if (ethType == EthType.ARP) {
+                builder.add(MatchField.ARP_SPA);
+            } else if (ethType == EthType.IPv4) {
+                builder.add(MatchField.IPV4_SRC);
+            } else {
+                throw new UnsupportedOperationException(
+                        "Unsupported Ethertype for matching on source IP " + ethType);
+            }
+        }
+        if (((wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT) < 32) {
+            if (ethType == EthType.ARP) {
+                builder.add(MatchField.ARP_TPA);
+            } else if (ethType == EthType.IPv4) {
+                builder.add(MatchField.IPV4_DST);
+            } else {
+                throw new UnsupportedOperationException(
+                        "Unsupported Ethertype for matching on destination IP " + ethType);
+            }
+        }
+        if ((wildcards & OFPFW_DL_VLAN_PCP) == 0)
+            builder.add(MatchField.VLAN_PCP);
+        if ((wildcards & OFPFW_NW_TOS) == 0)
+            builder.add(MatchField.IP_DSCP);
+        return builder.build();
+    }
+
+    public OFMatchV1.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMatchV1.Builder {
+        final OFMatchV1Ver10 parentMessage;
+
+        // OF message fields
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean ethSrcSet;
+        private MacAddress ethSrc;
+        private boolean ethDstSet;
+        private MacAddress ethDst;
+        private boolean vlanVidSet;
+        private OFVlanVidMatch vlanVid;
+        private boolean vlanPcpSet;
+        private VlanPcp vlanPcp;
+        private boolean ethTypeSet;
+        private EthType ethType;
+        private boolean ipDscpSet;
+        private IpDscp ipDscp;
+        private boolean ipProtoSet;
+        private IpProtocol ipProto;
+        private boolean ipv4SrcSet;
+        private IPv4Address ipv4Src;
+        private boolean ipv4DstSet;
+        private IPv4Address ipv4Dst;
+        private boolean tcpSrcSet;
+        private TransportPort tcpSrc;
+        private boolean tcpDstSet;
+        private TransportPort tcpDst;
+
+        BuilderWithParent(OFMatchV1Ver10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFMatchV1.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFMatchV1.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthSrc() {
+        return ethSrc;
+    }
+
+    @Override
+    public OFMatchV1.Builder setEthSrc(MacAddress ethSrc) {
+        this.ethSrc = ethSrc;
+        this.ethSrcSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthDst() {
+        return ethDst;
+    }
+
+    @Override
+    public OFMatchV1.Builder setEthDst(MacAddress ethDst) {
+        this.ethDst = ethDst;
+        this.ethDstSet = true;
+        return this;
+    }
+    @Override
+    public OFVlanVidMatch getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFMatchV1.Builder setVlanVid(OFVlanVidMatch vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFMatchV1.Builder setVlanPcp(VlanPcp vlanPcp) {
+        this.vlanPcp = vlanPcp;
+        this.vlanPcpSet = true;
+        return this;
+    }
+    @Override
+    public EthType getEthType() {
+        return ethType;
+    }
+
+    @Override
+    public OFMatchV1.Builder setEthType(EthType ethType) {
+        this.ethType = ethType;
+        this.ethTypeSet = true;
+        return this;
+    }
+    @Override
+    public IpDscp getIpDscp() {
+        return ipDscp;
+    }
+
+    @Override
+    public OFMatchV1.Builder setIpDscp(IpDscp ipDscp) {
+        this.ipDscp = ipDscp;
+        this.ipDscpSet = true;
+        return this;
+    }
+    @Override
+    public IpProtocol getIpProto() {
+        return ipProto;
+    }
+
+    @Override
+    public OFMatchV1.Builder setIpProto(IpProtocol ipProto) {
+        this.ipProto = ipProto;
+        this.ipProtoSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Src() {
+        return ipv4Src;
+    }
+
+    @Override
+    public OFMatchV1.Builder setIpv4Src(IPv4Address ipv4Src) {
+        this.ipv4Src = ipv4Src;
+        this.ipv4SrcSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Dst() {
+        return ipv4Dst;
+    }
+
+    @Override
+    public OFMatchV1.Builder setIpv4Dst(IPv4Address ipv4Dst) {
+        this.ipv4Dst = ipv4Dst;
+        this.ipv4DstSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getTcpSrc() {
+        return tcpSrc;
+    }
+
+    @Override
+    public OFMatchV1.Builder setTcpSrc(TransportPort tcpSrc) {
+        this.tcpSrc = tcpSrc;
+        this.tcpSrcSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getTcpDst() {
+        return tcpDst;
+    }
+
+    @Override
+    public OFMatchV1.Builder setTcpDst(TransportPort tcpDst) {
+        this.tcpDst = tcpDst;
+        this.tcpDstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFMatchV1 build() {
+                int wildcards = this.wildcardsSet ? this.wildcards : parentMessage.wildcards;
+                OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort;
+                if(inPort == null)
+                    throw new NullPointerException("Property inPort must not be null");
+                MacAddress ethSrc = this.ethSrcSet ? this.ethSrc : parentMessage.ethSrc;
+                if(ethSrc == null)
+                    throw new NullPointerException("Property ethSrc must not be null");
+                MacAddress ethDst = this.ethDstSet ? this.ethDst : parentMessage.ethDst;
+                if(ethDst == null)
+                    throw new NullPointerException("Property ethDst must not be null");
+                OFVlanVidMatch vlanVid = this.vlanVidSet ? this.vlanVid : parentMessage.vlanVid;
+                if(vlanVid == null)
+                    throw new NullPointerException("Property vlanVid must not be null");
+                VlanPcp vlanPcp = this.vlanPcpSet ? this.vlanPcp : parentMessage.vlanPcp;
+                if(vlanPcp == null)
+                    throw new NullPointerException("Property vlanPcp must not be null");
+                EthType ethType = this.ethTypeSet ? this.ethType : parentMessage.ethType;
+                if(ethType == null)
+                    throw new NullPointerException("Property ethType must not be null");
+                IpDscp ipDscp = this.ipDscpSet ? this.ipDscp : parentMessage.ipDscp;
+                if(ipDscp == null)
+                    throw new NullPointerException("Property ipDscp must not be null");
+                IpProtocol ipProto = this.ipProtoSet ? this.ipProto : parentMessage.ipProto;
+                if(ipProto == null)
+                    throw new NullPointerException("Property ipProto must not be null");
+                IPv4Address ipv4Src = this.ipv4SrcSet ? this.ipv4Src : parentMessage.ipv4Src;
+                if(ipv4Src == null)
+                    throw new NullPointerException("Property ipv4Src must not be null");
+                IPv4Address ipv4Dst = this.ipv4DstSet ? this.ipv4Dst : parentMessage.ipv4Dst;
+                if(ipv4Dst == null)
+                    throw new NullPointerException("Property ipv4Dst must not be null");
+                TransportPort tcpSrc = this.tcpSrcSet ? this.tcpSrc : parentMessage.tcpSrc;
+                if(tcpSrc == null)
+                    throw new NullPointerException("Property tcpSrc must not be null");
+                TransportPort tcpDst = this.tcpDstSet ? this.tcpDst : parentMessage.tcpDst;
+                if(tcpDst == null)
+                    throw new NullPointerException("Property tcpDst must not be null");
+
+                //
+            // normalize match fields according to current OpenVSwitch behavior. When prerequisites for a field are not met
+            // e.g., eth_type is not set to 0x800, OVS sets the value of corresponding ignored fields (e.g.,
+            // ip_src, tcp_dst) to 0, and sets the wildcard bit to 1.
+            if(ethType.equals(EthType.IPv4)) {
+                // IP
+                if(ipProto.equals(IpProtocol.TCP) || ipProto.equals(IpProtocol.UDP) || ipProto.equals(IpProtocol.ICMP)) {
+                    // fully speced, wildcards and all values are fine
+                    // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                        wildcards |= OFPFW_NW_SRC_MASK;
+
+                    // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                        wildcards |= OFPFW_NW_DST_MASK;
+
+                } else {
+                    // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                        wildcards |= OFPFW_NW_SRC_MASK;
+
+                    // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                        wildcards |= OFPFW_NW_DST_MASK;
+
+                    // not TCP/UDP/ICMP -> Clear TP wildcards for the wire
+                    wildcards |= (OFPFW_TP_SRC | OFPFW_TP_DST);
+                    tcpSrc = TransportPort.NONE;
+                    tcpDst = TransportPort.NONE;
+                }
+            } else if (ethType.equals(EthType.ARP)) {
+                // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                    wildcards |= OFPFW_NW_SRC_MASK;
+
+                // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                    wildcards |= OFPFW_NW_DST_MASK;
+
+                // ARP: clear NW_TOS / TP wildcards for the wire
+                wildcards |= ( OFPFW_NW_TOS | OFPFW_TP_SRC | OFPFW_TP_DST);
+                ipDscp = IpDscp.NONE;
+                tcpSrc = TransportPort.NONE;
+                tcpDst = TransportPort.NONE;
+            } else {
+                // not even IP. Clear NW/TP wildcards for the wire
+                wildcards |= ( OFPFW_NW_TOS | OFPFW_NW_PROTO | OFPFW_NW_SRC_MASK | OFPFW_NW_DST_MASK | OFPFW_TP_SRC | OFPFW_TP_DST);
+                ipDscp = IpDscp.NONE;
+                ipProto = IpProtocol.NONE;
+                ipv4Src = IPv4Address.NONE;
+                ipv4Dst = IPv4Address.NONE;
+                tcpSrc = TransportPort.NONE;
+                tcpDst = TransportPort.NONE;
+            }
+                return new OFMatchV1Ver10(
+                    wildcards,
+                    inPort,
+                    ethSrc,
+                    ethDst,
+                    vlanVid,
+                    vlanPcp,
+                    ethType,
+                    ipDscp,
+                    ipProto,
+                    ipv4Src,
+                    ipv4Dst,
+                    tcpSrc,
+                    tcpDst
+                );
+        }
+        @SuppressWarnings("unchecked")
+        @Override
+        public <F extends OFValueType<F>> F get(MatchField<F> field)
+                throws UnsupportedOperationException {
+            if (isFullyWildcarded(field))
+                return null;
+
+            Object result;
+            switch (field.id) {
+                case IN_PORT:
+                    result = inPort;
+                    break;
+                case ETH_DST:
+                    result = ethDst;
+                    break;
+                case ETH_SRC:
+                    result = ethSrc;
+                    break;
+                case ETH_TYPE:
+                    result = ethType;
+                    break;
+                case VLAN_VID:
+                    result = vlanVid;
+                    break;
+                case VLAN_PCP:
+                    result = vlanPcp;
+                    break;
+                case ARP_OP:
+                    result = ArpOpcode.of(ipProto.getIpProtocolNumber());
+                    break;
+                case ARP_SPA:
+                    result = ipv4Src;
+                    break;
+                case ARP_TPA:
+                    result = ipv4Dst;
+                    break;
+                case IP_DSCP:
+                    result = ipDscp;
+                    break;
+                case IP_PROTO:
+                    result = ipProto;
+                    break;
+                case IPV4_SRC:
+                    result = ipv4Src;
+                    break;
+                case IPV4_DST:
+                    result = ipv4Dst;
+                    break;
+                case TCP_SRC:
+                    result = tcpSrc;
+                    break;
+                case TCP_DST:
+                    result = tcpDst;
+                    break;
+                case UDP_SRC:
+                    result = tcpSrc;
+                    break;
+                case UDP_DST:
+                    result = tcpDst;
+                    break;
+                case SCTP_SRC:
+                    result = tcpSrc;
+                    break;
+                case SCTP_DST:
+                    result = tcpDst;
+                    break;
+                case ICMPV4_TYPE:
+                    result = tcpSrc;
+                    break;
+                case ICMPV4_CODE:
+                    result = tcpDst;
+                    break;
+                // NOT SUPPORTED:
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+            }
+            return (F)result;
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+                throws UnsupportedOperationException {
+            if (!isPartiallyMasked(field))
+                return null;
+            Object result;
+            switch (field.id) {
+                case IPV4_SRC:
+                case ARP_SPA:
+                    int srcBitMask = (-1) << (32 - getIpv4SrcCidrMaskLen());
+                    result = IPv4AddressWithMask.of(ipv4Src, IPv4Address.of(srcBitMask));
+                    break;
+                case IPV4_DST:
+                case ARP_TPA:
+                    int dstMaskedBits = Math.min(32, (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT);
+                    int dstBitMask = (-1) << (32 - getIpv4DstCidrMaskLen());
+
+                    result = IPv4AddressWithMask.of(ipv4Dst, IPv4Address.of(dstBitMask));
+                    break;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+            }
+            return (Masked<F>)result;
+        }
+
+        @Override
+        public boolean supports(MatchField<?> field) {
+            switch (field.id) {
+                case IN_PORT:
+                case ETH_DST:
+                case ETH_SRC:
+                case ETH_TYPE:
+                case VLAN_VID:
+                case VLAN_PCP:
+                case ARP_OP:
+                case ARP_SPA:
+                case ARP_TPA:
+                case IP_DSCP:
+                case IP_PROTO:
+                case IPV4_SRC:
+                case IPV4_DST:
+                case TCP_SRC:
+                case TCP_DST:
+                case UDP_SRC:
+                case UDP_DST:
+                case SCTP_SRC:
+                case SCTP_DST:
+                case ICMPV4_TYPE:
+                case ICMPV4_CODE:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        @Override
+        public boolean supportsMasked(MatchField<?> field) {
+            switch (field.id) {
+                case ARP_SPA:
+                case ARP_TPA:
+                case IPV4_SRC:
+                case IPV4_DST:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        @Override
+        public boolean isExact(MatchField<?> field) {
+            switch (field.id) {
+                case IN_PORT:
+                    return (this.wildcards & OFPFW_IN_PORT) == 0;
+                case ETH_DST:
+                    return (this.wildcards & OFPFW_DL_DST) == 0;
+                case ETH_SRC:
+                    return (this.wildcards & OFPFW_DL_SRC) == 0;
+                case ETH_TYPE:
+                    return (this.wildcards & OFPFW_DL_TYPE) == 0;
+                case VLAN_VID:
+                    return (this.wildcards & OFPFW_DL_VLAN) == 0;
+                case VLAN_PCP:
+                    return (this.wildcards & OFPFW_DL_VLAN_PCP) == 0;
+                case ARP_OP:
+                    return (this.wildcards & OFPFW_NW_PROTO) == 0;
+                case ARP_SPA:
+                    return this.getIpv4SrcCidrMaskLen() >= 32;
+                case ARP_TPA:
+                    return this.getIpv4DstCidrMaskLen() >= 32;
+                case IP_DSCP:
+                    return (this.wildcards & OFPFW_NW_TOS) == 0;
+                case IP_PROTO:
+                    return (this.wildcards & OFPFW_NW_PROTO) == 0;
+                case IPV4_SRC:
+                    return this.getIpv4SrcCidrMaskLen() >= 32;
+                case IPV4_DST:
+                    return this.getIpv4DstCidrMaskLen() >= 32;
+                case TCP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) == 0;
+                case TCP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) == 0;
+                case UDP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) == 0;
+                case UDP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) == 0;
+                case SCTP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) == 0;
+                case SCTP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) == 0;
+                case ICMPV4_TYPE:
+                    return (this.wildcards & OFPFW_TP_SRC) == 0;
+                case ICMPV4_CODE:
+                    return (this.wildcards & OFPFW_TP_DST) == 0;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+            }
+        }
+
+        /**
+         * Parse this match's wildcard fields and return the number of significant
+         * bits in the IP destination field. NOTE: this returns the number of bits
+         * that are fixed, i.e., like CIDR, not the number of bits that are free
+         * like OpenFlow encodes.
+         *
+         * @return A number between 0 (matches all IPs) and 32 (exact match)
+         */
+        public int getIpv4DstCidrMaskLen() {
+            return Math.max(32 - ((wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT),
+                            0);
+        }
+
+        /**
+         * Parse this match's wildcard fields and return the number of significant
+         * bits in the IP destination field. NOTE: this returns the number of bits
+         * that are fixed, i.e., like CIDR, not the number of bits that are free
+         * like OpenFlow encodes.
+         *
+         * @return A number between 0 (matches all IPs) and 32 (exact match)
+         */
+        public int getIpv4SrcCidrMaskLen() {
+            return Math.max(32 - ((wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT),
+                            0);
+        }
+
+
+        @Override
+        public boolean isFullyWildcarded(MatchField<?> field) {
+            switch (field.id) {
+                case IN_PORT:
+                    return (this.wildcards & OFPFW_IN_PORT) != 0;
+                case ETH_DST:
+                    return (this.wildcards & OFPFW_DL_DST) != 0;
+                case ETH_SRC:
+                    return (this.wildcards & OFPFW_DL_SRC) != 0;
+                case ETH_TYPE:
+                    return (this.wildcards & OFPFW_DL_TYPE) != 0;
+                case VLAN_VID:
+                    return (this.wildcards & OFPFW_DL_VLAN) != 0;
+                case VLAN_PCP:
+                    return (this.wildcards & OFPFW_DL_VLAN_PCP) != 0;
+                case ARP_OP:
+                    return (this.wildcards & OFPFW_NW_PROTO) != 0;
+                case ARP_SPA:
+                    return this.getIpv4SrcCidrMaskLen() <= 0;
+                case ARP_TPA:
+                    return this.getIpv4DstCidrMaskLen() <= 0;
+                case IP_DSCP:
+                    return (this.wildcards & OFPFW_NW_TOS) != 0;
+                case IP_PROTO:
+                    return (this.wildcards & OFPFW_NW_PROTO) != 0;
+                case TCP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) != 0;
+                case TCP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) != 0;
+                case UDP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) != 0;
+                case UDP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) != 0;
+                case SCTP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) != 0;
+                case SCTP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) != 0;
+                case ICMPV4_TYPE:
+                    return (this.wildcards & OFPFW_TP_SRC) != 0;
+                case ICMPV4_CODE:
+                    return (this.wildcards & OFPFW_TP_DST) != 0;
+                case IPV4_SRC:
+                    return this.getIpv4SrcCidrMaskLen() <= 0;
+                case IPV4_DST:
+                    return this.getIpv4DstCidrMaskLen() <= 0;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+            }
+        }
+
+        @Override
+        public boolean isPartiallyMasked(MatchField<?> field) {
+            switch (field.id) {
+                case ARP_SPA:
+                case IPV4_SRC:
+                    int srcCidrLen = getIpv4SrcCidrMaskLen();
+                    return srcCidrLen > 0 && srcCidrLen < 32;
+                case ARP_TPA:
+                case IPV4_DST:
+                    int dstCidrLen = getIpv4DstCidrMaskLen();
+                    return dstCidrLen > 0 && dstCidrLen < 32;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+            }
+        }
+
+        private final void initWildcards() {
+            if(!wildcardsSet) {
+                wildcards = parentMessage.wildcards;
+                wildcardsSet = true;
+            }
+        }
+
+        @Override
+        public <F extends OFValueType<F>> Match.Builder setExact(MatchField<F> field,
+                F value) {
+            initWildcards();
+            Object val = value;
+            switch (field.id) {
+                case ETH_DST:
+                    setEthDst((MacAddress) value);
+                    wildcards &= ~OFPFW_DL_DST;
+                    break;
+                case ETH_SRC:
+                    setEthSrc((MacAddress) value);
+                    wildcards &= ~OFPFW_DL_SRC;
+                    break;
+                case ETH_TYPE:
+                    setEthType((EthType) value);
+                    wildcards &= ~OFPFW_DL_TYPE;
+                    break;
+                case ICMPV4_CODE:
+                    setTcpDst(TransportPort.of(((ICMPv4Code)value).getCode()));
+                    wildcards &= ~OFPFW_TP_DST;
+                    break;
+                case ICMPV4_TYPE:
+                    setTcpSrc(TransportPort.of(((ICMPv4Type)value).getType()));
+                    wildcards &= ~OFPFW_TP_SRC;
+                    break;
+                case IN_PORT:
+                    setInPort((OFPort) value);
+                    wildcards &= ~OFPFW_IN_PORT;
+                    break;
+                case ARP_OP:
+                    setIpProto(IpProtocol.of((short)((ArpOpcode)value).getOpcode()));
+                    wildcards &= ~OFPFW_NW_PROTO;
+                    break;
+                case ARP_TPA:
+                case IPV4_DST:
+                    setIpv4Dst((IPv4Address) value);
+                    wildcards &= ~OFPFW_NW_DST_MASK;
+                    break;
+                case ARP_SPA:
+                case IPV4_SRC:
+                    setIpv4Src((IPv4Address) value);
+                    wildcards &= ~OFPFW_NW_SRC_MASK;
+                    break;
+                case IP_DSCP:
+                    setIpDscp((IpDscp) value);
+                    wildcards &= ~OFPFW_NW_TOS;
+                    break;
+                case IP_PROTO:
+                    setIpProto((IpProtocol) value);
+                    wildcards &= ~OFPFW_NW_PROTO;
+                    break;
+                case SCTP_DST:
+                    setTcpDst((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_DST;
+                    break;
+                case SCTP_SRC:
+                    setTcpSrc((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_SRC;
+                    break;
+                case TCP_DST:
+                    setTcpDst((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_DST;
+                    break;
+                case TCP_SRC:
+                    setTcpSrc((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_SRC;
+                    break;
+                case UDP_DST:
+                    setTcpDst((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_DST;
+                    break;
+                case UDP_SRC:
+                    setTcpSrc((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_SRC;
+                    break;
+                case VLAN_PCP:
+                    setVlanPcp((VlanPcp) value);
+                    wildcards &= ~OFPFW_DL_VLAN_PCP;
+                    break;
+                case VLAN_VID:
+                    setVlanVid((OFVlanVidMatch) value);
+                    wildcards &= ~OFPFW_DL_VLAN;
+                    break;
+                default:
+                    throw new UnsupportedOperationException(
+                            "OFMatch does not support matching on field " + field.getName());
+            }
+            return this;
+        }
+
+        @Override
+        public <F extends OFValueType<F>> Match.Builder setMasked(MatchField<F> field,
+                F value, F mask) {
+            initWildcards();
+            switch (field.id) {
+                case ARP_SPA:
+                case ARP_TPA:
+                case IPV4_DST:
+                case IPV4_SRC:
+                    Object valObj = value;
+                    Object masObj = mask;
+                    IPv4Address ip = ((IPv4Address)valObj);
+                    int maskval = ((IPv4Address)masObj).getInt();
+                    if (Integer.bitCount(~maskval + 1) != 1)
+                        throw new UnsupportedOperationException("OFMatch only supports CIDR masks for IPv4");
+                    int maskLen = 32 - Integer.bitCount(maskval);
+                    switch(field.id) {
+                        case ARP_TPA:
+                        case IPV4_DST:
+                            setIpv4Dst(ip);
+                            wildcards = (wildcards &~OFPFW_NW_DST_MASK) | (maskLen << OFPFW_NW_DST_SHIFT);
+                            break;
+                        case ARP_SPA:
+                        case IPV4_SRC:
+                            setIpv4Src(ip);
+                            wildcards = (wildcards &~OFPFW_NW_SRC_MASK) | (maskLen << OFPFW_NW_SRC_SHIFT);
+                            break;
+                        default:
+                            // Cannot really get here
+                            break;
+                    }
+                    break;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+            }
+            return this;
+        }
+
+        @Override
+        public <F extends OFValueType<F>> Match.Builder setMasked(MatchField<F> field, Masked<F> valueWithMask)
+                                                                       throws UnsupportedOperationException {
+            return this.setMasked(field, valueWithMask.getValue(), valueWithMask.getMask());
+        }
+
+        @Override
+        public <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+            initWildcards();
+            switch (field.id) {
+                case ETH_DST:
+                    setEthDst(MacAddress.NONE);
+                    wildcards |= OFPFW_DL_DST;
+                    break;
+                case ETH_SRC:
+                    setEthSrc(MacAddress.NONE);
+                    wildcards |= OFPFW_DL_SRC;
+                    break;
+                case ETH_TYPE:
+                    setEthType(EthType.NONE);
+                    wildcards |= OFPFW_DL_TYPE;
+                    break;
+                case ICMPV4_CODE:
+                case TCP_DST:
+                case UDP_DST:
+                case SCTP_DST:
+                    setTcpDst(TransportPort.NONE);
+                    wildcards |= OFPFW_TP_DST;
+                    break;
+                case ICMPV4_TYPE:
+                case TCP_SRC:
+                case UDP_SRC:
+                case SCTP_SRC:
+                    setTcpSrc(TransportPort.NONE);
+                    wildcards |= OFPFW_TP_SRC;
+                    break;
+                case IN_PORT:
+                    setInPort(OFPort.of(0)); // NOTE: not 'NONE' -- that is 0xFF for ports
+                    wildcards |= OFPFW_IN_PORT;
+                    break;
+                case ARP_TPA:
+                case IPV4_DST:
+                    setIpv4Dst(IPv4Address.NONE);
+                    wildcards |= OFPFW_NW_DST_MASK;
+                    break;
+                case ARP_SPA:
+                case IPV4_SRC:
+                    setIpv4Src(IPv4Address.NONE);
+                    wildcards |= OFPFW_NW_SRC_MASK;
+                    break;
+                case IP_DSCP:
+                    setIpDscp(IpDscp.NONE);
+                    wildcards |= OFPFW_NW_TOS;
+                    break;
+                case IP_PROTO:
+                    setIpProto(IpProtocol.NONE);
+                    wildcards |= OFPFW_NW_PROTO;
+                    break;
+                case VLAN_PCP:
+                    setVlanPcp(VlanPcp.NONE);
+                    wildcards |= OFPFW_DL_VLAN_PCP;
+                    break;
+                case VLAN_VID:
+                    setVlanVid(OFVlanVidMatch.NONE);
+                    wildcards |= OFPFW_DL_VLAN;
+                    break;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+            }
+            return this;
+        }
+
+    }
+
+    static class Builder implements OFMatchV1.Builder {
+        // OF message fields
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean ethSrcSet;
+        private MacAddress ethSrc;
+        private boolean ethDstSet;
+        private MacAddress ethDst;
+        private boolean vlanVidSet;
+        private OFVlanVidMatch vlanVid;
+        private boolean vlanPcpSet;
+        private VlanPcp vlanPcp;
+        private boolean ethTypeSet;
+        private EthType ethType;
+        private boolean ipDscpSet;
+        private IpDscp ipDscp;
+        private boolean ipProtoSet;
+        private IpProtocol ipProto;
+        private boolean ipv4SrcSet;
+        private IPv4Address ipv4Src;
+        private boolean ipv4DstSet;
+        private IPv4Address ipv4Dst;
+        private boolean tcpSrcSet;
+        private TransportPort tcpSrc;
+        private boolean tcpDstSet;
+        private TransportPort tcpDst;
+
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFMatchV1.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFMatchV1.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthSrc() {
+        return ethSrc;
+    }
+
+    @Override
+    public OFMatchV1.Builder setEthSrc(MacAddress ethSrc) {
+        this.ethSrc = ethSrc;
+        this.ethSrcSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthDst() {
+        return ethDst;
+    }
+
+    @Override
+    public OFMatchV1.Builder setEthDst(MacAddress ethDst) {
+        this.ethDst = ethDst;
+        this.ethDstSet = true;
+        return this;
+    }
+    @Override
+    public OFVlanVidMatch getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFMatchV1.Builder setVlanVid(OFVlanVidMatch vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFMatchV1.Builder setVlanPcp(VlanPcp vlanPcp) {
+        this.vlanPcp = vlanPcp;
+        this.vlanPcpSet = true;
+        return this;
+    }
+    @Override
+    public EthType getEthType() {
+        return ethType;
+    }
+
+    @Override
+    public OFMatchV1.Builder setEthType(EthType ethType) {
+        this.ethType = ethType;
+        this.ethTypeSet = true;
+        return this;
+    }
+    @Override
+    public IpDscp getIpDscp() {
+        return ipDscp;
+    }
+
+    @Override
+    public OFMatchV1.Builder setIpDscp(IpDscp ipDscp) {
+        this.ipDscp = ipDscp;
+        this.ipDscpSet = true;
+        return this;
+    }
+    @Override
+    public IpProtocol getIpProto() {
+        return ipProto;
+    }
+
+    @Override
+    public OFMatchV1.Builder setIpProto(IpProtocol ipProto) {
+        this.ipProto = ipProto;
+        this.ipProtoSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Src() {
+        return ipv4Src;
+    }
+
+    @Override
+    public OFMatchV1.Builder setIpv4Src(IPv4Address ipv4Src) {
+        this.ipv4Src = ipv4Src;
+        this.ipv4SrcSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Dst() {
+        return ipv4Dst;
+    }
+
+    @Override
+    public OFMatchV1.Builder setIpv4Dst(IPv4Address ipv4Dst) {
+        this.ipv4Dst = ipv4Dst;
+        this.ipv4DstSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getTcpSrc() {
+        return tcpSrc;
+    }
+
+    @Override
+    public OFMatchV1.Builder setTcpSrc(TransportPort tcpSrc) {
+        this.tcpSrc = tcpSrc;
+        this.tcpSrcSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getTcpDst() {
+        return tcpDst;
+    }
+
+    @Override
+    public OFMatchV1.Builder setTcpDst(TransportPort tcpDst) {
+        this.tcpDst = tcpDst;
+        this.tcpDstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFMatchV1 build() {
+            int wildcards = this.wildcardsSet ? this.wildcards : DEFAULT_WILDCARDS;
+            OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT;
+            if(inPort == null)
+                throw new NullPointerException("Property inPort must not be null");
+            MacAddress ethSrc = this.ethSrcSet ? this.ethSrc : DEFAULT_ETH_SRC;
+            if(ethSrc == null)
+                throw new NullPointerException("Property ethSrc must not be null");
+            MacAddress ethDst = this.ethDstSet ? this.ethDst : DEFAULT_ETH_DST;
+            if(ethDst == null)
+                throw new NullPointerException("Property ethDst must not be null");
+            OFVlanVidMatch vlanVid = this.vlanVidSet ? this.vlanVid : DEFAULT_VLAN_VID;
+            if(vlanVid == null)
+                throw new NullPointerException("Property vlanVid must not be null");
+            VlanPcp vlanPcp = this.vlanPcpSet ? this.vlanPcp : DEFAULT_VLAN_PCP;
+            if(vlanPcp == null)
+                throw new NullPointerException("Property vlanPcp must not be null");
+            EthType ethType = this.ethTypeSet ? this.ethType : DEFAULT_ETH_TYPE;
+            if(ethType == null)
+                throw new NullPointerException("Property ethType must not be null");
+            IpDscp ipDscp = this.ipDscpSet ? this.ipDscp : DEFAULT_IP_DSCP;
+            if(ipDscp == null)
+                throw new NullPointerException("Property ipDscp must not be null");
+            IpProtocol ipProto = this.ipProtoSet ? this.ipProto : DEFAULT_IP_PROTO;
+            if(ipProto == null)
+                throw new NullPointerException("Property ipProto must not be null");
+            IPv4Address ipv4Src = this.ipv4SrcSet ? this.ipv4Src : DEFAULT_IPV4_SRC;
+            if(ipv4Src == null)
+                throw new NullPointerException("Property ipv4Src must not be null");
+            IPv4Address ipv4Dst = this.ipv4DstSet ? this.ipv4Dst : DEFAULT_IPV4_DST;
+            if(ipv4Dst == null)
+                throw new NullPointerException("Property ipv4Dst must not be null");
+            TransportPort tcpSrc = this.tcpSrcSet ? this.tcpSrc : DEFAULT_TCP_SRC;
+            if(tcpSrc == null)
+                throw new NullPointerException("Property tcpSrc must not be null");
+            TransportPort tcpDst = this.tcpDstSet ? this.tcpDst : DEFAULT_TCP_DST;
+            if(tcpDst == null)
+                throw new NullPointerException("Property tcpDst must not be null");
+
+            // normalize match fields according to current OpenVSwitch behavior. When prerequisites for a field are not met
+            // e.g., eth_type is not set to 0x800, OVS sets the value of corresponding ignored fields (e.g.,
+            // ip_src, tcp_dst) to 0, and sets the wildcard bit to 1.
+            if(ethType.equals(EthType.IPv4)) {
+                // IP
+                if(ipProto.equals(IpProtocol.TCP) || ipProto.equals(IpProtocol.UDP) || ipProto.equals(IpProtocol.ICMP)) {
+                    // fully speced, wildcards and all values are fine
+                    // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                        wildcards |= OFPFW_NW_SRC_MASK;
+
+                    // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                        wildcards |= OFPFW_NW_DST_MASK;
+
+                } else {
+                    // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                        wildcards |= OFPFW_NW_SRC_MASK;
+
+                    // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                        wildcards |= OFPFW_NW_DST_MASK;
+
+                    // not TCP/UDP/ICMP -> Clear TP wildcards for the wire
+                    wildcards |= (OFPFW_TP_SRC | OFPFW_TP_DST);
+                    tcpSrc = TransportPort.NONE;
+                    tcpDst = TransportPort.NONE;
+                }
+            } else if (ethType.equals(EthType.ARP)) {
+                // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                    wildcards |= OFPFW_NW_SRC_MASK;
+
+                // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                    wildcards |= OFPFW_NW_DST_MASK;
+
+                // ARP: clear NW_TOS / TP wildcards for the wire
+                wildcards |= ( OFPFW_NW_TOS | OFPFW_TP_SRC | OFPFW_TP_DST);
+                ipDscp = IpDscp.NONE;
+                tcpSrc = TransportPort.NONE;
+                tcpDst = TransportPort.NONE;
+            } else {
+                // not even IP. Clear NW/TP wildcards for the wire
+                wildcards |= ( OFPFW_NW_TOS | OFPFW_NW_PROTO | OFPFW_NW_SRC_MASK | OFPFW_NW_DST_MASK | OFPFW_TP_SRC | OFPFW_TP_DST);
+                ipDscp = IpDscp.NONE;
+                ipProto = IpProtocol.NONE;
+                ipv4Src = IPv4Address.NONE;
+                ipv4Dst = IPv4Address.NONE;
+                tcpSrc = TransportPort.NONE;
+                tcpDst = TransportPort.NONE;
+            }
+
+            return new OFMatchV1Ver10(
+                    wildcards,
+                    inPort,
+                    ethSrc,
+                    ethDst,
+                    vlanVid,
+                    vlanPcp,
+                    ethType,
+                    ipDscp,
+                    ipProto,
+                    ipv4Src,
+                    ipv4Dst,
+                    tcpSrc,
+                    tcpDst
+                );
+        }
+        @SuppressWarnings("unchecked")
+        @Override
+        public <F extends OFValueType<F>> F get(MatchField<F> field)
+                throws UnsupportedOperationException {
+            if (isFullyWildcarded(field))
+                return null;
+
+            Object result;
+            switch (field.id) {
+                case IN_PORT:
+                    result = inPort;
+                    break;
+                case ETH_DST:
+                    result = ethDst;
+                    break;
+                case ETH_SRC:
+                    result = ethSrc;
+                    break;
+                case ETH_TYPE:
+                    result = ethType;
+                    break;
+                case VLAN_VID:
+                    result = vlanVid;
+                    break;
+                case VLAN_PCP:
+                    result = vlanPcp;
+                    break;
+                case ARP_OP:
+                    result = ArpOpcode.of(ipProto.getIpProtocolNumber());
+                    break;
+                case ARP_SPA:
+                    result = ipv4Src;
+                    break;
+                case ARP_TPA:
+                    result = ipv4Dst;
+                    break;
+                case IP_DSCP:
+                    result = ipDscp;
+                    break;
+                case IP_PROTO:
+                    result = ipProto;
+                    break;
+                case IPV4_SRC:
+                    result = ipv4Src;
+                    break;
+                case IPV4_DST:
+                    result = ipv4Dst;
+                    break;
+                case TCP_SRC:
+                    result = tcpSrc;
+                    break;
+                case TCP_DST:
+                    result = tcpDst;
+                    break;
+                case UDP_SRC:
+                    result = tcpSrc;
+                    break;
+                case UDP_DST:
+                    result = tcpDst;
+                    break;
+                case SCTP_SRC:
+                    result = tcpSrc;
+                    break;
+                case SCTP_DST:
+                    result = tcpDst;
+                    break;
+                case ICMPV4_TYPE:
+                    result = tcpSrc;
+                    break;
+                case ICMPV4_CODE:
+                    result = tcpDst;
+                    break;
+                // NOT SUPPORTED:
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+            }
+            return (F)result;
+        }
+
+        @SuppressWarnings("unchecked")
+        @Override
+        public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+                throws UnsupportedOperationException {
+            if (!isPartiallyMasked(field))
+                return null;
+            Object result;
+            switch (field.id) {
+                case IPV4_SRC:
+                case ARP_SPA:
+                    int srcBitMask = (-1) << (32 - getIpv4SrcCidrMaskLen());
+                    result = IPv4AddressWithMask.of(ipv4Src, IPv4Address.of(srcBitMask));
+                    break;
+                case IPV4_DST:
+                case ARP_TPA:
+                    int dstMaskedBits = Math.min(32, (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT);
+                    int dstBitMask = (-1) << (32 - getIpv4DstCidrMaskLen());
+
+                    result = IPv4AddressWithMask.of(ipv4Dst, IPv4Address.of(dstBitMask));
+                    break;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+            }
+            return (Masked<F>)result;
+        }
+
+        @Override
+        public boolean supports(MatchField<?> field) {
+            switch (field.id) {
+                case IN_PORT:
+                case ETH_DST:
+                case ETH_SRC:
+                case ETH_TYPE:
+                case VLAN_VID:
+                case VLAN_PCP:
+                case ARP_OP:
+                case ARP_SPA:
+                case ARP_TPA:
+                case IP_DSCP:
+                case IP_PROTO:
+                case IPV4_SRC:
+                case IPV4_DST:
+                case TCP_SRC:
+                case TCP_DST:
+                case UDP_SRC:
+                case UDP_DST:
+                case SCTP_SRC:
+                case SCTP_DST:
+                case ICMPV4_TYPE:
+                case ICMPV4_CODE:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        @Override
+        public boolean supportsMasked(MatchField<?> field) {
+            switch (field.id) {
+                case ARP_SPA:
+                case ARP_TPA:
+                case IPV4_SRC:
+                case IPV4_DST:
+                    return true;
+                default:
+                    return false;
+            }
+        }
+
+        @Override
+        public boolean isExact(MatchField<?> field) {
+            switch (field.id) {
+                case IN_PORT:
+                    return (this.wildcards & OFPFW_IN_PORT) == 0;
+                case ETH_DST:
+                    return (this.wildcards & OFPFW_DL_DST) == 0;
+                case ETH_SRC:
+                    return (this.wildcards & OFPFW_DL_SRC) == 0;
+                case ETH_TYPE:
+                    return (this.wildcards & OFPFW_DL_TYPE) == 0;
+                case VLAN_VID:
+                    return (this.wildcards & OFPFW_DL_VLAN) == 0;
+                case VLAN_PCP:
+                    return (this.wildcards & OFPFW_DL_VLAN_PCP) == 0;
+                case ARP_OP:
+                    return (this.wildcards & OFPFW_NW_PROTO) == 0;
+                case ARP_SPA:
+                    return this.getIpv4SrcCidrMaskLen() >= 32;
+                case ARP_TPA:
+                    return this.getIpv4DstCidrMaskLen() >= 32;
+                case IP_DSCP:
+                    return (this.wildcards & OFPFW_NW_TOS) == 0;
+                case IP_PROTO:
+                    return (this.wildcards & OFPFW_NW_PROTO) == 0;
+                case IPV4_SRC:
+                    return this.getIpv4SrcCidrMaskLen() >= 32;
+                case IPV4_DST:
+                    return this.getIpv4DstCidrMaskLen() >= 32;
+                case TCP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) == 0;
+                case TCP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) == 0;
+                case UDP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) == 0;
+                case UDP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) == 0;
+                case SCTP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) == 0;
+                case SCTP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) == 0;
+                case ICMPV4_TYPE:
+                    return (this.wildcards & OFPFW_TP_SRC) == 0;
+                case ICMPV4_CODE:
+                    return (this.wildcards & OFPFW_TP_DST) == 0;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+            }
+        }
+
+        /**
+         * Parse this match's wildcard fields and return the number of significant
+         * bits in the IP destination field. NOTE: this returns the number of bits
+         * that are fixed, i.e., like CIDR, not the number of bits that are free
+         * like OpenFlow encodes.
+         *
+         * @return A number between 0 (matches all IPs) and 32 (exact match)
+         */
+        public int getIpv4DstCidrMaskLen() {
+            return Math.max(32 - ((wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT),
+                            0);
+        }
+
+        /**
+         * Parse this match's wildcard fields and return the number of significant
+         * bits in the IP destination field. NOTE: this returns the number of bits
+         * that are fixed, i.e., like CIDR, not the number of bits that are free
+         * like OpenFlow encodes.
+         *
+         * @return A number between 0 (matches all IPs) and 32 (exact match)
+         */
+        public int getIpv4SrcCidrMaskLen() {
+            return Math.max(32 - ((wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT),
+                            0);
+        }
+
+
+        @Override
+        public boolean isFullyWildcarded(MatchField<?> field) {
+            switch (field.id) {
+                case IN_PORT:
+                    return (this.wildcards & OFPFW_IN_PORT) != 0;
+                case ETH_DST:
+                    return (this.wildcards & OFPFW_DL_DST) != 0;
+                case ETH_SRC:
+                    return (this.wildcards & OFPFW_DL_SRC) != 0;
+                case ETH_TYPE:
+                    return (this.wildcards & OFPFW_DL_TYPE) != 0;
+                case VLAN_VID:
+                    return (this.wildcards & OFPFW_DL_VLAN) != 0;
+                case VLAN_PCP:
+                    return (this.wildcards & OFPFW_DL_VLAN_PCP) != 0;
+                case ARP_OP:
+                    return (this.wildcards & OFPFW_NW_PROTO) != 0;
+                case ARP_SPA:
+                    return this.getIpv4SrcCidrMaskLen() <= 0;
+                case ARP_TPA:
+                    return this.getIpv4DstCidrMaskLen() <= 0;
+                case IP_DSCP:
+                    return (this.wildcards & OFPFW_NW_TOS) != 0;
+                case IP_PROTO:
+                    return (this.wildcards & OFPFW_NW_PROTO) != 0;
+                case TCP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) != 0;
+                case TCP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) != 0;
+                case UDP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) != 0;
+                case UDP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) != 0;
+                case SCTP_SRC:
+                    return (this.wildcards & OFPFW_TP_SRC) != 0;
+                case SCTP_DST:
+                    return (this.wildcards & OFPFW_TP_DST) != 0;
+                case ICMPV4_TYPE:
+                    return (this.wildcards & OFPFW_TP_SRC) != 0;
+                case ICMPV4_CODE:
+                    return (this.wildcards & OFPFW_TP_DST) != 0;
+                case IPV4_SRC:
+                    return this.getIpv4SrcCidrMaskLen() <= 0;
+                case IPV4_DST:
+                    return this.getIpv4DstCidrMaskLen() <= 0;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+            }
+        }
+
+        @Override
+        public boolean isPartiallyMasked(MatchField<?> field) {
+            switch (field.id) {
+                case ARP_SPA:
+                case IPV4_SRC:
+                    int srcCidrLen = getIpv4SrcCidrMaskLen();
+                    return srcCidrLen > 0 && srcCidrLen < 32;
+                case ARP_TPA:
+                case IPV4_DST:
+                    int dstCidrLen = getIpv4DstCidrMaskLen();
+                    return dstCidrLen > 0 && dstCidrLen < 32;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+            }
+        }
+
+        private final void initWildcards() {
+            if(!wildcardsSet) {
+                wildcards = OFPFW_ALL;
+                wildcardsSet = true;
+            }
+        }
+
+        @Override
+        public <F extends OFValueType<F>> Match.Builder setExact(MatchField<F> field,
+                F value) {
+            initWildcards();
+            Object val = value;
+            switch (field.id) {
+                case ETH_DST:
+                    setEthDst((MacAddress) value);
+                    wildcards &= ~OFPFW_DL_DST;
+                    break;
+                case ETH_SRC:
+                    setEthSrc((MacAddress) value);
+                    wildcards &= ~OFPFW_DL_SRC;
+                    break;
+                case ETH_TYPE:
+                    setEthType((EthType) value);
+                    wildcards &= ~OFPFW_DL_TYPE;
+                    break;
+                case ICMPV4_CODE:
+                    setTcpDst(TransportPort.of(((ICMPv4Code)value).getCode()));
+                    wildcards &= ~OFPFW_TP_DST;
+                    break;
+                case ICMPV4_TYPE:
+                    setTcpSrc(TransportPort.of(((ICMPv4Type)value).getType()));
+                    wildcards &= ~OFPFW_TP_SRC;
+                    break;
+                case IN_PORT:
+                    setInPort((OFPort) value);
+                    wildcards &= ~OFPFW_IN_PORT;
+                    break;
+                case ARP_OP:
+                    setIpProto(IpProtocol.of((short)((ArpOpcode)value).getOpcode()));
+                    wildcards &= ~OFPFW_NW_PROTO;
+                    break;
+                case ARP_TPA:
+                case IPV4_DST:
+                    setIpv4Dst((IPv4Address) value);
+                    wildcards &= ~OFPFW_NW_DST_MASK;
+                    break;
+                case ARP_SPA:
+                case IPV4_SRC:
+                    setIpv4Src((IPv4Address) value);
+                    wildcards &= ~OFPFW_NW_SRC_MASK;
+                    break;
+                case IP_DSCP:
+                    setIpDscp((IpDscp) value);
+                    wildcards &= ~OFPFW_NW_TOS;
+                    break;
+                case IP_PROTO:
+                    setIpProto((IpProtocol) value);
+                    wildcards &= ~OFPFW_NW_PROTO;
+                    break;
+                case SCTP_DST:
+                    setTcpDst((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_DST;
+                    break;
+                case SCTP_SRC:
+                    setTcpSrc((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_SRC;
+                    break;
+                case TCP_DST:
+                    setTcpDst((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_DST;
+                    break;
+                case TCP_SRC:
+                    setTcpSrc((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_SRC;
+                    break;
+                case UDP_DST:
+                    setTcpDst((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_DST;
+                    break;
+                case UDP_SRC:
+                    setTcpSrc((TransportPort) value);
+                    wildcards &= ~OFPFW_TP_SRC;
+                    break;
+                case VLAN_PCP:
+                    setVlanPcp((VlanPcp) value);
+                    wildcards &= ~OFPFW_DL_VLAN_PCP;
+                    break;
+                case VLAN_VID:
+                    setVlanVid((OFVlanVidMatch) value);
+                    wildcards &= ~OFPFW_DL_VLAN;
+                    break;
+                default:
+                    throw new UnsupportedOperationException(
+                            "OFMatch does not support matching on field " + field.getName());
+            }
+            return this;
+        }
+
+        @Override
+        public <F extends OFValueType<F>> Match.Builder setMasked(MatchField<F> field,
+                F value, F mask) {
+            initWildcards();
+            switch (field.id) {
+                case ARP_SPA:
+                case ARP_TPA:
+                case IPV4_DST:
+                case IPV4_SRC:
+                    Object valObj = value;
+                    Object masObj = mask;
+                    IPv4Address ip = ((IPv4Address)valObj);
+                    int maskval = ((IPv4Address)masObj).getInt();
+                    if (Integer.bitCount(~maskval + 1) != 1)
+                        throw new UnsupportedOperationException("OFMatch only supports CIDR masks for IPv4");
+                    int maskLen = 32 - Integer.bitCount(maskval);
+                    switch(field.id) {
+                        case ARP_TPA:
+                        case IPV4_DST:
+                            setIpv4Dst(ip);
+                            wildcards = (wildcards &~OFPFW_NW_DST_MASK) | (maskLen << OFPFW_NW_DST_SHIFT);
+                            break;
+                        case ARP_SPA:
+                        case IPV4_SRC:
+                            setIpv4Src(ip);
+                            wildcards = (wildcards &~OFPFW_NW_SRC_MASK) | (maskLen << OFPFW_NW_SRC_SHIFT);
+                            break;
+                        default:
+                            // Cannot really get here
+                            break;
+                    }
+                    break;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support masked matching on field " + field.getName());
+            }
+            return this;
+        }
+
+        @Override
+        public <F extends OFValueType<F>> Match.Builder setMasked(MatchField<F> field, Masked<F> valueWithMask)
+                                                                       throws UnsupportedOperationException {
+            return this.setMasked(field, valueWithMask.getValue(), valueWithMask.getMask());
+        }
+
+        @Override
+        public <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+            initWildcards();
+            switch (field.id) {
+                case ETH_DST:
+                    setEthDst(MacAddress.NONE);
+                    wildcards |= OFPFW_DL_DST;
+                    break;
+                case ETH_SRC:
+                    setEthSrc(MacAddress.NONE);
+                    wildcards |= OFPFW_DL_SRC;
+                    break;
+                case ETH_TYPE:
+                    setEthType(EthType.NONE);
+                    wildcards |= OFPFW_DL_TYPE;
+                    break;
+                case ICMPV4_CODE:
+                case TCP_DST:
+                case UDP_DST:
+                case SCTP_DST:
+                    setTcpDst(TransportPort.NONE);
+                    wildcards |= OFPFW_TP_DST;
+                    break;
+                case ICMPV4_TYPE:
+                case TCP_SRC:
+                case UDP_SRC:
+                case SCTP_SRC:
+                    setTcpSrc(TransportPort.NONE);
+                    wildcards |= OFPFW_TP_SRC;
+                    break;
+                case IN_PORT:
+                    setInPort(OFPort.of(0)); // NOTE: not 'NONE' -- that is 0xFF for ports
+                    wildcards |= OFPFW_IN_PORT;
+                    break;
+                case ARP_TPA:
+                case IPV4_DST:
+                    setIpv4Dst(IPv4Address.NONE);
+                    wildcards |= OFPFW_NW_DST_MASK;
+                    break;
+                case ARP_SPA:
+                case IPV4_SRC:
+                    setIpv4Src(IPv4Address.NONE);
+                    wildcards |= OFPFW_NW_SRC_MASK;
+                    break;
+                case IP_DSCP:
+                    setIpDscp(IpDscp.NONE);
+                    wildcards |= OFPFW_NW_TOS;
+                    break;
+                case IP_PROTO:
+                    setIpProto(IpProtocol.NONE);
+                    wildcards |= OFPFW_NW_PROTO;
+                    break;
+                case VLAN_PCP:
+                    setVlanPcp(VlanPcp.NONE);
+                    wildcards |= OFPFW_DL_VLAN_PCP;
+                    break;
+                case VLAN_VID:
+                    setVlanVid(OFVlanVidMatch.NONE);
+                    wildcards |= OFPFW_DL_VLAN;
+                    break;
+                default:
+                    throw new UnsupportedOperationException("OFMatch does not support matching on field " + field.getName());
+            }
+            return this;
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMatchV1> {
+        @Override
+        public OFMatchV1 readFrom(ChannelBuffer bb) throws OFParseError {
+            int wildcards = bb.readInt();
+            OFPort inPort = OFPort.read2Bytes(bb);
+            MacAddress ethSrc = MacAddress.read6Bytes(bb);
+            MacAddress ethDst = MacAddress.read6Bytes(bb);
+            OFVlanVidMatch vlanVid = OFVlanVidMatch.read2BytesOF10(bb);
+            VlanPcp vlanPcp = VlanPcp.readByte(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            EthType ethType = EthType.read2Bytes(bb);
+            IpDscp ipDscp = IpDscp.readByte(bb);
+            IpProtocol ipProto = IpProtocol.readByte(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            IPv4Address ipv4Src = IPv4Address.read4Bytes(bb);
+            IPv4Address ipv4Dst = IPv4Address.read4Bytes(bb);
+            TransportPort tcpSrc = TransportPort.read2Bytes(bb);
+            TransportPort tcpDst = TransportPort.read2Bytes(bb);
+
+            // normalize match fields according to current OpenVSwitch behavior. When prerequisites for a field are not met
+            // e.g., eth_type is not set to 0x800, OVS sets the value of corresponding ignored fields (e.g.,
+            // ip_src, tcp_dst) to 0, and sets the wildcard bit to 1.
+            if(ethType.equals(EthType.IPv4)) {
+                // IP
+                if(ipProto.equals(IpProtocol.TCP) || ipProto.equals(IpProtocol.UDP) || ipProto.equals(IpProtocol.ICMP)) {
+                    // fully speced, wildcards and all values are fine
+                    // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                        wildcards |= OFPFW_NW_SRC_MASK;
+
+                    // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                        wildcards |= OFPFW_NW_DST_MASK;
+
+                } else {
+                    // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                        wildcards |= OFPFW_NW_SRC_MASK;
+
+                    // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                    if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                        wildcards |= OFPFW_NW_DST_MASK;
+
+                    // not TCP/UDP/ICMP -> Clear TP wildcards for the wire
+                    wildcards |= (OFPFW_TP_SRC | OFPFW_TP_DST);
+                    tcpSrc = TransportPort.NONE;
+                    tcpDst = TransportPort.NONE;
+                }
+            } else if (ethType.equals(EthType.ARP)) {
+                // normalize 32-63 ipv4 src 'mask' to a full bitmask
+                if((wildcards & OFPFW_NW_SRC_ALL) != 0)
+                    wildcards |= OFPFW_NW_SRC_MASK;
+
+                // normalize 32-63 ipv4 dst 'mask' to a full bitmask
+                if((wildcards & OFPFW_NW_DST_ALL) != 0)
+                    wildcards |= OFPFW_NW_DST_MASK;
+
+                // ARP: clear NW_TOS / TP wildcards for the wire
+                wildcards |= ( OFPFW_NW_TOS | OFPFW_TP_SRC | OFPFW_TP_DST);
+                ipDscp = IpDscp.NONE;
+                tcpSrc = TransportPort.NONE;
+                tcpDst = TransportPort.NONE;
+            } else {
+                // not even IP. Clear NW/TP wildcards for the wire
+                wildcards |= ( OFPFW_NW_TOS | OFPFW_NW_PROTO | OFPFW_NW_SRC_MASK | OFPFW_NW_DST_MASK | OFPFW_TP_SRC | OFPFW_TP_DST);
+                ipDscp = IpDscp.NONE;
+                ipProto = IpProtocol.NONE;
+                ipv4Src = IPv4Address.NONE;
+                ipv4Dst = IPv4Address.NONE;
+                tcpSrc = TransportPort.NONE;
+                tcpDst = TransportPort.NONE;
+            }
+            OFMatchV1Ver10 matchV1Ver10 = new OFMatchV1Ver10(
+                    wildcards,
+                      inPort,
+                      ethSrc,
+                      ethDst,
+                      vlanVid,
+                      vlanPcp,
+                      ethType,
+                      ipDscp,
+                      ipProto,
+                      ipv4Src,
+                      ipv4Dst,
+                      tcpSrc,
+                      tcpDst
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", matchV1Ver10);
+            return matchV1Ver10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMatchV1Ver10Funnel FUNNEL = new OFMatchV1Ver10Funnel();
+    static class OFMatchV1Ver10Funnel implements Funnel<OFMatchV1Ver10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMatchV1Ver10 message, PrimitiveSink sink) {
+            sink.putInt(message.wildcards);
+            message.inPort.putTo(sink);
+            message.ethSrc.putTo(sink);
+            message.ethDst.putTo(sink);
+            message.vlanVid.putTo(sink);
+            message.vlanPcp.putTo(sink);
+            // skip pad (1 bytes)
+            message.ethType.putTo(sink);
+            message.ipDscp.putTo(sink);
+            message.ipProto.putTo(sink);
+            // skip pad (2 bytes)
+            message.ipv4Src.putTo(sink);
+            message.ipv4Dst.putTo(sink);
+            message.tcpSrc.putTo(sink);
+            message.tcpDst.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMatchV1Ver10> {
+        @Override
+        public void write(ChannelBuffer bb, OFMatchV1Ver10 message) {
+            bb.writeInt(message.wildcards);
+            message.inPort.write2Bytes(bb);
+            message.ethSrc.write6Bytes(bb);
+            message.ethDst.write6Bytes(bb);
+            message.vlanVid.write2BytesOF10(bb);
+            message.vlanPcp.writeByte(bb);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.ethType.write2Bytes(bb);
+            message.ipDscp.writeByte(bb);
+            message.ipProto.writeByte(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.ipv4Src.write4Bytes(bb);
+            message.ipv4Dst.write4Bytes(bb);
+            message.tcpSrc.write2Bytes(bb);
+            message.tcpDst.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMatchV1Ver10(");
+        boolean first = true;
+        for(MatchField<?> field : getMatchFields()) {
+            if(first)
+                first = false;
+            else
+                b.append(", ");
+            String name = field.getName();
+            b.append(name).append('=').append(this.get(field));
+            if(isPartiallyMasked(field)) {
+                b.append('/').append(this.getMasked(field).getMask());
+            }
+        }
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMatchV1Ver10 other = (OFMatchV1Ver10) obj;
+
+        if( wildcards != other.wildcards)
+            return false;
+        if (inPort == null) {
+            if (other.inPort != null)
+                return false;
+        } else if (!inPort.equals(other.inPort))
+            return false;
+        if (ethSrc == null) {
+            if (other.ethSrc != null)
+                return false;
+        } else if (!ethSrc.equals(other.ethSrc))
+            return false;
+        if (ethDst == null) {
+            if (other.ethDst != null)
+                return false;
+        } else if (!ethDst.equals(other.ethDst))
+            return false;
+        if (vlanVid == null) {
+            if (other.vlanVid != null)
+                return false;
+        } else if (!vlanVid.equals(other.vlanVid))
+            return false;
+        if (vlanPcp == null) {
+            if (other.vlanPcp != null)
+                return false;
+        } else if (!vlanPcp.equals(other.vlanPcp))
+            return false;
+        if (ethType == null) {
+            if (other.ethType != null)
+                return false;
+        } else if (!ethType.equals(other.ethType))
+            return false;
+        if (ipDscp == null) {
+            if (other.ipDscp != null)
+                return false;
+        } else if (!ipDscp.equals(other.ipDscp))
+            return false;
+        if (ipProto == null) {
+            if (other.ipProto != null)
+                return false;
+        } else if (!ipProto.equals(other.ipProto))
+            return false;
+        if (ipv4Src == null) {
+            if (other.ipv4Src != null)
+                return false;
+        } else if (!ipv4Src.equals(other.ipv4Src))
+            return false;
+        if (ipv4Dst == null) {
+            if (other.ipv4Dst != null)
+                return false;
+        } else if (!ipv4Dst.equals(other.ipv4Dst))
+            return false;
+        if (tcpSrc == null) {
+            if (other.tcpSrc != null)
+                return false;
+        } else if (!tcpSrc.equals(other.tcpSrc))
+            return false;
+        if (tcpDst == null) {
+            if (other.tcpDst != null)
+                return false;
+        } else if (!tcpDst.equals(other.tcpDst))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + wildcards;
+        result = prime * result + ((inPort == null) ? 0 : inPort.hashCode());
+        result = prime * result + ((ethSrc == null) ? 0 : ethSrc.hashCode());
+        result = prime * result + ((ethDst == null) ? 0 : ethDst.hashCode());
+        result = prime * result + ((vlanVid == null) ? 0 : vlanVid.hashCode());
+        result = prime * result + ((vlanPcp == null) ? 0 : vlanPcp.hashCode());
+        result = prime * result + ((ethType == null) ? 0 : ethType.hashCode());
+        result = prime * result + ((ipDscp == null) ? 0 : ipDscp.hashCode());
+        result = prime * result + ((ipProto == null) ? 0 : ipProto.hashCode());
+        result = prime * result + ((ipv4Src == null) ? 0 : ipv4Src.hashCode());
+        result = prime * result + ((ipv4Dst == null) ? 0 : ipv4Dst.hashCode());
+        result = prime * result + ((tcpSrc == null) ? 0 : tcpSrc.hashCode());
+        result = prime * result + ((tcpDst == null) ? 0 : tcpDst.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMessageVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMessageVer10.java
new file mode 100644
index 0000000..1c461df
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMessageVer10.java
@@ -0,0 +1,122 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFMessageVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFMessageVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFMessage> {
+        @Override
+        public OFMessage readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            byte type = bb.readByte();
+            bb.readerIndex(start);
+            switch(type) {
+               case (byte) 0x11:
+                   // discriminator value OFType.STATS_REPLY=17 for class OFStatsReplyVer10
+                   return OFStatsReplyVer10.READER.readFrom(bb);
+               case (byte) 0x10:
+                   // discriminator value OFType.STATS_REQUEST=16 for class OFStatsRequestVer10
+                   return OFStatsRequestVer10.READER.readFrom(bb);
+               case (byte) 0x1:
+                   // discriminator value OFType.ERROR=1 for class OFErrorMsgVer10
+                   return OFErrorMsgVer10.READER.readFrom(bb);
+               case (byte) 0x13:
+                   // discriminator value OFType.BARRIER_REPLY=19 for class OFBarrierReplyVer10
+                   return OFBarrierReplyVer10.READER.readFrom(bb);
+               case (byte) 0x12:
+                   // discriminator value OFType.BARRIER_REQUEST=18 for class OFBarrierRequestVer10
+                   return OFBarrierRequestVer10.READER.readFrom(bb);
+               case (byte) 0x4:
+                   // discriminator value OFType.EXPERIMENTER=4 for class OFExperimenterVer10
+                   return OFExperimenterVer10.READER.readFrom(bb);
+               case (byte) 0x3:
+                   // discriminator value OFType.ECHO_REPLY=3 for class OFEchoReplyVer10
+                   return OFEchoReplyVer10.READER.readFrom(bb);
+               case (byte) 0x2:
+                   // discriminator value OFType.ECHO_REQUEST=2 for class OFEchoRequestVer10
+                   return OFEchoRequestVer10.READER.readFrom(bb);
+               case (byte) 0x6:
+                   // discriminator value OFType.FEATURES_REPLY=6 for class OFFeaturesReplyVer10
+                   return OFFeaturesReplyVer10.READER.readFrom(bb);
+               case (byte) 0x5:
+                   // discriminator value OFType.FEATURES_REQUEST=5 for class OFFeaturesRequestVer10
+                   return OFFeaturesRequestVer10.READER.readFrom(bb);
+               case (byte) 0xe:
+                   // discriminator value OFType.FLOW_MOD=14 for class OFFlowModVer10
+                   return OFFlowModVer10.READER.readFrom(bb);
+               case (byte) 0xb:
+                   // discriminator value OFType.FLOW_REMOVED=11 for class OFFlowRemovedVer10
+                   return OFFlowRemovedVer10.READER.readFrom(bb);
+               case (byte) 0x8:
+                   // discriminator value OFType.GET_CONFIG_REPLY=8 for class OFGetConfigReplyVer10
+                   return OFGetConfigReplyVer10.READER.readFrom(bb);
+               case (byte) 0x7:
+                   // discriminator value OFType.GET_CONFIG_REQUEST=7 for class OFGetConfigRequestVer10
+                   return OFGetConfigRequestVer10.READER.readFrom(bb);
+               case (byte) 0x0:
+                   // discriminator value OFType.HELLO=0 for class OFHelloVer10
+                   return OFHelloVer10.READER.readFrom(bb);
+               case (byte) 0xa:
+                   // discriminator value OFType.PACKET_IN=10 for class OFPacketInVer10
+                   return OFPacketInVer10.READER.readFrom(bb);
+               case (byte) 0xd:
+                   // discriminator value OFType.PACKET_OUT=13 for class OFPacketOutVer10
+                   return OFPacketOutVer10.READER.readFrom(bb);
+               case (byte) 0xf:
+                   // discriminator value OFType.PORT_MOD=15 for class OFPortModVer10
+                   return OFPortModVer10.READER.readFrom(bb);
+               case (byte) 0xc:
+                   // discriminator value OFType.PORT_STATUS=12 for class OFPortStatusVer10
+                   return OFPortStatusVer10.READER.readFrom(bb);
+               case (byte) 0x15:
+                   // discriminator value OFType.QUEUE_GET_CONFIG_REPLY=21 for class OFQueueGetConfigReplyVer10
+                   return OFQueueGetConfigReplyVer10.READER.readFrom(bb);
+               case (byte) 0x14:
+                   // discriminator value OFType.QUEUE_GET_CONFIG_REQUEST=20 for class OFQueueGetConfigRequestVer10
+                   return OFQueueGetConfigRequestVer10.READER.readFrom(bb);
+               case (byte) 0x9:
+                   // discriminator value OFType.SET_CONFIG=9 for class OFSetConfigVer10
+                   return OFSetConfigVer10.READER.readFrom(bb);
+               // skip OFTableModVer10 - excluded from generation
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFMessageVer10: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMeterBandsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMeterBandsVer10.java
new file mode 100644
index 0000000..35f9fc9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFMeterBandsVer10.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFMeterBandsVer10 implements OFMeterBands {
+    public final static OFMeterBandsVer10 INSTANCE = new OFMeterBandsVer10();
+
+
+
+
+    public OFMeterBandDrop.Builder buildDrop() {
+        throw new UnsupportedOperationException("OFMeterBandDrop not supported in version 1.0");
+    }
+    public OFMeterBandDrop drop(long rate, long burstSize) {
+        throw new UnsupportedOperationException("OFMeterBandDrop not supported in version 1.0");
+    }
+
+    public OFMeterBandDscpRemark.Builder buildDscpRemark() {
+        throw new UnsupportedOperationException("OFMeterBandDscpRemark not supported in version 1.0");
+    }
+
+    public OFMeterBandExperimenter.Builder buildExperimenter() {
+        throw new UnsupportedOperationException("OFMeterBandExperimenter not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFMeterBand> getReader() {
+        throw new UnsupportedOperationException("Reader<OFMeterBand> not supported in version 1.0");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleReplyVer10.java
new file mode 100644
index 0000000..20ea97e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleReplyVer10.java
@@ -0,0 +1,364 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFNiciraControllerRoleReplyVer10 implements OFNiciraControllerRoleReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFNiciraControllerRoleReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFNiciraControllerRole role;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFNiciraControllerRoleReplyVer10(long xid, OFNiciraControllerRole role) {
+        this.xid = xid;
+        this.role = role;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public OFNiciraControllerRole getRole() {
+        return role;
+    }
+
+
+
+    public OFNiciraControllerRoleReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFNiciraControllerRoleReply.Builder {
+        final OFNiciraControllerRoleReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFNiciraControllerRole role;
+
+        BuilderWithParent(OFNiciraControllerRoleReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFNiciraControllerRoleReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public OFNiciraControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFNiciraControllerRoleReply.Builder setRole(OFNiciraControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFNiciraControllerRoleReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFNiciraControllerRole role = this.roleSet ? this.role : parentMessage.role;
+                if(role == null)
+                    throw new NullPointerException("Property role must not be null");
+
+                //
+                return new OFNiciraControllerRoleReplyVer10(
+                    xid,
+                    role
+                );
+        }
+
+    }
+
+    static class Builder implements OFNiciraControllerRoleReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFNiciraControllerRole role;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFNiciraControllerRoleReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public OFNiciraControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFNiciraControllerRoleReply.Builder setRole(OFNiciraControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFNiciraControllerRoleReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.roleSet)
+                throw new IllegalStateException("Property role doesn't have default value -- must be set");
+            if(role == null)
+                throw new NullPointerException("Property role must not be null");
+
+
+            return new OFNiciraControllerRoleReplyVer10(
+                    xid,
+                    role
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFNiciraControllerRoleReply> {
+        @Override
+        public OFNiciraControllerRoleReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            // fixed value property subtype == 0xbL
+            int subtype = bb.readInt();
+            if(subtype != 0xb)
+                throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got="+subtype);
+            OFNiciraControllerRole role = OFNiciraControllerRoleSerializerVer10.readFrom(bb);
+
+            OFNiciraControllerRoleReplyVer10 niciraControllerRoleReplyVer10 = new OFNiciraControllerRoleReplyVer10(
+                    xid,
+                      role
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", niciraControllerRoleReplyVer10);
+            return niciraControllerRoleReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFNiciraControllerRoleReplyVer10Funnel FUNNEL = new OFNiciraControllerRoleReplyVer10Funnel();
+    static class OFNiciraControllerRoleReplyVer10Funnel implements Funnel<OFNiciraControllerRoleReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFNiciraControllerRoleReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x2320L
+            sink.putInt(0x2320);
+            // fixed value property subtype = 0xbL
+            sink.putInt(0xb);
+            OFNiciraControllerRoleSerializerVer10.putTo(message.role, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFNiciraControllerRoleReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFNiciraControllerRoleReplyVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x2320L
+            bb.writeInt(0x2320);
+            // fixed value property subtype = 0xbL
+            bb.writeInt(0xb);
+            OFNiciraControllerRoleSerializerVer10.writeTo(bb, message.role);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFNiciraControllerRoleReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("role=").append(role);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFNiciraControllerRoleReplyVer10 other = (OFNiciraControllerRoleReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (role == null) {
+            if (other.role != null)
+                return false;
+        } else if (!role.equals(other.role))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((role == null) ? 0 : role.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleRequestVer10.java
new file mode 100644
index 0000000..b05afe8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleRequestVer10.java
@@ -0,0 +1,364 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFNiciraControllerRoleRequestVer10 implements OFNiciraControllerRoleRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFNiciraControllerRoleRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFNiciraControllerRole role;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFNiciraControllerRoleRequestVer10(long xid, OFNiciraControllerRole role) {
+        this.xid = xid;
+        this.role = role;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public OFNiciraControllerRole getRole() {
+        return role;
+    }
+
+
+
+    public OFNiciraControllerRoleRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFNiciraControllerRoleRequest.Builder {
+        final OFNiciraControllerRoleRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFNiciraControllerRole role;
+
+        BuilderWithParent(OFNiciraControllerRoleRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFNiciraControllerRoleRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public OFNiciraControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFNiciraControllerRoleRequest.Builder setRole(OFNiciraControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFNiciraControllerRoleRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFNiciraControllerRole role = this.roleSet ? this.role : parentMessage.role;
+                if(role == null)
+                    throw new NullPointerException("Property role must not be null");
+
+                //
+                return new OFNiciraControllerRoleRequestVer10(
+                    xid,
+                    role
+                );
+        }
+
+    }
+
+    static class Builder implements OFNiciraControllerRoleRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFNiciraControllerRole role;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFNiciraControllerRoleRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public OFNiciraControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFNiciraControllerRoleRequest.Builder setRole(OFNiciraControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFNiciraControllerRoleRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.roleSet)
+                throw new IllegalStateException("Property role doesn't have default value -- must be set");
+            if(role == null)
+                throw new NullPointerException("Property role must not be null");
+
+
+            return new OFNiciraControllerRoleRequestVer10(
+                    xid,
+                    role
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFNiciraControllerRoleRequest> {
+        @Override
+        public OFNiciraControllerRoleRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            // fixed value property subtype == 0xaL
+            int subtype = bb.readInt();
+            if(subtype != 0xa)
+                throw new OFParseError("Wrong subtype: Expected=0xaL(0xaL), got="+subtype);
+            OFNiciraControllerRole role = OFNiciraControllerRoleSerializerVer10.readFrom(bb);
+
+            OFNiciraControllerRoleRequestVer10 niciraControllerRoleRequestVer10 = new OFNiciraControllerRoleRequestVer10(
+                    xid,
+                      role
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", niciraControllerRoleRequestVer10);
+            return niciraControllerRoleRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFNiciraControllerRoleRequestVer10Funnel FUNNEL = new OFNiciraControllerRoleRequestVer10Funnel();
+    static class OFNiciraControllerRoleRequestVer10Funnel implements Funnel<OFNiciraControllerRoleRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFNiciraControllerRoleRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x2320L
+            sink.putInt(0x2320);
+            // fixed value property subtype = 0xaL
+            sink.putInt(0xa);
+            OFNiciraControllerRoleSerializerVer10.putTo(message.role, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFNiciraControllerRoleRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFNiciraControllerRoleRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x2320L
+            bb.writeInt(0x2320);
+            // fixed value property subtype = 0xaL
+            bb.writeInt(0xa);
+            OFNiciraControllerRoleSerializerVer10.writeTo(bb, message.role);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFNiciraControllerRoleRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("role=").append(role);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFNiciraControllerRoleRequestVer10 other = (OFNiciraControllerRoleRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (role == null) {
+            if (other.role != null)
+                return false;
+        } else if (!role.equals(other.role))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((role == null) ? 0 : role.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleSerializerVer10.java
new file mode 100644
index 0000000..f318a48
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraControllerRoleSerializerVer10.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFNiciraControllerRole;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFNiciraControllerRoleSerializerVer10 {
+
+    public final static int ROLE_OTHER_VAL = 0x0;
+    public final static int ROLE_MASTER_VAL = 0x1;
+    public final static int ROLE_SLAVE_VAL = 0x2;
+
+    public static OFNiciraControllerRole readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFNiciraControllerRole e) {
+        bb.writeInt(toWireValue(e));
+    }
+
+    public static void putTo(OFNiciraControllerRole e, PrimitiveSink sink) {
+        sink.putInt(toWireValue(e));
+    }
+
+    public static OFNiciraControllerRole ofWireValue(int val) {
+        switch(val) {
+            case ROLE_OTHER_VAL:
+                return OFNiciraControllerRole.ROLE_OTHER;
+            case ROLE_MASTER_VAL:
+                return OFNiciraControllerRole.ROLE_MASTER;
+            case ROLE_SLAVE_VAL:
+                return OFNiciraControllerRole.ROLE_SLAVE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFNiciraControllerRole in version 1.0: " + val);
+        }
+    }
+
+
+    public static int toWireValue(OFNiciraControllerRole e) {
+        switch(e) {
+            case ROLE_OTHER:
+                return ROLE_OTHER_VAL;
+            case ROLE_MASTER:
+                return ROLE_MASTER_VAL;
+            case ROLE_SLAVE:
+                return ROLE_SLAVE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFNiciraControllerRole in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraHeaderVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraHeaderVer10.java
new file mode 100644
index 0000000..a23d3c3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFNiciraHeaderVer10.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFNiciraHeaderVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFNiciraHeaderVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFNiciraHeader> {
+        @Override
+        public OFNiciraHeader readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0xb:
+                   // discriminator value 0xbL=0xbL for class OFNiciraControllerRoleReplyVer10
+                   return OFNiciraControllerRoleReplyVer10.READER.readFrom(bb);
+               case 0xa:
+                   // discriminator value 0xaL=0xaL for class OFNiciraControllerRoleRequestVer10
+                   return OFNiciraControllerRoleRequestVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFNiciraHeaderVer10: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFOxmsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFOxmsVer10.java
new file mode 100644
index 0000000..a53c7a3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFOxmsVer10.java
@@ -0,0 +1,1165 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFOxmsVer10 implements OFOxms {
+    public final static OFOxmsVer10 INSTANCE = new OFOxmsVer10();
+
+
+
+
+    public OFOxmArpOp.Builder buildArpOp() {
+        throw new UnsupportedOperationException("OFOxmArpOp not supported in version 1.0");
+    }
+    public OFOxmArpOp arpOp(ArpOpcode value) {
+        throw new UnsupportedOperationException("OFOxmArpOp not supported in version 1.0");
+    }
+
+    public OFOxmArpOpMasked.Builder buildArpOpMasked() {
+        throw new UnsupportedOperationException("OFOxmArpOpMasked not supported in version 1.0");
+    }
+    public OFOxmArpOpMasked arpOpMasked(ArpOpcode value, ArpOpcode mask) {
+        throw new UnsupportedOperationException("OFOxmArpOpMasked not supported in version 1.0");
+    }
+
+    public OFOxmArpSha.Builder buildArpSha() {
+        throw new UnsupportedOperationException("OFOxmArpSha not supported in version 1.0");
+    }
+    public OFOxmArpSha arpSha(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmArpSha not supported in version 1.0");
+    }
+
+    public OFOxmArpShaMasked.Builder buildArpShaMasked() {
+        throw new UnsupportedOperationException("OFOxmArpShaMasked not supported in version 1.0");
+    }
+    public OFOxmArpShaMasked arpShaMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmArpShaMasked not supported in version 1.0");
+    }
+
+    public OFOxmArpSpa.Builder buildArpSpa() {
+        throw new UnsupportedOperationException("OFOxmArpSpa not supported in version 1.0");
+    }
+    public OFOxmArpSpa arpSpa(IPv4Address value) {
+        throw new UnsupportedOperationException("OFOxmArpSpa not supported in version 1.0");
+    }
+
+    public OFOxmArpSpaMasked.Builder buildArpSpaMasked() {
+        throw new UnsupportedOperationException("OFOxmArpSpaMasked not supported in version 1.0");
+    }
+    public OFOxmArpSpaMasked arpSpaMasked(IPv4Address value, IPv4Address mask) {
+        throw new UnsupportedOperationException("OFOxmArpSpaMasked not supported in version 1.0");
+    }
+
+    public OFOxmArpTha.Builder buildArpTha() {
+        throw new UnsupportedOperationException("OFOxmArpTha not supported in version 1.0");
+    }
+    public OFOxmArpTha arpTha(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmArpTha not supported in version 1.0");
+    }
+
+    public OFOxmArpThaMasked.Builder buildArpThaMasked() {
+        throw new UnsupportedOperationException("OFOxmArpThaMasked not supported in version 1.0");
+    }
+    public OFOxmArpThaMasked arpThaMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmArpThaMasked not supported in version 1.0");
+    }
+
+    public OFOxmArpTpa.Builder buildArpTpa() {
+        throw new UnsupportedOperationException("OFOxmArpTpa not supported in version 1.0");
+    }
+    public OFOxmArpTpa arpTpa(IPv4Address value) {
+        throw new UnsupportedOperationException("OFOxmArpTpa not supported in version 1.0");
+    }
+
+    public OFOxmArpTpaMasked.Builder buildArpTpaMasked() {
+        throw new UnsupportedOperationException("OFOxmArpTpaMasked not supported in version 1.0");
+    }
+    public OFOxmArpTpaMasked arpTpaMasked(IPv4Address value, IPv4Address mask) {
+        throw new UnsupportedOperationException("OFOxmArpTpaMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnEgrPortGroupId.Builder buildBsnEgrPortGroupId() {
+        throw new UnsupportedOperationException("OFOxmBsnEgrPortGroupId not supported in version 1.0");
+    }
+    public OFOxmBsnEgrPortGroupId bsnEgrPortGroupId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnEgrPortGroupId not supported in version 1.0");
+    }
+
+    public OFOxmBsnEgrPortGroupIdMasked.Builder buildBsnEgrPortGroupIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnEgrPortGroupIdMasked not supported in version 1.0");
+    }
+    public OFOxmBsnEgrPortGroupIdMasked bsnEgrPortGroupIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnEgrPortGroupIdMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnGlobalVrfAllowed.Builder buildBsnGlobalVrfAllowed() {
+        throw new UnsupportedOperationException("OFOxmBsnGlobalVrfAllowed not supported in version 1.0");
+    }
+    public OFOxmBsnGlobalVrfAllowed bsnGlobalVrfAllowed(OFBooleanValue value) {
+        throw new UnsupportedOperationException("OFOxmBsnGlobalVrfAllowed not supported in version 1.0");
+    }
+
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder buildBsnGlobalVrfAllowedMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnGlobalVrfAllowedMasked not supported in version 1.0");
+    }
+    public OFOxmBsnGlobalVrfAllowedMasked bsnGlobalVrfAllowedMasked(OFBooleanValue value, OFBooleanValue mask) {
+        throw new UnsupportedOperationException("OFOxmBsnGlobalVrfAllowedMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnInPorts128.Builder buildBsnInPorts128() {
+        throw new UnsupportedOperationException("OFOxmBsnInPorts128 not supported in version 1.0");
+    }
+    public OFOxmBsnInPorts128 bsnInPorts128(OFBitMask128 value) {
+        throw new UnsupportedOperationException("OFOxmBsnInPorts128 not supported in version 1.0");
+    }
+
+    public OFOxmBsnInPorts128Masked.Builder buildBsnInPorts128Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnInPorts128Masked not supported in version 1.0");
+    }
+    public OFOxmBsnInPorts128Masked bsnInPorts128Masked(OFBitMask128 value, OFBitMask128 mask) {
+        throw new UnsupportedOperationException("OFOxmBsnInPorts128Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnL3DstClassId.Builder buildBsnL3DstClassId() {
+        throw new UnsupportedOperationException("OFOxmBsnL3DstClassId not supported in version 1.0");
+    }
+    public OFOxmBsnL3DstClassId bsnL3DstClassId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnL3DstClassId not supported in version 1.0");
+    }
+
+    public OFOxmBsnL3DstClassIdMasked.Builder buildBsnL3DstClassIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnL3DstClassIdMasked not supported in version 1.0");
+    }
+    public OFOxmBsnL3DstClassIdMasked bsnL3DstClassIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnL3DstClassIdMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnL3InterfaceClassId.Builder buildBsnL3InterfaceClassId() {
+        throw new UnsupportedOperationException("OFOxmBsnL3InterfaceClassId not supported in version 1.0");
+    }
+    public OFOxmBsnL3InterfaceClassId bsnL3InterfaceClassId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnL3InterfaceClassId not supported in version 1.0");
+    }
+
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder buildBsnL3InterfaceClassIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnL3InterfaceClassIdMasked not supported in version 1.0");
+    }
+    public OFOxmBsnL3InterfaceClassIdMasked bsnL3InterfaceClassIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnL3InterfaceClassIdMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnL3SrcClassId.Builder buildBsnL3SrcClassId() {
+        throw new UnsupportedOperationException("OFOxmBsnL3SrcClassId not supported in version 1.0");
+    }
+    public OFOxmBsnL3SrcClassId bsnL3SrcClassId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnL3SrcClassId not supported in version 1.0");
+    }
+
+    public OFOxmBsnL3SrcClassIdMasked.Builder buildBsnL3SrcClassIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnL3SrcClassIdMasked not supported in version 1.0");
+    }
+    public OFOxmBsnL3SrcClassIdMasked bsnL3SrcClassIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnL3SrcClassIdMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnLagId.Builder buildBsnLagId() {
+        throw new UnsupportedOperationException("OFOxmBsnLagId not supported in version 1.0");
+    }
+    public OFOxmBsnLagId bsnLagId(LagId value) {
+        throw new UnsupportedOperationException("OFOxmBsnLagId not supported in version 1.0");
+    }
+
+    public OFOxmBsnLagIdMasked.Builder buildBsnLagIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnLagIdMasked not supported in version 1.0");
+    }
+    public OFOxmBsnLagIdMasked bsnLagIdMasked(LagId value, LagId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnLagIdMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnTcpFlags.Builder buildBsnTcpFlags() {
+        throw new UnsupportedOperationException("OFOxmBsnTcpFlags not supported in version 1.0");
+    }
+    public OFOxmBsnTcpFlags bsnTcpFlags(U16 value) {
+        throw new UnsupportedOperationException("OFOxmBsnTcpFlags not supported in version 1.0");
+    }
+
+    public OFOxmBsnTcpFlagsMasked.Builder buildBsnTcpFlagsMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnTcpFlagsMasked not supported in version 1.0");
+    }
+    public OFOxmBsnTcpFlagsMasked bsnTcpFlagsMasked(U16 value, U16 mask) {
+        throw new UnsupportedOperationException("OFOxmBsnTcpFlagsMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf0.Builder buildBsnUdf0() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf0 not supported in version 1.0");
+    }
+    public OFOxmBsnUdf0 bsnUdf0(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf0 not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf0Masked.Builder buildBsnUdf0Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf0Masked not supported in version 1.0");
+    }
+    public OFOxmBsnUdf0Masked bsnUdf0Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf0Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf1.Builder buildBsnUdf1() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf1 not supported in version 1.0");
+    }
+    public OFOxmBsnUdf1 bsnUdf1(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf1 not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf1Masked.Builder buildBsnUdf1Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf1Masked not supported in version 1.0");
+    }
+    public OFOxmBsnUdf1Masked bsnUdf1Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf1Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf2.Builder buildBsnUdf2() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf2 not supported in version 1.0");
+    }
+    public OFOxmBsnUdf2 bsnUdf2(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf2 not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf2Masked.Builder buildBsnUdf2Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf2Masked not supported in version 1.0");
+    }
+    public OFOxmBsnUdf2Masked bsnUdf2Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf2Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf3.Builder buildBsnUdf3() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf3 not supported in version 1.0");
+    }
+    public OFOxmBsnUdf3 bsnUdf3(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf3 not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf3Masked.Builder buildBsnUdf3Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf3Masked not supported in version 1.0");
+    }
+    public OFOxmBsnUdf3Masked bsnUdf3Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf3Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf4.Builder buildBsnUdf4() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf4 not supported in version 1.0");
+    }
+    public OFOxmBsnUdf4 bsnUdf4(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf4 not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf4Masked.Builder buildBsnUdf4Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf4Masked not supported in version 1.0");
+    }
+    public OFOxmBsnUdf4Masked bsnUdf4Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf4Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf5.Builder buildBsnUdf5() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf5 not supported in version 1.0");
+    }
+    public OFOxmBsnUdf5 bsnUdf5(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf5 not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf5Masked.Builder buildBsnUdf5Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf5Masked not supported in version 1.0");
+    }
+    public OFOxmBsnUdf5Masked bsnUdf5Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf5Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf6.Builder buildBsnUdf6() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf6 not supported in version 1.0");
+    }
+    public OFOxmBsnUdf6 bsnUdf6(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf6 not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf6Masked.Builder buildBsnUdf6Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf6Masked not supported in version 1.0");
+    }
+    public OFOxmBsnUdf6Masked bsnUdf6Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf6Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf7.Builder buildBsnUdf7() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf7 not supported in version 1.0");
+    }
+    public OFOxmBsnUdf7 bsnUdf7(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf7 not supported in version 1.0");
+    }
+
+    public OFOxmBsnUdf7Masked.Builder buildBsnUdf7Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf7Masked not supported in version 1.0");
+    }
+    public OFOxmBsnUdf7Masked bsnUdf7Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf7Masked not supported in version 1.0");
+    }
+
+    public OFOxmBsnVlanXlatePortGroupId.Builder buildBsnVlanXlatePortGroupId() {
+        throw new UnsupportedOperationException("OFOxmBsnVlanXlatePortGroupId not supported in version 1.0");
+    }
+    public OFOxmBsnVlanXlatePortGroupId bsnVlanXlatePortGroupId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnVlanXlatePortGroupId not supported in version 1.0");
+    }
+
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder buildBsnVlanXlatePortGroupIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnVlanXlatePortGroupIdMasked not supported in version 1.0");
+    }
+    public OFOxmBsnVlanXlatePortGroupIdMasked bsnVlanXlatePortGroupIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnVlanXlatePortGroupIdMasked not supported in version 1.0");
+    }
+
+    public OFOxmBsnVrf.Builder buildBsnVrf() {
+        throw new UnsupportedOperationException("OFOxmBsnVrf not supported in version 1.0");
+    }
+    public OFOxmBsnVrf bsnVrf(VRF value) {
+        throw new UnsupportedOperationException("OFOxmBsnVrf not supported in version 1.0");
+    }
+
+    public OFOxmBsnVrfMasked.Builder buildBsnVrfMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnVrfMasked not supported in version 1.0");
+    }
+    public OFOxmBsnVrfMasked bsnVrfMasked(VRF value, VRF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnVrfMasked not supported in version 1.0");
+    }
+
+    public OFOxmEthDst.Builder buildEthDst() {
+        throw new UnsupportedOperationException("OFOxmEthDst not supported in version 1.0");
+    }
+    public OFOxmEthDst ethDst(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmEthDst not supported in version 1.0");
+    }
+
+    public OFOxmEthDstMasked.Builder buildEthDstMasked() {
+        throw new UnsupportedOperationException("OFOxmEthDstMasked not supported in version 1.0");
+    }
+    public OFOxmEthDstMasked ethDstMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmEthDstMasked not supported in version 1.0");
+    }
+
+    public OFOxmEthSrc.Builder buildEthSrc() {
+        throw new UnsupportedOperationException("OFOxmEthSrc not supported in version 1.0");
+    }
+    public OFOxmEthSrc ethSrc(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmEthSrc not supported in version 1.0");
+    }
+
+    public OFOxmEthSrcMasked.Builder buildEthSrcMasked() {
+        throw new UnsupportedOperationException("OFOxmEthSrcMasked not supported in version 1.0");
+    }
+    public OFOxmEthSrcMasked ethSrcMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmEthSrcMasked not supported in version 1.0");
+    }
+
+    public OFOxmEthType.Builder buildEthType() {
+        throw new UnsupportedOperationException("OFOxmEthType not supported in version 1.0");
+    }
+    public OFOxmEthType ethType(EthType value) {
+        throw new UnsupportedOperationException("OFOxmEthType not supported in version 1.0");
+    }
+
+    public OFOxmEthTypeMasked.Builder buildEthTypeMasked() {
+        throw new UnsupportedOperationException("OFOxmEthTypeMasked not supported in version 1.0");
+    }
+    public OFOxmEthTypeMasked ethTypeMasked(EthType value, EthType mask) {
+        throw new UnsupportedOperationException("OFOxmEthTypeMasked not supported in version 1.0");
+    }
+
+    public OFOxmIcmpv4Code.Builder buildIcmpv4Code() {
+        throw new UnsupportedOperationException("OFOxmIcmpv4Code not supported in version 1.0");
+    }
+    public OFOxmIcmpv4Code icmpv4Code(ICMPv4Code value) {
+        throw new UnsupportedOperationException("OFOxmIcmpv4Code not supported in version 1.0");
+    }
+
+    public OFOxmIcmpv4CodeMasked.Builder buildIcmpv4CodeMasked() {
+        throw new UnsupportedOperationException("OFOxmIcmpv4CodeMasked not supported in version 1.0");
+    }
+    public OFOxmIcmpv4CodeMasked icmpv4CodeMasked(ICMPv4Code value, ICMPv4Code mask) {
+        throw new UnsupportedOperationException("OFOxmIcmpv4CodeMasked not supported in version 1.0");
+    }
+
+    public OFOxmIcmpv4Type.Builder buildIcmpv4Type() {
+        throw new UnsupportedOperationException("OFOxmIcmpv4Type not supported in version 1.0");
+    }
+    public OFOxmIcmpv4Type icmpv4Type(ICMPv4Type value) {
+        throw new UnsupportedOperationException("OFOxmIcmpv4Type not supported in version 1.0");
+    }
+
+    public OFOxmIcmpv4TypeMasked.Builder buildIcmpv4TypeMasked() {
+        throw new UnsupportedOperationException("OFOxmIcmpv4TypeMasked not supported in version 1.0");
+    }
+    public OFOxmIcmpv4TypeMasked icmpv4TypeMasked(ICMPv4Type value, ICMPv4Type mask) {
+        throw new UnsupportedOperationException("OFOxmIcmpv4TypeMasked not supported in version 1.0");
+    }
+
+    public OFOxmIcmpv6Code.Builder buildIcmpv6Code() {
+        throw new UnsupportedOperationException("OFOxmIcmpv6Code not supported in version 1.0");
+    }
+    public OFOxmIcmpv6Code icmpv6Code(U8 value) {
+        throw new UnsupportedOperationException("OFOxmIcmpv6Code not supported in version 1.0");
+    }
+
+    public OFOxmIcmpv6CodeMasked.Builder buildIcmpv6CodeMasked() {
+        throw new UnsupportedOperationException("OFOxmIcmpv6CodeMasked not supported in version 1.0");
+    }
+    public OFOxmIcmpv6CodeMasked icmpv6CodeMasked(U8 value, U8 mask) {
+        throw new UnsupportedOperationException("OFOxmIcmpv6CodeMasked not supported in version 1.0");
+    }
+
+    public OFOxmIcmpv6Type.Builder buildIcmpv6Type() {
+        throw new UnsupportedOperationException("OFOxmIcmpv6Type not supported in version 1.0");
+    }
+    public OFOxmIcmpv6Type icmpv6Type(U8 value) {
+        throw new UnsupportedOperationException("OFOxmIcmpv6Type not supported in version 1.0");
+    }
+
+    public OFOxmIcmpv6TypeMasked.Builder buildIcmpv6TypeMasked() {
+        throw new UnsupportedOperationException("OFOxmIcmpv6TypeMasked not supported in version 1.0");
+    }
+    public OFOxmIcmpv6TypeMasked icmpv6TypeMasked(U8 value, U8 mask) {
+        throw new UnsupportedOperationException("OFOxmIcmpv6TypeMasked not supported in version 1.0");
+    }
+
+    public OFOxmInPhyPort.Builder buildInPhyPort() {
+        throw new UnsupportedOperationException("OFOxmInPhyPort not supported in version 1.0");
+    }
+    public OFOxmInPhyPort inPhyPort(OFPort value) {
+        throw new UnsupportedOperationException("OFOxmInPhyPort not supported in version 1.0");
+    }
+
+    public OFOxmInPhyPortMasked.Builder buildInPhyPortMasked() {
+        throw new UnsupportedOperationException("OFOxmInPhyPortMasked not supported in version 1.0");
+    }
+    public OFOxmInPhyPortMasked inPhyPortMasked(OFPort value, OFPort mask) {
+        throw new UnsupportedOperationException("OFOxmInPhyPortMasked not supported in version 1.0");
+    }
+
+    public OFOxmInPort.Builder buildInPort() {
+        throw new UnsupportedOperationException("OFOxmInPort not supported in version 1.0");
+    }
+    public OFOxmInPort inPort(OFPort value) {
+        throw new UnsupportedOperationException("OFOxmInPort not supported in version 1.0");
+    }
+
+    public OFOxmInPortMasked.Builder buildInPortMasked() {
+        throw new UnsupportedOperationException("OFOxmInPortMasked not supported in version 1.0");
+    }
+    public OFOxmInPortMasked inPortMasked(OFPort value, OFPort mask) {
+        throw new UnsupportedOperationException("OFOxmInPortMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpDscp.Builder buildIpDscp() {
+        throw new UnsupportedOperationException("OFOxmIpDscp not supported in version 1.0");
+    }
+    public OFOxmIpDscp ipDscp(IpDscp value) {
+        throw new UnsupportedOperationException("OFOxmIpDscp not supported in version 1.0");
+    }
+
+    public OFOxmIpDscpMasked.Builder buildIpDscpMasked() {
+        throw new UnsupportedOperationException("OFOxmIpDscpMasked not supported in version 1.0");
+    }
+    public OFOxmIpDscpMasked ipDscpMasked(IpDscp value, IpDscp mask) {
+        throw new UnsupportedOperationException("OFOxmIpDscpMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpEcn.Builder buildIpEcn() {
+        throw new UnsupportedOperationException("OFOxmIpEcn not supported in version 1.0");
+    }
+    public OFOxmIpEcn ipEcn(IpEcn value) {
+        throw new UnsupportedOperationException("OFOxmIpEcn not supported in version 1.0");
+    }
+
+    public OFOxmIpEcnMasked.Builder buildIpEcnMasked() {
+        throw new UnsupportedOperationException("OFOxmIpEcnMasked not supported in version 1.0");
+    }
+    public OFOxmIpEcnMasked ipEcnMasked(IpEcn value, IpEcn mask) {
+        throw new UnsupportedOperationException("OFOxmIpEcnMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpProto.Builder buildIpProto() {
+        throw new UnsupportedOperationException("OFOxmIpProto not supported in version 1.0");
+    }
+    public OFOxmIpProto ipProto(IpProtocol value) {
+        throw new UnsupportedOperationException("OFOxmIpProto not supported in version 1.0");
+    }
+
+    public OFOxmIpProtoMasked.Builder buildIpProtoMasked() {
+        throw new UnsupportedOperationException("OFOxmIpProtoMasked not supported in version 1.0");
+    }
+    public OFOxmIpProtoMasked ipProtoMasked(IpProtocol value, IpProtocol mask) {
+        throw new UnsupportedOperationException("OFOxmIpProtoMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpv4Dst.Builder buildIpv4Dst() {
+        throw new UnsupportedOperationException("OFOxmIpv4Dst not supported in version 1.0");
+    }
+    public OFOxmIpv4Dst ipv4Dst(IPv4Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv4Dst not supported in version 1.0");
+    }
+
+    public OFOxmIpv4DstMasked.Builder buildIpv4DstMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv4DstMasked not supported in version 1.0");
+    }
+    public OFOxmIpv4DstMasked ipv4DstMasked(IPv4Address value, IPv4Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv4DstMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpv4Src.Builder buildIpv4Src() {
+        throw new UnsupportedOperationException("OFOxmIpv4Src not supported in version 1.0");
+    }
+    public OFOxmIpv4Src ipv4Src(IPv4Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv4Src not supported in version 1.0");
+    }
+
+    public OFOxmIpv4SrcMasked.Builder buildIpv4SrcMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv4SrcMasked not supported in version 1.0");
+    }
+    public OFOxmIpv4SrcMasked ipv4SrcMasked(IPv4Address value, IPv4Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv4SrcMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpv6Dst.Builder buildIpv6Dst() {
+        throw new UnsupportedOperationException("OFOxmIpv6Dst not supported in version 1.0");
+    }
+    public OFOxmIpv6Dst ipv6Dst(IPv6Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv6Dst not supported in version 1.0");
+    }
+
+    public OFOxmIpv6DstMasked.Builder buildIpv6DstMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6DstMasked not supported in version 1.0");
+    }
+    public OFOxmIpv6DstMasked ipv6DstMasked(IPv6Address value, IPv6Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6DstMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpv6Flabel.Builder buildIpv6Flabel() {
+        throw new UnsupportedOperationException("OFOxmIpv6Flabel not supported in version 1.0");
+    }
+    public OFOxmIpv6Flabel ipv6Flabel(IPv6FlowLabel value) {
+        throw new UnsupportedOperationException("OFOxmIpv6Flabel not supported in version 1.0");
+    }
+
+    public OFOxmIpv6FlabelMasked.Builder buildIpv6FlabelMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6FlabelMasked not supported in version 1.0");
+    }
+    public OFOxmIpv6FlabelMasked ipv6FlabelMasked(IPv6FlowLabel value, IPv6FlowLabel mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6FlabelMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpv6NdSll.Builder buildIpv6NdSll() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdSll not supported in version 1.0");
+    }
+    public OFOxmIpv6NdSll ipv6NdSll(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdSll not supported in version 1.0");
+    }
+
+    public OFOxmIpv6NdSllMasked.Builder buildIpv6NdSllMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdSllMasked not supported in version 1.0");
+    }
+    public OFOxmIpv6NdSllMasked ipv6NdSllMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdSllMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpv6NdTarget.Builder buildIpv6NdTarget() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTarget not supported in version 1.0");
+    }
+    public OFOxmIpv6NdTarget ipv6NdTarget(IPv6Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTarget not supported in version 1.0");
+    }
+
+    public OFOxmIpv6NdTargetMasked.Builder buildIpv6NdTargetMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTargetMasked not supported in version 1.0");
+    }
+    public OFOxmIpv6NdTargetMasked ipv6NdTargetMasked(IPv6Address value, IPv6Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTargetMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpv6NdTll.Builder buildIpv6NdTll() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTll not supported in version 1.0");
+    }
+    public OFOxmIpv6NdTll ipv6NdTll(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTll not supported in version 1.0");
+    }
+
+    public OFOxmIpv6NdTllMasked.Builder buildIpv6NdTllMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTllMasked not supported in version 1.0");
+    }
+    public OFOxmIpv6NdTllMasked ipv6NdTllMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTllMasked not supported in version 1.0");
+    }
+
+    public OFOxmIpv6Src.Builder buildIpv6Src() {
+        throw new UnsupportedOperationException("OFOxmIpv6Src not supported in version 1.0");
+    }
+    public OFOxmIpv6Src ipv6Src(IPv6Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv6Src not supported in version 1.0");
+    }
+
+    public OFOxmIpv6SrcMasked.Builder buildIpv6SrcMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6SrcMasked not supported in version 1.0");
+    }
+    public OFOxmIpv6SrcMasked ipv6SrcMasked(IPv6Address value, IPv6Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6SrcMasked not supported in version 1.0");
+    }
+
+    public OFOxmMetadata.Builder buildMetadata() {
+        throw new UnsupportedOperationException("OFOxmMetadata not supported in version 1.0");
+    }
+    public OFOxmMetadata metadata(OFMetadata value) {
+        throw new UnsupportedOperationException("OFOxmMetadata not supported in version 1.0");
+    }
+
+    public OFOxmMetadataMasked.Builder buildMetadataMasked() {
+        throw new UnsupportedOperationException("OFOxmMetadataMasked not supported in version 1.0");
+    }
+    public OFOxmMetadataMasked metadataMasked(OFMetadata value, OFMetadata mask) {
+        throw new UnsupportedOperationException("OFOxmMetadataMasked not supported in version 1.0");
+    }
+
+    public OFOxmMplsLabel.Builder buildMplsLabel() {
+        throw new UnsupportedOperationException("OFOxmMplsLabel not supported in version 1.0");
+    }
+    public OFOxmMplsLabel mplsLabel(U32 value) {
+        throw new UnsupportedOperationException("OFOxmMplsLabel not supported in version 1.0");
+    }
+
+    public OFOxmMplsLabelMasked.Builder buildMplsLabelMasked() {
+        throw new UnsupportedOperationException("OFOxmMplsLabelMasked not supported in version 1.0");
+    }
+    public OFOxmMplsLabelMasked mplsLabelMasked(U32 value, U32 mask) {
+        throw new UnsupportedOperationException("OFOxmMplsLabelMasked not supported in version 1.0");
+    }
+
+    public OFOxmMplsTc.Builder buildMplsTc() {
+        throw new UnsupportedOperationException("OFOxmMplsTc not supported in version 1.0");
+    }
+    public OFOxmMplsTc mplsTc(U8 value) {
+        throw new UnsupportedOperationException("OFOxmMplsTc not supported in version 1.0");
+    }
+
+    public OFOxmMplsTcMasked.Builder buildMplsTcMasked() {
+        throw new UnsupportedOperationException("OFOxmMplsTcMasked not supported in version 1.0");
+    }
+    public OFOxmMplsTcMasked mplsTcMasked(U8 value, U8 mask) {
+        throw new UnsupportedOperationException("OFOxmMplsTcMasked not supported in version 1.0");
+    }
+
+    public OFOxmSctpDst.Builder buildSctpDst() {
+        throw new UnsupportedOperationException("OFOxmSctpDst not supported in version 1.0");
+    }
+    public OFOxmSctpDst sctpDst(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmSctpDst not supported in version 1.0");
+    }
+
+    public OFOxmSctpDstMasked.Builder buildSctpDstMasked() {
+        throw new UnsupportedOperationException("OFOxmSctpDstMasked not supported in version 1.0");
+    }
+    public OFOxmSctpDstMasked sctpDstMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmSctpDstMasked not supported in version 1.0");
+    }
+
+    public OFOxmSctpSrc.Builder buildSctpSrc() {
+        throw new UnsupportedOperationException("OFOxmSctpSrc not supported in version 1.0");
+    }
+    public OFOxmSctpSrc sctpSrc(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmSctpSrc not supported in version 1.0");
+    }
+
+    public OFOxmSctpSrcMasked.Builder buildSctpSrcMasked() {
+        throw new UnsupportedOperationException("OFOxmSctpSrcMasked not supported in version 1.0");
+    }
+    public OFOxmSctpSrcMasked sctpSrcMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmSctpSrcMasked not supported in version 1.0");
+    }
+
+    public OFOxmTcpDst.Builder buildTcpDst() {
+        throw new UnsupportedOperationException("OFOxmTcpDst not supported in version 1.0");
+    }
+    public OFOxmTcpDst tcpDst(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmTcpDst not supported in version 1.0");
+    }
+
+    public OFOxmTcpDstMasked.Builder buildTcpDstMasked() {
+        throw new UnsupportedOperationException("OFOxmTcpDstMasked not supported in version 1.0");
+    }
+    public OFOxmTcpDstMasked tcpDstMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmTcpDstMasked not supported in version 1.0");
+    }
+
+    public OFOxmTcpSrc.Builder buildTcpSrc() {
+        throw new UnsupportedOperationException("OFOxmTcpSrc not supported in version 1.0");
+    }
+    public OFOxmTcpSrc tcpSrc(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmTcpSrc not supported in version 1.0");
+    }
+
+    public OFOxmTcpSrcMasked.Builder buildTcpSrcMasked() {
+        throw new UnsupportedOperationException("OFOxmTcpSrcMasked not supported in version 1.0");
+    }
+    public OFOxmTcpSrcMasked tcpSrcMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmTcpSrcMasked not supported in version 1.0");
+    }
+
+    public OFOxmUdpDst.Builder buildUdpDst() {
+        throw new UnsupportedOperationException("OFOxmUdpDst not supported in version 1.0");
+    }
+    public OFOxmUdpDst udpDst(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmUdpDst not supported in version 1.0");
+    }
+
+    public OFOxmUdpDstMasked.Builder buildUdpDstMasked() {
+        throw new UnsupportedOperationException("OFOxmUdpDstMasked not supported in version 1.0");
+    }
+    public OFOxmUdpDstMasked udpDstMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmUdpDstMasked not supported in version 1.0");
+    }
+
+    public OFOxmUdpSrc.Builder buildUdpSrc() {
+        throw new UnsupportedOperationException("OFOxmUdpSrc not supported in version 1.0");
+    }
+    public OFOxmUdpSrc udpSrc(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmUdpSrc not supported in version 1.0");
+    }
+
+    public OFOxmUdpSrcMasked.Builder buildUdpSrcMasked() {
+        throw new UnsupportedOperationException("OFOxmUdpSrcMasked not supported in version 1.0");
+    }
+    public OFOxmUdpSrcMasked udpSrcMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmUdpSrcMasked not supported in version 1.0");
+    }
+
+    public OFOxmVlanPcp.Builder buildVlanPcp() {
+        throw new UnsupportedOperationException("OFOxmVlanPcp not supported in version 1.0");
+    }
+    public OFOxmVlanPcp vlanPcp(VlanPcp value) {
+        throw new UnsupportedOperationException("OFOxmVlanPcp not supported in version 1.0");
+    }
+
+    public OFOxmVlanPcpMasked.Builder buildVlanPcpMasked() {
+        throw new UnsupportedOperationException("OFOxmVlanPcpMasked not supported in version 1.0");
+    }
+    public OFOxmVlanPcpMasked vlanPcpMasked(VlanPcp value, VlanPcp mask) {
+        throw new UnsupportedOperationException("OFOxmVlanPcpMasked not supported in version 1.0");
+    }
+
+    public OFOxmVlanVid.Builder buildVlanVid() {
+        throw new UnsupportedOperationException("OFOxmVlanVid not supported in version 1.0");
+    }
+    public OFOxmVlanVid vlanVid(OFVlanVidMatch value) {
+        throw new UnsupportedOperationException("OFOxmVlanVid not supported in version 1.0");
+    }
+
+    public OFOxmVlanVidMasked.Builder buildVlanVidMasked() {
+        throw new UnsupportedOperationException("OFOxmVlanVidMasked not supported in version 1.0");
+    }
+    public OFOxmVlanVidMasked vlanVidMasked(OFVlanVidMatch value, OFVlanVidMatch mask) {
+        throw new UnsupportedOperationException("OFOxmVlanVidMasked not supported in version 1.0");
+    }
+
+    public OFOxmTunnelId.Builder buildTunnelId() {
+        throw new UnsupportedOperationException("OFOxmTunnelId not supported in version 1.0");
+    }
+    public OFOxmTunnelId tunnelId(U64 value) {
+        throw new UnsupportedOperationException("OFOxmTunnelId not supported in version 1.0");
+    }
+
+    public OFOxmTunnelIdMasked.Builder buildTunnelIdMasked() {
+        throw new UnsupportedOperationException("OFOxmTunnelIdMasked not supported in version 1.0");
+    }
+    public OFOxmTunnelIdMasked tunnelIdMasked(U64 value, U64 mask) {
+        throw new UnsupportedOperationException("OFOxmTunnelIdMasked not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFOxm<?>> getReader() {
+        throw new UnsupportedOperationException("Reader<OFOxm<?>> not supported in version 1.0");
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromValue(F value, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOp((ArpOpcode)((Object)value)));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpSha((MacAddress)((Object)value)));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpa((IPv4Address)((Object)value)));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpTha((MacAddress)((Object)value)));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpa((IPv4Address)((Object)value)));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupId((ClassId)((Object)value)));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowed((OFBooleanValue)((Object)value)));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128((OFBitMask128)((Object)value)));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassId((ClassId)((Object)value)));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassId((ClassId)((Object)value)));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassId((ClassId)((Object)value)));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagId((LagId)((Object)value)));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlags((U16)((Object)value)));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0((UDF)((Object)value)));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1((UDF)((Object)value)));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2((UDF)((Object)value)));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3((UDF)((Object)value)));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4((UDF)((Object)value)));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5((UDF)((Object)value)));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6((UDF)((Object)value)));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7((UDF)((Object)value)));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupId((ClassId)((Object)value)));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrf((VRF)((Object)value)));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDst((MacAddress)((Object)value)));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrc((MacAddress)((Object)value)));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethType((EthType)((Object)value)));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4Code((ICMPv4Code)((Object)value)));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4Type((ICMPv4Type)((Object)value)));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6Code((U8)((Object)value)));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6Type((U8)((Object)value)));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPort((OFPort)((Object)value)));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPort((OFPort)((Object)value)));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscp((IpDscp)((Object)value)));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcn((IpEcn)((Object)value)));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProto((IpProtocol)((Object)value)));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4Dst((IPv4Address)((Object)value)));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4Src((IPv4Address)((Object)value)));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6Dst((IPv6Address)((Object)value)));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6Flabel((IPv6FlowLabel)((Object)value)));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSll((MacAddress)((Object)value)));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTarget((IPv6Address)((Object)value)));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTll((MacAddress)((Object)value)));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6Src((IPv6Address)((Object)value)));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadata((OFMetadata)((Object)value)));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabel((U32)((Object)value)));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTc((U8)((Object)value)));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDst((TransportPort)((Object)value)));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrc((TransportPort)((Object)value)));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDst((TransportPort)((Object)value)));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrc((TransportPort)((Object)value)));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDst((TransportPort)((Object)value)));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrc((TransportPort)((Object)value)));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcp((VlanPcp)((Object)value)));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVid((OFVlanVidMatch)((Object)value)));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelId((U64)((Object)value)));
+            default:
+                throw new IllegalArgumentException("No OXM known for match field " + field);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromValueAndMask(F value, F mask, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOpMasked((ArpOpcode)((Object)value), (ArpOpcode)((Object)mask)));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpShaMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpaMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpThaMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpaMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowedMasked((OFBooleanValue)((Object)value), (OFBooleanValue)((Object)mask)));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128Masked((OFBitMask128)((Object)value), (OFBitMask128)((Object)mask)));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagIdMasked((LagId)((Object)value), (LagId)((Object)mask)));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlagsMasked((U16)((Object)value), (U16)((Object)mask)));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrfMasked((VRF)((Object)value), (VRF)((Object)mask)));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDstMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrcMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethTypeMasked((EthType)((Object)value), (EthType)((Object)mask)));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4CodeMasked((ICMPv4Code)((Object)value), (ICMPv4Code)((Object)mask)));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4TypeMasked((ICMPv4Type)((Object)value), (ICMPv4Type)((Object)mask)));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6CodeMasked((U8)((Object)value), (U8)((Object)mask)));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6TypeMasked((U8)((Object)value), (U8)((Object)mask)));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPortMasked((OFPort)((Object)value), (OFPort)((Object)mask)));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPortMasked((OFPort)((Object)value), (OFPort)((Object)mask)));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscpMasked((IpDscp)((Object)value), (IpDscp)((Object)mask)));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcnMasked((IpEcn)((Object)value), (IpEcn)((Object)mask)));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProtoMasked((IpProtocol)((Object)value), (IpProtocol)((Object)mask)));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4DstMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4SrcMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6DstMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6FlabelMasked((IPv6FlowLabel)((Object)value), (IPv6FlowLabel)((Object)mask)));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSllMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTargetMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTllMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6SrcMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadataMasked((OFMetadata)((Object)value), (OFMetadata)((Object)mask)));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabelMasked((U32)((Object)value), (U32)((Object)mask)));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTcMasked((U8)((Object)value), (U8)((Object)mask)));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcpMasked((VlanPcp)((Object)value), (VlanPcp)((Object)mask)));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVidMasked((OFVlanVidMatch)((Object)value), (OFVlanVidMatch)((Object)mask)));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelIdMasked((U64)((Object)value), (U64)((Object)mask)));
+            default:
+                throw new IllegalArgumentException("No OXM known for match field " + field);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromMasked(Masked<F> masked, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOpMasked((ArpOpcode)((Object)(masked.getValue())), (ArpOpcode)((Object)(masked.getMask()))));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpShaMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpaMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpThaMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpaMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowedMasked((OFBooleanValue)((Object)(masked.getValue())), (OFBooleanValue)((Object)(masked.getMask()))));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128Masked((OFBitMask128)((Object)(masked.getValue())), (OFBitMask128)((Object)(masked.getMask()))));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagIdMasked((LagId)((Object)(masked.getValue())), (LagId)((Object)(masked.getMask()))));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlagsMasked((U16)((Object)(masked.getValue())), (U16)((Object)(masked.getMask()))));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrfMasked((VRF)((Object)(masked.getValue())), (VRF)((Object)(masked.getMask()))));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDstMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrcMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethTypeMasked((EthType)((Object)(masked.getValue())), (EthType)((Object)(masked.getMask()))));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4CodeMasked((ICMPv4Code)((Object)(masked.getValue())), (ICMPv4Code)((Object)(masked.getMask()))));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4TypeMasked((ICMPv4Type)((Object)(masked.getValue())), (ICMPv4Type)((Object)(masked.getMask()))));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6CodeMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6TypeMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPortMasked((OFPort)((Object)(masked.getValue())), (OFPort)((Object)(masked.getMask()))));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPortMasked((OFPort)((Object)(masked.getValue())), (OFPort)((Object)(masked.getMask()))));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscpMasked((IpDscp)((Object)(masked.getValue())), (IpDscp)((Object)(masked.getMask()))));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcnMasked((IpEcn)((Object)(masked.getValue())), (IpEcn)((Object)(masked.getMask()))));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProtoMasked((IpProtocol)((Object)(masked.getValue())), (IpProtocol)((Object)(masked.getMask()))));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4DstMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4SrcMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6DstMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6FlabelMasked((IPv6FlowLabel)((Object)(masked.getValue())), (IPv6FlowLabel)((Object)(masked.getMask()))));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSllMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTargetMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTllMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6SrcMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadataMasked((OFMetadata)((Object)(masked.getValue())), (OFMetadata)((Object)(masked.getMask()))));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabelMasked((U32)((Object)(masked.getValue())), (U32)((Object)(masked.getMask()))));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTcMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcpMasked((VlanPcp)((Object)(masked.getValue())), (VlanPcp)((Object)(masked.getMask()))));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVidMasked((OFVlanVidMatch)((Object)(masked.getValue())), (OFVlanVidMatch)((Object)(masked.getMask()))));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelIdMasked((U64)((Object)(masked.getValue())), (U64)((Object)(masked.getMask()))));
+            default:
+                return null;
+        }
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInReasonSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInReasonSerializerVer10.java
new file mode 100644
index 0000000..4f114b8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInReasonSerializerVer10.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPacketInReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPacketInReasonSerializerVer10 {
+
+    public final static byte NO_MATCH_VAL = (byte) 0x0;
+    public final static byte ACTION_VAL = (byte) 0x1;
+
+    public static OFPacketInReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPacketInReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFPacketInReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFPacketInReason ofWireValue(byte val) {
+        switch(val) {
+            case NO_MATCH_VAL:
+                return OFPacketInReason.NO_MATCH;
+            case ACTION_VAL:
+                return OFPacketInReason.ACTION;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPacketInReason in version 1.0: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFPacketInReason e) {
+        switch(e) {
+            case NO_MATCH:
+                return NO_MATCH_VAL;
+            case ACTION:
+                return ACTION_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPacketInReason in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInVer10.java
new file mode 100644
index 0000000..3f7a0df
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInVer10.java
@@ -0,0 +1,627 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFPacketInVer10 implements OFPacketIn {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketInVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 18;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static int DEFAULT_TOTAL_LEN = 0x0;
+        private final static OFPort DEFAULT_IN_PORT = OFPort.ANY;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final OFBufferId bufferId;
+    private final int totalLen;
+    private final OFPort inPort;
+    private final OFPacketInReason reason;
+    private final byte[] data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketInVer10(long xid, OFBufferId bufferId, int totalLen, OFPort inPort, OFPacketInReason reason, byte[] data) {
+        this.xid = xid;
+        this.bufferId = bufferId;
+        this.totalLen = totalLen;
+        this.inPort = inPort;
+        this.reason = reason;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public Match getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+
+
+    public OFPacketIn.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketIn.Builder {
+        final OFPacketInVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean totalLenSet;
+        private int totalLen;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean reasonSet;
+        private OFPacketInReason reason;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFPacketInVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketIn.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTotalLen(int totalLen) {
+        this.totalLen = totalLen;
+        this.totalLenSet = true;
+        return this;
+    }
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPacketIn.Builder setReason(OFPacketInReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketIn.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public Match getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketIn.Builder setMatch(Match match) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketIn.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketIn.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+
+        @Override
+        public OFPacketIn build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                int totalLen = this.totalLenSet ? this.totalLen : parentMessage.totalLen;
+                OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort;
+                if(inPort == null)
+                    throw new NullPointerException("Property inPort must not be null");
+                OFPacketInReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPacketInVer10(
+                    xid,
+                    bufferId,
+                    totalLen,
+                    inPort,
+                    reason,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketIn.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean totalLenSet;
+        private int totalLen;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean reasonSet;
+        private OFPacketInReason reason;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketIn.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTotalLen(int totalLen) {
+        this.totalLen = totalLen;
+        this.totalLenSet = true;
+        return this;
+    }
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPacketIn.Builder setReason(OFPacketInReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketIn.Builder setTableId(TableId tableId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property tableId not supported in version 1.0");
+    }
+    @Override
+    public Match getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketIn.Builder setMatch(Match match) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketIn.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.0");
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketIn.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.0");
+    }
+//
+        @Override
+        public OFPacketIn build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            int totalLen = this.totalLenSet ? this.totalLen : DEFAULT_TOTAL_LEN;
+            OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT;
+            if(inPort == null)
+                throw new NullPointerException("Property inPort must not be null");
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPacketInVer10(
+                    xid,
+                    bufferId,
+                    totalLen,
+                    inPort,
+                    reason,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketIn> {
+        @Override
+        public OFPacketIn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 10
+            byte type = bb.readByte();
+            if(type != (byte) 0xa)
+                throw new OFParseError("Wrong type: Expected=OFType.PACKET_IN(10), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            int totalLen = U16.f(bb.readShort());
+            OFPort inPort = OFPort.read2Bytes(bb);
+            OFPacketInReason reason = OFPacketInReasonSerializerVer10.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFPacketInVer10 packetInVer10 = new OFPacketInVer10(
+                    xid,
+                      bufferId,
+                      totalLen,
+                      inPort,
+                      reason,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetInVer10);
+            return packetInVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketInVer10Funnel FUNNEL = new OFPacketInVer10Funnel();
+    static class OFPacketInVer10Funnel implements Funnel<OFPacketInVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketInVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 10
+            sink.putByte((byte) 0xa);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.bufferId.putTo(sink);
+            sink.putInt(message.totalLen);
+            message.inPort.putTo(sink);
+            OFPacketInReasonSerializerVer10.putTo(message.reason, sink);
+            // skip pad (1 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketInVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketInVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 10
+            bb.writeByte((byte) 0xa);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(message.bufferId.getInt());
+            bb.writeShort(U16.t(message.totalLen));
+            message.inPort.write2Bytes(bb);
+            OFPacketInReasonSerializerVer10.writeTo(bb, message.reason);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketInVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("totalLen=").append(totalLen);
+        b.append(", ");
+        b.append("inPort=").append(inPort);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketInVer10 other = (OFPacketInVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if( totalLen != other.totalLen)
+            return false;
+        if (inPort == null) {
+            if (other.inPort != null)
+                return false;
+        } else if (!inPort.equals(other.inPort))
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + totalLen;
+        result = prime * result + ((inPort == null) ? 0 : inPort.hashCode());
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketOutVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketOutVer10.java
new file mode 100644
index 0000000..b299aab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketOutVer10.java
@@ -0,0 +1,499 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFPacketOutVer10 implements OFPacketOut {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketOutVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_IN_PORT = OFPort.ANY;
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final OFBufferId bufferId;
+    private final OFPort inPort;
+    private final List<OFAction> actions;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFPacketOutVer10 DEFAULT = new OFPacketOutVer10(
+        DEFAULT_XID, DEFAULT_BUFFER_ID, DEFAULT_IN_PORT, DEFAULT_ACTIONS, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketOutVer10(long xid, OFBufferId bufferId, OFPort inPort, List<OFAction> actions, byte[] data) {
+        this.xid = xid;
+        this.bufferId = bufferId;
+        this.inPort = inPort;
+        this.actions = actions;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFPacketOut.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketOut.Builder {
+        final OFPacketOutVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFPacketOutVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketOut.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketOut.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketOut.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFPacketOut.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketOut.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPacketOut build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort;
+                if(inPort == null)
+                    throw new NullPointerException("Property inPort must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPacketOutVer10(
+                    xid,
+                    bufferId,
+                    inPort,
+                    actions,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketOut.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketOut.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketOut.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketOut.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFPacketOut.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketOut.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPacketOut build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT;
+            if(inPort == null)
+                throw new NullPointerException("Property inPort must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPacketOutVer10(
+                    xid,
+                    bufferId,
+                    inPort,
+                    actions,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketOut> {
+        @Override
+        public OFPacketOut readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 13
+            byte type = bb.readByte();
+            if(type != (byte) 0xd)
+                throw new OFParseError("Wrong type: Expected=OFType.PACKET_OUT(13), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort inPort = OFPort.read2Bytes(bb);
+            int actionsLen = U16.f(bb.readShort());
+            List<OFAction> actions = ChannelUtils.readList(bb, actionsLen, OFActionVer10.READER);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFPacketOutVer10 packetOutVer10 = new OFPacketOutVer10(
+                    xid,
+                      bufferId,
+                      inPort,
+                      actions,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetOutVer10);
+            return packetOutVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketOutVer10Funnel FUNNEL = new OFPacketOutVer10Funnel();
+    static class OFPacketOutVer10Funnel implements Funnel<OFPacketOutVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketOutVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 13
+            sink.putByte((byte) 0xd);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.bufferId.putTo(sink);
+            message.inPort.putTo(sink);
+            // FIXME: skip funnel of actionsLen
+            FunnelUtils.putList(message.actions, sink);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketOutVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketOutVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 13
+            bb.writeByte((byte) 0xd);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(message.bufferId.getInt());
+            message.inPort.write2Bytes(bb);
+            // actionsLen is length indicator for actions, will be
+            // udpated when actions has been written
+            int actionsLenIndex = bb.writerIndex();
+            bb.writeShort(0);
+            int actionsStartIndex = bb.writerIndex();
+            ChannelUtils.writeList(bb, message.actions);
+            // update field length member actionsLen
+            int actionsLength = bb.writerIndex() - actionsStartIndex;
+            bb.setShort(actionsLenIndex, actionsLength);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketOutVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("inPort=").append(inPort);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketOutVer10 other = (OFPacketOutVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (inPort == null) {
+            if (other.inPort != null)
+                return false;
+        } else if (!inPort.equals(other.inPort))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((inPort == null) ? 0 : inPort.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketQueueVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketQueueVer10.java
new file mode 100644
index 0000000..e328c2c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketQueueVer10.java
@@ -0,0 +1,326 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPacketQueueVer10 implements OFPacketQueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketQueueVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+        private final static List<OFQueueProp> DEFAULT_PROPERTIES = ImmutableList.<OFQueueProp>of();
+
+    // OF message fields
+    private final long queueId;
+    private final List<OFQueueProp> properties;
+//
+    // Immutable default instance
+    final static OFPacketQueueVer10 DEFAULT = new OFPacketQueueVer10(
+        DEFAULT_QUEUE_ID, DEFAULT_PROPERTIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketQueueVer10(long queueId, List<OFQueueProp> properties) {
+        this.queueId = queueId;
+        this.properties = properties;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPort getPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property port not supported in version 1.0");
+    }
+
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFPacketQueue.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketQueue.Builder {
+        final OFPacketQueueVer10 parentMessage;
+
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean propertiesSet;
+        private List<OFQueueProp> properties;
+
+        BuilderWithParent(OFPacketQueueVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property port not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketQueue.Builder setPort(OFPort port) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property port not supported in version 1.0");
+    }
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setProperties(List<OFQueueProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFPacketQueue build() {
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+                List<OFQueueProp> properties = this.propertiesSet ? this.properties : parentMessage.properties;
+                if(properties == null)
+                    throw new NullPointerException("Property properties must not be null");
+
+                //
+                return new OFPacketQueueVer10(
+                    queueId,
+                    properties
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketQueue.Builder {
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean propertiesSet;
+        private List<OFQueueProp> properties;
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property port not supported in version 1.0");
+    }
+
+    @Override
+    public OFPacketQueue.Builder setPort(OFPort port) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property port not supported in version 1.0");
+    }
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setProperties(List<OFQueueProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFPacketQueue build() {
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+            List<OFQueueProp> properties = this.propertiesSet ? this.properties : DEFAULT_PROPERTIES;
+            if(properties == null)
+                throw new NullPointerException("Property properties must not be null");
+
+
+            return new OFPacketQueueVer10(
+                    queueId,
+                    properties
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketQueue> {
+        @Override
+        public OFPacketQueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            long queueId = U32.f(bb.readInt());
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            List<OFQueueProp> properties = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFQueuePropVer10.READER);
+
+            OFPacketQueueVer10 packetQueueVer10 = new OFPacketQueueVer10(
+                    queueId,
+                      properties
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetQueueVer10);
+            return packetQueueVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketQueueVer10Funnel FUNNEL = new OFPacketQueueVer10Funnel();
+    static class OFPacketQueueVer10Funnel implements Funnel<OFPacketQueueVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketQueueVer10 message, PrimitiveSink sink) {
+            sink.putLong(message.queueId);
+            // FIXME: skip funnel of length
+            // skip pad (2 bytes)
+            FunnelUtils.putList(message.properties, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketQueueVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketQueueVer10 message) {
+            int startIndex = bb.writerIndex();
+            bb.writeInt(U32.t(message.queueId));
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeList(bb, message.properties);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketQueueVer10(");
+        b.append("queueId=").append(queueId);
+        b.append(", ");
+        b.append("properties=").append(properties);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketQueueVer10 other = (OFPacketQueueVer10) obj;
+
+        if( queueId != other.queueId)
+            return false;
+        if (properties == null) {
+            if (other.properties != null)
+                return false;
+        } else if (!properties.equals(other.properties))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortConfigSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortConfigSerializerVer10.java
new file mode 100644
index 0000000..148dea5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortConfigSerializerVer10.java
@@ -0,0 +1,120 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortConfig;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortConfigSerializerVer10 {
+
+    public final static int PORT_DOWN_VAL = 0x1;
+    public final static int NO_STP_VAL = 0x2;
+    public final static int NO_RECV_VAL = 0x4;
+    public final static int NO_RECV_STP_VAL = 0x8;
+    public final static int NO_FLOOD_VAL = 0x10;
+    public final static int NO_FWD_VAL = 0x20;
+    public final static int NO_PACKET_IN_VAL = 0x40;
+    public final static int BSN_MIRROR_DEST_VAL = (int) 0x80000000;
+
+    public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortConfig> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortConfig> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortConfig> ofWireValue(int val) {
+        EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);
+
+        if((val & PORT_DOWN_VAL) != 0)
+            set.add(OFPortConfig.PORT_DOWN);
+        if((val & NO_STP_VAL) != 0)
+            set.add(OFPortConfig.NO_STP);
+        if((val & NO_RECV_VAL) != 0)
+            set.add(OFPortConfig.NO_RECV);
+        if((val & NO_RECV_STP_VAL) != 0)
+            set.add(OFPortConfig.NO_RECV_STP);
+        if((val & NO_FLOOD_VAL) != 0)
+            set.add(OFPortConfig.NO_FLOOD);
+        if((val & NO_FWD_VAL) != 0)
+            set.add(OFPortConfig.NO_FWD);
+        if((val & NO_PACKET_IN_VAL) != 0)
+            set.add(OFPortConfig.NO_PACKET_IN);
+        if((val & BSN_MIRROR_DEST_VAL) != 0)
+            set.add(OFPortConfig.BSN_MIRROR_DEST);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortConfig> set) {
+        int wireValue = 0;
+
+        for(OFPortConfig e: set) {
+            switch(e) {
+                case PORT_DOWN:
+                    wireValue |= PORT_DOWN_VAL;
+                    break;
+                case NO_STP:
+                    wireValue |= NO_STP_VAL;
+                    break;
+                case NO_RECV:
+                    wireValue |= NO_RECV_VAL;
+                    break;
+                case NO_RECV_STP:
+                    wireValue |= NO_RECV_STP_VAL;
+                    break;
+                case NO_FLOOD:
+                    wireValue |= NO_FLOOD_VAL;
+                    break;
+                case NO_FWD:
+                    wireValue |= NO_FWD_VAL;
+                    break;
+                case NO_PACKET_IN:
+                    wireValue |= NO_PACKET_IN_VAL;
+                    break;
+                case BSN_MIRROR_DEST:
+                    wireValue |= BSN_MIRROR_DEST_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortDescVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortDescVer10.java
new file mode 100644
index 0000000..61da66e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortDescVer10.java
@@ -0,0 +1,708 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortDescVer10 implements OFPortDesc {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortDescVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 48;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static String DEFAULT_NAME = "";
+        private final static Set<OFPortConfig> DEFAULT_CONFIG = ImmutableSet.<OFPortConfig>of();
+        private final static Set<OFPortState> DEFAULT_STATE = ImmutableSet.<OFPortState>of();
+        private final static Set<OFPortFeatures> DEFAULT_CURR = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_ADVERTISED = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_SUPPORTED = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_PEER = ImmutableSet.<OFPortFeatures>of();
+
+    // OF message fields
+    private final OFPort portNo;
+    private final MacAddress hwAddr;
+    private final String name;
+    private final Set<OFPortConfig> config;
+    private final Set<OFPortState> state;
+    private final Set<OFPortFeatures> curr;
+    private final Set<OFPortFeatures> advertised;
+    private final Set<OFPortFeatures> supported;
+    private final Set<OFPortFeatures> peer;
+//
+    // Immutable default instance
+    final static OFPortDescVer10 DEFAULT = new OFPortDescVer10(
+        DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_CONFIG, DEFAULT_STATE, DEFAULT_CURR, DEFAULT_ADVERTISED, DEFAULT_SUPPORTED, DEFAULT_PEER
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortDescVer10(OFPort portNo, MacAddress hwAddr, String name, Set<OFPortConfig> config, Set<OFPortState> state, Set<OFPortFeatures> curr, Set<OFPortFeatures> advertised, Set<OFPortFeatures> supported, Set<OFPortFeatures> peer) {
+        this.portNo = portNo;
+        this.hwAddr = hwAddr;
+        this.name = name;
+        this.config = config;
+        this.state = state;
+        this.curr = curr;
+        this.advertised = advertised;
+        this.supported = supported;
+        this.peer = peer;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public long getCurrSpeed()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property currSpeed not supported in version 1.0");
+    }
+
+    @Override
+    public long getMaxSpeed()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property maxSpeed not supported in version 1.0");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFPortDesc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortDesc.Builder {
+        final OFPortDescVer10 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean configSet;
+        private Set<OFPortConfig> config;
+        private boolean stateSet;
+        private Set<OFPortState> state;
+        private boolean currSet;
+        private Set<OFPortFeatures> curr;
+        private boolean advertisedSet;
+        private Set<OFPortFeatures> advertised;
+        private boolean supportedSet;
+        private Set<OFPortFeatures> supported;
+        private boolean peerSet;
+        private Set<OFPortFeatures> peer;
+
+        BuilderWithParent(OFPortDescVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFPortDesc.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public OFPortDesc.Builder setState(Set<OFPortState> state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) {
+        this.curr = curr;
+        this.currSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) {
+        this.advertised = advertised;
+        this.advertisedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) {
+        this.supported = supported;
+        this.supportedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) {
+        this.peer = peer;
+        this.peerSet = true;
+        return this;
+    }
+    @Override
+    public long getCurrSpeed()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property currSpeed not supported in version 1.0");
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurrSpeed(long currSpeed) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property currSpeed not supported in version 1.0");
+    }
+    @Override
+    public long getMaxSpeed()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property maxSpeed not supported in version 1.0");
+    }
+
+    @Override
+    public OFPortDesc.Builder setMaxSpeed(long maxSpeed) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property maxSpeed not supported in version 1.0");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFPortDesc build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                Set<OFPortConfig> config = this.configSet ? this.config : parentMessage.config;
+                if(config == null)
+                    throw new NullPointerException("Property config must not be null");
+                Set<OFPortState> state = this.stateSet ? this.state : parentMessage.state;
+                if(state == null)
+                    throw new NullPointerException("Property state must not be null");
+                Set<OFPortFeatures> curr = this.currSet ? this.curr : parentMessage.curr;
+                if(curr == null)
+                    throw new NullPointerException("Property curr must not be null");
+                Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : parentMessage.advertised;
+                if(advertised == null)
+                    throw new NullPointerException("Property advertised must not be null");
+                Set<OFPortFeatures> supported = this.supportedSet ? this.supported : parentMessage.supported;
+                if(supported == null)
+                    throw new NullPointerException("Property supported must not be null");
+                Set<OFPortFeatures> peer = this.peerSet ? this.peer : parentMessage.peer;
+                if(peer == null)
+                    throw new NullPointerException("Property peer must not be null");
+
+                //
+                return new OFPortDescVer10(
+                    portNo,
+                    hwAddr,
+                    name,
+                    config,
+                    state,
+                    curr,
+                    advertised,
+                    supported,
+                    peer
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortDesc.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean configSet;
+        private Set<OFPortConfig> config;
+        private boolean stateSet;
+        private Set<OFPortState> state;
+        private boolean currSet;
+        private Set<OFPortFeatures> curr;
+        private boolean advertisedSet;
+        private Set<OFPortFeatures> advertised;
+        private boolean supportedSet;
+        private Set<OFPortFeatures> supported;
+        private boolean peerSet;
+        private Set<OFPortFeatures> peer;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFPortDesc.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public OFPortDesc.Builder setState(Set<OFPortState> state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) {
+        this.curr = curr;
+        this.currSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) {
+        this.advertised = advertised;
+        this.advertisedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) {
+        this.supported = supported;
+        this.supportedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) {
+        this.peer = peer;
+        this.peerSet = true;
+        return this;
+    }
+    @Override
+    public long getCurrSpeed()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property currSpeed not supported in version 1.0");
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurrSpeed(long currSpeed) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property currSpeed not supported in version 1.0");
+    }
+    @Override
+    public long getMaxSpeed()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property maxSpeed not supported in version 1.0");
+    }
+
+    @Override
+    public OFPortDesc.Builder setMaxSpeed(long maxSpeed) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property maxSpeed not supported in version 1.0");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFPortDesc build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            Set<OFPortConfig> config = this.configSet ? this.config : DEFAULT_CONFIG;
+            if(config == null)
+                throw new NullPointerException("Property config must not be null");
+            Set<OFPortState> state = this.stateSet ? this.state : DEFAULT_STATE;
+            if(state == null)
+                throw new NullPointerException("Property state must not be null");
+            Set<OFPortFeatures> curr = this.currSet ? this.curr : DEFAULT_CURR;
+            if(curr == null)
+                throw new NullPointerException("Property curr must not be null");
+            Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : DEFAULT_ADVERTISED;
+            if(advertised == null)
+                throw new NullPointerException("Property advertised must not be null");
+            Set<OFPortFeatures> supported = this.supportedSet ? this.supported : DEFAULT_SUPPORTED;
+            if(supported == null)
+                throw new NullPointerException("Property supported must not be null");
+            Set<OFPortFeatures> peer = this.peerSet ? this.peer : DEFAULT_PEER;
+            if(peer == null)
+                throw new NullPointerException("Property peer must not be null");
+
+
+            return new OFPortDescVer10(
+                    portNo,
+                    hwAddr,
+                    name,
+                    config,
+                    state,
+                    curr,
+                    advertised,
+                    supported,
+                    peer
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortDesc> {
+        @Override
+        public OFPortDesc readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read2Bytes(bb);
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            String name = ChannelUtils.readFixedLengthString(bb, 16);
+            Set<OFPortConfig> config = OFPortConfigSerializerVer10.readFrom(bb);
+            Set<OFPortState> state = OFPortStateSerializerVer10.readFrom(bb);
+            Set<OFPortFeatures> curr = OFPortFeaturesSerializerVer10.readFrom(bb);
+            Set<OFPortFeatures> advertised = OFPortFeaturesSerializerVer10.readFrom(bb);
+            Set<OFPortFeatures> supported = OFPortFeaturesSerializerVer10.readFrom(bb);
+            Set<OFPortFeatures> peer = OFPortFeaturesSerializerVer10.readFrom(bb);
+
+            OFPortDescVer10 portDescVer10 = new OFPortDescVer10(
+                    portNo,
+                      hwAddr,
+                      name,
+                      config,
+                      state,
+                      curr,
+                      advertised,
+                      supported,
+                      peer
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portDescVer10);
+            return portDescVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortDescVer10Funnel FUNNEL = new OFPortDescVer10Funnel();
+    static class OFPortDescVer10Funnel implements Funnel<OFPortDescVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortDescVer10 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            message.hwAddr.putTo(sink);
+            sink.putUnencodedChars(message.name);
+            OFPortConfigSerializerVer10.putTo(message.config, sink);
+            OFPortStateSerializerVer10.putTo(message.state, sink);
+            OFPortFeaturesSerializerVer10.putTo(message.curr, sink);
+            OFPortFeaturesSerializerVer10.putTo(message.advertised, sink);
+            OFPortFeaturesSerializerVer10.putTo(message.supported, sink);
+            OFPortFeaturesSerializerVer10.putTo(message.peer, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortDescVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortDescVer10 message) {
+            message.portNo.write2Bytes(bb);
+            message.hwAddr.write6Bytes(bb);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 16);
+            OFPortConfigSerializerVer10.writeTo(bb, message.config);
+            OFPortStateSerializerVer10.writeTo(bb, message.state);
+            OFPortFeaturesSerializerVer10.writeTo(bb, message.curr);
+            OFPortFeaturesSerializerVer10.writeTo(bb, message.advertised);
+            OFPortFeaturesSerializerVer10.writeTo(bb, message.supported);
+            OFPortFeaturesSerializerVer10.writeTo(bb, message.peer);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortDescVer10(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("state=").append(state);
+        b.append(", ");
+        b.append("curr=").append(curr);
+        b.append(", ");
+        b.append("advertised=").append(advertised);
+        b.append(", ");
+        b.append("supported=").append(supported);
+        b.append(", ");
+        b.append("peer=").append(peer);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortDescVer10 other = (OFPortDescVer10) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (config == null) {
+            if (other.config != null)
+                return false;
+        } else if (!config.equals(other.config))
+            return false;
+        if (state == null) {
+            if (other.state != null)
+                return false;
+        } else if (!state.equals(other.state))
+            return false;
+        if (curr == null) {
+            if (other.curr != null)
+                return false;
+        } else if (!curr.equals(other.curr))
+            return false;
+        if (advertised == null) {
+            if (other.advertised != null)
+                return false;
+        } else if (!advertised.equals(other.advertised))
+            return false;
+        if (supported == null) {
+            if (other.supported != null)
+                return false;
+        } else if (!supported.equals(other.supported))
+            return false;
+        if (peer == null) {
+            if (other.peer != null)
+                return false;
+        } else if (!peer.equals(other.peer))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((config == null) ? 0 : config.hashCode());
+        result = prime * result + ((state == null) ? 0 : state.hashCode());
+        result = prime * result + ((curr == null) ? 0 : curr.hashCode());
+        result = prime * result + ((advertised == null) ? 0 : advertised.hashCode());
+        result = prime * result + ((supported == null) ? 0 : supported.hashCode());
+        result = prime * result + ((peer == null) ? 0 : peer.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortFeaturesSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortFeaturesSerializerVer10.java
new file mode 100644
index 0000000..b19e2e3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortFeaturesSerializerVer10.java
@@ -0,0 +1,144 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortFeatures;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortFeaturesSerializerVer10 {
+
+    public final static int PF_10MB_HD_VAL = 0x1;
+    public final static int PF_10MB_FD_VAL = 0x2;
+    public final static int PF_100MB_HD_VAL = 0x4;
+    public final static int PF_100MB_FD_VAL = 0x8;
+    public final static int PF_1GB_HD_VAL = 0x10;
+    public final static int PF_1GB_FD_VAL = 0x20;
+    public final static int PF_10GB_FD_VAL = 0x40;
+    public final static int PF_COPPER_VAL = 0x80;
+    public final static int PF_FIBER_VAL = 0x100;
+    public final static int PF_AUTONEG_VAL = 0x200;
+    public final static int PF_PAUSE_VAL = 0x400;
+    public final static int PF_PAUSE_ASYM_VAL = 0x800;
+
+    public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortFeatures> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortFeatures> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortFeatures> ofWireValue(int val) {
+        EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);
+
+        if((val & PF_10MB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10MB_HD);
+        if((val & PF_10MB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10MB_FD);
+        if((val & PF_100MB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100MB_HD);
+        if((val & PF_100MB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100MB_FD);
+        if((val & PF_1GB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1GB_HD);
+        if((val & PF_1GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1GB_FD);
+        if((val & PF_10GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10GB_FD);
+        if((val & PF_COPPER_VAL) != 0)
+            set.add(OFPortFeatures.PF_COPPER);
+        if((val & PF_FIBER_VAL) != 0)
+            set.add(OFPortFeatures.PF_FIBER);
+        if((val & PF_AUTONEG_VAL) != 0)
+            set.add(OFPortFeatures.PF_AUTONEG);
+        if((val & PF_PAUSE_VAL) != 0)
+            set.add(OFPortFeatures.PF_PAUSE);
+        if((val & PF_PAUSE_ASYM_VAL) != 0)
+            set.add(OFPortFeatures.PF_PAUSE_ASYM);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortFeatures> set) {
+        int wireValue = 0;
+
+        for(OFPortFeatures e: set) {
+            switch(e) {
+                case PF_10MB_HD:
+                    wireValue |= PF_10MB_HD_VAL;
+                    break;
+                case PF_10MB_FD:
+                    wireValue |= PF_10MB_FD_VAL;
+                    break;
+                case PF_100MB_HD:
+                    wireValue |= PF_100MB_HD_VAL;
+                    break;
+                case PF_100MB_FD:
+                    wireValue |= PF_100MB_FD_VAL;
+                    break;
+                case PF_1GB_HD:
+                    wireValue |= PF_1GB_HD_VAL;
+                    break;
+                case PF_1GB_FD:
+                    wireValue |= PF_1GB_FD_VAL;
+                    break;
+                case PF_10GB_FD:
+                    wireValue |= PF_10GB_FD_VAL;
+                    break;
+                case PF_COPPER:
+                    wireValue |= PF_COPPER_VAL;
+                    break;
+                case PF_FIBER:
+                    wireValue |= PF_FIBER_VAL;
+                    break;
+                case PF_AUTONEG:
+                    wireValue |= PF_AUTONEG_VAL;
+                    break;
+                case PF_PAUSE:
+                    wireValue |= PF_PAUSE_VAL;
+                    break;
+                case PF_PAUSE_ASYM:
+                    wireValue |= PF_PAUSE_ASYM_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortFeatures in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModFailedCodeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModFailedCodeSerializerVer10.java
new file mode 100644
index 0000000..5e7a87d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModFailedCodeSerializerVer10.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPortModFailedCodeSerializerVer10 {
+
+    public final static short BAD_PORT_VAL = (short) 0x0;
+    public final static short BAD_HW_ADDR_VAL = (short) 0x1;
+
+    public static OFPortModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPortModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFPortModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFPortModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_PORT_VAL:
+                return OFPortModFailedCode.BAD_PORT;
+            case BAD_HW_ADDR_VAL:
+                return OFPortModFailedCode.BAD_HW_ADDR;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPortModFailedCode in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFPortModFailedCode e) {
+        switch(e) {
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_HW_ADDR:
+                return BAD_HW_ADDR_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPortModFailedCode in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModFailedErrorMsgVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModFailedErrorMsgVer10.java
new file mode 100644
index 0000000..4159850
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModFailedErrorMsgVer10.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortModFailedErrorMsgVer10 implements OFPortModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortModFailedErrorMsgVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFPortModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortModFailedErrorMsgVer10(long xid, OFPortModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFPortModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortModFailedErrorMsg.Builder {
+        final OFPortModFailedErrorMsgVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFPortModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFPortModFailedErrorMsgVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setCode(OFPortModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPortModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPortModFailedErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFPortModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setCode(OFPortModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPortModFailedErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortModFailedErrorMsg> {
+        @Override
+        public OFPortModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 4
+            short errType = bb.readShort();
+            if(errType != (short) 0x4)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.PORT_MOD_FAILED(4), got="+errType);
+            OFPortModFailedCode code = OFPortModFailedCodeSerializerVer10.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_10);
+
+            OFPortModFailedErrorMsgVer10 portModFailedErrorMsgVer10 = new OFPortModFailedErrorMsgVer10(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portModFailedErrorMsgVer10);
+            return portModFailedErrorMsgVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortModFailedErrorMsgVer10Funnel FUNNEL = new OFPortModFailedErrorMsgVer10Funnel();
+    static class OFPortModFailedErrorMsgVer10Funnel implements Funnel<OFPortModFailedErrorMsgVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortModFailedErrorMsgVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 4
+            sink.putShort((short) 0x4);
+            OFPortModFailedCodeSerializerVer10.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortModFailedErrorMsgVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortModFailedErrorMsgVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 4
+            bb.writeShort((short) 0x4);
+            OFPortModFailedCodeSerializerVer10.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortModFailedErrorMsgVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortModFailedErrorMsgVer10 other = (OFPortModFailedErrorMsgVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModVer10.java
new file mode 100644
index 0000000..e83b993
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModVer10.java
@@ -0,0 +1,522 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortModVer10 implements OFPortMod {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortModVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static long DEFAULT_CONFIG = 0x0L;
+        private final static long DEFAULT_MASK = 0x0L;
+        private final static long DEFAULT_ADVERTISE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort portNo;
+    private final MacAddress hwAddr;
+    private final long config;
+    private final long mask;
+    private final long advertise;
+//
+    // Immutable default instance
+    final static OFPortModVer10 DEFAULT = new OFPortModVer10(
+        DEFAULT_XID, DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_CONFIG, DEFAULT_MASK, DEFAULT_ADVERTISE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortModVer10(long xid, OFPort portNo, MacAddress hwAddr, long config, long mask, long advertise) {
+        this.xid = xid;
+        this.portNo = portNo;
+        this.hwAddr = hwAddr;
+        this.config = config;
+        this.mask = mask;
+        this.advertise = advertise;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+
+
+    public OFPortMod.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortMod.Builder {
+        final OFPortModVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean configSet;
+        private long config;
+        private boolean maskSet;
+        private long mask;
+        private boolean advertiseSet;
+        private long advertise;
+
+        BuilderWithParent(OFPortModVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortMod.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortMod.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFPortMod.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+    @Override
+    public OFPortMod.Builder setAdvertise(long advertise) {
+        this.advertise = advertise;
+        this.advertiseSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortMod build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                long config = this.configSet ? this.config : parentMessage.config;
+                long mask = this.maskSet ? this.mask : parentMessage.mask;
+                long advertise = this.advertiseSet ? this.advertise : parentMessage.advertise;
+
+                //
+                return new OFPortModVer10(
+                    xid,
+                    portNo,
+                    hwAddr,
+                    config,
+                    mask,
+                    advertise
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortMod.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean configSet;
+        private long config;
+        private boolean maskSet;
+        private long mask;
+        private boolean advertiseSet;
+        private long advertise;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortMod.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortMod.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFPortMod.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+    @Override
+    public OFPortMod.Builder setAdvertise(long advertise) {
+        this.advertise = advertise;
+        this.advertiseSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortMod build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+            long mask = this.maskSet ? this.mask : DEFAULT_MASK;
+            long advertise = this.advertiseSet ? this.advertise : DEFAULT_ADVERTISE;
+
+
+            return new OFPortModVer10(
+                    xid,
+                    portNo,
+                    hwAddr,
+                    config,
+                    mask,
+                    advertise
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortMod> {
+        @Override
+        public OFPortMod readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.PORT_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read2Bytes(bb);
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            long config = U32.f(bb.readInt());
+            long mask = U32.f(bb.readInt());
+            long advertise = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFPortModVer10 portModVer10 = new OFPortModVer10(
+                    xid,
+                      portNo,
+                      hwAddr,
+                      config,
+                      mask,
+                      advertise
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portModVer10);
+            return portModVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortModVer10Funnel FUNNEL = new OFPortModVer10Funnel();
+    static class OFPortModVer10Funnel implements Funnel<OFPortModVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortModVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            message.portNo.putTo(sink);
+            message.hwAddr.putTo(sink);
+            sink.putLong(message.config);
+            sink.putLong(message.mask);
+            sink.putLong(message.advertise);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortModVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortModVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            message.portNo.write2Bytes(bb);
+            message.hwAddr.write6Bytes(bb);
+            bb.writeInt(U32.t(message.config));
+            bb.writeInt(U32.t(message.mask));
+            bb.writeInt(U32.t(message.advertise));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortModVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(", ");
+        b.append("advertise=").append(advertise);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortModVer10 other = (OFPortModVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if( config != other.config)
+            return false;
+        if( mask != other.mask)
+            return false;
+        if( advertise != other.advertise)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime *  (int) (config ^ (config >>> 32));
+        result = prime *  (int) (mask ^ (mask >>> 32));
+        result = prime *  (int) (advertise ^ (advertise >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortReasonSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortReasonSerializerVer10.java
new file mode 100644
index 0000000..0fcdea7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortReasonSerializerVer10.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPortReasonSerializerVer10 {
+
+    public final static byte ADD_VAL = (byte) 0x0;
+    public final static byte DELETE_VAL = (byte) 0x1;
+    public final static byte MODIFY_VAL = (byte) 0x2;
+
+    public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPortReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFPortReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFPortReason ofWireValue(byte val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFPortReason.ADD;
+            case DELETE_VAL:
+                return OFPortReason.DELETE;
+            case MODIFY_VAL:
+                return OFPortReason.MODIFY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.0: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFPortReason e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStateSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStateSerializerVer10.java
new file mode 100644
index 0000000..48b7191
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStateSerializerVer10.java
@@ -0,0 +1,103 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortState;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortStateSerializerVer10 {
+
+    public final static int LINK_DOWN_VAL = 0x1;
+    public final static int STP_LISTEN_VAL = 0x0;
+    public final static int STP_LEARN_VAL = 0x100;
+    public final static int STP_FORWARD_VAL = 0x200;
+    public final static int STP_BLOCK_VAL = 0x300;
+    public final static int STP_MASK_VAL = 0x300;
+
+    public static Set<OFPortState> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortState> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortState> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortState> ofWireValue(int val) {
+        EnumSet<OFPortState> set = EnumSet.noneOf(OFPortState.class);
+
+        if((val & LINK_DOWN_VAL) != 0)
+            set.add(OFPortState.LINK_DOWN);
+        if((val & STP_MASK_VAL) == STP_LISTEN_VAL)
+            set.add(OFPortState.STP_LISTEN);
+        else if((val & STP_MASK_VAL) == STP_LEARN_VAL)
+            set.add(OFPortState.STP_LEARN);
+        else if((val & STP_MASK_VAL) == STP_FORWARD_VAL)
+            set.add(OFPortState.STP_FORWARD);
+        else if((val & STP_MASK_VAL) == STP_BLOCK_VAL)
+            set.add(OFPortState.STP_BLOCK);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortState> set) {
+        int wireValue = 0;
+
+        for(OFPortState e: set) {
+            switch(e) {
+                case LINK_DOWN:
+                    wireValue |= LINK_DOWN_VAL;
+                    break;
+                case STP_LISTEN:
+                    wireValue |= STP_LISTEN_VAL;
+                    break;
+                case STP_LEARN:
+                    wireValue |= STP_LEARN_VAL;
+                    break;
+                case STP_FORWARD:
+                    wireValue |= STP_FORWARD_VAL;
+                    break;
+                case STP_BLOCK:
+                    wireValue |= STP_BLOCK_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsEntryVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsEntryVer10.java
new file mode 100644
index 0000000..f129f9e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsEntryVer10.java
@@ -0,0 +1,928 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsEntryVer10 implements OFPortStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsEntryVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 104;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static U64 DEFAULT_RX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_RX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_RX_DROPPED = U64.ZERO;
+        private final static U64 DEFAULT_TX_DROPPED = U64.ZERO;
+        private final static U64 DEFAULT_RX_ERRORS = U64.ZERO;
+        private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
+        private final static U64 DEFAULT_RX_FRAME_ERR = U64.ZERO;
+        private final static U64 DEFAULT_RX_OVER_ERR = U64.ZERO;
+        private final static U64 DEFAULT_RX_CRC_ERR = U64.ZERO;
+        private final static U64 DEFAULT_COLLISIONS = U64.ZERO;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final U64 rxPackets;
+    private final U64 txPackets;
+    private final U64 rxBytes;
+    private final U64 txBytes;
+    private final U64 rxDropped;
+    private final U64 txDropped;
+    private final U64 rxErrors;
+    private final U64 txErrors;
+    private final U64 rxFrameErr;
+    private final U64 rxOverErr;
+    private final U64 rxCrcErr;
+    private final U64 collisions;
+//
+    // Immutable default instance
+    final static OFPortStatsEntryVer10 DEFAULT = new OFPortStatsEntryVer10(
+        DEFAULT_PORT_NO, DEFAULT_RX_PACKETS, DEFAULT_TX_PACKETS, DEFAULT_RX_BYTES, DEFAULT_TX_BYTES, DEFAULT_RX_DROPPED, DEFAULT_TX_DROPPED, DEFAULT_RX_ERRORS, DEFAULT_TX_ERRORS, DEFAULT_RX_FRAME_ERR, DEFAULT_RX_OVER_ERR, DEFAULT_RX_CRC_ERR, DEFAULT_COLLISIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsEntryVer10(OFPort portNo, U64 rxPackets, U64 txPackets, U64 rxBytes, U64 txBytes, U64 rxDropped, U64 txDropped, U64 rxErrors, U64 txErrors, U64 rxFrameErr, U64 rxOverErr, U64 rxCrcErr, U64 collisions) {
+        this.portNo = portNo;
+        this.rxPackets = rxPackets;
+        this.txPackets = txPackets;
+        this.rxBytes = rxBytes;
+        this.txBytes = txBytes;
+        this.rxDropped = rxDropped;
+        this.txDropped = txDropped;
+        this.rxErrors = rxErrors;
+        this.txErrors = txErrors;
+        this.rxFrameErr = rxFrameErr;
+        this.rxOverErr = rxOverErr;
+        this.rxCrcErr = rxCrcErr;
+        this.collisions = collisions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFPortStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsEntry.Builder {
+        final OFPortStatsEntryVer10 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean rxPacketsSet;
+        private U64 rxPackets;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean rxBytesSet;
+        private U64 rxBytes;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean rxDroppedSet;
+        private U64 rxDropped;
+        private boolean txDroppedSet;
+        private U64 txDropped;
+        private boolean rxErrorsSet;
+        private U64 rxErrors;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean rxFrameErrSet;
+        private U64 rxFrameErr;
+        private boolean rxOverErrSet;
+        private U64 rxOverErr;
+        private boolean rxCrcErrSet;
+        private U64 rxCrcErr;
+        private boolean collisionsSet;
+        private U64 collisions;
+
+        BuilderWithParent(OFPortStatsEntryVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxPackets(U64 rxPackets) {
+        this.rxPackets = rxPackets;
+        this.rxPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxBytes(U64 rxBytes) {
+        this.rxBytes = rxBytes;
+        this.rxBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxDropped(U64 rxDropped) {
+        this.rxDropped = rxDropped;
+        this.rxDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxDropped(U64 txDropped) {
+        this.txDropped = txDropped;
+        this.txDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxErrors(U64 rxErrors) {
+        this.rxErrors = rxErrors;
+        this.rxErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxFrameErr(U64 rxFrameErr) {
+        this.rxFrameErr = rxFrameErr;
+        this.rxFrameErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxOverErr(U64 rxOverErr) {
+        this.rxOverErr = rxOverErr;
+        this.rxOverErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxCrcErr(U64 rxCrcErr) {
+        this.rxCrcErr = rxCrcErr;
+        this.rxCrcErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setCollisions(U64 collisions) {
+        this.collisions = collisions;
+        this.collisionsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFPortStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                U64 rxPackets = this.rxPacketsSet ? this.rxPackets : parentMessage.rxPackets;
+                if(rxPackets == null)
+                    throw new NullPointerException("Property rxPackets must not be null");
+                U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
+                if(txPackets == null)
+                    throw new NullPointerException("Property txPackets must not be null");
+                U64 rxBytes = this.rxBytesSet ? this.rxBytes : parentMessage.rxBytes;
+                if(rxBytes == null)
+                    throw new NullPointerException("Property rxBytes must not be null");
+                U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
+                if(txBytes == null)
+                    throw new NullPointerException("Property txBytes must not be null");
+                U64 rxDropped = this.rxDroppedSet ? this.rxDropped : parentMessage.rxDropped;
+                if(rxDropped == null)
+                    throw new NullPointerException("Property rxDropped must not be null");
+                U64 txDropped = this.txDroppedSet ? this.txDropped : parentMessage.txDropped;
+                if(txDropped == null)
+                    throw new NullPointerException("Property txDropped must not be null");
+                U64 rxErrors = this.rxErrorsSet ? this.rxErrors : parentMessage.rxErrors;
+                if(rxErrors == null)
+                    throw new NullPointerException("Property rxErrors must not be null");
+                U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
+                if(txErrors == null)
+                    throw new NullPointerException("Property txErrors must not be null");
+                U64 rxFrameErr = this.rxFrameErrSet ? this.rxFrameErr : parentMessage.rxFrameErr;
+                if(rxFrameErr == null)
+                    throw new NullPointerException("Property rxFrameErr must not be null");
+                U64 rxOverErr = this.rxOverErrSet ? this.rxOverErr : parentMessage.rxOverErr;
+                if(rxOverErr == null)
+                    throw new NullPointerException("Property rxOverErr must not be null");
+                U64 rxCrcErr = this.rxCrcErrSet ? this.rxCrcErr : parentMessage.rxCrcErr;
+                if(rxCrcErr == null)
+                    throw new NullPointerException("Property rxCrcErr must not be null");
+                U64 collisions = this.collisionsSet ? this.collisions : parentMessage.collisions;
+                if(collisions == null)
+                    throw new NullPointerException("Property collisions must not be null");
+
+                //
+                return new OFPortStatsEntryVer10(
+                    portNo,
+                    rxPackets,
+                    txPackets,
+                    rxBytes,
+                    txBytes,
+                    rxDropped,
+                    txDropped,
+                    rxErrors,
+                    txErrors,
+                    rxFrameErr,
+                    rxOverErr,
+                    rxCrcErr,
+                    collisions
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean rxPacketsSet;
+        private U64 rxPackets;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean rxBytesSet;
+        private U64 rxBytes;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean rxDroppedSet;
+        private U64 rxDropped;
+        private boolean txDroppedSet;
+        private U64 txDropped;
+        private boolean rxErrorsSet;
+        private U64 rxErrors;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean rxFrameErrSet;
+        private U64 rxFrameErr;
+        private boolean rxOverErrSet;
+        private U64 rxOverErr;
+        private boolean rxCrcErrSet;
+        private U64 rxCrcErr;
+        private boolean collisionsSet;
+        private U64 collisions;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxPackets(U64 rxPackets) {
+        this.rxPackets = rxPackets;
+        this.rxPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxBytes(U64 rxBytes) {
+        this.rxBytes = rxBytes;
+        this.rxBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxDropped(U64 rxDropped) {
+        this.rxDropped = rxDropped;
+        this.rxDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxDropped(U64 txDropped) {
+        this.txDropped = txDropped;
+        this.txDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxErrors(U64 rxErrors) {
+        this.rxErrors = rxErrors;
+        this.rxErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxFrameErr(U64 rxFrameErr) {
+        this.rxFrameErr = rxFrameErr;
+        this.rxFrameErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxOverErr(U64 rxOverErr) {
+        this.rxOverErr = rxOverErr;
+        this.rxOverErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxCrcErr(U64 rxCrcErr) {
+        this.rxCrcErr = rxCrcErr;
+        this.rxCrcErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setCollisions(U64 collisions) {
+        this.collisions = collisions;
+        this.collisionsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFPortStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            U64 rxPackets = this.rxPacketsSet ? this.rxPackets : DEFAULT_RX_PACKETS;
+            if(rxPackets == null)
+                throw new NullPointerException("Property rxPackets must not be null");
+            U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
+            if(txPackets == null)
+                throw new NullPointerException("Property txPackets must not be null");
+            U64 rxBytes = this.rxBytesSet ? this.rxBytes : DEFAULT_RX_BYTES;
+            if(rxBytes == null)
+                throw new NullPointerException("Property rxBytes must not be null");
+            U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
+            if(txBytes == null)
+                throw new NullPointerException("Property txBytes must not be null");
+            U64 rxDropped = this.rxDroppedSet ? this.rxDropped : DEFAULT_RX_DROPPED;
+            if(rxDropped == null)
+                throw new NullPointerException("Property rxDropped must not be null");
+            U64 txDropped = this.txDroppedSet ? this.txDropped : DEFAULT_TX_DROPPED;
+            if(txDropped == null)
+                throw new NullPointerException("Property txDropped must not be null");
+            U64 rxErrors = this.rxErrorsSet ? this.rxErrors : DEFAULT_RX_ERRORS;
+            if(rxErrors == null)
+                throw new NullPointerException("Property rxErrors must not be null");
+            U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
+            if(txErrors == null)
+                throw new NullPointerException("Property txErrors must not be null");
+            U64 rxFrameErr = this.rxFrameErrSet ? this.rxFrameErr : DEFAULT_RX_FRAME_ERR;
+            if(rxFrameErr == null)
+                throw new NullPointerException("Property rxFrameErr must not be null");
+            U64 rxOverErr = this.rxOverErrSet ? this.rxOverErr : DEFAULT_RX_OVER_ERR;
+            if(rxOverErr == null)
+                throw new NullPointerException("Property rxOverErr must not be null");
+            U64 rxCrcErr = this.rxCrcErrSet ? this.rxCrcErr : DEFAULT_RX_CRC_ERR;
+            if(rxCrcErr == null)
+                throw new NullPointerException("Property rxCrcErr must not be null");
+            U64 collisions = this.collisionsSet ? this.collisions : DEFAULT_COLLISIONS;
+            if(collisions == null)
+                throw new NullPointerException("Property collisions must not be null");
+
+
+            return new OFPortStatsEntryVer10(
+                    portNo,
+                    rxPackets,
+                    txPackets,
+                    rxBytes,
+                    txBytes,
+                    rxDropped,
+                    txDropped,
+                    rxErrors,
+                    txErrors,
+                    rxFrameErr,
+                    rxOverErr,
+                    rxCrcErr,
+                    collisions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsEntry> {
+        @Override
+        public OFPortStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read2Bytes(bb);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            U64 rxPackets = U64.ofRaw(bb.readLong());
+            U64 txPackets = U64.ofRaw(bb.readLong());
+            U64 rxBytes = U64.ofRaw(bb.readLong());
+            U64 txBytes = U64.ofRaw(bb.readLong());
+            U64 rxDropped = U64.ofRaw(bb.readLong());
+            U64 txDropped = U64.ofRaw(bb.readLong());
+            U64 rxErrors = U64.ofRaw(bb.readLong());
+            U64 txErrors = U64.ofRaw(bb.readLong());
+            U64 rxFrameErr = U64.ofRaw(bb.readLong());
+            U64 rxOverErr = U64.ofRaw(bb.readLong());
+            U64 rxCrcErr = U64.ofRaw(bb.readLong());
+            U64 collisions = U64.ofRaw(bb.readLong());
+
+            OFPortStatsEntryVer10 portStatsEntryVer10 = new OFPortStatsEntryVer10(
+                    portNo,
+                      rxPackets,
+                      txPackets,
+                      rxBytes,
+                      txBytes,
+                      rxDropped,
+                      txDropped,
+                      rxErrors,
+                      txErrors,
+                      rxFrameErr,
+                      rxOverErr,
+                      rxCrcErr,
+                      collisions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsEntryVer10);
+            return portStatsEntryVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsEntryVer10Funnel FUNNEL = new OFPortStatsEntryVer10Funnel();
+    static class OFPortStatsEntryVer10Funnel implements Funnel<OFPortStatsEntryVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsEntryVer10 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            // skip pad (6 bytes)
+            message.rxPackets.putTo(sink);
+            message.txPackets.putTo(sink);
+            message.rxBytes.putTo(sink);
+            message.txBytes.putTo(sink);
+            message.rxDropped.putTo(sink);
+            message.txDropped.putTo(sink);
+            message.rxErrors.putTo(sink);
+            message.txErrors.putTo(sink);
+            message.rxFrameErr.putTo(sink);
+            message.rxOverErr.putTo(sink);
+            message.rxCrcErr.putTo(sink);
+            message.collisions.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsEntryVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsEntryVer10 message) {
+            message.portNo.write2Bytes(bb);
+            // pad: 6 bytes
+            bb.writeZero(6);
+            bb.writeLong(message.rxPackets.getValue());
+            bb.writeLong(message.txPackets.getValue());
+            bb.writeLong(message.rxBytes.getValue());
+            bb.writeLong(message.txBytes.getValue());
+            bb.writeLong(message.rxDropped.getValue());
+            bb.writeLong(message.txDropped.getValue());
+            bb.writeLong(message.rxErrors.getValue());
+            bb.writeLong(message.txErrors.getValue());
+            bb.writeLong(message.rxFrameErr.getValue());
+            bb.writeLong(message.rxOverErr.getValue());
+            bb.writeLong(message.rxCrcErr.getValue());
+            bb.writeLong(message.collisions.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsEntryVer10(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("rxPackets=").append(rxPackets);
+        b.append(", ");
+        b.append("txPackets=").append(txPackets);
+        b.append(", ");
+        b.append("rxBytes=").append(rxBytes);
+        b.append(", ");
+        b.append("txBytes=").append(txBytes);
+        b.append(", ");
+        b.append("rxDropped=").append(rxDropped);
+        b.append(", ");
+        b.append("txDropped=").append(txDropped);
+        b.append(", ");
+        b.append("rxErrors=").append(rxErrors);
+        b.append(", ");
+        b.append("txErrors=").append(txErrors);
+        b.append(", ");
+        b.append("rxFrameErr=").append(rxFrameErr);
+        b.append(", ");
+        b.append("rxOverErr=").append(rxOverErr);
+        b.append(", ");
+        b.append("rxCrcErr=").append(rxCrcErr);
+        b.append(", ");
+        b.append("collisions=").append(collisions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsEntryVer10 other = (OFPortStatsEntryVer10) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (rxPackets == null) {
+            if (other.rxPackets != null)
+                return false;
+        } else if (!rxPackets.equals(other.rxPackets))
+            return false;
+        if (txPackets == null) {
+            if (other.txPackets != null)
+                return false;
+        } else if (!txPackets.equals(other.txPackets))
+            return false;
+        if (rxBytes == null) {
+            if (other.rxBytes != null)
+                return false;
+        } else if (!rxBytes.equals(other.rxBytes))
+            return false;
+        if (txBytes == null) {
+            if (other.txBytes != null)
+                return false;
+        } else if (!txBytes.equals(other.txBytes))
+            return false;
+        if (rxDropped == null) {
+            if (other.rxDropped != null)
+                return false;
+        } else if (!rxDropped.equals(other.rxDropped))
+            return false;
+        if (txDropped == null) {
+            if (other.txDropped != null)
+                return false;
+        } else if (!txDropped.equals(other.txDropped))
+            return false;
+        if (rxErrors == null) {
+            if (other.rxErrors != null)
+                return false;
+        } else if (!rxErrors.equals(other.rxErrors))
+            return false;
+        if (txErrors == null) {
+            if (other.txErrors != null)
+                return false;
+        } else if (!txErrors.equals(other.txErrors))
+            return false;
+        if (rxFrameErr == null) {
+            if (other.rxFrameErr != null)
+                return false;
+        } else if (!rxFrameErr.equals(other.rxFrameErr))
+            return false;
+        if (rxOverErr == null) {
+            if (other.rxOverErr != null)
+                return false;
+        } else if (!rxOverErr.equals(other.rxOverErr))
+            return false;
+        if (rxCrcErr == null) {
+            if (other.rxCrcErr != null)
+                return false;
+        } else if (!rxCrcErr.equals(other.rxCrcErr))
+            return false;
+        if (collisions == null) {
+            if (other.collisions != null)
+                return false;
+        } else if (!collisions.equals(other.collisions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((rxPackets == null) ? 0 : rxPackets.hashCode());
+        result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
+        result = prime * result + ((rxBytes == null) ? 0 : rxBytes.hashCode());
+        result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
+        result = prime * result + ((rxDropped == null) ? 0 : rxDropped.hashCode());
+        result = prime * result + ((txDropped == null) ? 0 : txDropped.hashCode());
+        result = prime * result + ((rxErrors == null) ? 0 : rxErrors.hashCode());
+        result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
+        result = prime * result + ((rxFrameErr == null) ? 0 : rxFrameErr.hashCode());
+        result = prime * result + ((rxOverErr == null) ? 0 : rxOverErr.hashCode());
+        result = prime * result + ((rxCrcErr == null) ? 0 : rxCrcErr.hashCode());
+        result = prime * result + ((collisions == null) ? 0 : collisions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsReplyVer10.java
new file mode 100644
index 0000000..0bcde9e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsReplyVer10.java
@@ -0,0 +1,407 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsReplyVer10 implements OFPortStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFPortStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFPortStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFPortStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFPortStatsReplyVer10 DEFAULT = new OFPortStatsReplyVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsReplyVer10(long xid, Set<OFStatsReplyFlags> flags, List<OFPortStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFPortStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsReply.Builder {
+        final OFPortStatsReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortStatsEntry> entries;
+
+        BuilderWithParent(OFPortStatsReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setEntries(List<OFPortStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFPortStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFPortStatsReplyVer10(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setEntries(List<OFPortStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFPortStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFPortStatsReplyVer10(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsReply> {
+        @Override
+        public OFPortStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 4
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x4)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer10.readFrom(bb);
+            List<OFPortStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPortStatsEntryVer10.READER);
+
+            OFPortStatsReplyVer10 portStatsReplyVer10 = new OFPortStatsReplyVer10(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsReplyVer10);
+            return portStatsReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsReplyVer10Funnel FUNNEL = new OFPortStatsReplyVer10Funnel();
+    static class OFPortStatsReplyVer10Funnel implements Funnel<OFPortStatsReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 4
+            sink.putShort((short) 0x4);
+            OFStatsReplyFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsReplyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 4
+            bb.writeShort((short) 0x4);
+            OFStatsReplyFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsReplyVer10 other = (OFPortStatsReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsRequestVer10.java
new file mode 100644
index 0000000..837de43
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsRequestVer10.java
@@ -0,0 +1,405 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsRequestVer10 implements OFPortStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+//
+    // Immutable default instance
+    final static OFPortStatsRequestVer10 DEFAULT = new OFPortStatsRequestVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsRequestVer10(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+
+
+    public OFPortStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsRequest.Builder {
+        final OFPortStatsRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+        BuilderWithParent(OFPortStatsRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+
+                //
+                return new OFPortStatsRequestVer10(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+
+
+            return new OFPortStatsRequestVer10(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsRequest> {
+        @Override
+        public OFPortStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 4
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x4)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer10.readFrom(bb);
+            OFPort portNo = OFPort.read2Bytes(bb);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFPortStatsRequestVer10 portStatsRequestVer10 = new OFPortStatsRequestVer10(
+                    xid,
+                      flags,
+                      portNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsRequestVer10);
+            return portStatsRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsRequestVer10Funnel FUNNEL = new OFPortStatsRequestVer10Funnel();
+    static class OFPortStatsRequestVer10Funnel implements Funnel<OFPortStatsRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 4
+            sink.putShort((short) 0x4);
+            OFStatsRequestFlagsSerializerVer10.putTo(message.flags, sink);
+            message.portNo.putTo(sink);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 4
+            bb.writeShort((short) 0x4);
+            OFStatsRequestFlagsSerializerVer10.writeTo(bb, message.flags);
+            message.portNo.write2Bytes(bb);
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsRequestVer10 other = (OFPortStatsRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatusVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatusVer10.java
new file mode 100644
index 0000000..ec71b10
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatusVer10.java
@@ -0,0 +1,377 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatusVer10 implements OFPortStatus {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatusVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 64;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFPortReason reason;
+    private final OFPortDesc desc;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatusVer10(long xid, OFPortReason reason, OFPortDesc desc) {
+        this.xid = xid;
+        this.reason = reason;
+        this.desc = desc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+
+
+    public OFPortStatus.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatus.Builder {
+        final OFPortStatusVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reasonSet;
+        private OFPortReason reason;
+        private boolean descSet;
+        private OFPortDesc desc;
+
+        BuilderWithParent(OFPortStatusVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortStatus.Builder setReason(OFPortReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+    @Override
+    public OFPortStatus.Builder setDesc(OFPortDesc desc) {
+        this.desc = desc;
+        this.descSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatus build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPortReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                OFPortDesc desc = this.descSet ? this.desc : parentMessage.desc;
+                if(desc == null)
+                    throw new NullPointerException("Property desc must not be null");
+
+                //
+                return new OFPortStatusVer10(
+                    xid,
+                    reason,
+                    desc
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatus.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reasonSet;
+        private OFPortReason reason;
+        private boolean descSet;
+        private OFPortDesc desc;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortStatus.Builder setReason(OFPortReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+    @Override
+    public OFPortStatus.Builder setDesc(OFPortDesc desc) {
+        this.desc = desc;
+        this.descSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatus build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            if(!this.descSet)
+                throw new IllegalStateException("Property desc doesn't have default value -- must be set");
+            if(desc == null)
+                throw new NullPointerException("Property desc must not be null");
+
+
+            return new OFPortStatusVer10(
+                    xid,
+                    reason,
+                    desc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatus> {
+        @Override
+        public OFPortStatus readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 12
+            byte type = bb.readByte();
+            if(type != (byte) 0xc)
+                throw new OFParseError("Wrong type: Expected=OFType.PORT_STATUS(12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 64)
+                throw new OFParseError("Wrong length: Expected=64(64), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPortReason reason = OFPortReasonSerializerVer10.readFrom(bb);
+            // pad: 7 bytes
+            bb.skipBytes(7);
+            OFPortDesc desc = OFPortDescVer10.READER.readFrom(bb);
+
+            OFPortStatusVer10 portStatusVer10 = new OFPortStatusVer10(
+                    xid,
+                      reason,
+                      desc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatusVer10);
+            return portStatusVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatusVer10Funnel FUNNEL = new OFPortStatusVer10Funnel();
+    static class OFPortStatusVer10Funnel implements Funnel<OFPortStatusVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatusVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 12
+            sink.putByte((byte) 0xc);
+            // fixed value property length = 64
+            sink.putShort((short) 0x40);
+            sink.putLong(message.xid);
+            OFPortReasonSerializerVer10.putTo(message.reason, sink);
+            // skip pad (7 bytes)
+            message.desc.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatusVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatusVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 12
+            bb.writeByte((byte) 0xc);
+            // fixed value property length = 64
+            bb.writeShort((short) 0x40);
+            bb.writeInt(U32.t(message.xid));
+            OFPortReasonSerializerVer10.writeTo(bb, message.reason);
+            // pad: 7 bytes
+            bb.writeZero(7);
+            message.desc.writeTo(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatusVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("desc=").append(desc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatusVer10 other = (OFPortStatusVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (desc == null) {
+            if (other.desc != null)
+                return false;
+        } else if (!desc.equals(other.desc))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + ((desc == null) ? 0 : desc.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigReplyVer10.java
new file mode 100644
index 0000000..66eff00
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigReplyVer10.java
@@ -0,0 +1,388 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueGetConfigReplyVer10 implements OFQueueGetConfigReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueGetConfigReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static List<OFPacketQueue> DEFAULT_QUEUES = ImmutableList.<OFPacketQueue>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFPort port;
+    private final List<OFPacketQueue> queues;
+//
+    // Immutable default instance
+    final static OFQueueGetConfigReplyVer10 DEFAULT = new OFQueueGetConfigReplyVer10(
+        DEFAULT_XID, DEFAULT_PORT, DEFAULT_QUEUES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueGetConfigReplyVer10(long xid, OFPort port, List<OFPacketQueue> queues) {
+        this.xid = xid;
+        this.port = port;
+        this.queues = queues;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+
+
+    public OFQueueGetConfigReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueGetConfigReply.Builder {
+        final OFQueueGetConfigReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+        private boolean queuesSet;
+        private List<OFPacketQueue> queues;
+
+        BuilderWithParent(OFQueueGetConfigReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setQueues(List<OFPacketQueue> queues) {
+        this.queues = queues;
+        this.queuesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueGetConfigReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                List<OFPacketQueue> queues = this.queuesSet ? this.queues : parentMessage.queues;
+                if(queues == null)
+                    throw new NullPointerException("Property queues must not be null");
+
+                //
+                return new OFQueueGetConfigReplyVer10(
+                    xid,
+                    port,
+                    queues
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueGetConfigReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+        private boolean queuesSet;
+        private List<OFPacketQueue> queues;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setQueues(List<OFPacketQueue> queues) {
+        this.queues = queues;
+        this.queuesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueGetConfigReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            List<OFPacketQueue> queues = this.queuesSet ? this.queues : DEFAULT_QUEUES;
+            if(queues == null)
+                throw new NullPointerException("Property queues must not be null");
+
+
+            return new OFQueueGetConfigReplyVer10(
+                    xid,
+                    port,
+                    queues
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueGetConfigReply> {
+        @Override
+        public OFQueueGetConfigReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 21
+            byte type = bb.readByte();
+            if(type != (byte) 0x15)
+                throw new OFParseError("Wrong type: Expected=OFType.QUEUE_GET_CONFIG_REPLY(21), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort port = OFPort.read2Bytes(bb);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            List<OFPacketQueue> queues = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPacketQueueVer10.READER);
+
+            OFQueueGetConfigReplyVer10 queueGetConfigReplyVer10 = new OFQueueGetConfigReplyVer10(
+                    xid,
+                      port,
+                      queues
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueGetConfigReplyVer10);
+            return queueGetConfigReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueGetConfigReplyVer10Funnel FUNNEL = new OFQueueGetConfigReplyVer10Funnel();
+    static class OFQueueGetConfigReplyVer10Funnel implements Funnel<OFQueueGetConfigReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueGetConfigReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 21
+            sink.putByte((byte) 0x15);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.port.putTo(sink);
+            // skip pad (6 bytes)
+            FunnelUtils.putList(message.queues, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueGetConfigReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueGetConfigReplyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 21
+            bb.writeByte((byte) 0x15);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.port.write2Bytes(bb);
+            // pad: 6 bytes
+            bb.writeZero(6);
+            ChannelUtils.writeList(bb, message.queues);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueGetConfigReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("queues=").append(queues);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueGetConfigReplyVer10 other = (OFQueueGetConfigReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if (queues == null) {
+            if (other.queues != null)
+                return false;
+        } else if (!queues.equals(other.queues))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + ((queues == null) ? 0 : queues.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigRequestVer10.java
new file mode 100644
index 0000000..4d4c4bf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigRequestVer10.java
@@ -0,0 +1,327 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueGetConfigRequestVer10 implements OFQueueGetConfigRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueGetConfigRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort port;
+//
+    // Immutable default instance
+    final static OFQueueGetConfigRequestVer10 DEFAULT = new OFQueueGetConfigRequestVer10(
+        DEFAULT_XID, DEFAULT_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueGetConfigRequestVer10(long xid, OFPort port) {
+        this.xid = xid;
+        this.port = port;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+
+
+    public OFQueueGetConfigRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueGetConfigRequest.Builder {
+        final OFQueueGetConfigRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+
+        BuilderWithParent(OFQueueGetConfigRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueGetConfigRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+
+                //
+                return new OFQueueGetConfigRequestVer10(
+                    xid,
+                    port
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueGetConfigRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueGetConfigRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+
+
+            return new OFQueueGetConfigRequestVer10(
+                    xid,
+                    port
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueGetConfigRequest> {
+        @Override
+        public OFQueueGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 20
+            byte type = bb.readByte();
+            if(type != (byte) 0x14)
+                throw new OFParseError("Wrong type: Expected=OFType.QUEUE_GET_CONFIG_REQUEST(20), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort port = OFPort.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFQueueGetConfigRequestVer10 queueGetConfigRequestVer10 = new OFQueueGetConfigRequestVer10(
+                    xid,
+                      port
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueGetConfigRequestVer10);
+            return queueGetConfigRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueGetConfigRequestVer10Funnel FUNNEL = new OFQueueGetConfigRequestVer10Funnel();
+    static class OFQueueGetConfigRequestVer10Funnel implements Funnel<OFQueueGetConfigRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueGetConfigRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 20
+            sink.putByte((byte) 0x14);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            message.port.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueGetConfigRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueGetConfigRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 20
+            bb.writeByte((byte) 0x14);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            message.port.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueGetConfigRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueGetConfigRequestVer10 other = (OFQueueGetConfigRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueOpFailedCodeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueOpFailedCodeSerializerVer10.java
new file mode 100644
index 0000000..01fcbc2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueOpFailedCodeSerializerVer10.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFQueueOpFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFQueueOpFailedCodeSerializerVer10 {
+
+    public final static short BAD_PORT_VAL = (short) 0x0;
+    public final static short BAD_QUEUE_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+
+    public static OFQueueOpFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFQueueOpFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFQueueOpFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFQueueOpFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_PORT_VAL:
+                return OFQueueOpFailedCode.BAD_PORT;
+            case BAD_QUEUE_VAL:
+                return OFQueueOpFailedCode.BAD_QUEUE;
+            case EPERM_VAL:
+                return OFQueueOpFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFQueueOpFailedCode in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFQueueOpFailedCode e) {
+        switch(e) {
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_QUEUE:
+                return BAD_QUEUE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFQueueOpFailedCode in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueOpFailedErrorMsgVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueOpFailedErrorMsgVer10.java
new file mode 100644
index 0000000..5ed21f9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueOpFailedErrorMsgVer10.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueOpFailedErrorMsgVer10 implements OFQueueOpFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueOpFailedErrorMsgVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFQueueOpFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueOpFailedErrorMsgVer10(long xid, OFQueueOpFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFQueueOpFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueOpFailedErrorMsg.Builder {
+        final OFQueueOpFailedErrorMsgVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFQueueOpFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFQueueOpFailedErrorMsgVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setCode(OFQueueOpFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueOpFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFQueueOpFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFQueueOpFailedErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueOpFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFQueueOpFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setCode(OFQueueOpFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueOpFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFQueueOpFailedErrorMsgVer10(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueOpFailedErrorMsg> {
+        @Override
+        public OFQueueOpFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 5
+            short errType = bb.readShort();
+            if(errType != (short) 0x5)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.QUEUE_OP_FAILED(5), got="+errType);
+            OFQueueOpFailedCode code = OFQueueOpFailedCodeSerializerVer10.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_10);
+
+            OFQueueOpFailedErrorMsgVer10 queueOpFailedErrorMsgVer10 = new OFQueueOpFailedErrorMsgVer10(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueOpFailedErrorMsgVer10);
+            return queueOpFailedErrorMsgVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueOpFailedErrorMsgVer10Funnel FUNNEL = new OFQueueOpFailedErrorMsgVer10Funnel();
+    static class OFQueueOpFailedErrorMsgVer10Funnel implements Funnel<OFQueueOpFailedErrorMsgVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueOpFailedErrorMsgVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 5
+            sink.putShort((short) 0x5);
+            OFQueueOpFailedCodeSerializerVer10.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueOpFailedErrorMsgVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueOpFailedErrorMsgVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 5
+            bb.writeShort((short) 0x5);
+            OFQueueOpFailedCodeSerializerVer10.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueOpFailedErrorMsgVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueOpFailedErrorMsgVer10 other = (OFQueueOpFailedErrorMsgVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropMinRateVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropMinRateVer10.java
new file mode 100644
index 0000000..8c8876e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropMinRateVer10.java
@@ -0,0 +1,270 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueuePropMinRateVer10 implements OFQueuePropMinRate {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueuePropMinRateVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 16;
+
+        private final static int DEFAULT_RATE = 0x0;
+
+    // OF message fields
+    private final int rate;
+//
+    // Immutable default instance
+    final static OFQueuePropMinRateVer10 DEFAULT = new OFQueuePropMinRateVer10(
+        DEFAULT_RATE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueuePropMinRateVer10(int rate) {
+        this.rate = rate;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFQueuePropMinRate.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueuePropMinRate.Builder {
+        final OFQueuePropMinRateVer10 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+        BuilderWithParent(OFQueuePropMinRateVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMinRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFQueuePropMinRate build() {
+                int rate = this.rateSet ? this.rate : parentMessage.rate;
+
+                //
+                return new OFQueuePropMinRateVer10(
+                    rate
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueuePropMinRate.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMinRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFQueuePropMinRate build() {
+            int rate = this.rateSet ? this.rate : DEFAULT_RATE;
+
+
+            return new OFQueuePropMinRateVer10(
+                    rate
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueuePropMinRate> {
+        @Override
+        public OFQueuePropMinRate readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int rate = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFQueuePropMinRateVer10 queuePropMinRateVer10 = new OFQueuePropMinRateVer10(
+                    rate
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queuePropMinRateVer10);
+            return queuePropMinRateVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueuePropMinRateVer10Funnel FUNNEL = new OFQueuePropMinRateVer10Funnel();
+    static class OFQueuePropMinRateVer10Funnel implements Funnel<OFQueuePropMinRateVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueuePropMinRateVer10 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // skip pad (4 bytes)
+            sink.putInt(message.rate);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueuePropMinRateVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueuePropMinRateVer10 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeShort(U16.t(message.rate));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueuePropMinRateVer10(");
+        b.append("rate=").append(rate);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueuePropMinRateVer10 other = (OFQueuePropMinRateVer10) obj;
+
+        if( rate != other.rate)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + rate;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropVer10.java
new file mode 100644
index 0000000..647c927
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropVer10.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFQueuePropVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFQueuePropVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFQueueProp> {
+        @Override
+        public OFQueueProp readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFQueuePropMinRateVer10
+                   return OFQueuePropMinRateVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFQueuePropVer10: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropertiesSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropertiesSerializerVer10.java
new file mode 100644
index 0000000..2d69bcf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropertiesSerializerVer10.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFQueueProperties;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFQueuePropertiesSerializerVer10 {
+
+    public final static int NONE_VAL = 0x0;
+    public final static int MIN_RATE_VAL = 0x1;
+
+    public static OFQueueProperties readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFQueueProperties e) {
+        bb.writeInt(toWireValue(e));
+    }
+
+    public static void putTo(OFQueueProperties e, PrimitiveSink sink) {
+        sink.putInt(toWireValue(e));
+    }
+
+    public static OFQueueProperties ofWireValue(int val) {
+        switch(val) {
+            case NONE_VAL:
+                return OFQueueProperties.NONE;
+            case MIN_RATE_VAL:
+                return OFQueueProperties.MIN_RATE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFQueueProperties in version 1.0: " + val);
+        }
+    }
+
+
+    public static int toWireValue(OFQueueProperties e) {
+        switch(e) {
+            case NONE:
+                return NONE_VAL;
+            case MIN_RATE:
+                return MIN_RATE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFQueueProperties in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropsVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropsVer10.java
new file mode 100644
index 0000000..044a6c7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueuePropsVer10.java
@@ -0,0 +1,58 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFQueuePropsVer10 implements OFQueueProps {
+    public final static OFQueuePropsVer10 INSTANCE = new OFQueuePropsVer10();
+
+
+
+
+    public OFQueuePropMinRate.Builder buildMinRate() {
+        return new OFQueuePropMinRateVer10.Builder();
+    }
+    public OFQueuePropMinRate minRate(int rate) {
+        return new OFQueuePropMinRateVer10(
+                rate
+                    );
+    }
+
+    public OFQueuePropMaxRate.Builder buildMaxRate() {
+        throw new UnsupportedOperationException("OFQueuePropMaxRate not supported in version 1.0");
+    }
+    public OFQueuePropMaxRate maxRate(int rate) {
+        throw new UnsupportedOperationException("OFQueuePropMaxRate not supported in version 1.0");
+    }
+
+    public OFMessageReader<OFQueueProp> getReader() {
+        return OFQueuePropVer10.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_10;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsEntryVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsEntryVer10.java
new file mode 100644
index 0000000..9354936
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsEntryVer10.java
@@ -0,0 +1,489 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsEntryVer10 implements OFQueueStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsEntryVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 32;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+        private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final long queueId;
+    private final U64 txBytes;
+    private final U64 txPackets;
+    private final U64 txErrors;
+//
+    // Immutable default instance
+    final static OFQueueStatsEntryVer10 DEFAULT = new OFQueueStatsEntryVer10(
+        DEFAULT_PORT_NO, DEFAULT_QUEUE_ID, DEFAULT_TX_BYTES, DEFAULT_TX_PACKETS, DEFAULT_TX_ERRORS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsEntryVer10(OFPort portNo, long queueId, U64 txBytes, U64 txPackets, U64 txErrors) {
+        this.portNo = portNo;
+        this.queueId = queueId;
+        this.txBytes = txBytes;
+        this.txPackets = txPackets;
+        this.txErrors = txErrors;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFQueueStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsEntry.Builder {
+        final OFQueueStatsEntryVer10 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+
+        BuilderWithParent(OFQueueStatsEntryVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFQueueStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+                U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
+                if(txBytes == null)
+                    throw new NullPointerException("Property txBytes must not be null");
+                U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
+                if(txPackets == null)
+                    throw new NullPointerException("Property txPackets must not be null");
+                U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
+                if(txErrors == null)
+                    throw new NullPointerException("Property txErrors must not be null");
+
+                //
+                return new OFQueueStatsEntryVer10(
+                    portNo,
+                    queueId,
+                    txBytes,
+                    txPackets,
+                    txErrors
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.0");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.0");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFQueueStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+            U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
+            if(txBytes == null)
+                throw new NullPointerException("Property txBytes must not be null");
+            U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
+            if(txPackets == null)
+                throw new NullPointerException("Property txPackets must not be null");
+            U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
+            if(txErrors == null)
+                throw new NullPointerException("Property txErrors must not be null");
+
+
+            return new OFQueueStatsEntryVer10(
+                    portNo,
+                    queueId,
+                    txBytes,
+                    txPackets,
+                    txErrors
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsEntry> {
+        @Override
+        public OFQueueStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long queueId = U32.f(bb.readInt());
+            U64 txBytes = U64.ofRaw(bb.readLong());
+            U64 txPackets = U64.ofRaw(bb.readLong());
+            U64 txErrors = U64.ofRaw(bb.readLong());
+
+            OFQueueStatsEntryVer10 queueStatsEntryVer10 = new OFQueueStatsEntryVer10(
+                    portNo,
+                      queueId,
+                      txBytes,
+                      txPackets,
+                      txErrors
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsEntryVer10);
+            return queueStatsEntryVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsEntryVer10Funnel FUNNEL = new OFQueueStatsEntryVer10Funnel();
+    static class OFQueueStatsEntryVer10Funnel implements Funnel<OFQueueStatsEntryVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsEntryVer10 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.queueId);
+            message.txBytes.putTo(sink);
+            message.txPackets.putTo(sink);
+            message.txErrors.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsEntryVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsEntryVer10 message) {
+            message.portNo.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.queueId));
+            bb.writeLong(message.txBytes.getValue());
+            bb.writeLong(message.txPackets.getValue());
+            bb.writeLong(message.txErrors.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsEntryVer10(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(", ");
+        b.append("txBytes=").append(txBytes);
+        b.append(", ");
+        b.append("txPackets=").append(txPackets);
+        b.append(", ");
+        b.append("txErrors=").append(txErrors);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsEntryVer10 other = (OFQueueStatsEntryVer10) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        if (txBytes == null) {
+            if (other.txBytes != null)
+                return false;
+        } else if (!txBytes.equals(other.txBytes))
+            return false;
+        if (txPackets == null) {
+            if (other.txPackets != null)
+                return false;
+        } else if (!txPackets.equals(other.txPackets))
+            return false;
+        if (txErrors == null) {
+            if (other.txErrors != null)
+                return false;
+        } else if (!txErrors.equals(other.txErrors))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
+        result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
+        result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsReplyVer10.java
new file mode 100644
index 0000000..d78fd11
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsReplyVer10.java
@@ -0,0 +1,407 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsReplyVer10 implements OFQueueStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFQueueStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFQueueStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFQueueStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFQueueStatsReplyVer10 DEFAULT = new OFQueueStatsReplyVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsReplyVer10(long xid, Set<OFStatsReplyFlags> flags, List<OFQueueStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFQueueStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsReply.Builder {
+        final OFQueueStatsReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFQueueStatsEntry> entries;
+
+        BuilderWithParent(OFQueueStatsReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setEntries(List<OFQueueStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFQueueStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFQueueStatsReplyVer10(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFQueueStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setEntries(List<OFQueueStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFQueueStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFQueueStatsReplyVer10(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsReply> {
+        @Override
+        public OFQueueStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 5
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x5)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.QUEUE(5), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer10.readFrom(bb);
+            List<OFQueueStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFQueueStatsEntryVer10.READER);
+
+            OFQueueStatsReplyVer10 queueStatsReplyVer10 = new OFQueueStatsReplyVer10(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsReplyVer10);
+            return queueStatsReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsReplyVer10Funnel FUNNEL = new OFQueueStatsReplyVer10Funnel();
+    static class OFQueueStatsReplyVer10Funnel implements Funnel<OFQueueStatsReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 5
+            sink.putShort((short) 0x5);
+            OFStatsReplyFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsReplyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 5
+            bb.writeShort((short) 0x5);
+            OFStatsReplyFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsReplyVer10 other = (OFQueueStatsReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsRequestVer10.java
new file mode 100644
index 0000000..7f95a6b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueStatsRequestVer10.java
@@ -0,0 +1,452 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsRequestVer10 implements OFQueueStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+    private final long queueId;
+//
+    // Immutable default instance
+    final static OFQueueStatsRequestVer10 DEFAULT = new OFQueueStatsRequestVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO, DEFAULT_QUEUE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsRequestVer10(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo, long queueId) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+        this.queueId = queueId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+
+
+    public OFQueueStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsRequest.Builder {
+        final OFQueueStatsRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+
+        BuilderWithParent(OFQueueStatsRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+
+                //
+                return new OFQueueStatsRequestVer10(
+                    xid,
+                    flags,
+                    portNo,
+                    queueId
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+
+
+            return new OFQueueStatsRequestVer10(
+                    xid,
+                    flags,
+                    portNo,
+                    queueId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsRequest> {
+        @Override
+        public OFQueueStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 5
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x5)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.QUEUE(5), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer10.readFrom(bb);
+            OFPort portNo = OFPort.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long queueId = U32.f(bb.readInt());
+
+            OFQueueStatsRequestVer10 queueStatsRequestVer10 = new OFQueueStatsRequestVer10(
+                    xid,
+                      flags,
+                      portNo,
+                      queueId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsRequestVer10);
+            return queueStatsRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsRequestVer10Funnel FUNNEL = new OFQueueStatsRequestVer10Funnel();
+    static class OFQueueStatsRequestVer10Funnel implements Funnel<OFQueueStatsRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 5
+            sink.putShort((short) 0x5);
+            OFStatsRequestFlagsSerializerVer10.putTo(message.flags, sink);
+            message.portNo.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.queueId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 5
+            bb.writeShort((short) 0x5);
+            OFStatsRequestFlagsSerializerVer10.writeTo(bb, message.flags);
+            message.portNo.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.queueId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsRequestVer10 other = (OFQueueStatsRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFSetConfigVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFSetConfigVer10.java
new file mode 100644
index 0000000..1393ee1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFSetConfigVer10.java
@@ -0,0 +1,370 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFSetConfigVer10 implements OFSetConfig {
+    private static final Logger logger = LoggerFactory.getLogger(OFSetConfigVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFConfigFlags> DEFAULT_FLAGS = ImmutableSet.<OFConfigFlags>of();
+        private final static int DEFAULT_MISS_SEND_LEN = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFConfigFlags> flags;
+    private final int missSendLen;
+//
+    // Immutable default instance
+    final static OFSetConfigVer10 DEFAULT = new OFSetConfigVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MISS_SEND_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFSetConfigVer10(long xid, Set<OFConfigFlags> flags, int missSendLen) {
+        this.xid = xid;
+        this.flags = flags;
+        this.missSendLen = missSendLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+
+
+    public OFSetConfig.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFSetConfig.Builder {
+        final OFSetConfigVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+        BuilderWithParent(OFSetConfigVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSetConfig.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFSetConfig.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFSetConfig.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFSetConfig build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFConfigFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int missSendLen = this.missSendLenSet ? this.missSendLen : parentMessage.missSendLen;
+
+                //
+                return new OFSetConfigVer10(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFSetConfig.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSetConfig.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFSetConfig.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFSetConfig.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFSetConfig build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFConfigFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int missSendLen = this.missSendLenSet ? this.missSendLen : DEFAULT_MISS_SEND_LEN;
+
+
+            return new OFSetConfigVer10(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFSetConfig> {
+        @Override
+        public OFSetConfig readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 9
+            byte type = bb.readByte();
+            if(type != (byte) 0x9)
+                throw new OFParseError("Wrong type: Expected=OFType.SET_CONFIG(9), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Set<OFConfigFlags> flags = OFConfigFlagsSerializerVer10.readFrom(bb);
+            int missSendLen = U16.f(bb.readShort());
+
+            OFSetConfigVer10 setConfigVer10 = new OFSetConfigVer10(
+                    xid,
+                      flags,
+                      missSendLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", setConfigVer10);
+            return setConfigVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFSetConfigVer10Funnel FUNNEL = new OFSetConfigVer10Funnel();
+    static class OFSetConfigVer10Funnel implements Funnel<OFSetConfigVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFSetConfigVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 9
+            sink.putByte((byte) 0x9);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            OFConfigFlagsSerializerVer10.putTo(message.flags, sink);
+            sink.putInt(message.missSendLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFSetConfigVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFSetConfigVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 9
+            bb.writeByte((byte) 0x9);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            OFConfigFlagsSerializerVer10.writeTo(bb, message.flags);
+            bb.writeShort(U16.t(message.missSendLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFSetConfigVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("missSendLen=").append(missSendLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFSetConfigVer10 other = (OFSetConfigVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( missSendLen != other.missSendLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + missSendLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsReplyFlagsSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsReplyFlagsSerializerVer10.java
new file mode 100644
index 0000000..b3db49e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsReplyFlagsSerializerVer10.java
@@ -0,0 +1,78 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFStatsReplyFlagsSerializerVer10 {
+
+    public final static short REPLY_MORE_VAL = (short) 0x1;
+
+    public static Set<OFStatsReplyFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFStatsReplyFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFStatsReplyFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFStatsReplyFlags> ofWireValue(short val) {
+        EnumSet<OFStatsReplyFlags> set = EnumSet.noneOf(OFStatsReplyFlags.class);
+
+        if((val & REPLY_MORE_VAL) != 0)
+            set.add(OFStatsReplyFlags.REPLY_MORE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFStatsReplyFlags> set) {
+        short wireValue = 0;
+
+        for(OFStatsReplyFlags e: set) {
+            switch(e) {
+                case REPLY_MORE:
+                    wireValue |= REPLY_MORE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFStatsReplyFlags in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsReplyVer10.java
new file mode 100644
index 0000000..0250bcc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsReplyVer10.java
@@ -0,0 +1,83 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFStatsReplyVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+
+    public final static OFStatsReplyVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFStatsReply> {
+        @Override
+        public OFStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short statsType = bb.readShort();
+            bb.readerIndex(start);
+            switch(statsType) {
+               case (short) 0x2:
+                   // discriminator value OFStatsType.AGGREGATE=2 for class OFAggregateStatsReplyVer10
+                   return OFAggregateStatsReplyVer10.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFStatsType.EXPERIMENTER=65535 for class OFExperimenterStatsReplyVer10
+                   return OFExperimenterStatsReplyVer10.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFStatsType.DESC=0 for class OFDescStatsReplyVer10
+                   return OFDescStatsReplyVer10.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFStatsType.FLOW=1 for class OFFlowStatsReplyVer10
+                   return OFFlowStatsReplyVer10.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFStatsType.PORT=4 for class OFPortStatsReplyVer10
+                   return OFPortStatsReplyVer10.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFStatsType.QUEUE=5 for class OFQueueStatsReplyVer10
+                   return OFQueueStatsReplyVer10.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFStatsType.TABLE=3 for class OFTableStatsReplyVer10
+                   return OFTableStatsReplyVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator statsType of class OFStatsReplyVer10: " + statsType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsRequestFlagsSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsRequestFlagsSerializerVer10.java
new file mode 100644
index 0000000..1854651
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsRequestFlagsSerializerVer10.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsRequestFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFStatsRequestFlagsSerializerVer10 {
+
+
+    public static Set<OFStatsRequestFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFStatsRequestFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFStatsRequestFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFStatsRequestFlags> ofWireValue(short val) {
+        EnumSet<OFStatsRequestFlags> set = EnumSet.noneOf(OFStatsRequestFlags.class);
+
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFStatsRequestFlags> set) {
+        short wireValue = 0;
+
+        for(OFStatsRequestFlags e: set) {
+            switch(e) {
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFStatsRequestFlags in version 1.0: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsRequestVer10.java
new file mode 100644
index 0000000..06e24d6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsRequestVer10.java
@@ -0,0 +1,83 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFStatsRequestVer10 {
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+
+    public final static OFStatsRequestVer10.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFStatsRequest<?>> {
+        @Override
+        public OFStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short statsType = bb.readShort();
+            bb.readerIndex(start);
+            switch(statsType) {
+               case (short) 0x2:
+                   // discriminator value OFStatsType.AGGREGATE=2 for class OFAggregateStatsRequestVer10
+                   return OFAggregateStatsRequestVer10.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFStatsType.EXPERIMENTER=65535 for class OFExperimenterStatsRequestVer10
+                   return OFExperimenterStatsRequestVer10.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFStatsType.DESC=0 for class OFDescStatsRequestVer10
+                   return OFDescStatsRequestVer10.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFStatsType.FLOW=1 for class OFFlowStatsRequestVer10
+                   return OFFlowStatsRequestVer10.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFStatsType.PORT=4 for class OFPortStatsRequestVer10
+                   return OFPortStatsRequestVer10.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFStatsType.QUEUE=5 for class OFQueueStatsRequestVer10
+                   return OFQueueStatsRequestVer10.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFStatsType.TABLE=3 for class OFTableStatsRequestVer10
+                   return OFTableStatsRequestVer10.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator statsType of class OFStatsRequestVer10: " + statsType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsTypeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsTypeSerializerVer10.java
new file mode 100644
index 0000000..dde6186
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFStatsTypeSerializerVer10.java
@@ -0,0 +1,99 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFStatsTypeSerializerVer10 {
+
+    public final static short DESC_VAL = (short) 0x0;
+    public final static short FLOW_VAL = (short) 0x1;
+    public final static short AGGREGATE_VAL = (short) 0x2;
+    public final static short TABLE_VAL = (short) 0x3;
+    public final static short PORT_VAL = (short) 0x4;
+    public final static short QUEUE_VAL = (short) 0x5;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFStatsType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFStatsType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFStatsType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFStatsType ofWireValue(short val) {
+        switch(val) {
+            case DESC_VAL:
+                return OFStatsType.DESC;
+            case FLOW_VAL:
+                return OFStatsType.FLOW;
+            case AGGREGATE_VAL:
+                return OFStatsType.AGGREGATE;
+            case TABLE_VAL:
+                return OFStatsType.TABLE;
+            case PORT_VAL:
+                return OFStatsType.PORT;
+            case QUEUE_VAL:
+                return OFStatsType.QUEUE;
+            case EXPERIMENTER_VAL:
+                return OFStatsType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.0: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFStatsType e) {
+        switch(e) {
+            case DESC:
+                return DESC_VAL;
+            case FLOW:
+                return FLOW_VAL;
+            case AGGREGATE:
+                return AGGREGATE_VAL;
+            case TABLE:
+                return TABLE_VAL;
+            case PORT:
+                return PORT_VAL;
+            case QUEUE:
+                return QUEUE_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsEntryVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsEntryVer10.java
new file mode 100644
index 0000000..78a7da3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsEntryVer10.java
@@ -0,0 +1,744 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsEntryVer10 implements OFTableStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsEntryVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 64;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static String DEFAULT_NAME = "";
+        private final static int DEFAULT_WILDCARDS = 0x0;
+        private final static long DEFAULT_MAX_ENTRIES = 0x0L;
+        private final static long DEFAULT_ACTIVE_COUNT = 0x0L;
+        private final static U64 DEFAULT_LOOKUP_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_MATCHED_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final TableId tableId;
+    private final String name;
+    private final int wildcards;
+    private final long maxEntries;
+    private final long activeCount;
+    private final U64 lookupCount;
+    private final U64 matchedCount;
+//
+    // Immutable default instance
+    final static OFTableStatsEntryVer10 DEFAULT = new OFTableStatsEntryVer10(
+        DEFAULT_TABLE_ID, DEFAULT_NAME, DEFAULT_WILDCARDS, DEFAULT_MAX_ENTRIES, DEFAULT_ACTIVE_COUNT, DEFAULT_LOOKUP_COUNT, DEFAULT_MATCHED_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsEntryVer10(TableId tableId, String name, int wildcards, long maxEntries, long activeCount, U64 lookupCount, U64 matchedCount) {
+        this.tableId = tableId;
+        this.name = name;
+        this.wildcards = wildcards;
+        this.maxEntries = maxEntries;
+        this.activeCount = activeCount;
+        this.lookupCount = lookupCount;
+        this.matchedCount = matchedCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFMatchBmap getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public long getWriteActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeActions not supported in version 1.0");
+    }
+
+    @Override
+    public long getApplyActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applyActions not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.0");
+    }
+
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.0");
+    }
+
+    @Override
+    public long getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public long getConfig()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property config not supported in version 1.0");
+    }
+
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+    public OFTableStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsEntry.Builder {
+        final OFTableStatsEntryVer10 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+        private boolean activeCountSet;
+        private long activeCount;
+        private boolean lookupCountSet;
+        private U64 lookupCount;
+        private boolean matchedCountSet;
+        private U64 matchedCount;
+
+        BuilderWithParent(OFTableStatsEntryVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public OFMatchBmap getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatch(OFMatchBmap match) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public long getWriteActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeActions not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteActions(long writeActions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeActions not supported in version 1.0");
+    }
+    @Override
+    public long getApplyActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applyActions not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplyActions(long applyActions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applyActions not supported in version 1.0");
+    }
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteSetfields(U64 writeSetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.0");
+    }
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplySetfields(U64 applySetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applySetfields not supported in version 1.0");
+    }
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataMatch(U64 metadataMatch) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.0");
+    }
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataWrite(U64 metadataWrite) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.0");
+    }
+    @Override
+    public long getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setInstructions(long instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public long getConfig()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property config not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setConfig(long config) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property config not supported in version 1.0");
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setActiveCount(long activeCount) {
+        this.activeCount = activeCount;
+        this.activeCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setLookupCount(U64 lookupCount) {
+        this.lookupCount = lookupCount;
+        this.lookupCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatchedCount(U64 matchedCount) {
+        this.matchedCount = matchedCount;
+        this.matchedCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+
+
+        @Override
+        public OFTableStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                int wildcards = this.wildcardsSet ? this.wildcards : parentMessage.wildcards;
+                long maxEntries = this.maxEntriesSet ? this.maxEntries : parentMessage.maxEntries;
+                long activeCount = this.activeCountSet ? this.activeCount : parentMessage.activeCount;
+                U64 lookupCount = this.lookupCountSet ? this.lookupCount : parentMessage.lookupCount;
+                if(lookupCount == null)
+                    throw new NullPointerException("Property lookupCount must not be null");
+                U64 matchedCount = this.matchedCountSet ? this.matchedCount : parentMessage.matchedCount;
+                if(matchedCount == null)
+                    throw new NullPointerException("Property matchedCount must not be null");
+
+                //
+                return new OFTableStatsEntryVer10(
+                    tableId,
+                    name,
+                    wildcards,
+                    maxEntries,
+                    activeCount,
+                    lookupCount,
+                    matchedCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+        private boolean activeCountSet;
+        private long activeCount;
+        private boolean lookupCountSet;
+        private U64 lookupCount;
+        private boolean matchedCountSet;
+        private U64 matchedCount;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public OFMatchBmap getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatch(OFMatchBmap match) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property match not supported in version 1.0");
+    }
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public long getWriteActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeActions not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteActions(long writeActions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeActions not supported in version 1.0");
+    }
+    @Override
+    public long getApplyActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applyActions not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplyActions(long applyActions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applyActions not supported in version 1.0");
+    }
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteSetfields(U64 writeSetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.0");
+    }
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplySetfields(U64 applySetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applySetfields not supported in version 1.0");
+    }
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataMatch(U64 metadataMatch) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.0");
+    }
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataWrite(U64 metadataWrite) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.0");
+    }
+    @Override
+    public long getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setInstructions(long instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.0");
+    }
+    @Override
+    public long getConfig()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property config not supported in version 1.0");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setConfig(long config) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property config not supported in version 1.0");
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setActiveCount(long activeCount) {
+        this.activeCount = activeCount;
+        this.activeCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setLookupCount(U64 lookupCount) {
+        this.lookupCount = lookupCount;
+        this.lookupCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatchedCount(U64 matchedCount) {
+        this.matchedCount = matchedCount;
+        this.matchedCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+//
+        @Override
+        public OFTableStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            int wildcards = this.wildcardsSet ? this.wildcards : DEFAULT_WILDCARDS;
+            long maxEntries = this.maxEntriesSet ? this.maxEntries : DEFAULT_MAX_ENTRIES;
+            long activeCount = this.activeCountSet ? this.activeCount : DEFAULT_ACTIVE_COUNT;
+            U64 lookupCount = this.lookupCountSet ? this.lookupCount : DEFAULT_LOOKUP_COUNT;
+            if(lookupCount == null)
+                throw new NullPointerException("Property lookupCount must not be null");
+            U64 matchedCount = this.matchedCountSet ? this.matchedCount : DEFAULT_MATCHED_COUNT;
+            if(matchedCount == null)
+                throw new NullPointerException("Property matchedCount must not be null");
+
+
+            return new OFTableStatsEntryVer10(
+                    tableId,
+                    name,
+                    wildcards,
+                    maxEntries,
+                    activeCount,
+                    lookupCount,
+                    matchedCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsEntry> {
+        @Override
+        public OFTableStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            String name = ChannelUtils.readFixedLengthString(bb, 32);
+            int wildcards = bb.readInt();
+            long maxEntries = U32.f(bb.readInt());
+            long activeCount = U32.f(bb.readInt());
+            U64 lookupCount = U64.ofRaw(bb.readLong());
+            U64 matchedCount = U64.ofRaw(bb.readLong());
+
+            OFTableStatsEntryVer10 tableStatsEntryVer10 = new OFTableStatsEntryVer10(
+                    tableId,
+                      name,
+                      wildcards,
+                      maxEntries,
+                      activeCount,
+                      lookupCount,
+                      matchedCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsEntryVer10);
+            return tableStatsEntryVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsEntryVer10Funnel FUNNEL = new OFTableStatsEntryVer10Funnel();
+    static class OFTableStatsEntryVer10Funnel implements Funnel<OFTableStatsEntryVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsEntryVer10 message, PrimitiveSink sink) {
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            sink.putUnencodedChars(message.name);
+            sink.putInt(message.wildcards);
+            sink.putLong(message.maxEntries);
+            sink.putLong(message.activeCount);
+            message.lookupCount.putTo(sink);
+            message.matchedCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsEntryVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsEntryVer10 message) {
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 32);
+            bb.writeInt(message.wildcards);
+            bb.writeInt(U32.t(message.maxEntries));
+            bb.writeInt(U32.t(message.activeCount));
+            bb.writeLong(message.lookupCount.getValue());
+            bb.writeLong(message.matchedCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsEntryVer10(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("wildcards=").append(wildcards);
+        b.append(", ");
+        b.append("maxEntries=").append(maxEntries);
+        b.append(", ");
+        b.append("activeCount=").append(activeCount);
+        b.append(", ");
+        b.append("lookupCount=").append(lookupCount);
+        b.append(", ");
+        b.append("matchedCount=").append(matchedCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsEntryVer10 other = (OFTableStatsEntryVer10) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if( wildcards != other.wildcards)
+            return false;
+        if( maxEntries != other.maxEntries)
+            return false;
+        if( activeCount != other.activeCount)
+            return false;
+        if (lookupCount == null) {
+            if (other.lookupCount != null)
+                return false;
+        } else if (!lookupCount.equals(other.lookupCount))
+            return false;
+        if (matchedCount == null) {
+            if (other.matchedCount != null)
+                return false;
+        } else if (!matchedCount.equals(other.matchedCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + wildcards;
+        result = prime *  (int) (maxEntries ^ (maxEntries >>> 32));
+        result = prime *  (int) (activeCount ^ (activeCount >>> 32));
+        result = prime * result + ((lookupCount == null) ? 0 : lookupCount.hashCode());
+        result = prime * result + ((matchedCount == null) ? 0 : matchedCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsReplyVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsReplyVer10.java
new file mode 100644
index 0000000..f94b8cc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsReplyVer10.java
@@ -0,0 +1,407 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsReplyVer10 implements OFTableStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsReplyVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFTableStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFTableStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFTableStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFTableStatsReplyVer10 DEFAULT = new OFTableStatsReplyVer10(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsReplyVer10(long xid, Set<OFStatsReplyFlags> flags, List<OFTableStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFTableStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsReply.Builder {
+        final OFTableStatsReplyVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableStatsEntry> entries;
+
+        BuilderWithParent(OFTableStatsReplyVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setEntries(List<OFTableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFTableStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFTableStatsReplyVer10(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setEntries(List<OFTableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFTableStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFTableStatsReplyVer10(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsReply> {
+        @Override
+        public OFTableStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 3
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x3)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer10.readFrom(bb);
+            List<OFTableStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFTableStatsEntryVer10.READER);
+
+            OFTableStatsReplyVer10 tableStatsReplyVer10 = new OFTableStatsReplyVer10(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsReplyVer10);
+            return tableStatsReplyVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsReplyVer10Funnel FUNNEL = new OFTableStatsReplyVer10Funnel();
+    static class OFTableStatsReplyVer10Funnel implements Funnel<OFTableStatsReplyVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsReplyVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 3
+            sink.putShort((short) 0x3);
+            OFStatsReplyFlagsSerializerVer10.putTo(message.flags, sink);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsReplyVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsReplyVer10 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 3
+            bb.writeShort((short) 0x3);
+            OFStatsReplyFlagsSerializerVer10.writeTo(bb, message.flags);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsReplyVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsReplyVer10 other = (OFTableStatsReplyVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsRequestVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsRequestVer10.java
new file mode 100644
index 0000000..1f930d7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsRequestVer10.java
@@ -0,0 +1,346 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsRequestVer10 implements OFTableStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsRequestVer10.class);
+    // version: 1.0
+    final static byte WIRE_VERSION = 1;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFTableStatsRequestVer10 DEFAULT = new OFTableStatsRequestVer10(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsRequestVer10(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFTableStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsRequest.Builder {
+        final OFTableStatsRequestVer10 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFTableStatsRequestVer10 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFTableStatsRequestVer10(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_10;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFTableStatsRequestVer10(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsRequest> {
+        @Override
+        public OFTableStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 1
+            byte version = bb.readByte();
+            if(version != (byte) 0x1)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 3
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x3)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer10.readFrom(bb);
+
+            OFTableStatsRequestVer10 tableStatsRequestVer10 = new OFTableStatsRequestVer10(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsRequestVer10);
+            return tableStatsRequestVer10;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsRequestVer10Funnel FUNNEL = new OFTableStatsRequestVer10Funnel();
+    static class OFTableStatsRequestVer10Funnel implements Funnel<OFTableStatsRequestVer10> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsRequestVer10 message, PrimitiveSink sink) {
+            // fixed value property version = 1
+            sink.putByte((byte) 0x1);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 3
+            sink.putShort((short) 0x3);
+            OFStatsRequestFlagsSerializerVer10.putTo(message.flags, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsRequestVer10> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsRequestVer10 message) {
+            // fixed value property version = 1
+            bb.writeByte((byte) 0x1);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 3
+            bb.writeShort((short) 0x3);
+            OFStatsRequestFlagsSerializerVer10.writeTo(bb, message.flags);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsRequestVer10(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsRequestVer10 other = (OFTableStatsRequestVer10) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTypeSerializerVer10.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTypeSerializerVer10.java
new file mode 100644
index 0000000..6fb3594
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver10/OFTypeSerializerVer10.java
@@ -0,0 +1,174 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTypeSerializerVer10 {
+
+    public final static byte HELLO_VAL = (byte) 0x0;
+    public final static byte ERROR_VAL = (byte) 0x1;
+    public final static byte ECHO_REQUEST_VAL = (byte) 0x2;
+    public final static byte ECHO_REPLY_VAL = (byte) 0x3;
+    public final static byte EXPERIMENTER_VAL = (byte) 0x4;
+    public final static byte FEATURES_REQUEST_VAL = (byte) 0x5;
+    public final static byte FEATURES_REPLY_VAL = (byte) 0x6;
+    public final static byte GET_CONFIG_REQUEST_VAL = (byte) 0x7;
+    public final static byte GET_CONFIG_REPLY_VAL = (byte) 0x8;
+    public final static byte SET_CONFIG_VAL = (byte) 0x9;
+    public final static byte PACKET_IN_VAL = (byte) 0xa;
+    public final static byte FLOW_REMOVED_VAL = (byte) 0xb;
+    public final static byte PORT_STATUS_VAL = (byte) 0xc;
+    public final static byte PACKET_OUT_VAL = (byte) 0xd;
+    public final static byte FLOW_MOD_VAL = (byte) 0xe;
+    public final static byte PORT_MOD_VAL = (byte) 0xf;
+    public final static byte STATS_REQUEST_VAL = (byte) 0x10;
+    public final static byte STATS_REPLY_VAL = (byte) 0x11;
+    public final static byte BARRIER_REQUEST_VAL = (byte) 0x12;
+    public final static byte BARRIER_REPLY_VAL = (byte) 0x13;
+    public final static byte QUEUE_GET_CONFIG_REQUEST_VAL = (byte) 0x14;
+    public final static byte QUEUE_GET_CONFIG_REPLY_VAL = (byte) 0x15;
+
+    public static OFType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFType e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFType e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFType ofWireValue(byte val) {
+        switch(val) {
+            case HELLO_VAL:
+                return OFType.HELLO;
+            case ERROR_VAL:
+                return OFType.ERROR;
+            case ECHO_REQUEST_VAL:
+                return OFType.ECHO_REQUEST;
+            case ECHO_REPLY_VAL:
+                return OFType.ECHO_REPLY;
+            case EXPERIMENTER_VAL:
+                return OFType.EXPERIMENTER;
+            case FEATURES_REQUEST_VAL:
+                return OFType.FEATURES_REQUEST;
+            case FEATURES_REPLY_VAL:
+                return OFType.FEATURES_REPLY;
+            case GET_CONFIG_REQUEST_VAL:
+                return OFType.GET_CONFIG_REQUEST;
+            case GET_CONFIG_REPLY_VAL:
+                return OFType.GET_CONFIG_REPLY;
+            case SET_CONFIG_VAL:
+                return OFType.SET_CONFIG;
+            case PACKET_IN_VAL:
+                return OFType.PACKET_IN;
+            case FLOW_REMOVED_VAL:
+                return OFType.FLOW_REMOVED;
+            case PORT_STATUS_VAL:
+                return OFType.PORT_STATUS;
+            case PACKET_OUT_VAL:
+                return OFType.PACKET_OUT;
+            case FLOW_MOD_VAL:
+                return OFType.FLOW_MOD;
+            case PORT_MOD_VAL:
+                return OFType.PORT_MOD;
+            case STATS_REQUEST_VAL:
+                return OFType.STATS_REQUEST;
+            case STATS_REPLY_VAL:
+                return OFType.STATS_REPLY;
+            case BARRIER_REQUEST_VAL:
+                return OFType.BARRIER_REQUEST;
+            case BARRIER_REPLY_VAL:
+                return OFType.BARRIER_REPLY;
+            case QUEUE_GET_CONFIG_REQUEST_VAL:
+                return OFType.QUEUE_GET_CONFIG_REQUEST;
+            case QUEUE_GET_CONFIG_REPLY_VAL:
+                return OFType.QUEUE_GET_CONFIG_REPLY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFType in version 1.0: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFType e) {
+        switch(e) {
+            case HELLO:
+                return HELLO_VAL;
+            case ERROR:
+                return ERROR_VAL;
+            case ECHO_REQUEST:
+                return ECHO_REQUEST_VAL;
+            case ECHO_REPLY:
+                return ECHO_REPLY_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            case FEATURES_REQUEST:
+                return FEATURES_REQUEST_VAL;
+            case FEATURES_REPLY:
+                return FEATURES_REPLY_VAL;
+            case GET_CONFIG_REQUEST:
+                return GET_CONFIG_REQUEST_VAL;
+            case GET_CONFIG_REPLY:
+                return GET_CONFIG_REPLY_VAL;
+            case SET_CONFIG:
+                return SET_CONFIG_VAL;
+            case PACKET_IN:
+                return PACKET_IN_VAL;
+            case FLOW_REMOVED:
+                return FLOW_REMOVED_VAL;
+            case PORT_STATUS:
+                return PORT_STATUS_VAL;
+            case PACKET_OUT:
+                return PACKET_OUT_VAL;
+            case FLOW_MOD:
+                return FLOW_MOD_VAL;
+            case PORT_MOD:
+                return PORT_MOD_VAL;
+            case STATS_REQUEST:
+                return STATS_REQUEST_VAL;
+            case STATS_REPLY:
+                return STATS_REPLY_VAL;
+            case BARRIER_REQUEST:
+                return BARRIER_REQUEST_VAL;
+            case BARRIER_REPLY:
+                return BARRIER_REPLY_VAL;
+            case QUEUE_GET_CONFIG_REQUEST:
+                return QUEUE_GET_CONFIG_REQUEST_VAL;
+            case QUEUE_GET_CONFIG_REPLY:
+                return QUEUE_GET_CONFIG_REPLY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFType in version 1.0: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnChecksumVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnChecksumVer11.java
new file mode 100644
index 0000000..0f9ef12
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnChecksumVer11.java
@@ -0,0 +1,313 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnChecksumVer11 implements OFActionBsnChecksum {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnChecksumVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 28;
+
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+
+    // OF message fields
+    private final U128 checksum;
+//
+    // Immutable default instance
+    final static OFActionBsnChecksumVer11 DEFAULT = new OFActionBsnChecksumVer11(
+        DEFAULT_CHECKSUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnChecksumVer11(U128 checksum) {
+        this.checksum = checksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionBsnChecksum.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnChecksum.Builder {
+        final OFActionBsnChecksumVer11 parentMessage;
+
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+        BuilderWithParent(OFActionBsnChecksumVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFActionBsnChecksum.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionBsnChecksum build() {
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+
+                //
+                return new OFActionBsnChecksumVer11(
+                    checksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnChecksum.Builder {
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFActionBsnChecksum.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionBsnChecksum build() {
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+
+
+            return new OFActionBsnChecksumVer11(
+                    checksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnChecksum> {
+        @Override
+        public OFActionBsnChecksum readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 28)
+                throw new OFParseError("Wrong length: Expected=28(28), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            U128 checksum = U128.read16Bytes(bb);
+
+            OFActionBsnChecksumVer11 actionBsnChecksumVer11 = new OFActionBsnChecksumVer11(
+                    checksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnChecksumVer11);
+            return actionBsnChecksumVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnChecksumVer11Funnel FUNNEL = new OFActionBsnChecksumVer11Funnel();
+    static class OFActionBsnChecksumVer11Funnel implements Funnel<OFActionBsnChecksumVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnChecksumVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 28
+            sink.putShort((short) 0x1c);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            message.checksum.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnChecksumVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnChecksumVer11 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 28
+            bb.writeShort((short) 0x1c);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            message.checksum.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnChecksumVer11(");
+        b.append("checksum=").append(checksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnChecksumVer11 other = (OFActionBsnChecksumVer11) obj;
+
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnMirrorVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnMirrorVer11.java
new file mode 100644
index 0000000..ed51203
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnMirrorVer11.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnMirrorVer11 implements OFActionBsnMirror {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnMirrorVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 24;
+
+        private final static OFPort DEFAULT_DEST_PORT = OFPort.ANY;
+        private final static long DEFAULT_VLAN_TAG = 0x0L;
+        private final static short DEFAULT_COPY_STAGE = (short) 0x0;
+
+    // OF message fields
+    private final OFPort destPort;
+    private final long vlanTag;
+    private final short copyStage;
+//
+    // Immutable default instance
+    final static OFActionBsnMirrorVer11 DEFAULT = new OFActionBsnMirrorVer11(
+        DEFAULT_DEST_PORT, DEFAULT_VLAN_TAG, DEFAULT_COPY_STAGE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnMirrorVer11(OFPort destPort, long vlanTag, short copyStage) {
+        this.destPort = destPort;
+        this.vlanTag = vlanTag;
+        this.copyStage = copyStage;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionBsnMirror.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnMirror.Builder {
+        final OFActionBsnMirrorVer11 parentMessage;
+
+        // OF message fields
+        private boolean destPortSet;
+        private OFPort destPort;
+        private boolean vlanTagSet;
+        private long vlanTag;
+        private boolean copyStageSet;
+        private short copyStage;
+
+        BuilderWithParent(OFActionBsnMirrorVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setDestPort(OFPort destPort) {
+        this.destPort = destPort;
+        this.destPortSet = true;
+        return this;
+    }
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setVlanTag(long vlanTag) {
+        this.vlanTag = vlanTag;
+        this.vlanTagSet = true;
+        return this;
+    }
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setCopyStage(short copyStage) {
+        this.copyStage = copyStage;
+        this.copyStageSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionBsnMirror build() {
+                OFPort destPort = this.destPortSet ? this.destPort : parentMessage.destPort;
+                if(destPort == null)
+                    throw new NullPointerException("Property destPort must not be null");
+                long vlanTag = this.vlanTagSet ? this.vlanTag : parentMessage.vlanTag;
+                short copyStage = this.copyStageSet ? this.copyStage : parentMessage.copyStage;
+
+                //
+                return new OFActionBsnMirrorVer11(
+                    destPort,
+                    vlanTag,
+                    copyStage
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnMirror.Builder {
+        // OF message fields
+        private boolean destPortSet;
+        private OFPort destPort;
+        private boolean vlanTagSet;
+        private long vlanTag;
+        private boolean copyStageSet;
+        private short copyStage;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setDestPort(OFPort destPort) {
+        this.destPort = destPort;
+        this.destPortSet = true;
+        return this;
+    }
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setVlanTag(long vlanTag) {
+        this.vlanTag = vlanTag;
+        this.vlanTagSet = true;
+        return this;
+    }
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setCopyStage(short copyStage) {
+        this.copyStage = copyStage;
+        this.copyStageSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionBsnMirror build() {
+            OFPort destPort = this.destPortSet ? this.destPort : DEFAULT_DEST_PORT;
+            if(destPort == null)
+                throw new NullPointerException("Property destPort must not be null");
+            long vlanTag = this.vlanTagSet ? this.vlanTag : DEFAULT_VLAN_TAG;
+            short copyStage = this.copyStageSet ? this.copyStage : DEFAULT_COPY_STAGE;
+
+
+            return new OFActionBsnMirrorVer11(
+                    destPort,
+                    vlanTag,
+                    copyStage
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnMirror> {
+        @Override
+        public OFActionBsnMirror readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+            OFPort destPort = OFPort.read4Bytes(bb);
+            long vlanTag = U32.f(bb.readInt());
+            short copyStage = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionBsnMirrorVer11 actionBsnMirrorVer11 = new OFActionBsnMirrorVer11(
+                    destPort,
+                      vlanTag,
+                      copyStage
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnMirrorVer11);
+            return actionBsnMirrorVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnMirrorVer11Funnel FUNNEL = new OFActionBsnMirrorVer11Funnel();
+    static class OFActionBsnMirrorVer11Funnel implements Funnel<OFActionBsnMirrorVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnMirrorVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+            message.destPort.putTo(sink);
+            sink.putLong(message.vlanTag);
+            sink.putShort(message.copyStage);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnMirrorVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnMirrorVer11 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+            message.destPort.write4Bytes(bb);
+            bb.writeInt(U32.t(message.vlanTag));
+            bb.writeByte(U8.t(message.copyStage));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnMirrorVer11(");
+        b.append("destPort=").append(destPort);
+        b.append(", ");
+        b.append("vlanTag=").append(vlanTag);
+        b.append(", ");
+        b.append("copyStage=").append(copyStage);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnMirrorVer11 other = (OFActionBsnMirrorVer11) obj;
+
+        if (destPort == null) {
+            if (other.destPort != null)
+                return false;
+        } else if (!destPort.equals(other.destPort))
+            return false;
+        if( vlanTag != other.vlanTag)
+            return false;
+        if( copyStage != other.copyStage)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((destPort == null) ? 0 : destPort.hashCode());
+        result = prime *  (int) (vlanTag ^ (vlanTag >>> 32));
+        result = prime * result + copyStage;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnSetTunnelDstVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnSetTunnelDstVer11.java
new file mode 100644
index 0000000..352ae69
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnSetTunnelDstVer11.java
@@ -0,0 +1,306 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnSetTunnelDstVer11 implements OFActionBsnSetTunnelDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnSetTunnelDstVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_DST = 0x0L;
+
+    // OF message fields
+    private final long dst;
+//
+    // Immutable default instance
+    final static OFActionBsnSetTunnelDstVer11 DEFAULT = new OFActionBsnSetTunnelDstVer11(
+        DEFAULT_DST
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnSetTunnelDstVer11(long dst) {
+        this.dst = dst;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionBsnSetTunnelDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnSetTunnelDst.Builder {
+        final OFActionBsnSetTunnelDstVer11 parentMessage;
+
+        // OF message fields
+        private boolean dstSet;
+        private long dst;
+
+        BuilderWithParent(OFActionBsnSetTunnelDstVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFActionBsnSetTunnelDst.Builder setDst(long dst) {
+        this.dst = dst;
+        this.dstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionBsnSetTunnelDst build() {
+                long dst = this.dstSet ? this.dst : parentMessage.dst;
+
+                //
+                return new OFActionBsnSetTunnelDstVer11(
+                    dst
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnSetTunnelDst.Builder {
+        // OF message fields
+        private boolean dstSet;
+        private long dst;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFActionBsnSetTunnelDst.Builder setDst(long dst) {
+        this.dst = dst;
+        this.dstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionBsnSetTunnelDst build() {
+            long dst = this.dstSet ? this.dst : DEFAULT_DST;
+
+
+            return new OFActionBsnSetTunnelDstVer11(
+                    dst
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnSetTunnelDst> {
+        @Override
+        public OFActionBsnSetTunnelDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+            long dst = U32.f(bb.readInt());
+
+            OFActionBsnSetTunnelDstVer11 actionBsnSetTunnelDstVer11 = new OFActionBsnSetTunnelDstVer11(
+                    dst
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnSetTunnelDstVer11);
+            return actionBsnSetTunnelDstVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnSetTunnelDstVer11Funnel FUNNEL = new OFActionBsnSetTunnelDstVer11Funnel();
+    static class OFActionBsnSetTunnelDstVer11Funnel implements Funnel<OFActionBsnSetTunnelDstVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnSetTunnelDstVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+            sink.putLong(message.dst);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnSetTunnelDstVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnSetTunnelDstVer11 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+            bb.writeInt(U32.t(message.dst));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnSetTunnelDstVer11(");
+        b.append("dst=").append(dst);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnSetTunnelDstVer11 other = (OFActionBsnSetTunnelDstVer11) obj;
+
+        if( dst != other.dst)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (dst ^ (dst >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnVer11.java
new file mode 100644
index 0000000..4d830e9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionBsnVer11.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionBsnVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFActionBsnVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionBsn> {
+        @Override
+        public OFActionBsn readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFActionBsnChecksumVer11
+                   return OFActionBsnChecksumVer11.READER.readFrom(bb);
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFActionBsnMirrorVer11
+                   return OFActionBsnMirrorVer11.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFActionBsnSetTunnelDstVer11
+                   return OFActionBsnSetTunnelDstVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionBsnVer11: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionCopyTtlInVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionCopyTtlInVer11.java
new file mode 100644
index 0000000..3aeb423
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionCopyTtlInVer11.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionCopyTtlInVer11 implements OFActionCopyTtlIn {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionCopyTtlInVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionCopyTtlInVer11 DEFAULT = new OFActionCopyTtlInVer11(
+
+    );
+
+    final static OFActionCopyTtlInVer11 INSTANCE = new OFActionCopyTtlInVer11();
+    // private empty constructor - use shared instance!
+    private OFActionCopyTtlInVer11() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.COPY_TTL_IN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionCopyTtlIn.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionCopyTtlInVer11 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionCopyTtlIn> {
+        @Override
+        public OFActionCopyTtlIn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 12
+            short type = bb.readShort();
+            if(type != (short) 0xc)
+                throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_IN(12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionCopyTtlInVer11Funnel FUNNEL = new OFActionCopyTtlInVer11Funnel();
+    static class OFActionCopyTtlInVer11Funnel implements Funnel<OFActionCopyTtlInVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionCopyTtlInVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 12
+            sink.putShort((short) 0xc);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionCopyTtlInVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionCopyTtlInVer11 message) {
+            // fixed value property type = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionCopyTtlInVer11(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionCopyTtlOutVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionCopyTtlOutVer11.java
new file mode 100644
index 0000000..fd72fff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionCopyTtlOutVer11.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionCopyTtlOutVer11 implements OFActionCopyTtlOut {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionCopyTtlOutVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionCopyTtlOutVer11 DEFAULT = new OFActionCopyTtlOutVer11(
+
+    );
+
+    final static OFActionCopyTtlOutVer11 INSTANCE = new OFActionCopyTtlOutVer11();
+    // private empty constructor - use shared instance!
+    private OFActionCopyTtlOutVer11() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.COPY_TTL_OUT;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionCopyTtlOut.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionCopyTtlOutVer11 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionCopyTtlOut> {
+        @Override
+        public OFActionCopyTtlOut readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 11
+            short type = bb.readShort();
+            if(type != (short) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_OUT(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionCopyTtlOutVer11Funnel FUNNEL = new OFActionCopyTtlOutVer11Funnel();
+    static class OFActionCopyTtlOutVer11Funnel implements Funnel<OFActionCopyTtlOutVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionCopyTtlOutVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 11
+            sink.putShort((short) 0xb);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionCopyTtlOutVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionCopyTtlOutVer11 message) {
+            // fixed value property type = 11
+            bb.writeShort((short) 0xb);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionCopyTtlOutVer11(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionDecMplsTtlVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionDecMplsTtlVer11.java
new file mode 100644
index 0000000..b1df509
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionDecMplsTtlVer11.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionDecMplsTtlVer11 implements OFActionDecMplsTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionDecMplsTtlVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionDecMplsTtlVer11 DEFAULT = new OFActionDecMplsTtlVer11(
+
+    );
+
+    final static OFActionDecMplsTtlVer11 INSTANCE = new OFActionDecMplsTtlVer11();
+    // private empty constructor - use shared instance!
+    private OFActionDecMplsTtlVer11() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.DEC_MPLS_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionDecMplsTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionDecMplsTtlVer11 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionDecMplsTtl> {
+        @Override
+        public OFActionDecMplsTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 16
+            short type = bb.readShort();
+            if(type != (short) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFActionType.DEC_MPLS_TTL(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionDecMplsTtlVer11Funnel FUNNEL = new OFActionDecMplsTtlVer11Funnel();
+    static class OFActionDecMplsTtlVer11Funnel implements Funnel<OFActionDecMplsTtlVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionDecMplsTtlVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 16
+            sink.putShort((short) 0x10);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionDecMplsTtlVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionDecMplsTtlVer11 message) {
+            // fixed value property type = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionDecMplsTtlVer11(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionDecNwTtlVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionDecNwTtlVer11.java
new file mode 100644
index 0000000..0d95fc3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionDecNwTtlVer11.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionDecNwTtlVer11 implements OFActionDecNwTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionDecNwTtlVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionDecNwTtlVer11 DEFAULT = new OFActionDecNwTtlVer11(
+
+    );
+
+    final static OFActionDecNwTtlVer11 INSTANCE = new OFActionDecNwTtlVer11();
+    // private empty constructor - use shared instance!
+    private OFActionDecNwTtlVer11() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.DEC_NW_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionDecNwTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionDecNwTtlVer11 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionDecNwTtl> {
+        @Override
+        public OFActionDecNwTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 24
+            short type = bb.readShort();
+            if(type != (short) 0x18)
+                throw new OFParseError("Wrong type: Expected=OFActionType.DEC_NW_TTL(24), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionDecNwTtlVer11Funnel FUNNEL = new OFActionDecNwTtlVer11Funnel();
+    static class OFActionDecNwTtlVer11Funnel implements Funnel<OFActionDecNwTtlVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionDecNwTtlVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 24
+            sink.putShort((short) 0x18);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionDecNwTtlVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionDecNwTtlVer11 message) {
+            // fixed value property type = 24
+            bb.writeShort((short) 0x18);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionDecNwTtlVer11(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionExperimenterVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionExperimenterVer11.java
new file mode 100644
index 0000000..710a54b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionExperimenterVer11.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionExperimenterVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionExperimenterVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionExperimenter> {
+        @Override
+        public OFActionExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFActionBsnVer11
+                   return OFActionBsnVer11.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFActionNiciraVer11
+                   return OFActionNiciraVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFActionExperimenterVer11: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionGroupVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionGroupVer11.java
new file mode 100644
index 0000000..f0e6c2a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionGroupVer11.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionGroupVer11 implements OFActionGroup {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionGroupVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+
+    // OF message fields
+    private final OFGroup group;
+//
+    // Immutable default instance
+    final static OFActionGroupVer11 DEFAULT = new OFActionGroupVer11(
+        DEFAULT_GROUP_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionGroupVer11(OFGroup group) {
+        this.group = group;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionGroup.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionGroup.Builder {
+        final OFActionGroupVer11 parentMessage;
+
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+
+        BuilderWithParent(OFActionGroupVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFActionGroup.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionGroup build() {
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+
+                //
+                return new OFActionGroupVer11(
+                    group
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionGroup.Builder {
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFActionGroup.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionGroup build() {
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+
+
+            return new OFActionGroupVer11(
+                    group
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionGroup> {
+        @Override
+        public OFActionGroup readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 22
+            short type = bb.readShort();
+            if(type != (short) 0x16)
+                throw new OFParseError("Wrong type: Expected=OFActionType.GROUP(22), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFGroup group = OFGroup.read4Bytes(bb);
+
+            OFActionGroupVer11 actionGroupVer11 = new OFActionGroupVer11(
+                    group
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionGroupVer11);
+            return actionGroupVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionGroupVer11Funnel FUNNEL = new OFActionGroupVer11Funnel();
+    static class OFActionGroupVer11Funnel implements Funnel<OFActionGroupVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionGroupVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 22
+            sink.putShort((short) 0x16);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.group.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionGroupVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionGroupVer11 message) {
+            // fixed value property type = 22
+            bb.writeShort((short) 0x16);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.group.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionGroupVer11(");
+        b.append("group=").append(group);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionGroupVer11 other = (OFActionGroupVer11) obj;
+
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionIdsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionIdsVer11.java
new file mode 100644
index 0000000..a91c194
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionIdsVer11.java
@@ -0,0 +1,123 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+
+public class OFActionIdsVer11 implements OFActionIds {
+    public final static OFActionIdsVer11 INSTANCE = new OFActionIdsVer11();
+
+
+
+
+    public OFActionIdBsnChecksum bsnChecksum() {
+        throw new UnsupportedOperationException("OFActionIdBsnChecksum not supported in version 1.1");
+    }
+
+    public OFActionIdBsnMirror bsnMirror() {
+        throw new UnsupportedOperationException("OFActionIdBsnMirror not supported in version 1.1");
+    }
+
+    public OFActionIdBsnSetTunnelDst bsnSetTunnelDst() {
+        throw new UnsupportedOperationException("OFActionIdBsnSetTunnelDst not supported in version 1.1");
+    }
+
+    public OFActionIdCopyTtlIn copyTtlIn() {
+        throw new UnsupportedOperationException("OFActionIdCopyTtlIn not supported in version 1.1");
+    }
+
+    public OFActionIdCopyTtlOut copyTtlOut() {
+        throw new UnsupportedOperationException("OFActionIdCopyTtlOut not supported in version 1.1");
+    }
+
+    public OFActionIdDecMplsTtl decMplsTtl() {
+        throw new UnsupportedOperationException("OFActionIdDecMplsTtl not supported in version 1.1");
+    }
+
+    public OFActionIdDecNwTtl decNwTtl() {
+        throw new UnsupportedOperationException("OFActionIdDecNwTtl not supported in version 1.1");
+    }
+
+    public OFActionIdGroup group() {
+        throw new UnsupportedOperationException("OFActionIdGroup not supported in version 1.1");
+    }
+
+    public OFActionIdNiciraDecTtl niciraDecTtl() {
+        throw new UnsupportedOperationException("OFActionIdNiciraDecTtl not supported in version 1.1");
+    }
+
+    public OFActionIdOutput output() {
+        throw new UnsupportedOperationException("OFActionIdOutput not supported in version 1.1");
+    }
+
+    public OFActionIdPopMpls popMpls() {
+        throw new UnsupportedOperationException("OFActionIdPopMpls not supported in version 1.1");
+    }
+
+    public OFActionIdPopPbb popPbb() {
+        throw new UnsupportedOperationException("OFActionIdPopPbb not supported in version 1.1");
+    }
+
+    public OFActionIdPopVlan popVlan() {
+        throw new UnsupportedOperationException("OFActionIdPopVlan not supported in version 1.1");
+    }
+
+    public OFActionIdPushMpls pushMpls() {
+        throw new UnsupportedOperationException("OFActionIdPushMpls not supported in version 1.1");
+    }
+
+    public OFActionIdPushPbb pushPbb() {
+        throw new UnsupportedOperationException("OFActionIdPushPbb not supported in version 1.1");
+    }
+
+    public OFActionIdPushVlan pushVlan() {
+        throw new UnsupportedOperationException("OFActionIdPushVlan not supported in version 1.1");
+    }
+
+    public OFActionIdSetField setField() {
+        throw new UnsupportedOperationException("OFActionIdSetField not supported in version 1.1");
+    }
+
+    public OFActionIdSetMplsTtl setMplsTtl() {
+        throw new UnsupportedOperationException("OFActionIdSetMplsTtl not supported in version 1.1");
+    }
+
+    public OFActionIdSetNwTtl setNwTtl() {
+        throw new UnsupportedOperationException("OFActionIdSetNwTtl not supported in version 1.1");
+    }
+
+    public OFActionIdSetQueue setQueue() {
+        throw new UnsupportedOperationException("OFActionIdSetQueue not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFActionId> getReader() {
+        throw new UnsupportedOperationException("Reader<OFActionId> not supported in version 1.1");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionNiciraDecTtlVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionNiciraDecTtlVer11.java
new file mode 100644
index 0000000..4216f4e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionNiciraDecTtlVer11.java
@@ -0,0 +1,192 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionNiciraDecTtlVer11 implements OFActionNiciraDecTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionNiciraDecTtlVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionNiciraDecTtlVer11 DEFAULT = new OFActionNiciraDecTtlVer11(
+
+    );
+
+    final static OFActionNiciraDecTtlVer11 INSTANCE = new OFActionNiciraDecTtlVer11();
+    // private empty constructor - use shared instance!
+    private OFActionNiciraDecTtlVer11() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public int getSubtype() {
+        return 0x12;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionNiciraDecTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionNiciraDecTtlVer11 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionNiciraDecTtl> {
+        @Override
+        public OFActionNiciraDecTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            // fixed value property subtype == 0x12
+            short subtype = bb.readShort();
+            if(subtype != (short) 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12(0x12), got="+subtype);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionNiciraDecTtlVer11Funnel FUNNEL = new OFActionNiciraDecTtlVer11Funnel();
+    static class OFActionNiciraDecTtlVer11Funnel implements Funnel<OFActionNiciraDecTtlVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionNiciraDecTtlVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x2320L
+            sink.putInt(0x2320);
+            // fixed value property subtype = 0x12
+            sink.putShort((short) 0x12);
+            // skip pad (2 bytes)
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionNiciraDecTtlVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionNiciraDecTtlVer11 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x2320L
+            bb.writeInt(0x2320);
+            // fixed value property subtype = 0x12
+            bb.writeShort((short) 0x12);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionNiciraDecTtlVer11(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionNiciraVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionNiciraVer11.java
new file mode 100644
index 0000000..a130746
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionNiciraVer11.java
@@ -0,0 +1,64 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionNiciraVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFActionNiciraVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionNicira> {
+        @Override
+        public OFActionNicira readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            short subtype = bb.readShort();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case (short) 0x12:
+                   // discriminator value 0x12=0x12 for class OFActionNiciraDecTtlVer11
+                   return OFActionNiciraDecTtlVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionNiciraVer11: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionOutputVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionOutputVer11.java
new file mode 100644
index 0000000..ccc6138
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionOutputVer11.java
@@ -0,0 +1,319 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionOutputVer11 implements OFActionOutput {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionOutputVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static int DEFAULT_MAX_LEN = 0x0;
+
+    // OF message fields
+    private final OFPort port;
+    private final int maxLen;
+//
+    // Immutable default instance
+    final static OFActionOutputVer11 DEFAULT = new OFActionOutputVer11(
+        DEFAULT_PORT, DEFAULT_MAX_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionOutputVer11(OFPort port, int maxLen) {
+        this.port = port;
+        this.maxLen = maxLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionOutput.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionOutput.Builder {
+        final OFActionOutputVer11 parentMessage;
+
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean maxLenSet;
+        private int maxLen;
+
+        BuilderWithParent(OFActionOutputVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionOutput.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFActionOutput.Builder setMaxLen(int maxLen) {
+        this.maxLen = maxLen;
+        this.maxLenSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionOutput build() {
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                int maxLen = this.maxLenSet ? this.maxLen : parentMessage.maxLen;
+
+                //
+                return new OFActionOutputVer11(
+                    port,
+                    maxLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionOutput.Builder {
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean maxLenSet;
+        private int maxLen;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionOutput.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFActionOutput.Builder setMaxLen(int maxLen) {
+        this.maxLen = maxLen;
+        this.maxLenSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionOutput build() {
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            int maxLen = this.maxLenSet ? this.maxLen : DEFAULT_MAX_LEN;
+
+
+            return new OFActionOutputVer11(
+                    port,
+                    maxLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionOutput> {
+        @Override
+        public OFActionOutput readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFActionType.OUTPUT(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFPort port = OFPort.read4Bytes(bb);
+            int maxLen = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFActionOutputVer11 actionOutputVer11 = new OFActionOutputVer11(
+                    port,
+                      maxLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionOutputVer11);
+            return actionOutputVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionOutputVer11Funnel FUNNEL = new OFActionOutputVer11Funnel();
+    static class OFActionOutputVer11Funnel implements Funnel<OFActionOutputVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionOutputVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            message.port.putTo(sink);
+            sink.putInt(message.maxLen);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionOutputVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionOutputVer11 message) {
+            // fixed value property type = 0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            message.port.write4Bytes(bb);
+            bb.writeShort(U16.t(message.maxLen));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionOutputVer11(");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("maxLen=").append(maxLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionOutputVer11 other = (OFActionOutputVer11) obj;
+
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if( maxLen != other.maxLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + maxLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPopMplsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPopMplsVer11.java
new file mode 100644
index 0000000..f07e019
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPopMplsVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPopMplsVer11 implements OFActionPopMpls {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPopMplsVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPopMplsVer11 DEFAULT = new OFActionPopMplsVer11(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPopMplsVer11(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionPopMpls.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPopMpls.Builder {
+        final OFActionPopMplsVer11 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPopMplsVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPopMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionPopMpls build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPopMplsVer11(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPopMpls.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPopMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionPopMpls build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPopMplsVer11(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPopMpls> {
+        @Override
+        public OFActionPopMpls readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 20
+            short type = bb.readShort();
+            if(type != (short) 0x14)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_MPLS(20), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPopMplsVer11 actionPopMplsVer11 = new OFActionPopMplsVer11(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPopMplsVer11);
+            return actionPopMplsVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPopMplsVer11Funnel FUNNEL = new OFActionPopMplsVer11Funnel();
+    static class OFActionPopMplsVer11Funnel implements Funnel<OFActionPopMplsVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPopMplsVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 20
+            sink.putShort((short) 0x14);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPopMplsVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPopMplsVer11 message) {
+            // fixed value property type = 20
+            bb.writeShort((short) 0x14);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPopMplsVer11(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPopMplsVer11 other = (OFActionPopMplsVer11) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPopVlanVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPopVlanVer11.java
new file mode 100644
index 0000000..f463142
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPopVlanVer11.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPopVlanVer11 implements OFActionPopVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPopVlanVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionPopVlanVer11 DEFAULT = new OFActionPopVlanVer11(
+
+    );
+
+    final static OFActionPopVlanVer11 INSTANCE = new OFActionPopVlanVer11();
+    // private empty constructor - use shared instance!
+    private OFActionPopVlanVer11() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_VLAN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionPopVlan.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionPopVlanVer11 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPopVlan> {
+        @Override
+        public OFActionPopVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 18
+            short type = bb.readShort();
+            if(type != (short) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_VLAN(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPopVlanVer11Funnel FUNNEL = new OFActionPopVlanVer11Funnel();
+    static class OFActionPopVlanVer11Funnel implements Funnel<OFActionPopVlanVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPopVlanVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 18
+            sink.putShort((short) 0x12);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPopVlanVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPopVlanVer11 message) {
+            // fixed value property type = 18
+            bb.writeShort((short) 0x12);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPopVlanVer11(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPushMplsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPushMplsVer11.java
new file mode 100644
index 0000000..8039cea
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPushMplsVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPushMplsVer11 implements OFActionPushMpls {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPushMplsVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPushMplsVer11 DEFAULT = new OFActionPushMplsVer11(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPushMplsVer11(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionPushMpls.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPushMpls.Builder {
+        final OFActionPushMplsVer11 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPushMplsVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionPushMpls build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPushMplsVer11(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPushMpls.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionPushMpls build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPushMplsVer11(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPushMpls> {
+        @Override
+        public OFActionPushMpls readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 19
+            short type = bb.readShort();
+            if(type != (short) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_MPLS(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPushMplsVer11 actionPushMplsVer11 = new OFActionPushMplsVer11(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPushMplsVer11);
+            return actionPushMplsVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPushMplsVer11Funnel FUNNEL = new OFActionPushMplsVer11Funnel();
+    static class OFActionPushMplsVer11Funnel implements Funnel<OFActionPushMplsVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPushMplsVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 19
+            sink.putShort((short) 0x13);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPushMplsVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPushMplsVer11 message) {
+            // fixed value property type = 19
+            bb.writeShort((short) 0x13);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPushMplsVer11(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPushMplsVer11 other = (OFActionPushMplsVer11) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPushVlanVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPushVlanVer11.java
new file mode 100644
index 0000000..25420f1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionPushVlanVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPushVlanVer11 implements OFActionPushVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPushVlanVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPushVlanVer11 DEFAULT = new OFActionPushVlanVer11(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPushVlanVer11(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionPushVlan.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPushVlan.Builder {
+        final OFActionPushVlanVer11 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPushVlanVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushVlan.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionPushVlan build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPushVlanVer11(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPushVlan.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushVlan.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionPushVlan build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPushVlanVer11(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPushVlan> {
+        @Override
+        public OFActionPushVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 17
+            short type = bb.readShort();
+            if(type != (short) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_VLAN(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPushVlanVer11 actionPushVlanVer11 = new OFActionPushVlanVer11(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPushVlanVer11);
+            return actionPushVlanVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPushVlanVer11Funnel FUNNEL = new OFActionPushVlanVer11Funnel();
+    static class OFActionPushVlanVer11Funnel implements Funnel<OFActionPushVlanVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPushVlanVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 17
+            sink.putShort((short) 0x11);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPushVlanVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPushVlanVer11 message) {
+            // fixed value property type = 17
+            bb.writeShort((short) 0x11);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPushVlanVer11(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPushVlanVer11 other = (OFActionPushVlanVer11) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetDlDstVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetDlDstVer11.java
new file mode 100644
index 0000000..1bdf172
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetDlDstVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetDlDstVer11 implements OFActionSetDlDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetDlDstVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_DL_ADDR = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress dlAddr;
+//
+    // Immutable default instance
+    final static OFActionSetDlDstVer11 DEFAULT = new OFActionSetDlDstVer11(
+        DEFAULT_DL_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetDlDstVer11(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_DST;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetDlDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetDlDst.Builder {
+        final OFActionSetDlDstVer11 parentMessage;
+
+        // OF message fields
+        private boolean dlAddrSet;
+        private MacAddress dlAddr;
+
+        BuilderWithParent(OFActionSetDlDstVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_DST;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFActionSetDlDst.Builder setDlAddr(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+        this.dlAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetDlDst build() {
+                MacAddress dlAddr = this.dlAddrSet ? this.dlAddr : parentMessage.dlAddr;
+                if(dlAddr == null)
+                    throw new NullPointerException("Property dlAddr must not be null");
+
+                //
+                return new OFActionSetDlDstVer11(
+                    dlAddr
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetDlDst.Builder {
+        // OF message fields
+        private boolean dlAddrSet;
+        private MacAddress dlAddr;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_DST;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFActionSetDlDst.Builder setDlAddr(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+        this.dlAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetDlDst build() {
+            MacAddress dlAddr = this.dlAddrSet ? this.dlAddr : DEFAULT_DL_ADDR;
+            if(dlAddr == null)
+                throw new NullPointerException("Property dlAddr must not be null");
+
+
+            return new OFActionSetDlDstVer11(
+                    dlAddr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetDlDst> {
+        @Override
+        public OFActionSetDlDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 4
+            short type = bb.readShort();
+            if(type != (short) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_DL_DST(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            MacAddress dlAddr = MacAddress.read6Bytes(bb);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFActionSetDlDstVer11 actionSetDlDstVer11 = new OFActionSetDlDstVer11(
+                    dlAddr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetDlDstVer11);
+            return actionSetDlDstVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetDlDstVer11Funnel FUNNEL = new OFActionSetDlDstVer11Funnel();
+    static class OFActionSetDlDstVer11Funnel implements Funnel<OFActionSetDlDstVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetDlDstVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 4
+            sink.putShort((short) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            message.dlAddr.putTo(sink);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetDlDstVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetDlDstVer11 message) {
+            // fixed value property type = 4
+            bb.writeShort((short) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            message.dlAddr.write6Bytes(bb);
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetDlDstVer11(");
+        b.append("dlAddr=").append(dlAddr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetDlDstVer11 other = (OFActionSetDlDstVer11) obj;
+
+        if (dlAddr == null) {
+            if (other.dlAddr != null)
+                return false;
+        } else if (!dlAddr.equals(other.dlAddr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((dlAddr == null) ? 0 : dlAddr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetDlSrcVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetDlSrcVer11.java
new file mode 100644
index 0000000..873706a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetDlSrcVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetDlSrcVer11 implements OFActionSetDlSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetDlSrcVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_DL_ADDR = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress dlAddr;
+//
+    // Immutable default instance
+    final static OFActionSetDlSrcVer11 DEFAULT = new OFActionSetDlSrcVer11(
+        DEFAULT_DL_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetDlSrcVer11(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_SRC;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetDlSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetDlSrc.Builder {
+        final OFActionSetDlSrcVer11 parentMessage;
+
+        // OF message fields
+        private boolean dlAddrSet;
+        private MacAddress dlAddr;
+
+        BuilderWithParent(OFActionSetDlSrcVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_SRC;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFActionSetDlSrc.Builder setDlAddr(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+        this.dlAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetDlSrc build() {
+                MacAddress dlAddr = this.dlAddrSet ? this.dlAddr : parentMessage.dlAddr;
+                if(dlAddr == null)
+                    throw new NullPointerException("Property dlAddr must not be null");
+
+                //
+                return new OFActionSetDlSrcVer11(
+                    dlAddr
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetDlSrc.Builder {
+        // OF message fields
+        private boolean dlAddrSet;
+        private MacAddress dlAddr;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_DL_SRC;
+    }
+
+    @Override
+    public MacAddress getDlAddr() {
+        return dlAddr;
+    }
+
+    @Override
+    public OFActionSetDlSrc.Builder setDlAddr(MacAddress dlAddr) {
+        this.dlAddr = dlAddr;
+        this.dlAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetDlSrc build() {
+            MacAddress dlAddr = this.dlAddrSet ? this.dlAddr : DEFAULT_DL_ADDR;
+            if(dlAddr == null)
+                throw new NullPointerException("Property dlAddr must not be null");
+
+
+            return new OFActionSetDlSrcVer11(
+                    dlAddr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetDlSrc> {
+        @Override
+        public OFActionSetDlSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 3
+            short type = bb.readShort();
+            if(type != (short) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_DL_SRC(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            MacAddress dlAddr = MacAddress.read6Bytes(bb);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFActionSetDlSrcVer11 actionSetDlSrcVer11 = new OFActionSetDlSrcVer11(
+                    dlAddr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetDlSrcVer11);
+            return actionSetDlSrcVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetDlSrcVer11Funnel FUNNEL = new OFActionSetDlSrcVer11Funnel();
+    static class OFActionSetDlSrcVer11Funnel implements Funnel<OFActionSetDlSrcVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetDlSrcVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 3
+            sink.putShort((short) 0x3);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            message.dlAddr.putTo(sink);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetDlSrcVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetDlSrcVer11 message) {
+            // fixed value property type = 3
+            bb.writeShort((short) 0x3);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            message.dlAddr.write6Bytes(bb);
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetDlSrcVer11(");
+        b.append("dlAddr=").append(dlAddr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetDlSrcVer11 other = (OFActionSetDlSrcVer11) obj;
+
+        if (dlAddr == null) {
+            if (other.dlAddr != null)
+                return false;
+        } else if (!dlAddr.equals(other.dlAddr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((dlAddr == null) ? 0 : dlAddr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsLabelVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsLabelVer11.java
new file mode 100644
index 0000000..6e77fb4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsLabelVer11.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetMplsLabelVer11 implements OFActionSetMplsLabel {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetMplsLabelVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_MPLS_LABEL = 0x0L;
+
+    // OF message fields
+    private final long mplsLabel;
+//
+    // Immutable default instance
+    final static OFActionSetMplsLabelVer11 DEFAULT = new OFActionSetMplsLabelVer11(
+        DEFAULT_MPLS_LABEL
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetMplsLabelVer11(long mplsLabel) {
+        this.mplsLabel = mplsLabel;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_LABEL;
+    }
+
+    @Override
+    public long getMplsLabel() {
+        return mplsLabel;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetMplsLabel.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetMplsLabel.Builder {
+        final OFActionSetMplsLabelVer11 parentMessage;
+
+        // OF message fields
+        private boolean mplsLabelSet;
+        private long mplsLabel;
+
+        BuilderWithParent(OFActionSetMplsLabelVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_LABEL;
+    }
+
+    @Override
+    public long getMplsLabel() {
+        return mplsLabel;
+    }
+
+    @Override
+    public OFActionSetMplsLabel.Builder setMplsLabel(long mplsLabel) {
+        this.mplsLabel = mplsLabel;
+        this.mplsLabelSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetMplsLabel build() {
+                long mplsLabel = this.mplsLabelSet ? this.mplsLabel : parentMessage.mplsLabel;
+
+                //
+                return new OFActionSetMplsLabelVer11(
+                    mplsLabel
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetMplsLabel.Builder {
+        // OF message fields
+        private boolean mplsLabelSet;
+        private long mplsLabel;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_LABEL;
+    }
+
+    @Override
+    public long getMplsLabel() {
+        return mplsLabel;
+    }
+
+    @Override
+    public OFActionSetMplsLabel.Builder setMplsLabel(long mplsLabel) {
+        this.mplsLabel = mplsLabel;
+        this.mplsLabelSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetMplsLabel build() {
+            long mplsLabel = this.mplsLabelSet ? this.mplsLabel : DEFAULT_MPLS_LABEL;
+
+
+            return new OFActionSetMplsLabelVer11(
+                    mplsLabel
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetMplsLabel> {
+        @Override
+        public OFActionSetMplsLabel readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 13
+            short type = bb.readShort();
+            if(type != (short) 0xd)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_MPLS_LABEL(13), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long mplsLabel = U32.f(bb.readInt());
+
+            OFActionSetMplsLabelVer11 actionSetMplsLabelVer11 = new OFActionSetMplsLabelVer11(
+                    mplsLabel
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetMplsLabelVer11);
+            return actionSetMplsLabelVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetMplsLabelVer11Funnel FUNNEL = new OFActionSetMplsLabelVer11Funnel();
+    static class OFActionSetMplsLabelVer11Funnel implements Funnel<OFActionSetMplsLabelVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetMplsLabelVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 13
+            sink.putShort((short) 0xd);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.mplsLabel);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetMplsLabelVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetMplsLabelVer11 message) {
+            // fixed value property type = 13
+            bb.writeShort((short) 0xd);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.mplsLabel));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetMplsLabelVer11(");
+        b.append("mplsLabel=").append(mplsLabel);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetMplsLabelVer11 other = (OFActionSetMplsLabelVer11) obj;
+
+        if( mplsLabel != other.mplsLabel)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (mplsLabel ^ (mplsLabel >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsTcVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsTcVer11.java
new file mode 100644
index 0000000..9a01e6d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsTcVer11.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetMplsTcVer11 implements OFActionSetMplsTc {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetMplsTcVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_MPLS_TC = (short) 0x0;
+
+    // OF message fields
+    private final short mplsTc;
+//
+    // Immutable default instance
+    final static OFActionSetMplsTcVer11 DEFAULT = new OFActionSetMplsTcVer11(
+        DEFAULT_MPLS_TC
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetMplsTcVer11(short mplsTc) {
+        this.mplsTc = mplsTc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TC;
+    }
+
+    @Override
+    public short getMplsTc() {
+        return mplsTc;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetMplsTc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetMplsTc.Builder {
+        final OFActionSetMplsTcVer11 parentMessage;
+
+        // OF message fields
+        private boolean mplsTcSet;
+        private short mplsTc;
+
+        BuilderWithParent(OFActionSetMplsTcVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TC;
+    }
+
+    @Override
+    public short getMplsTc() {
+        return mplsTc;
+    }
+
+    @Override
+    public OFActionSetMplsTc.Builder setMplsTc(short mplsTc) {
+        this.mplsTc = mplsTc;
+        this.mplsTcSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetMplsTc build() {
+                short mplsTc = this.mplsTcSet ? this.mplsTc : parentMessage.mplsTc;
+
+                //
+                return new OFActionSetMplsTcVer11(
+                    mplsTc
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetMplsTc.Builder {
+        // OF message fields
+        private boolean mplsTcSet;
+        private short mplsTc;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TC;
+    }
+
+    @Override
+    public short getMplsTc() {
+        return mplsTc;
+    }
+
+    @Override
+    public OFActionSetMplsTc.Builder setMplsTc(short mplsTc) {
+        this.mplsTc = mplsTc;
+        this.mplsTcSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetMplsTc build() {
+            short mplsTc = this.mplsTcSet ? this.mplsTc : DEFAULT_MPLS_TC;
+
+
+            return new OFActionSetMplsTcVer11(
+                    mplsTc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetMplsTc> {
+        @Override
+        public OFActionSetMplsTc readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 14
+            short type = bb.readShort();
+            if(type != (short) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_MPLS_TC(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short mplsTc = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetMplsTcVer11 actionSetMplsTcVer11 = new OFActionSetMplsTcVer11(
+                    mplsTc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetMplsTcVer11);
+            return actionSetMplsTcVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetMplsTcVer11Funnel FUNNEL = new OFActionSetMplsTcVer11Funnel();
+    static class OFActionSetMplsTcVer11Funnel implements Funnel<OFActionSetMplsTcVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetMplsTcVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 14
+            sink.putShort((short) 0xe);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.mplsTc);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetMplsTcVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetMplsTcVer11 message) {
+            // fixed value property type = 14
+            bb.writeShort((short) 0xe);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.mplsTc));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetMplsTcVer11(");
+        b.append("mplsTc=").append(mplsTc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetMplsTcVer11 other = (OFActionSetMplsTcVer11) obj;
+
+        if( mplsTc != other.mplsTc)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + mplsTc;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsTtlVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsTtlVer11.java
new file mode 100644
index 0000000..13594ac
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetMplsTtlVer11.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetMplsTtlVer11 implements OFActionSetMplsTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetMplsTtlVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_MPLS_TTL = (short) 0x0;
+
+    // OF message fields
+    private final short mplsTtl;
+//
+    // Immutable default instance
+    final static OFActionSetMplsTtlVer11 DEFAULT = new OFActionSetMplsTtlVer11(
+        DEFAULT_MPLS_TTL
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetMplsTtlVer11(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetMplsTtl.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetMplsTtl.Builder {
+        final OFActionSetMplsTtlVer11 parentMessage;
+
+        // OF message fields
+        private boolean mplsTtlSet;
+        private short mplsTtl;
+
+        BuilderWithParent(OFActionSetMplsTtlVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFActionSetMplsTtl.Builder setMplsTtl(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+        this.mplsTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetMplsTtl build() {
+                short mplsTtl = this.mplsTtlSet ? this.mplsTtl : parentMessage.mplsTtl;
+
+                //
+                return new OFActionSetMplsTtlVer11(
+                    mplsTtl
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetMplsTtl.Builder {
+        // OF message fields
+        private boolean mplsTtlSet;
+        private short mplsTtl;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFActionSetMplsTtl.Builder setMplsTtl(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+        this.mplsTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetMplsTtl build() {
+            short mplsTtl = this.mplsTtlSet ? this.mplsTtl : DEFAULT_MPLS_TTL;
+
+
+            return new OFActionSetMplsTtlVer11(
+                    mplsTtl
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetMplsTtl> {
+        @Override
+        public OFActionSetMplsTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 15
+            short type = bb.readShort();
+            if(type != (short) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_MPLS_TTL(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short mplsTtl = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetMplsTtlVer11 actionSetMplsTtlVer11 = new OFActionSetMplsTtlVer11(
+                    mplsTtl
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetMplsTtlVer11);
+            return actionSetMplsTtlVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetMplsTtlVer11Funnel FUNNEL = new OFActionSetMplsTtlVer11Funnel();
+    static class OFActionSetMplsTtlVer11Funnel implements Funnel<OFActionSetMplsTtlVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetMplsTtlVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 15
+            sink.putShort((short) 0xf);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.mplsTtl);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetMplsTtlVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetMplsTtlVer11 message) {
+            // fixed value property type = 15
+            bb.writeShort((short) 0xf);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.mplsTtl));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetMplsTtlVer11(");
+        b.append("mplsTtl=").append(mplsTtl);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetMplsTtlVer11 other = (OFActionSetMplsTtlVer11) obj;
+
+        if( mplsTtl != other.mplsTtl)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + mplsTtl;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwDstVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwDstVer11.java
new file mode 100644
index 0000000..fb4d405
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwDstVer11.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwDstVer11 implements OFActionSetNwDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwDstVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_NW_ADDR = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address nwAddr;
+//
+    // Immutable default instance
+    final static OFActionSetNwDstVer11 DEFAULT = new OFActionSetNwDstVer11(
+        DEFAULT_NW_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwDstVer11(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_DST;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetNwDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwDst.Builder {
+        final OFActionSetNwDstVer11 parentMessage;
+
+        // OF message fields
+        private boolean nwAddrSet;
+        private IPv4Address nwAddr;
+
+        BuilderWithParent(OFActionSetNwDstVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_DST;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFActionSetNwDst.Builder setNwAddr(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+        this.nwAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetNwDst build() {
+                IPv4Address nwAddr = this.nwAddrSet ? this.nwAddr : parentMessage.nwAddr;
+                if(nwAddr == null)
+                    throw new NullPointerException("Property nwAddr must not be null");
+
+                //
+                return new OFActionSetNwDstVer11(
+                    nwAddr
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwDst.Builder {
+        // OF message fields
+        private boolean nwAddrSet;
+        private IPv4Address nwAddr;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_DST;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFActionSetNwDst.Builder setNwAddr(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+        this.nwAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetNwDst build() {
+            IPv4Address nwAddr = this.nwAddrSet ? this.nwAddr : DEFAULT_NW_ADDR;
+            if(nwAddr == null)
+                throw new NullPointerException("Property nwAddr must not be null");
+
+
+            return new OFActionSetNwDstVer11(
+                    nwAddr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwDst> {
+        @Override
+        public OFActionSetNwDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 6
+            short type = bb.readShort();
+            if(type != (short) 0x6)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_DST(6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            IPv4Address nwAddr = IPv4Address.read4Bytes(bb);
+
+            OFActionSetNwDstVer11 actionSetNwDstVer11 = new OFActionSetNwDstVer11(
+                    nwAddr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwDstVer11);
+            return actionSetNwDstVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwDstVer11Funnel FUNNEL = new OFActionSetNwDstVer11Funnel();
+    static class OFActionSetNwDstVer11Funnel implements Funnel<OFActionSetNwDstVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwDstVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 6
+            sink.putShort((short) 0x6);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.nwAddr.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwDstVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwDstVer11 message) {
+            // fixed value property type = 6
+            bb.writeShort((short) 0x6);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.nwAddr.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwDstVer11(");
+        b.append("nwAddr=").append(nwAddr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwDstVer11 other = (OFActionSetNwDstVer11) obj;
+
+        if (nwAddr == null) {
+            if (other.nwAddr != null)
+                return false;
+        } else if (!nwAddr.equals(other.nwAddr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((nwAddr == null) ? 0 : nwAddr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwEcnVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwEcnVer11.java
new file mode 100644
index 0000000..0f7b48b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwEcnVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwEcnVer11 implements OFActionSetNwEcn {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwEcnVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static IpEcn DEFAULT_NW_ECN = IpEcn.NONE;
+
+    // OF message fields
+    private final IpEcn nwEcn;
+//
+    // Immutable default instance
+    final static OFActionSetNwEcnVer11 DEFAULT = new OFActionSetNwEcnVer11(
+        DEFAULT_NW_ECN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwEcnVer11(IpEcn nwEcn) {
+        this.nwEcn = nwEcn;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_ECN;
+    }
+
+    @Override
+    public IpEcn getNwEcn() {
+        return nwEcn;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetNwEcn.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwEcn.Builder {
+        final OFActionSetNwEcnVer11 parentMessage;
+
+        // OF message fields
+        private boolean nwEcnSet;
+        private IpEcn nwEcn;
+
+        BuilderWithParent(OFActionSetNwEcnVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_ECN;
+    }
+
+    @Override
+    public IpEcn getNwEcn() {
+        return nwEcn;
+    }
+
+    @Override
+    public OFActionSetNwEcn.Builder setNwEcn(IpEcn nwEcn) {
+        this.nwEcn = nwEcn;
+        this.nwEcnSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetNwEcn build() {
+                IpEcn nwEcn = this.nwEcnSet ? this.nwEcn : parentMessage.nwEcn;
+                if(nwEcn == null)
+                    throw new NullPointerException("Property nwEcn must not be null");
+
+                //
+                return new OFActionSetNwEcnVer11(
+                    nwEcn
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwEcn.Builder {
+        // OF message fields
+        private boolean nwEcnSet;
+        private IpEcn nwEcn;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_ECN;
+    }
+
+    @Override
+    public IpEcn getNwEcn() {
+        return nwEcn;
+    }
+
+    @Override
+    public OFActionSetNwEcn.Builder setNwEcn(IpEcn nwEcn) {
+        this.nwEcn = nwEcn;
+        this.nwEcnSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetNwEcn build() {
+            IpEcn nwEcn = this.nwEcnSet ? this.nwEcn : DEFAULT_NW_ECN;
+            if(nwEcn == null)
+                throw new NullPointerException("Property nwEcn must not be null");
+
+
+            return new OFActionSetNwEcnVer11(
+                    nwEcn
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwEcn> {
+        @Override
+        public OFActionSetNwEcn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 8
+            short type = bb.readShort();
+            if(type != (short) 0x8)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_ECN(8), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            IpEcn nwEcn = IpEcn.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetNwEcnVer11 actionSetNwEcnVer11 = new OFActionSetNwEcnVer11(
+                    nwEcn
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwEcnVer11);
+            return actionSetNwEcnVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwEcnVer11Funnel FUNNEL = new OFActionSetNwEcnVer11Funnel();
+    static class OFActionSetNwEcnVer11Funnel implements Funnel<OFActionSetNwEcnVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwEcnVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 8
+            sink.putShort((short) 0x8);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.nwEcn.putTo(sink);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwEcnVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwEcnVer11 message) {
+            // fixed value property type = 8
+            bb.writeShort((short) 0x8);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.nwEcn.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwEcnVer11(");
+        b.append("nwEcn=").append(nwEcn);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwEcnVer11 other = (OFActionSetNwEcnVer11) obj;
+
+        if (nwEcn == null) {
+            if (other.nwEcn != null)
+                return false;
+        } else if (!nwEcn.equals(other.nwEcn))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((nwEcn == null) ? 0 : nwEcn.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwSrcVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwSrcVer11.java
new file mode 100644
index 0000000..fce4978
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwSrcVer11.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwSrcVer11 implements OFActionSetNwSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwSrcVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_NW_ADDR = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address nwAddr;
+//
+    // Immutable default instance
+    final static OFActionSetNwSrcVer11 DEFAULT = new OFActionSetNwSrcVer11(
+        DEFAULT_NW_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwSrcVer11(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_SRC;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetNwSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwSrc.Builder {
+        final OFActionSetNwSrcVer11 parentMessage;
+
+        // OF message fields
+        private boolean nwAddrSet;
+        private IPv4Address nwAddr;
+
+        BuilderWithParent(OFActionSetNwSrcVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_SRC;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFActionSetNwSrc.Builder setNwAddr(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+        this.nwAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetNwSrc build() {
+                IPv4Address nwAddr = this.nwAddrSet ? this.nwAddr : parentMessage.nwAddr;
+                if(nwAddr == null)
+                    throw new NullPointerException("Property nwAddr must not be null");
+
+                //
+                return new OFActionSetNwSrcVer11(
+                    nwAddr
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwSrc.Builder {
+        // OF message fields
+        private boolean nwAddrSet;
+        private IPv4Address nwAddr;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_SRC;
+    }
+
+    @Override
+    public IPv4Address getNwAddr() {
+        return nwAddr;
+    }
+
+    @Override
+    public OFActionSetNwSrc.Builder setNwAddr(IPv4Address nwAddr) {
+        this.nwAddr = nwAddr;
+        this.nwAddrSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetNwSrc build() {
+            IPv4Address nwAddr = this.nwAddrSet ? this.nwAddr : DEFAULT_NW_ADDR;
+            if(nwAddr == null)
+                throw new NullPointerException("Property nwAddr must not be null");
+
+
+            return new OFActionSetNwSrcVer11(
+                    nwAddr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwSrc> {
+        @Override
+        public OFActionSetNwSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 5
+            short type = bb.readShort();
+            if(type != (short) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_SRC(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            IPv4Address nwAddr = IPv4Address.read4Bytes(bb);
+
+            OFActionSetNwSrcVer11 actionSetNwSrcVer11 = new OFActionSetNwSrcVer11(
+                    nwAddr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwSrcVer11);
+            return actionSetNwSrcVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwSrcVer11Funnel FUNNEL = new OFActionSetNwSrcVer11Funnel();
+    static class OFActionSetNwSrcVer11Funnel implements Funnel<OFActionSetNwSrcVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwSrcVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 5
+            sink.putShort((short) 0x5);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.nwAddr.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwSrcVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwSrcVer11 message) {
+            // fixed value property type = 5
+            bb.writeShort((short) 0x5);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.nwAddr.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwSrcVer11(");
+        b.append("nwAddr=").append(nwAddr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwSrcVer11 other = (OFActionSetNwSrcVer11) obj;
+
+        if (nwAddr == null) {
+            if (other.nwAddr != null)
+                return false;
+        } else if (!nwAddr.equals(other.nwAddr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((nwAddr == null) ? 0 : nwAddr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwTosVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwTosVer11.java
new file mode 100644
index 0000000..81677c0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwTosVer11.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwTosVer11 implements OFActionSetNwTos {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwTosVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_NW_TOS = (short) 0x0;
+
+    // OF message fields
+    private final short nwTos;
+//
+    // Immutable default instance
+    final static OFActionSetNwTosVer11 DEFAULT = new OFActionSetNwTosVer11(
+        DEFAULT_NW_TOS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwTosVer11(short nwTos) {
+        this.nwTos = nwTos;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TOS;
+    }
+
+    @Override
+    public short getNwTos() {
+        return nwTos;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetNwTos.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwTos.Builder {
+        final OFActionSetNwTosVer11 parentMessage;
+
+        // OF message fields
+        private boolean nwTosSet;
+        private short nwTos;
+
+        BuilderWithParent(OFActionSetNwTosVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TOS;
+    }
+
+    @Override
+    public short getNwTos() {
+        return nwTos;
+    }
+
+    @Override
+    public OFActionSetNwTos.Builder setNwTos(short nwTos) {
+        this.nwTos = nwTos;
+        this.nwTosSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetNwTos build() {
+                short nwTos = this.nwTosSet ? this.nwTos : parentMessage.nwTos;
+
+                //
+                return new OFActionSetNwTosVer11(
+                    nwTos
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwTos.Builder {
+        // OF message fields
+        private boolean nwTosSet;
+        private short nwTos;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TOS;
+    }
+
+    @Override
+    public short getNwTos() {
+        return nwTos;
+    }
+
+    @Override
+    public OFActionSetNwTos.Builder setNwTos(short nwTos) {
+        this.nwTos = nwTos;
+        this.nwTosSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetNwTos build() {
+            short nwTos = this.nwTosSet ? this.nwTos : DEFAULT_NW_TOS;
+
+
+            return new OFActionSetNwTosVer11(
+                    nwTos
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwTos> {
+        @Override
+        public OFActionSetNwTos readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 7
+            short type = bb.readShort();
+            if(type != (short) 0x7)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_TOS(7), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short nwTos = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetNwTosVer11 actionSetNwTosVer11 = new OFActionSetNwTosVer11(
+                    nwTos
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwTosVer11);
+            return actionSetNwTosVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwTosVer11Funnel FUNNEL = new OFActionSetNwTosVer11Funnel();
+    static class OFActionSetNwTosVer11Funnel implements Funnel<OFActionSetNwTosVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwTosVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 7
+            sink.putShort((short) 0x7);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.nwTos);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwTosVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwTosVer11 message) {
+            // fixed value property type = 7
+            bb.writeShort((short) 0x7);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.nwTos));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwTosVer11(");
+        b.append("nwTos=").append(nwTos);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwTosVer11 other = (OFActionSetNwTosVer11) obj;
+
+        if( nwTos != other.nwTos)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + nwTos;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwTtlVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwTtlVer11.java
new file mode 100644
index 0000000..a738152
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetNwTtlVer11.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwTtlVer11 implements OFActionSetNwTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwTtlVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_NW_TTL = (short) 0x0;
+
+    // OF message fields
+    private final short nwTtl;
+//
+    // Immutable default instance
+    final static OFActionSetNwTtlVer11 DEFAULT = new OFActionSetNwTtlVer11(
+        DEFAULT_NW_TTL
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwTtlVer11(short nwTtl) {
+        this.nwTtl = nwTtl;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetNwTtl.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwTtl.Builder {
+        final OFActionSetNwTtlVer11 parentMessage;
+
+        // OF message fields
+        private boolean nwTtlSet;
+        private short nwTtl;
+
+        BuilderWithParent(OFActionSetNwTtlVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFActionSetNwTtl.Builder setNwTtl(short nwTtl) {
+        this.nwTtl = nwTtl;
+        this.nwTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetNwTtl build() {
+                short nwTtl = this.nwTtlSet ? this.nwTtl : parentMessage.nwTtl;
+
+                //
+                return new OFActionSetNwTtlVer11(
+                    nwTtl
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwTtl.Builder {
+        // OF message fields
+        private boolean nwTtlSet;
+        private short nwTtl;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFActionSetNwTtl.Builder setNwTtl(short nwTtl) {
+        this.nwTtl = nwTtl;
+        this.nwTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetNwTtl build() {
+            short nwTtl = this.nwTtlSet ? this.nwTtl : DEFAULT_NW_TTL;
+
+
+            return new OFActionSetNwTtlVer11(
+                    nwTtl
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwTtl> {
+        @Override
+        public OFActionSetNwTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 23
+            short type = bb.readShort();
+            if(type != (short) 0x17)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_TTL(23), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short nwTtl = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetNwTtlVer11 actionSetNwTtlVer11 = new OFActionSetNwTtlVer11(
+                    nwTtl
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwTtlVer11);
+            return actionSetNwTtlVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwTtlVer11Funnel FUNNEL = new OFActionSetNwTtlVer11Funnel();
+    static class OFActionSetNwTtlVer11Funnel implements Funnel<OFActionSetNwTtlVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwTtlVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 23
+            sink.putShort((short) 0x17);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.nwTtl);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwTtlVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwTtlVer11 message) {
+            // fixed value property type = 23
+            bb.writeShort((short) 0x17);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.nwTtl));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwTtlVer11(");
+        b.append("nwTtl=").append(nwTtl);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwTtlVer11 other = (OFActionSetNwTtlVer11) obj;
+
+        if( nwTtl != other.nwTtl)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + nwTtl;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetQueueVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetQueueVer11.java
new file mode 100644
index 0000000..4bb0d72
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetQueueVer11.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetQueueVer11 implements OFActionSetQueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetQueueVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+
+    // OF message fields
+    private final long queueId;
+//
+    // Immutable default instance
+    final static OFActionSetQueueVer11 DEFAULT = new OFActionSetQueueVer11(
+        DEFAULT_QUEUE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetQueueVer11(long queueId) {
+        this.queueId = queueId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetQueue.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetQueue.Builder {
+        final OFActionSetQueueVer11 parentMessage;
+
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+
+        BuilderWithParent(OFActionSetQueueVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFActionSetQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetQueue build() {
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+
+                //
+                return new OFActionSetQueueVer11(
+                    queueId
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetQueue.Builder {
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFActionSetQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetQueue build() {
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+
+
+            return new OFActionSetQueueVer11(
+                    queueId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetQueue> {
+        @Override
+        public OFActionSetQueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 21
+            short type = bb.readShort();
+            if(type != (short) 0x15)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_QUEUE(21), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long queueId = U32.f(bb.readInt());
+
+            OFActionSetQueueVer11 actionSetQueueVer11 = new OFActionSetQueueVer11(
+                    queueId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetQueueVer11);
+            return actionSetQueueVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetQueueVer11Funnel FUNNEL = new OFActionSetQueueVer11Funnel();
+    static class OFActionSetQueueVer11Funnel implements Funnel<OFActionSetQueueVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetQueueVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 21
+            sink.putShort((short) 0x15);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.queueId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetQueueVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetQueueVer11 message) {
+            // fixed value property type = 21
+            bb.writeShort((short) 0x15);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.queueId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetQueueVer11(");
+        b.append("queueId=").append(queueId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetQueueVer11 other = (OFActionSetQueueVer11) obj;
+
+        if( queueId != other.queueId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetTpDstVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetTpDstVer11.java
new file mode 100644
index 0000000..73c5292
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetTpDstVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetTpDstVer11 implements OFActionSetTpDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetTpDstVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_TP_PORT = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort tpPort;
+//
+    // Immutable default instance
+    final static OFActionSetTpDstVer11 DEFAULT = new OFActionSetTpDstVer11(
+        DEFAULT_TP_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetTpDstVer11(TransportPort tpPort) {
+        this.tpPort = tpPort;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_DST;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetTpDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetTpDst.Builder {
+        final OFActionSetTpDstVer11 parentMessage;
+
+        // OF message fields
+        private boolean tpPortSet;
+        private TransportPort tpPort;
+
+        BuilderWithParent(OFActionSetTpDstVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_DST;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFActionSetTpDst.Builder setTpPort(TransportPort tpPort) {
+        this.tpPort = tpPort;
+        this.tpPortSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetTpDst build() {
+                TransportPort tpPort = this.tpPortSet ? this.tpPort : parentMessage.tpPort;
+                if(tpPort == null)
+                    throw new NullPointerException("Property tpPort must not be null");
+
+                //
+                return new OFActionSetTpDstVer11(
+                    tpPort
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetTpDst.Builder {
+        // OF message fields
+        private boolean tpPortSet;
+        private TransportPort tpPort;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_DST;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFActionSetTpDst.Builder setTpPort(TransportPort tpPort) {
+        this.tpPort = tpPort;
+        this.tpPortSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetTpDst build() {
+            TransportPort tpPort = this.tpPortSet ? this.tpPort : DEFAULT_TP_PORT;
+            if(tpPort == null)
+                throw new NullPointerException("Property tpPort must not be null");
+
+
+            return new OFActionSetTpDstVer11(
+                    tpPort
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetTpDst> {
+        @Override
+        public OFActionSetTpDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 10
+            short type = bb.readShort();
+            if(type != (short) 0xa)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_TP_DST(10), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TransportPort tpPort = TransportPort.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionSetTpDstVer11 actionSetTpDstVer11 = new OFActionSetTpDstVer11(
+                    tpPort
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetTpDstVer11);
+            return actionSetTpDstVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetTpDstVer11Funnel FUNNEL = new OFActionSetTpDstVer11Funnel();
+    static class OFActionSetTpDstVer11Funnel implements Funnel<OFActionSetTpDstVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetTpDstVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 10
+            sink.putShort((short) 0xa);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.tpPort.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetTpDstVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetTpDstVer11 message) {
+            // fixed value property type = 10
+            bb.writeShort((short) 0xa);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.tpPort.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetTpDstVer11(");
+        b.append("tpPort=").append(tpPort);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetTpDstVer11 other = (OFActionSetTpDstVer11) obj;
+
+        if (tpPort == null) {
+            if (other.tpPort != null)
+                return false;
+        } else if (!tpPort.equals(other.tpPort))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tpPort == null) ? 0 : tpPort.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetTpSrcVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetTpSrcVer11.java
new file mode 100644
index 0000000..f421a34
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetTpSrcVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetTpSrcVer11 implements OFActionSetTpSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetTpSrcVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_TP_PORT = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort tpPort;
+//
+    // Immutable default instance
+    final static OFActionSetTpSrcVer11 DEFAULT = new OFActionSetTpSrcVer11(
+        DEFAULT_TP_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetTpSrcVer11(TransportPort tpPort) {
+        this.tpPort = tpPort;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_SRC;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetTpSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetTpSrc.Builder {
+        final OFActionSetTpSrcVer11 parentMessage;
+
+        // OF message fields
+        private boolean tpPortSet;
+        private TransportPort tpPort;
+
+        BuilderWithParent(OFActionSetTpSrcVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_SRC;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFActionSetTpSrc.Builder setTpPort(TransportPort tpPort) {
+        this.tpPort = tpPort;
+        this.tpPortSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetTpSrc build() {
+                TransportPort tpPort = this.tpPortSet ? this.tpPort : parentMessage.tpPort;
+                if(tpPort == null)
+                    throw new NullPointerException("Property tpPort must not be null");
+
+                //
+                return new OFActionSetTpSrcVer11(
+                    tpPort
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetTpSrc.Builder {
+        // OF message fields
+        private boolean tpPortSet;
+        private TransportPort tpPort;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_TP_SRC;
+    }
+
+    @Override
+    public TransportPort getTpPort() {
+        return tpPort;
+    }
+
+    @Override
+    public OFActionSetTpSrc.Builder setTpPort(TransportPort tpPort) {
+        this.tpPort = tpPort;
+        this.tpPortSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetTpSrc build() {
+            TransportPort tpPort = this.tpPortSet ? this.tpPort : DEFAULT_TP_PORT;
+            if(tpPort == null)
+                throw new NullPointerException("Property tpPort must not be null");
+
+
+            return new OFActionSetTpSrcVer11(
+                    tpPort
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetTpSrc> {
+        @Override
+        public OFActionSetTpSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 9
+            short type = bb.readShort();
+            if(type != (short) 0x9)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_TP_SRC(9), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TransportPort tpPort = TransportPort.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionSetTpSrcVer11 actionSetTpSrcVer11 = new OFActionSetTpSrcVer11(
+                    tpPort
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetTpSrcVer11);
+            return actionSetTpSrcVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetTpSrcVer11Funnel FUNNEL = new OFActionSetTpSrcVer11Funnel();
+    static class OFActionSetTpSrcVer11Funnel implements Funnel<OFActionSetTpSrcVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetTpSrcVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 9
+            sink.putShort((short) 0x9);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.tpPort.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetTpSrcVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetTpSrcVer11 message) {
+            // fixed value property type = 9
+            bb.writeShort((short) 0x9);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.tpPort.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetTpSrcVer11(");
+        b.append("tpPort=").append(tpPort);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetTpSrcVer11 other = (OFActionSetTpSrcVer11) obj;
+
+        if (tpPort == null) {
+            if (other.tpPort != null)
+                return false;
+        } else if (!tpPort.equals(other.tpPort))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tpPort == null) ? 0 : tpPort.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetVlanPcpVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetVlanPcpVer11.java
new file mode 100644
index 0000000..48d3664
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetVlanPcpVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetVlanPcpVer11 implements OFActionSetVlanPcp {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetVlanPcpVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static VlanPcp DEFAULT_VLAN_PCP = VlanPcp.NONE;
+
+    // OF message fields
+    private final VlanPcp vlanPcp;
+//
+    // Immutable default instance
+    final static OFActionSetVlanPcpVer11 DEFAULT = new OFActionSetVlanPcpVer11(
+        DEFAULT_VLAN_PCP
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetVlanPcpVer11(VlanPcp vlanPcp) {
+        this.vlanPcp = vlanPcp;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_PCP;
+    }
+
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetVlanPcp.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetVlanPcp.Builder {
+        final OFActionSetVlanPcpVer11 parentMessage;
+
+        // OF message fields
+        private boolean vlanPcpSet;
+        private VlanPcp vlanPcp;
+
+        BuilderWithParent(OFActionSetVlanPcpVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_PCP;
+    }
+
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFActionSetVlanPcp.Builder setVlanPcp(VlanPcp vlanPcp) {
+        this.vlanPcp = vlanPcp;
+        this.vlanPcpSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetVlanPcp build() {
+                VlanPcp vlanPcp = this.vlanPcpSet ? this.vlanPcp : parentMessage.vlanPcp;
+                if(vlanPcp == null)
+                    throw new NullPointerException("Property vlanPcp must not be null");
+
+                //
+                return new OFActionSetVlanPcpVer11(
+                    vlanPcp
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetVlanPcp.Builder {
+        // OF message fields
+        private boolean vlanPcpSet;
+        private VlanPcp vlanPcp;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_PCP;
+    }
+
+    @Override
+    public VlanPcp getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFActionSetVlanPcp.Builder setVlanPcp(VlanPcp vlanPcp) {
+        this.vlanPcp = vlanPcp;
+        this.vlanPcpSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetVlanPcp build() {
+            VlanPcp vlanPcp = this.vlanPcpSet ? this.vlanPcp : DEFAULT_VLAN_PCP;
+            if(vlanPcp == null)
+                throw new NullPointerException("Property vlanPcp must not be null");
+
+
+            return new OFActionSetVlanPcpVer11(
+                    vlanPcp
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetVlanPcp> {
+        @Override
+        public OFActionSetVlanPcp readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_VLAN_PCP(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            VlanPcp vlanPcp = VlanPcp.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetVlanPcpVer11 actionSetVlanPcpVer11 = new OFActionSetVlanPcpVer11(
+                    vlanPcp
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetVlanPcpVer11);
+            return actionSetVlanPcpVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetVlanPcpVer11Funnel FUNNEL = new OFActionSetVlanPcpVer11Funnel();
+    static class OFActionSetVlanPcpVer11Funnel implements Funnel<OFActionSetVlanPcpVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetVlanPcpVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.vlanPcp.putTo(sink);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetVlanPcpVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetVlanPcpVer11 message) {
+            // fixed value property type = 2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.vlanPcp.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetVlanPcpVer11(");
+        b.append("vlanPcp=").append(vlanPcp);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetVlanPcpVer11 other = (OFActionSetVlanPcpVer11) obj;
+
+        if (vlanPcp == null) {
+            if (other.vlanPcp != null)
+                return false;
+        } else if (!vlanPcp.equals(other.vlanPcp))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((vlanPcp == null) ? 0 : vlanPcp.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetVlanVidVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetVlanVidVer11.java
new file mode 100644
index 0000000..7d826dd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionSetVlanVidVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetVlanVidVer11 implements OFActionSetVlanVid {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetVlanVidVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static VlanVid DEFAULT_VLAN_VID = VlanVid.ZERO;
+
+    // OF message fields
+    private final VlanVid vlanVid;
+//
+    // Immutable default instance
+    final static OFActionSetVlanVidVer11 DEFAULT = new OFActionSetVlanVidVer11(
+        DEFAULT_VLAN_VID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetVlanVidVer11(VlanVid vlanVid) {
+        this.vlanVid = vlanVid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_VID;
+    }
+
+    @Override
+    public VlanVid getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFActionSetVlanVid.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetVlanVid.Builder {
+        final OFActionSetVlanVidVer11 parentMessage;
+
+        // OF message fields
+        private boolean vlanVidSet;
+        private VlanVid vlanVid;
+
+        BuilderWithParent(OFActionSetVlanVidVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_VID;
+    }
+
+    @Override
+    public VlanVid getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFActionSetVlanVid.Builder setVlanVid(VlanVid vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFActionSetVlanVid build() {
+                VlanVid vlanVid = this.vlanVidSet ? this.vlanVid : parentMessage.vlanVid;
+                if(vlanVid == null)
+                    throw new NullPointerException("Property vlanVid must not be null");
+
+                //
+                return new OFActionSetVlanVidVer11(
+                    vlanVid
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetVlanVid.Builder {
+        // OF message fields
+        private boolean vlanVidSet;
+        private VlanVid vlanVid;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_VLAN_VID;
+    }
+
+    @Override
+    public VlanVid getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFActionSetVlanVid.Builder setVlanVid(VlanVid vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFActionSetVlanVid build() {
+            VlanVid vlanVid = this.vlanVidSet ? this.vlanVid : DEFAULT_VLAN_VID;
+            if(vlanVid == null)
+                throw new NullPointerException("Property vlanVid must not be null");
+
+
+            return new OFActionSetVlanVidVer11(
+                    vlanVid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetVlanVid> {
+        @Override
+        public OFActionSetVlanVid readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_VLAN_VID(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            VlanVid vlanVid = VlanVid.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionSetVlanVidVer11 actionSetVlanVidVer11 = new OFActionSetVlanVidVer11(
+                    vlanVid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetVlanVidVer11);
+            return actionSetVlanVidVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetVlanVidVer11Funnel FUNNEL = new OFActionSetVlanVidVer11Funnel();
+    static class OFActionSetVlanVidVer11Funnel implements Funnel<OFActionSetVlanVidVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetVlanVidVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.vlanVid.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetVlanVidVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetVlanVidVer11 message) {
+            // fixed value property type = 1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.vlanVid.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetVlanVidVer11(");
+        b.append("vlanVid=").append(vlanVid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetVlanVidVer11 other = (OFActionSetVlanVidVer11) obj;
+
+        if (vlanVid == null) {
+            if (other.vlanVid != null)
+                return false;
+        } else if (!vlanVid.equals(other.vlanVid))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((vlanVid == null) ? 0 : vlanVid.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionTypeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionTypeSerializerVer11.java
new file mode 100644
index 0000000..9dbbdb7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionTypeSerializerVer11.java
@@ -0,0 +1,194 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFActionType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFActionTypeSerializerVer11 {
+
+    public final static short OUTPUT_VAL = (short) 0x0;
+    public final static short SET_VLAN_VID_VAL = (short) 0x1;
+    public final static short SET_VLAN_PCP_VAL = (short) 0x2;
+    public final static short SET_DL_SRC_VAL = (short) 0x3;
+    public final static short SET_DL_DST_VAL = (short) 0x4;
+    public final static short SET_NW_SRC_VAL = (short) 0x5;
+    public final static short SET_NW_DST_VAL = (short) 0x6;
+    public final static short SET_NW_TOS_VAL = (short) 0x7;
+    public final static short SET_NW_ECN_VAL = (short) 0x8;
+    public final static short SET_TP_SRC_VAL = (short) 0x9;
+    public final static short SET_TP_DST_VAL = (short) 0xa;
+    public final static short COPY_TTL_OUT_VAL = (short) 0xb;
+    public final static short COPY_TTL_IN_VAL = (short) 0xc;
+    public final static short SET_MPLS_LABEL_VAL = (short) 0xd;
+    public final static short SET_MPLS_TC_VAL = (short) 0xe;
+    public final static short SET_MPLS_TTL_VAL = (short) 0xf;
+    public final static short DEC_MPLS_TTL_VAL = (short) 0x10;
+    public final static short PUSH_VLAN_VAL = (short) 0x11;
+    public final static short POP_VLAN_VAL = (short) 0x12;
+    public final static short PUSH_MPLS_VAL = (short) 0x13;
+    public final static short POP_MPLS_VAL = (short) 0x14;
+    public final static short SET_QUEUE_VAL = (short) 0x15;
+    public final static short GROUP_VAL = (short) 0x16;
+    public final static short SET_NW_TTL_VAL = (short) 0x17;
+    public final static short DEC_NW_TTL_VAL = (short) 0x18;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFActionType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFActionType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFActionType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFActionType ofWireValue(short val) {
+        switch(val) {
+            case OUTPUT_VAL:
+                return OFActionType.OUTPUT;
+            case SET_VLAN_VID_VAL:
+                return OFActionType.SET_VLAN_VID;
+            case SET_VLAN_PCP_VAL:
+                return OFActionType.SET_VLAN_PCP;
+            case SET_DL_SRC_VAL:
+                return OFActionType.SET_DL_SRC;
+            case SET_DL_DST_VAL:
+                return OFActionType.SET_DL_DST;
+            case SET_NW_SRC_VAL:
+                return OFActionType.SET_NW_SRC;
+            case SET_NW_DST_VAL:
+                return OFActionType.SET_NW_DST;
+            case SET_NW_TOS_VAL:
+                return OFActionType.SET_NW_TOS;
+            case SET_NW_ECN_VAL:
+                return OFActionType.SET_NW_ECN;
+            case SET_TP_SRC_VAL:
+                return OFActionType.SET_TP_SRC;
+            case SET_TP_DST_VAL:
+                return OFActionType.SET_TP_DST;
+            case COPY_TTL_OUT_VAL:
+                return OFActionType.COPY_TTL_OUT;
+            case COPY_TTL_IN_VAL:
+                return OFActionType.COPY_TTL_IN;
+            case SET_MPLS_LABEL_VAL:
+                return OFActionType.SET_MPLS_LABEL;
+            case SET_MPLS_TC_VAL:
+                return OFActionType.SET_MPLS_TC;
+            case SET_MPLS_TTL_VAL:
+                return OFActionType.SET_MPLS_TTL;
+            case DEC_MPLS_TTL_VAL:
+                return OFActionType.DEC_MPLS_TTL;
+            case PUSH_VLAN_VAL:
+                return OFActionType.PUSH_VLAN;
+            case POP_VLAN_VAL:
+                return OFActionType.POP_VLAN;
+            case PUSH_MPLS_VAL:
+                return OFActionType.PUSH_MPLS;
+            case POP_MPLS_VAL:
+                return OFActionType.POP_MPLS;
+            case SET_QUEUE_VAL:
+                return OFActionType.SET_QUEUE;
+            case GROUP_VAL:
+                return OFActionType.GROUP;
+            case SET_NW_TTL_VAL:
+                return OFActionType.SET_NW_TTL;
+            case DEC_NW_TTL_VAL:
+                return OFActionType.DEC_NW_TTL;
+            case EXPERIMENTER_VAL:
+                return OFActionType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFActionType in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFActionType e) {
+        switch(e) {
+            case OUTPUT:
+                return OUTPUT_VAL;
+            case SET_VLAN_VID:
+                return SET_VLAN_VID_VAL;
+            case SET_VLAN_PCP:
+                return SET_VLAN_PCP_VAL;
+            case SET_DL_SRC:
+                return SET_DL_SRC_VAL;
+            case SET_DL_DST:
+                return SET_DL_DST_VAL;
+            case SET_NW_SRC:
+                return SET_NW_SRC_VAL;
+            case SET_NW_DST:
+                return SET_NW_DST_VAL;
+            case SET_NW_TOS:
+                return SET_NW_TOS_VAL;
+            case SET_NW_ECN:
+                return SET_NW_ECN_VAL;
+            case SET_TP_SRC:
+                return SET_TP_SRC_VAL;
+            case SET_TP_DST:
+                return SET_TP_DST_VAL;
+            case COPY_TTL_OUT:
+                return COPY_TTL_OUT_VAL;
+            case COPY_TTL_IN:
+                return COPY_TTL_IN_VAL;
+            case SET_MPLS_LABEL:
+                return SET_MPLS_LABEL_VAL;
+            case SET_MPLS_TC:
+                return SET_MPLS_TC_VAL;
+            case SET_MPLS_TTL:
+                return SET_MPLS_TTL_VAL;
+            case DEC_MPLS_TTL:
+                return DEC_MPLS_TTL_VAL;
+            case PUSH_VLAN:
+                return PUSH_VLAN_VAL;
+            case POP_VLAN:
+                return POP_VLAN_VAL;
+            case PUSH_MPLS:
+                return PUSH_MPLS_VAL;
+            case POP_MPLS:
+                return POP_MPLS_VAL;
+            case SET_QUEUE:
+                return SET_QUEUE_VAL;
+            case GROUP:
+                return GROUP_VAL;
+            case SET_NW_TTL:
+                return SET_NW_TTL_VAL;
+            case DEC_NW_TTL:
+                return DEC_NW_TTL_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFActionType in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionVer11.java
new file mode 100644
index 0000000..f4e8d6c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionVer11.java
@@ -0,0 +1,129 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFAction> {
+        @Override
+        public OFAction readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0xffff:
+                   // discriminator value OFActionType.EXPERIMENTER=65535 for class OFActionExperimenterVer11
+                   return OFActionExperimenterVer11.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFActionType.OUTPUT=0 for class OFActionOutputVer11
+                   return OFActionOutputVer11.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFActionType.SET_DL_DST=4 for class OFActionSetDlDstVer11
+                   return OFActionSetDlDstVer11.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFActionType.SET_DL_SRC=3 for class OFActionSetDlSrcVer11
+                   return OFActionSetDlSrcVer11.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFActionType.SET_NW_DST=6 for class OFActionSetNwDstVer11
+                   return OFActionSetNwDstVer11.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFActionType.SET_NW_SRC=5 for class OFActionSetNwSrcVer11
+                   return OFActionSetNwSrcVer11.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFActionType.SET_NW_TOS=7 for class OFActionSetNwTosVer11
+                   return OFActionSetNwTosVer11.READER.readFrom(bb);
+               case (short) 0xa:
+                   // discriminator value OFActionType.SET_TP_DST=10 for class OFActionSetTpDstVer11
+                   return OFActionSetTpDstVer11.READER.readFrom(bb);
+               case (short) 0x9:
+                   // discriminator value OFActionType.SET_TP_SRC=9 for class OFActionSetTpSrcVer11
+                   return OFActionSetTpSrcVer11.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFActionType.SET_VLAN_PCP=2 for class OFActionSetVlanPcpVer11
+                   return OFActionSetVlanPcpVer11.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFActionType.SET_VLAN_VID=1 for class OFActionSetVlanVidVer11
+                   return OFActionSetVlanVidVer11.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value OFActionType.COPY_TTL_IN=12 for class OFActionCopyTtlInVer11
+                   return OFActionCopyTtlInVer11.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFActionType.COPY_TTL_OUT=11 for class OFActionCopyTtlOutVer11
+                   return OFActionCopyTtlOutVer11.READER.readFrom(bb);
+               case (short) 0x10:
+                   // discriminator value OFActionType.DEC_MPLS_TTL=16 for class OFActionDecMplsTtlVer11
+                   return OFActionDecMplsTtlVer11.READER.readFrom(bb);
+               case (short) 0x18:
+                   // discriminator value OFActionType.DEC_NW_TTL=24 for class OFActionDecNwTtlVer11
+                   return OFActionDecNwTtlVer11.READER.readFrom(bb);
+               case (short) 0x16:
+                   // discriminator value OFActionType.GROUP=22 for class OFActionGroupVer11
+                   return OFActionGroupVer11.READER.readFrom(bb);
+               case (short) 0x14:
+                   // discriminator value OFActionType.POP_MPLS=20 for class OFActionPopMplsVer11
+                   return OFActionPopMplsVer11.READER.readFrom(bb);
+               case (short) 0x12:
+                   // discriminator value OFActionType.POP_VLAN=18 for class OFActionPopVlanVer11
+                   return OFActionPopVlanVer11.READER.readFrom(bb);
+               case (short) 0x13:
+                   // discriminator value OFActionType.PUSH_MPLS=19 for class OFActionPushMplsVer11
+                   return OFActionPushMplsVer11.READER.readFrom(bb);
+               case (short) 0x11:
+                   // discriminator value OFActionType.PUSH_VLAN=17 for class OFActionPushVlanVer11
+                   return OFActionPushVlanVer11.READER.readFrom(bb);
+               case (short) 0xd:
+                   // discriminator value OFActionType.SET_MPLS_LABEL=13 for class OFActionSetMplsLabelVer11
+                   return OFActionSetMplsLabelVer11.READER.readFrom(bb);
+               case (short) 0xe:
+                   // discriminator value OFActionType.SET_MPLS_TC=14 for class OFActionSetMplsTcVer11
+                   return OFActionSetMplsTcVer11.READER.readFrom(bb);
+               case (short) 0xf:
+                   // discriminator value OFActionType.SET_MPLS_TTL=15 for class OFActionSetMplsTtlVer11
+                   return OFActionSetMplsTtlVer11.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFActionType.SET_NW_ECN=8 for class OFActionSetNwEcnVer11
+                   return OFActionSetNwEcnVer11.READER.readFrom(bb);
+               case (short) 0x17:
+                   // discriminator value OFActionType.SET_NW_TTL=23 for class OFActionSetNwTtlVer11
+                   return OFActionSetNwTtlVer11.READER.readFrom(bb);
+               case (short) 0x15:
+                   // discriminator value OFActionType.SET_QUEUE=21 for class OFActionSetQueueVer11
+                   return OFActionSetQueueVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFActionVer11: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionsVer11.java
new file mode 100644
index 0000000..c496634
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFActionsVer11.java
@@ -0,0 +1,299 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+
+public class OFActionsVer11 implements OFActions {
+    public final static OFActionsVer11 INSTANCE = new OFActionsVer11();
+
+
+
+
+    public OFActionBsnChecksum.Builder buildBsnChecksum() {
+        return new OFActionBsnChecksumVer11.Builder();
+    }
+    public OFActionBsnChecksum bsnChecksum(U128 checksum) {
+        return new OFActionBsnChecksumVer11(
+                checksum
+                    );
+    }
+
+    public OFActionBsnMirror.Builder buildBsnMirror() {
+        return new OFActionBsnMirrorVer11.Builder();
+    }
+
+    public OFActionBsnSetTunnelDst.Builder buildBsnSetTunnelDst() {
+        return new OFActionBsnSetTunnelDstVer11.Builder();
+    }
+    public OFActionBsnSetTunnelDst bsnSetTunnelDst(long dst) {
+        return new OFActionBsnSetTunnelDstVer11(
+                dst
+                    );
+    }
+
+    public OFActionEnqueue.Builder buildEnqueue() {
+        throw new UnsupportedOperationException("OFActionEnqueue not supported in version 1.1");
+    }
+    public OFActionEnqueue enqueue(OFPort port, long queueId) {
+        throw new UnsupportedOperationException("OFActionEnqueue not supported in version 1.1");
+    }
+
+    public OFActionNiciraDecTtl niciraDecTtl() {
+        return OFActionNiciraDecTtlVer11.INSTANCE;
+    }
+
+    public OFActionOutput.Builder buildOutput() {
+        return new OFActionOutputVer11.Builder();
+    }
+    public OFActionOutput output(OFPort port, int maxLen) {
+        return new OFActionOutputVer11(
+                port,
+                      maxLen
+                    );
+    }
+
+    public OFActionSetDlDst.Builder buildSetDlDst() {
+        return new OFActionSetDlDstVer11.Builder();
+    }
+    public OFActionSetDlDst setDlDst(MacAddress dlAddr) {
+        return new OFActionSetDlDstVer11(
+                dlAddr
+                    );
+    }
+
+    public OFActionSetDlSrc.Builder buildSetDlSrc() {
+        return new OFActionSetDlSrcVer11.Builder();
+    }
+    public OFActionSetDlSrc setDlSrc(MacAddress dlAddr) {
+        return new OFActionSetDlSrcVer11(
+                dlAddr
+                    );
+    }
+
+    public OFActionSetNwDst.Builder buildSetNwDst() {
+        return new OFActionSetNwDstVer11.Builder();
+    }
+    public OFActionSetNwDst setNwDst(IPv4Address nwAddr) {
+        return new OFActionSetNwDstVer11(
+                nwAddr
+                    );
+    }
+
+    public OFActionSetNwSrc.Builder buildSetNwSrc() {
+        return new OFActionSetNwSrcVer11.Builder();
+    }
+    public OFActionSetNwSrc setNwSrc(IPv4Address nwAddr) {
+        return new OFActionSetNwSrcVer11(
+                nwAddr
+                    );
+    }
+
+    public OFActionSetNwTos.Builder buildSetNwTos() {
+        return new OFActionSetNwTosVer11.Builder();
+    }
+    public OFActionSetNwTos setNwTos(short nwTos) {
+        return new OFActionSetNwTosVer11(
+                nwTos
+                    );
+    }
+
+    public OFActionSetTpDst.Builder buildSetTpDst() {
+        return new OFActionSetTpDstVer11.Builder();
+    }
+    public OFActionSetTpDst setTpDst(TransportPort tpPort) {
+        return new OFActionSetTpDstVer11(
+                tpPort
+                    );
+    }
+
+    public OFActionSetTpSrc.Builder buildSetTpSrc() {
+        return new OFActionSetTpSrcVer11.Builder();
+    }
+    public OFActionSetTpSrc setTpSrc(TransportPort tpPort) {
+        return new OFActionSetTpSrcVer11(
+                tpPort
+                    );
+    }
+
+    public OFActionSetVlanPcp.Builder buildSetVlanPcp() {
+        return new OFActionSetVlanPcpVer11.Builder();
+    }
+    public OFActionSetVlanPcp setVlanPcp(VlanPcp vlanPcp) {
+        return new OFActionSetVlanPcpVer11(
+                vlanPcp
+                    );
+    }
+
+    public OFActionSetVlanVid.Builder buildSetVlanVid() {
+        return new OFActionSetVlanVidVer11.Builder();
+    }
+    public OFActionSetVlanVid setVlanVid(VlanVid vlanVid) {
+        return new OFActionSetVlanVidVer11(
+                vlanVid
+                    );
+    }
+
+    public OFActionStripVlan stripVlan() {
+        throw new UnsupportedOperationException("OFActionStripVlan not supported in version 1.1");
+    }
+
+    public OFActionCopyTtlIn copyTtlIn() {
+        return OFActionCopyTtlInVer11.INSTANCE;
+    }
+
+    public OFActionCopyTtlOut copyTtlOut() {
+        return OFActionCopyTtlOutVer11.INSTANCE;
+    }
+
+    public OFActionDecMplsTtl decMplsTtl() {
+        return OFActionDecMplsTtlVer11.INSTANCE;
+    }
+
+    public OFActionDecNwTtl decNwTtl() {
+        return OFActionDecNwTtlVer11.INSTANCE;
+    }
+
+    public OFActionGroup.Builder buildGroup() {
+        return new OFActionGroupVer11.Builder();
+    }
+    public OFActionGroup group(OFGroup group) {
+        return new OFActionGroupVer11(
+                group
+                    );
+    }
+
+    public OFActionPopMpls.Builder buildPopMpls() {
+        return new OFActionPopMplsVer11.Builder();
+    }
+    public OFActionPopMpls popMpls(EthType ethertype) {
+        return new OFActionPopMplsVer11(
+                ethertype
+                    );
+    }
+
+    public OFActionPopVlan popVlan() {
+        return OFActionPopVlanVer11.INSTANCE;
+    }
+
+    public OFActionPushMpls.Builder buildPushMpls() {
+        return new OFActionPushMplsVer11.Builder();
+    }
+    public OFActionPushMpls pushMpls(EthType ethertype) {
+        return new OFActionPushMplsVer11(
+                ethertype
+                    );
+    }
+
+    public OFActionPushVlan.Builder buildPushVlan() {
+        return new OFActionPushVlanVer11.Builder();
+    }
+    public OFActionPushVlan pushVlan(EthType ethertype) {
+        return new OFActionPushVlanVer11(
+                ethertype
+                    );
+    }
+
+    public OFActionSetMplsLabel.Builder buildSetMplsLabel() {
+        return new OFActionSetMplsLabelVer11.Builder();
+    }
+    public OFActionSetMplsLabel setMplsLabel(long mplsLabel) {
+        return new OFActionSetMplsLabelVer11(
+                mplsLabel
+                    );
+    }
+
+    public OFActionSetMplsTc.Builder buildSetMplsTc() {
+        return new OFActionSetMplsTcVer11.Builder();
+    }
+    public OFActionSetMplsTc setMplsTc(short mplsTc) {
+        return new OFActionSetMplsTcVer11(
+                mplsTc
+                    );
+    }
+
+    public OFActionSetMplsTtl.Builder buildSetMplsTtl() {
+        return new OFActionSetMplsTtlVer11.Builder();
+    }
+    public OFActionSetMplsTtl setMplsTtl(short mplsTtl) {
+        return new OFActionSetMplsTtlVer11(
+                mplsTtl
+                    );
+    }
+
+    public OFActionSetNwEcn.Builder buildSetNwEcn() {
+        return new OFActionSetNwEcnVer11.Builder();
+    }
+    public OFActionSetNwEcn setNwEcn(IpEcn nwEcn) {
+        return new OFActionSetNwEcnVer11(
+                nwEcn
+                    );
+    }
+
+    public OFActionSetNwTtl.Builder buildSetNwTtl() {
+        return new OFActionSetNwTtlVer11.Builder();
+    }
+    public OFActionSetNwTtl setNwTtl(short nwTtl) {
+        return new OFActionSetNwTtlVer11(
+                nwTtl
+                    );
+    }
+
+    public OFActionSetQueue.Builder buildSetQueue() {
+        return new OFActionSetQueueVer11.Builder();
+    }
+    public OFActionSetQueue setQueue(long queueId) {
+        return new OFActionSetQueueVer11(
+                queueId
+                    );
+    }
+
+    public OFActionSetField.Builder buildSetField() {
+        throw new UnsupportedOperationException("OFActionSetField not supported in version 1.1");
+    }
+    public OFActionSetField setField(OFOxm<?> field) {
+        throw new UnsupportedOperationException("OFActionSetField not supported in version 1.1");
+    }
+
+    public OFActionPopPbb popPbb() {
+        throw new UnsupportedOperationException("OFActionPopPbb not supported in version 1.1");
+    }
+
+    public OFActionPushPbb.Builder buildPushPbb() {
+        throw new UnsupportedOperationException("OFActionPushPbb not supported in version 1.1");
+    }
+    public OFActionPushPbb pushPbb(EthType ethertype) {
+        throw new UnsupportedOperationException("OFActionPushPbb not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFAction> getReader() {
+        return OFActionVer11.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFAggregateStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFAggregateStatsReplyVer11.java
new file mode 100644
index 0000000..2c5c58f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFAggregateStatsReplyVer11.java
@@ -0,0 +1,511 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAggregateStatsReplyVer11 implements OFAggregateStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 40;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static long DEFAULT_FLOW_COUNT = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final long flowCount;
+//
+    // Immutable default instance
+    final static OFAggregateStatsReplyVer11 DEFAULT = new OFAggregateStatsReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_FLOW_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAggregateStatsReplyVer11(long xid, Set<OFStatsReplyFlags> flags, U64 packetCount, U64 byteCount, long flowCount) {
+        this.xid = xid;
+        this.flags = flags;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.flowCount = flowCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+
+
+    public OFAggregateStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAggregateStatsReply.Builder {
+        final OFAggregateStatsReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean flowCountSet;
+        private long flowCount;
+
+        BuilderWithParent(OFAggregateStatsReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAggregateStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                long flowCount = this.flowCountSet ? this.flowCount : parentMessage.flowCount;
+
+                //
+                return new OFAggregateStatsReplyVer11(
+                    xid,
+                    flags,
+                    packetCount,
+                    byteCount,
+                    flowCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFAggregateStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean flowCountSet;
+        private long flowCount;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAggregateStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            long flowCount = this.flowCountSet ? this.flowCount : DEFAULT_FLOW_COUNT;
+
+
+            return new OFAggregateStatsReplyVer11(
+                    xid,
+                    flags,
+                    packetCount,
+                    byteCount,
+                    flowCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAggregateStatsReply> {
+        @Override
+        public OFAggregateStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 40)
+                throw new OFParseError("Wrong length: Expected=40(40), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 2
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x2)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.AGGREGATE(2), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            long flowCount = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFAggregateStatsReplyVer11 aggregateStatsReplyVer11 = new OFAggregateStatsReplyVer11(
+                    xid,
+                      flags,
+                      packetCount,
+                      byteCount,
+                      flowCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", aggregateStatsReplyVer11);
+            return aggregateStatsReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAggregateStatsReplyVer11Funnel FUNNEL = new OFAggregateStatsReplyVer11Funnel();
+    static class OFAggregateStatsReplyVer11Funnel implements Funnel<OFAggregateStatsReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAggregateStatsReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 40
+            sink.putShort((short) 0x28);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 2
+            sink.putShort((short) 0x2);
+            OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            sink.putLong(message.flowCount);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAggregateStatsReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFAggregateStatsReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 40
+            bb.writeShort((short) 0x28);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 2
+            bb.writeShort((short) 0x2);
+            OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            bb.writeInt(U32.t(message.flowCount));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAggregateStatsReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("flowCount=").append(flowCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAggregateStatsReplyVer11 other = (OFAggregateStatsReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if( flowCount != other.flowCount)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime *  (int) (flowCount ^ (flowCount >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFAggregateStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFAggregateStatsRequestVer11.java
new file mode 100644
index 0000000..aa1d294
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFAggregateStatsRequestVer11.java
@@ -0,0 +1,685 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAggregateStatsRequestVer11 implements OFAggregateStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 136;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final TableId tableId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFAggregateStatsRequestVer11 DEFAULT = new OFAggregateStatsRequestVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TABLE_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAggregateStatsRequestVer11(long xid, Set<OFStatsRequestFlags> flags, TableId tableId, OFPort outPort, OFGroup outGroup, U64 cookie, U64 cookieMask, Match match) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFAggregateStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAggregateStatsRequest.Builder {
+        final OFAggregateStatsRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFAggregateStatsRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAggregateStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFAggregateStatsRequestVer11(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFAggregateStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAggregateStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFAggregateStatsRequestVer11(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAggregateStatsRequest> {
+        @Override
+        public OFAggregateStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 136)
+                throw new OFParseError("Wrong length: Expected=136(136), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 2
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x2)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.AGGREGATE(2), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+
+            OFAggregateStatsRequestVer11 aggregateStatsRequestVer11 = new OFAggregateStatsRequestVer11(
+                    xid,
+                      flags,
+                      tableId,
+                      outPort,
+                      outGroup,
+                      cookie,
+                      cookieMask,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", aggregateStatsRequestVer11);
+            return aggregateStatsRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAggregateStatsRequestVer11Funnel FUNNEL = new OFAggregateStatsRequestVer11Funnel();
+    static class OFAggregateStatsRequestVer11Funnel implements Funnel<OFAggregateStatsRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAggregateStatsRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 136
+            sink.putShort((short) 0x88);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 2
+            sink.putShort((short) 0x2);
+            OFStatsRequestFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            // skip pad (4 bytes)
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAggregateStatsRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFAggregateStatsRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 136
+            bb.writeShort((short) 0x88);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 2
+            bb.writeShort((short) 0x2);
+            OFStatsRequestFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.match.writeTo(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAggregateStatsRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAggregateStatsRequestVer11 other = (OFAggregateStatsRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadActionCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadActionCodeSerializerVer11.java
new file mode 100644
index 0000000..8b31fc3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadActionCodeSerializerVer11.java
@@ -0,0 +1,129 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadActionCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadActionCodeSerializerVer11 {
+
+    public final static short BAD_TYPE_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x2;
+    public final static short BAD_EXPERIMENTER_TYPE_VAL = (short) 0x3;
+    public final static short BAD_OUT_PORT_VAL = (short) 0x4;
+    public final static short BAD_ARGUMENT_VAL = (short) 0x5;
+    public final static short EPERM_VAL = (short) 0x6;
+    public final static short TOO_MANY_VAL = (short) 0x7;
+    public final static short BAD_QUEUE_VAL = (short) 0x8;
+    public final static short BAD_OUT_GROUP_VAL = (short) 0x9;
+    public final static short MATCH_INCONSISTENT_VAL = (short) 0xa;
+    public final static short UNSUPPORTED_ORDER_VAL = (short) 0xb;
+    public final static short BAD_TAG_VAL = (short) 0xc;
+
+    public static OFBadActionCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadActionCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadActionCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadActionCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TYPE_VAL:
+                return OFBadActionCode.BAD_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadActionCode.BAD_LEN;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadActionCode.BAD_EXPERIMENTER;
+            case BAD_EXPERIMENTER_TYPE_VAL:
+                return OFBadActionCode.BAD_EXPERIMENTER_TYPE;
+            case BAD_OUT_PORT_VAL:
+                return OFBadActionCode.BAD_OUT_PORT;
+            case BAD_ARGUMENT_VAL:
+                return OFBadActionCode.BAD_ARGUMENT;
+            case EPERM_VAL:
+                return OFBadActionCode.EPERM;
+            case TOO_MANY_VAL:
+                return OFBadActionCode.TOO_MANY;
+            case BAD_QUEUE_VAL:
+                return OFBadActionCode.BAD_QUEUE;
+            case BAD_OUT_GROUP_VAL:
+                return OFBadActionCode.BAD_OUT_GROUP;
+            case MATCH_INCONSISTENT_VAL:
+                return OFBadActionCode.MATCH_INCONSISTENT;
+            case UNSUPPORTED_ORDER_VAL:
+                return OFBadActionCode.UNSUPPORTED_ORDER;
+            case BAD_TAG_VAL:
+                return OFBadActionCode.BAD_TAG;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadActionCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadActionCode e) {
+        switch(e) {
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_EXPERIMENTER_TYPE:
+                return BAD_EXPERIMENTER_TYPE_VAL;
+            case BAD_OUT_PORT:
+                return BAD_OUT_PORT_VAL;
+            case BAD_ARGUMENT:
+                return BAD_ARGUMENT_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case TOO_MANY:
+                return TOO_MANY_VAL;
+            case BAD_QUEUE:
+                return BAD_QUEUE_VAL;
+            case BAD_OUT_GROUP:
+                return BAD_OUT_GROUP_VAL;
+            case MATCH_INCONSISTENT:
+                return MATCH_INCONSISTENT_VAL;
+            case UNSUPPORTED_ORDER:
+                return UNSUPPORTED_ORDER_VAL;
+            case BAD_TAG:
+                return BAD_TAG_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadActionCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadActionErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadActionErrorMsgVer11.java
new file mode 100644
index 0000000..e16e1b9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadActionErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadActionErrorMsgVer11 implements OFBadActionErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadActionErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadActionCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadActionErrorMsgVer11(long xid, OFBadActionCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadActionErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadActionErrorMsg.Builder {
+        final OFBadActionErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadActionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadActionErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setCode(OFBadActionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadActionErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadActionCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadActionErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadActionErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadActionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setCode(OFBadActionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadActionErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadActionErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadActionErrorMsg> {
+        @Override
+        public OFBadActionErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 2
+            short errType = bb.readShort();
+            if(errType != (short) 0x2)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_ACTION(2), got="+errType);
+            OFBadActionCode code = OFBadActionCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFBadActionErrorMsgVer11 badActionErrorMsgVer11 = new OFBadActionErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badActionErrorMsgVer11);
+            return badActionErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadActionErrorMsgVer11Funnel FUNNEL = new OFBadActionErrorMsgVer11Funnel();
+    static class OFBadActionErrorMsgVer11Funnel implements Funnel<OFBadActionErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadActionErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 2
+            sink.putShort((short) 0x2);
+            OFBadActionCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadActionErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadActionErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 2
+            bb.writeShort((short) 0x2);
+            OFBadActionCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadActionErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadActionErrorMsgVer11 other = (OFBadActionErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadInstructionCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadInstructionCodeSerializerVer11.java
new file mode 100644
index 0000000..78ddd43
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadInstructionCodeSerializerVer11.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadInstructionCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadInstructionCodeSerializerVer11 {
+
+    public final static short UNKNOWN_INST_VAL = (short) 0x0;
+    public final static short UNSUP_INST_VAL = (short) 0x1;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x2;
+    public final static short UNSUP_METADATA_VAL = (short) 0x3;
+    public final static short UNSUP_METADATA_MASK_VAL = (short) 0x4;
+    public final static short UNSUP_EXP_INST_VAL = (short) 0x5;
+
+    public static OFBadInstructionCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadInstructionCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadInstructionCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadInstructionCode ofWireValue(short val) {
+        switch(val) {
+            case UNKNOWN_INST_VAL:
+                return OFBadInstructionCode.UNKNOWN_INST;
+            case UNSUP_INST_VAL:
+                return OFBadInstructionCode.UNSUP_INST;
+            case BAD_TABLE_ID_VAL:
+                return OFBadInstructionCode.BAD_TABLE_ID;
+            case UNSUP_METADATA_VAL:
+                return OFBadInstructionCode.UNSUP_METADATA;
+            case UNSUP_METADATA_MASK_VAL:
+                return OFBadInstructionCode.UNSUP_METADATA_MASK;
+            case UNSUP_EXP_INST_VAL:
+                return OFBadInstructionCode.UNSUP_EXP_INST;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadInstructionCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadInstructionCode e) {
+        switch(e) {
+            case UNKNOWN_INST:
+                return UNKNOWN_INST_VAL;
+            case UNSUP_INST:
+                return UNSUP_INST_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            case UNSUP_METADATA:
+                return UNSUP_METADATA_VAL;
+            case UNSUP_METADATA_MASK:
+                return UNSUP_METADATA_MASK_VAL;
+            case UNSUP_EXP_INST:
+                return UNSUP_EXP_INST_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadInstructionCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadInstructionErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadInstructionErrorMsgVer11.java
new file mode 100644
index 0000000..08d0086
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadInstructionErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadInstructionErrorMsgVer11 implements OFBadInstructionErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadInstructionErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadInstructionCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadInstructionErrorMsgVer11(long xid, OFBadInstructionCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadInstructionErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadInstructionErrorMsg.Builder {
+        final OFBadInstructionErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadInstructionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadInstructionErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setCode(OFBadInstructionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadInstructionErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadInstructionCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadInstructionErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadInstructionErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadInstructionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setCode(OFBadInstructionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadInstructionErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadInstructionErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadInstructionErrorMsg> {
+        @Override
+        public OFBadInstructionErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 3
+            short errType = bb.readShort();
+            if(errType != (short) 0x3)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_INSTRUCTION(3), got="+errType);
+            OFBadInstructionCode code = OFBadInstructionCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFBadInstructionErrorMsgVer11 badInstructionErrorMsgVer11 = new OFBadInstructionErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badInstructionErrorMsgVer11);
+            return badInstructionErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadInstructionErrorMsgVer11Funnel FUNNEL = new OFBadInstructionErrorMsgVer11Funnel();
+    static class OFBadInstructionErrorMsgVer11Funnel implements Funnel<OFBadInstructionErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadInstructionErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 3
+            sink.putShort((short) 0x3);
+            OFBadInstructionCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadInstructionErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadInstructionErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 3
+            bb.writeShort((short) 0x3);
+            OFBadInstructionCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadInstructionErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadInstructionErrorMsgVer11 other = (OFBadInstructionErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadMatchCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadMatchCodeSerializerVer11.java
new file mode 100644
index 0000000..1a649b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadMatchCodeSerializerVer11.java
@@ -0,0 +1,104 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadMatchCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadMatchCodeSerializerVer11 {
+
+    public final static short BAD_TYPE_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short BAD_TAG_VAL = (short) 0x2;
+    public final static short BAD_DL_ADDR_MASK_VAL = (short) 0x3;
+    public final static short BAD_NW_ADDR_MASK_VAL = (short) 0x4;
+    public final static short BAD_WILDCARDS_VAL = (short) 0x5;
+    public final static short BAD_FIELD_VAL = (short) 0x6;
+    public final static short BAD_VALUE_VAL = (short) 0x7;
+
+    public static OFBadMatchCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadMatchCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadMatchCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadMatchCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TYPE_VAL:
+                return OFBadMatchCode.BAD_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadMatchCode.BAD_LEN;
+            case BAD_TAG_VAL:
+                return OFBadMatchCode.BAD_TAG;
+            case BAD_DL_ADDR_MASK_VAL:
+                return OFBadMatchCode.BAD_DL_ADDR_MASK;
+            case BAD_NW_ADDR_MASK_VAL:
+                return OFBadMatchCode.BAD_NW_ADDR_MASK;
+            case BAD_WILDCARDS_VAL:
+                return OFBadMatchCode.BAD_WILDCARDS;
+            case BAD_FIELD_VAL:
+                return OFBadMatchCode.BAD_FIELD;
+            case BAD_VALUE_VAL:
+                return OFBadMatchCode.BAD_VALUE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadMatchCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadMatchCode e) {
+        switch(e) {
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BAD_TAG:
+                return BAD_TAG_VAL;
+            case BAD_DL_ADDR_MASK:
+                return BAD_DL_ADDR_MASK_VAL;
+            case BAD_NW_ADDR_MASK:
+                return BAD_NW_ADDR_MASK_VAL;
+            case BAD_WILDCARDS:
+                return BAD_WILDCARDS_VAL;
+            case BAD_FIELD:
+                return BAD_FIELD_VAL;
+            case BAD_VALUE:
+                return BAD_VALUE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadMatchCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadMatchErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadMatchErrorMsgVer11.java
new file mode 100644
index 0000000..5f82c26
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadMatchErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadMatchErrorMsgVer11 implements OFBadMatchErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadMatchErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadMatchCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadMatchErrorMsgVer11(long xid, OFBadMatchCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadMatchErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadMatchErrorMsg.Builder {
+        final OFBadMatchErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadMatchCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadMatchErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setCode(OFBadMatchCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadMatchErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadMatchCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadMatchErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadMatchErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadMatchCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setCode(OFBadMatchCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadMatchErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadMatchErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadMatchErrorMsg> {
+        @Override
+        public OFBadMatchErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 4
+            short errType = bb.readShort();
+            if(errType != (short) 0x4)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_MATCH(4), got="+errType);
+            OFBadMatchCode code = OFBadMatchCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFBadMatchErrorMsgVer11 badMatchErrorMsgVer11 = new OFBadMatchErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badMatchErrorMsgVer11);
+            return badMatchErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadMatchErrorMsgVer11Funnel FUNNEL = new OFBadMatchErrorMsgVer11Funnel();
+    static class OFBadMatchErrorMsgVer11Funnel implements Funnel<OFBadMatchErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadMatchErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 4
+            sink.putShort((short) 0x4);
+            OFBadMatchCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadMatchErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadMatchErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 4
+            bb.writeShort((short) 0x4);
+            OFBadMatchCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadMatchErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadMatchErrorMsgVer11 other = (OFBadMatchErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadRequestCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadRequestCodeSerializerVer11.java
new file mode 100644
index 0000000..fc0a51a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadRequestCodeSerializerVer11.java
@@ -0,0 +1,114 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadRequestCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadRequestCodeSerializerVer11 {
+
+    public final static short BAD_VERSION_VAL = (short) 0x0;
+    public final static short BAD_TYPE_VAL = (short) 0x1;
+    public final static short BAD_STAT_VAL = (short) 0x2;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x3;
+    public final static short BAD_SUBTYPE_VAL = (short) 0x4;
+    public final static short EPERM_VAL = (short) 0x5;
+    public final static short BAD_LEN_VAL = (short) 0x6;
+    public final static short BUFFER_EMPTY_VAL = (short) 0x7;
+    public final static short BUFFER_UNKNOWN_VAL = (short) 0x8;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x9;
+
+    public static OFBadRequestCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadRequestCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadRequestCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadRequestCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_VERSION_VAL:
+                return OFBadRequestCode.BAD_VERSION;
+            case BAD_TYPE_VAL:
+                return OFBadRequestCode.BAD_TYPE;
+            case BAD_STAT_VAL:
+                return OFBadRequestCode.BAD_STAT;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadRequestCode.BAD_EXPERIMENTER;
+            case BAD_SUBTYPE_VAL:
+                return OFBadRequestCode.BAD_SUBTYPE;
+            case EPERM_VAL:
+                return OFBadRequestCode.EPERM;
+            case BAD_LEN_VAL:
+                return OFBadRequestCode.BAD_LEN;
+            case BUFFER_EMPTY_VAL:
+                return OFBadRequestCode.BUFFER_EMPTY;
+            case BUFFER_UNKNOWN_VAL:
+                return OFBadRequestCode.BUFFER_UNKNOWN;
+            case BAD_TABLE_ID_VAL:
+                return OFBadRequestCode.BAD_TABLE_ID;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadRequestCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadRequestCode e) {
+        switch(e) {
+            case BAD_VERSION:
+                return BAD_VERSION_VAL;
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_STAT:
+                return BAD_STAT_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_SUBTYPE:
+                return BAD_SUBTYPE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BUFFER_EMPTY:
+                return BUFFER_EMPTY_VAL;
+            case BUFFER_UNKNOWN:
+                return BUFFER_UNKNOWN_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadRequestCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadRequestErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadRequestErrorMsgVer11.java
new file mode 100644
index 0000000..19aadaa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBadRequestErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadRequestErrorMsgVer11 implements OFBadRequestErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadRequestErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadRequestCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadRequestErrorMsgVer11(long xid, OFBadRequestCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadRequestErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadRequestErrorMsg.Builder {
+        final OFBadRequestErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadRequestCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadRequestErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setCode(OFBadRequestCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadRequestErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadRequestCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadRequestErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadRequestErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadRequestCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setCode(OFBadRequestCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadRequestErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadRequestErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadRequestErrorMsg> {
+        @Override
+        public OFBadRequestErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 1
+            short errType = bb.readShort();
+            if(errType != (short) 0x1)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_REQUEST(1), got="+errType);
+            OFBadRequestCode code = OFBadRequestCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFBadRequestErrorMsgVer11 badRequestErrorMsgVer11 = new OFBadRequestErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badRequestErrorMsgVer11);
+            return badRequestErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadRequestErrorMsgVer11Funnel FUNNEL = new OFBadRequestErrorMsgVer11Funnel();
+    static class OFBadRequestErrorMsgVer11Funnel implements Funnel<OFBadRequestErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadRequestErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 1
+            sink.putShort((short) 0x1);
+            OFBadRequestCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadRequestErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadRequestErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 1
+            bb.writeShort((short) 0x1);
+            OFBadRequestCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadRequestErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadRequestErrorMsgVer11 other = (OFBadRequestErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBarrierReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBarrierReplyVer11.java
new file mode 100644
index 0000000..f32ac97
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBarrierReplyVer11.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBarrierReplyVer11 implements OFBarrierReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBarrierReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBarrierReplyVer11 DEFAULT = new OFBarrierReplyVer11(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBarrierReplyVer11(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFBarrierReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBarrierReply.Builder {
+        final OFBarrierReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBarrierReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBarrierReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBarrierReplyVer11(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBarrierReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBarrierReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBarrierReplyVer11(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBarrierReply> {
+        @Override
+        public OFBarrierReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 21
+            byte type = bb.readByte();
+            if(type != (byte) 0x15)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REPLY(21), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFBarrierReplyVer11 barrierReplyVer11 = new OFBarrierReplyVer11(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", barrierReplyVer11);
+            return barrierReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBarrierReplyVer11Funnel FUNNEL = new OFBarrierReplyVer11Funnel();
+    static class OFBarrierReplyVer11Funnel implements Funnel<OFBarrierReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBarrierReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 21
+            sink.putByte((byte) 0x15);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBarrierReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBarrierReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 21
+            bb.writeByte((byte) 0x15);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBarrierReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBarrierReplyVer11 other = (OFBarrierReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBarrierRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBarrierRequestVer11.java
new file mode 100644
index 0000000..99601a1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBarrierRequestVer11.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBarrierRequestVer11 implements OFBarrierRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBarrierRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBarrierRequestVer11 DEFAULT = new OFBarrierRequestVer11(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBarrierRequestVer11(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFBarrierRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBarrierRequest.Builder {
+        final OFBarrierRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBarrierRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBarrierRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBarrierRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBarrierRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBarrierRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBarrierRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBarrierRequest> {
+        @Override
+        public OFBarrierRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 20
+            byte type = bb.readByte();
+            if(type != (byte) 0x14)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REQUEST(20), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFBarrierRequestVer11 barrierRequestVer11 = new OFBarrierRequestVer11(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", barrierRequestVer11);
+            return barrierRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBarrierRequestVer11Funnel FUNNEL = new OFBarrierRequestVer11Funnel();
+    static class OFBarrierRequestVer11Funnel implements Funnel<OFBarrierRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBarrierRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 20
+            sink.putByte((byte) 0x14);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBarrierRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBarrierRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 20
+            bb.writeByte((byte) 0x14);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBarrierRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBarrierRequestVer11 other = (OFBarrierRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwClearDataReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwClearDataReplyVer11.java
new file mode 100644
index 0000000..4354c41
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwClearDataReplyVer11.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwClearDataReplyVer11 implements OFBsnBwClearDataReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwClearDataReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnBwClearDataReplyVer11 DEFAULT = new OFBsnBwClearDataReplyVer11(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwClearDataReplyVer11(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnBwClearDataReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwClearDataReply.Builder {
+        final OFBsnBwClearDataReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnBwClearDataReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwClearDataReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnBwClearDataReplyVer11(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwClearDataReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwClearDataReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnBwClearDataReplyVer11(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwClearDataReply> {
+        @Override
+        public OFBsnBwClearDataReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x16L
+            int subtype = bb.readInt();
+            if(subtype != 0x16)
+                throw new OFParseError("Wrong subtype: Expected=0x16L(0x16L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnBwClearDataReplyVer11 bsnBwClearDataReplyVer11 = new OFBsnBwClearDataReplyVer11(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwClearDataReplyVer11);
+            return bsnBwClearDataReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwClearDataReplyVer11Funnel FUNNEL = new OFBsnBwClearDataReplyVer11Funnel();
+    static class OFBsnBwClearDataReplyVer11Funnel implements Funnel<OFBsnBwClearDataReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwClearDataReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x16L
+            sink.putInt(0x16);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwClearDataReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwClearDataReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x16L
+            bb.writeInt(0x16);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwClearDataReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwClearDataReplyVer11 other = (OFBsnBwClearDataReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwClearDataRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwClearDataRequestVer11.java
new file mode 100644
index 0000000..0e98b78
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwClearDataRequestVer11.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwClearDataRequestVer11 implements OFBsnBwClearDataRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwClearDataRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnBwClearDataRequestVer11 DEFAULT = new OFBsnBwClearDataRequestVer11(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwClearDataRequestVer11(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+
+
+    public OFBsnBwClearDataRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwClearDataRequest.Builder {
+        final OFBsnBwClearDataRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnBwClearDataRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+
+
+        @Override
+        public OFBsnBwClearDataRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnBwClearDataRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwClearDataRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+//
+        @Override
+        public OFBsnBwClearDataRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnBwClearDataRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwClearDataRequest> {
+        @Override
+        public OFBsnBwClearDataRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x15L
+            int subtype = bb.readInt();
+            if(subtype != 0x15)
+                throw new OFParseError("Wrong subtype: Expected=0x15L(0x15L), got="+subtype);
+
+            OFBsnBwClearDataRequestVer11 bsnBwClearDataRequestVer11 = new OFBsnBwClearDataRequestVer11(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwClearDataRequestVer11);
+            return bsnBwClearDataRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwClearDataRequestVer11Funnel FUNNEL = new OFBsnBwClearDataRequestVer11Funnel();
+    static class OFBsnBwClearDataRequestVer11Funnel implements Funnel<OFBsnBwClearDataRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwClearDataRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x15L
+            sink.putInt(0x15);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwClearDataRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwClearDataRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x15L
+            bb.writeInt(0x15);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwClearDataRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwClearDataRequestVer11 other = (OFBsnBwClearDataRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableGetReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableGetReplyVer11.java
new file mode 100644
index 0000000..9397dc2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableGetReplyVer11.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableGetReplyVer11 implements OFBsnBwEnableGetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableGetReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLED = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enabled;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableGetReplyVer11 DEFAULT = new OFBsnBwEnableGetReplyVer11(
+        DEFAULT_XID, DEFAULT_ENABLED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableGetReplyVer11(long xid, long enabled) {
+        this.xid = xid;
+        this.enabled = enabled;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+
+
+    public OFBsnBwEnableGetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableGetReply.Builder {
+        final OFBsnBwEnableGetReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+        BuilderWithParent(OFBsnBwEnableGetReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableGetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+
+                //
+                return new OFBsnBwEnableGetReplyVer11(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableGetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableGetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+
+
+            return new OFBsnBwEnableGetReplyVer11(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableGetReply> {
+        @Override
+        public OFBsnBwEnableGetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x14L
+            int subtype = bb.readInt();
+            if(subtype != 0x14)
+                throw new OFParseError("Wrong subtype: Expected=0x14L(0x14L), got="+subtype);
+            long enabled = U32.f(bb.readInt());
+
+            OFBsnBwEnableGetReplyVer11 bsnBwEnableGetReplyVer11 = new OFBsnBwEnableGetReplyVer11(
+                    xid,
+                      enabled
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableGetReplyVer11);
+            return bsnBwEnableGetReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableGetReplyVer11Funnel FUNNEL = new OFBsnBwEnableGetReplyVer11Funnel();
+    static class OFBsnBwEnableGetReplyVer11Funnel implements Funnel<OFBsnBwEnableGetReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableGetReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x14L
+            sink.putInt(0x14);
+            sink.putLong(message.enabled);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableGetReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableGetReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x14L
+            bb.writeInt(0x14);
+            bb.writeInt(U32.t(message.enabled));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableGetReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableGetReplyVer11 other = (OFBsnBwEnableGetReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enabled ^ (enabled >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableGetRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableGetRequestVer11.java
new file mode 100644
index 0000000..674f293
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableGetRequestVer11.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableGetRequestVer11 implements OFBsnBwEnableGetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableGetRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableGetRequestVer11 DEFAULT = new OFBsnBwEnableGetRequestVer11(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableGetRequestVer11(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+
+
+    public OFBsnBwEnableGetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableGetRequest.Builder {
+        final OFBsnBwEnableGetRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnBwEnableGetRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+
+
+        @Override
+        public OFBsnBwEnableGetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnBwEnableGetRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableGetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+//
+        @Override
+        public OFBsnBwEnableGetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnBwEnableGetRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableGetRequest> {
+        @Override
+        public OFBsnBwEnableGetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x13L
+            int subtype = bb.readInt();
+            if(subtype != 0x13)
+                throw new OFParseError("Wrong subtype: Expected=0x13L(0x13L), got="+subtype);
+
+            OFBsnBwEnableGetRequestVer11 bsnBwEnableGetRequestVer11 = new OFBsnBwEnableGetRequestVer11(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableGetRequestVer11);
+            return bsnBwEnableGetRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableGetRequestVer11Funnel FUNNEL = new OFBsnBwEnableGetRequestVer11Funnel();
+    static class OFBsnBwEnableGetRequestVer11Funnel implements Funnel<OFBsnBwEnableGetRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableGetRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x13L
+            sink.putInt(0x13);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableGetRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableGetRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x13L
+            bb.writeInt(0x13);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableGetRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableGetRequestVer11 other = (OFBsnBwEnableGetRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableSetReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableSetReplyVer11.java
new file mode 100644
index 0000000..b08bda3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableSetReplyVer11.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableSetReplyVer11 implements OFBsnBwEnableSetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableSetReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableSetReplyVer11 DEFAULT = new OFBsnBwEnableSetReplyVer11(
+        DEFAULT_XID, DEFAULT_ENABLE, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableSetReplyVer11(long xid, long enable, long status) {
+        this.xid = xid;
+        this.enable = enable;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnBwEnableSetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableSetReply.Builder {
+        final OFBsnBwEnableSetReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnBwEnableSetReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableSetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnBwEnableSetReplyVer11(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableSetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableSetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnBwEnableSetReplyVer11(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableSetReply> {
+        @Override
+        public OFBsnBwEnableSetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x17L
+            int subtype = bb.readInt();
+            if(subtype != 0x17)
+                throw new OFParseError("Wrong subtype: Expected=0x17L(0x17L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+            long status = U32.f(bb.readInt());
+
+            OFBsnBwEnableSetReplyVer11 bsnBwEnableSetReplyVer11 = new OFBsnBwEnableSetReplyVer11(
+                    xid,
+                      enable,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableSetReplyVer11);
+            return bsnBwEnableSetReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableSetReplyVer11Funnel FUNNEL = new OFBsnBwEnableSetReplyVer11Funnel();
+    static class OFBsnBwEnableSetReplyVer11Funnel implements Funnel<OFBsnBwEnableSetReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableSetReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x17L
+            sink.putInt(0x17);
+            sink.putLong(message.enable);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableSetReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableSetReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x17L
+            bb.writeInt(0x17);
+            bb.writeInt(U32.t(message.enable));
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableSetReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableSetReplyVer11 other = (OFBsnBwEnableSetReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableSetRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableSetRequestVer11.java
new file mode 100644
index 0000000..8fa7ea9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnBwEnableSetRequestVer11.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableSetRequestVer11 implements OFBsnBwEnableSetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableSetRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableSetRequestVer11 DEFAULT = new OFBsnBwEnableSetRequestVer11(
+        DEFAULT_XID, DEFAULT_ENABLE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableSetRequestVer11(long xid, long enable) {
+        this.xid = xid;
+        this.enable = enable;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+
+
+    public OFBsnBwEnableSetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableSetRequest.Builder {
+        final OFBsnBwEnableSetRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+        BuilderWithParent(OFBsnBwEnableSetRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableSetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+
+                //
+                return new OFBsnBwEnableSetRequestVer11(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableSetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableSetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+
+
+            return new OFBsnBwEnableSetRequestVer11(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableSetRequest> {
+        @Override
+        public OFBsnBwEnableSetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x12L
+            int subtype = bb.readInt();
+            if(subtype != 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12L(0x12L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+
+            OFBsnBwEnableSetRequestVer11 bsnBwEnableSetRequestVer11 = new OFBsnBwEnableSetRequestVer11(
+                    xid,
+                      enable
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableSetRequestVer11);
+            return bsnBwEnableSetRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableSetRequestVer11Funnel FUNNEL = new OFBsnBwEnableSetRequestVer11Funnel();
+    static class OFBsnBwEnableSetRequestVer11Funnel implements Funnel<OFBsnBwEnableSetRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableSetRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x12L
+            sink.putInt(0x12);
+            sink.putLong(message.enable);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableSetRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableSetRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x12L
+            bb.writeInt(0x12);
+            bb.writeInt(U32.t(message.enable));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableSetRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableSetRequestVer11 other = (OFBsnBwEnableSetRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetInterfacesReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetInterfacesReplyVer11.java
new file mode 100644
index 0000000..7ac2093
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetInterfacesReplyVer11.java
@@ -0,0 +1,375 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetInterfacesReplyVer11 implements OFBsnGetInterfacesReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetInterfacesReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static List<OFBsnInterface> DEFAULT_INTERFACES = ImmutableList.<OFBsnInterface>of();
+
+    // OF message fields
+    private final long xid;
+    private final List<OFBsnInterface> interfaces;
+//
+    // Immutable default instance
+    final static OFBsnGetInterfacesReplyVer11 DEFAULT = new OFBsnGetInterfacesReplyVer11(
+        DEFAULT_XID, DEFAULT_INTERFACES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetInterfacesReplyVer11(long xid, List<OFBsnInterface> interfaces) {
+        this.xid = xid;
+        this.interfaces = interfaces;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+
+
+    public OFBsnGetInterfacesReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetInterfacesReply.Builder {
+        final OFBsnGetInterfacesReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean interfacesSet;
+        private List<OFBsnInterface> interfaces;
+
+        BuilderWithParent(OFBsnGetInterfacesReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setInterfaces(List<OFBsnInterface> interfaces) {
+        this.interfaces = interfaces;
+        this.interfacesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetInterfacesReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                List<OFBsnInterface> interfaces = this.interfacesSet ? this.interfaces : parentMessage.interfaces;
+                if(interfaces == null)
+                    throw new NullPointerException("Property interfaces must not be null");
+
+                //
+                return new OFBsnGetInterfacesReplyVer11(
+                    xid,
+                    interfaces
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetInterfacesReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean interfacesSet;
+        private List<OFBsnInterface> interfaces;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setInterfaces(List<OFBsnInterface> interfaces) {
+        this.interfaces = interfaces;
+        this.interfacesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetInterfacesReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            List<OFBsnInterface> interfaces = this.interfacesSet ? this.interfaces : DEFAULT_INTERFACES;
+            if(interfaces == null)
+                throw new NullPointerException("Property interfaces must not be null");
+
+
+            return new OFBsnGetInterfacesReplyVer11(
+                    xid,
+                    interfaces
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetInterfacesReply> {
+        @Override
+        public OFBsnGetInterfacesReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xaL
+            int subtype = bb.readInt();
+            if(subtype != 0xa)
+                throw new OFParseError("Wrong subtype: Expected=0xaL(0xaL), got="+subtype);
+            List<OFBsnInterface> interfaces = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnInterfaceVer11.READER);
+
+            OFBsnGetInterfacesReplyVer11 bsnGetInterfacesReplyVer11 = new OFBsnGetInterfacesReplyVer11(
+                    xid,
+                      interfaces
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetInterfacesReplyVer11);
+            return bsnGetInterfacesReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetInterfacesReplyVer11Funnel FUNNEL = new OFBsnGetInterfacesReplyVer11Funnel();
+    static class OFBsnGetInterfacesReplyVer11Funnel implements Funnel<OFBsnGetInterfacesReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetInterfacesReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            sink.putInt(0xa);
+            FunnelUtils.putList(message.interfaces, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetInterfacesReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetInterfacesReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            bb.writeInt(0xa);
+            ChannelUtils.writeList(bb, message.interfaces);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetInterfacesReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("interfaces=").append(interfaces);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetInterfacesReplyVer11 other = (OFBsnGetInterfacesReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (interfaces == null) {
+            if (other.interfaces != null)
+                return false;
+        } else if (!interfaces.equals(other.interfaces))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetInterfacesRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetInterfacesRequestVer11.java
new file mode 100644
index 0000000..b5bdd2a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetInterfacesRequestVer11.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetInterfacesRequestVer11 implements OFBsnGetInterfacesRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetInterfacesRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnGetInterfacesRequestVer11 DEFAULT = new OFBsnGetInterfacesRequestVer11(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetInterfacesRequestVer11(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+
+
+    public OFBsnGetInterfacesRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetInterfacesRequest.Builder {
+        final OFBsnGetInterfacesRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnGetInterfacesRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+
+
+        @Override
+        public OFBsnGetInterfacesRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnGetInterfacesRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetInterfacesRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+//
+        @Override
+        public OFBsnGetInterfacesRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnGetInterfacesRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetInterfacesRequest> {
+        @Override
+        public OFBsnGetInterfacesRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x9L
+            int subtype = bb.readInt();
+            if(subtype != 0x9)
+                throw new OFParseError("Wrong subtype: Expected=0x9L(0x9L), got="+subtype);
+
+            OFBsnGetInterfacesRequestVer11 bsnGetInterfacesRequestVer11 = new OFBsnGetInterfacesRequestVer11(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetInterfacesRequestVer11);
+            return bsnGetInterfacesRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetInterfacesRequestVer11Funnel FUNNEL = new OFBsnGetInterfacesRequestVer11Funnel();
+    static class OFBsnGetInterfacesRequestVer11Funnel implements Funnel<OFBsnGetInterfacesRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetInterfacesRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            sink.putInt(0x9);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetInterfacesRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetInterfacesRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            bb.writeInt(0x9);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetInterfacesRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetInterfacesRequestVer11 other = (OFBsnGetInterfacesRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetMirroringReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetMirroringReplyVer11.java
new file mode 100644
index 0000000..cfd078f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetMirroringReplyVer11.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetMirroringReplyVer11 implements OFBsnGetMirroringReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetMirroringReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnGetMirroringReplyVer11 DEFAULT = new OFBsnGetMirroringReplyVer11(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetMirroringReplyVer11(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnGetMirroringReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetMirroringReply.Builder {
+        final OFBsnGetMirroringReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnGetMirroringReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetMirroringReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnGetMirroringReplyVer11(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetMirroringReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetMirroringReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnGetMirroringReplyVer11(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetMirroringReply> {
+        @Override
+        public OFBsnGetMirroringReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x5L
+            int subtype = bb.readInt();
+            if(subtype != 0x5)
+                throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnGetMirroringReplyVer11 bsnGetMirroringReplyVer11 = new OFBsnGetMirroringReplyVer11(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetMirroringReplyVer11);
+            return bsnGetMirroringReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetMirroringReplyVer11Funnel FUNNEL = new OFBsnGetMirroringReplyVer11Funnel();
+    static class OFBsnGetMirroringReplyVer11Funnel implements Funnel<OFBsnGetMirroringReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetMirroringReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            sink.putInt(0x5);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetMirroringReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetMirroringReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            bb.writeInt(0x5);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetMirroringReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetMirroringReplyVer11 other = (OFBsnGetMirroringReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetMirroringRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetMirroringRequestVer11.java
new file mode 100644
index 0000000..da39036
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnGetMirroringRequestVer11.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetMirroringRequestVer11 implements OFBsnGetMirroringRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetMirroringRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnGetMirroringRequestVer11 DEFAULT = new OFBsnGetMirroringRequestVer11(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetMirroringRequestVer11(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnGetMirroringRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetMirroringRequest.Builder {
+        final OFBsnGetMirroringRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnGetMirroringRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetMirroringRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnGetMirroringRequestVer11(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetMirroringRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetMirroringRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnGetMirroringRequestVer11(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetMirroringRequest> {
+        @Override
+        public OFBsnGetMirroringRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnGetMirroringRequestVer11 bsnGetMirroringRequestVer11 = new OFBsnGetMirroringRequestVer11(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetMirroringRequestVer11);
+            return bsnGetMirroringRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetMirroringRequestVer11Funnel FUNNEL = new OFBsnGetMirroringRequestVer11Funnel();
+    static class OFBsnGetMirroringRequestVer11Funnel implements Funnel<OFBsnGetMirroringRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetMirroringRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetMirroringRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetMirroringRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetMirroringRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetMirroringRequestVer11 other = (OFBsnGetMirroringRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnHeaderVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnHeaderVer11.java
new file mode 100644
index 0000000..ae20cc3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnHeaderVer11.java
@@ -0,0 +1,133 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFBsnHeaderVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFBsnHeaderVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnHeader> {
+        @Override
+        public OFBsnHeader readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x16:
+                   // discriminator value 0x16L=0x16L for class OFBsnBwClearDataReplyVer11
+                   return OFBsnBwClearDataReplyVer11.READER.readFrom(bb);
+               case 0x15:
+                   // discriminator value 0x15L=0x15L for class OFBsnBwClearDataRequestVer11
+                   return OFBsnBwClearDataRequestVer11.READER.readFrom(bb);
+               case 0x14:
+                   // discriminator value 0x14L=0x14L for class OFBsnBwEnableGetReplyVer11
+                   return OFBsnBwEnableGetReplyVer11.READER.readFrom(bb);
+               case 0x13:
+                   // discriminator value 0x13L=0x13L for class OFBsnBwEnableGetRequestVer11
+                   return OFBsnBwEnableGetRequestVer11.READER.readFrom(bb);
+               case 0x17:
+                   // discriminator value 0x17L=0x17L for class OFBsnBwEnableSetReplyVer11
+                   return OFBsnBwEnableSetReplyVer11.READER.readFrom(bb);
+               case 0x12:
+                   // discriminator value 0x12L=0x12L for class OFBsnBwEnableSetRequestVer11
+                   return OFBsnBwEnableSetRequestVer11.READER.readFrom(bb);
+               case 0xa:
+                   // discriminator value 0xaL=0xaL for class OFBsnGetInterfacesReplyVer11
+                   return OFBsnGetInterfacesReplyVer11.READER.readFrom(bb);
+               case 0x9:
+                   // discriminator value 0x9L=0x9L for class OFBsnGetInterfacesRequestVer11
+                   return OFBsnGetInterfacesRequestVer11.READER.readFrom(bb);
+               case 0x5:
+                   // discriminator value 0x5L=0x5L for class OFBsnGetMirroringReplyVer11
+                   return OFBsnGetMirroringReplyVer11.READER.readFrom(bb);
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFBsnGetMirroringRequestVer11
+                   return OFBsnGetMirroringRequestVer11.READER.readFrom(bb);
+               case 0x22:
+                   // discriminator value 0x22L=0x22L for class OFBsnPduRxReplyVer11
+                   return OFBsnPduRxReplyVer11.READER.readFrom(bb);
+               case 0x21:
+                   // discriminator value 0x21L=0x21L for class OFBsnPduRxRequestVer11
+                   return OFBsnPduRxRequestVer11.READER.readFrom(bb);
+               case 0x23:
+                   // discriminator value 0x23L=0x23L for class OFBsnPduRxTimeoutVer11
+                   return OFBsnPduRxTimeoutVer11.READER.readFrom(bb);
+               case 0x20:
+                   // discriminator value 0x20L=0x20L for class OFBsnPduTxReplyVer11
+                   return OFBsnPduTxReplyVer11.READER.readFrom(bb);
+               case 0x1f:
+                   // discriminator value 0x1fL=0x1fL for class OFBsnPduTxRequestVer11
+                   return OFBsnPduTxRequestVer11.READER.readFrom(bb);
+               case 0x3:
+                   // discriminator value 0x3L=0x3L for class OFBsnSetMirroringVer11
+                   return OFBsnSetMirroringVer11.READER.readFrom(bb);
+               case 0x19:
+                   // discriminator value 0x19L=0x19L for class OFBsnSetPktinSuppressionReplyVer11
+                   return OFBsnSetPktinSuppressionReplyVer11.READER.readFrom(bb);
+               case 0xb:
+                   // discriminator value 0xbL=0xbL for class OFBsnSetPktinSuppressionRequestVer11
+                   return OFBsnSetPktinSuppressionRequestVer11.READER.readFrom(bb);
+               case 0x10:
+                   // discriminator value 0x10L=0x10L for class OFBsnVirtualPortCreateReplyVer11
+                   return OFBsnVirtualPortCreateReplyVer11.READER.readFrom(bb);
+               case 0xf:
+                   // discriminator value 0xfL=0xfL for class OFBsnVirtualPortCreateRequestVer11
+                   return OFBsnVirtualPortCreateRequestVer11.READER.readFrom(bb);
+               case 0x1a:
+                   // discriminator value 0x1aL=0x1aL for class OFBsnVirtualPortRemoveReplyVer11
+                   return OFBsnVirtualPortRemoveReplyVer11.READER.readFrom(bb);
+               case 0x11:
+                   // discriminator value 0x11L=0x11L for class OFBsnVirtualPortRemoveRequestVer11
+                   return OFBsnVirtualPortRemoveRequestVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnHeaderVer11: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnInterfaceVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnInterfaceVer11.java
new file mode 100644
index 0000000..4112533
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnInterfaceVer11.java
@@ -0,0 +1,396 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnInterfaceVer11 implements OFBsnInterface {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnInterfaceVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 32;
+
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static String DEFAULT_NAME = "";
+        private final static IPv4Address DEFAULT_IPV4_ADDR = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_IPV4_NETMASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final MacAddress hwAddr;
+    private final String name;
+    private final IPv4Address ipv4Addr;
+    private final IPv4Address ipv4Netmask;
+//
+    // Immutable default instance
+    final static OFBsnInterfaceVer11 DEFAULT = new OFBsnInterfaceVer11(
+        DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_IPV4_ADDR, DEFAULT_IPV4_NETMASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnInterfaceVer11(MacAddress hwAddr, String name, IPv4Address ipv4Addr, IPv4Address ipv4Netmask) {
+        this.hwAddr = hwAddr;
+        this.name = name;
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4Netmask = ipv4Netmask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFBsnInterface.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnInterface.Builder {
+        final OFBsnInterfaceVer11 parentMessage;
+
+        // OF message fields
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+        private boolean ipv4NetmaskSet;
+        private IPv4Address ipv4Netmask;
+
+        BuilderWithParent(OFBsnInterfaceVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) {
+        this.ipv4Netmask = ipv4Netmask;
+        this.ipv4NetmaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFBsnInterface build() {
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : parentMessage.ipv4Addr;
+                if(ipv4Addr == null)
+                    throw new NullPointerException("Property ipv4Addr must not be null");
+                IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : parentMessage.ipv4Netmask;
+                if(ipv4Netmask == null)
+                    throw new NullPointerException("Property ipv4Netmask must not be null");
+
+                //
+                return new OFBsnInterfaceVer11(
+                    hwAddr,
+                    name,
+                    ipv4Addr,
+                    ipv4Netmask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnInterface.Builder {
+        // OF message fields
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+        private boolean ipv4NetmaskSet;
+        private IPv4Address ipv4Netmask;
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) {
+        this.ipv4Netmask = ipv4Netmask;
+        this.ipv4NetmaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFBsnInterface build() {
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : DEFAULT_IPV4_ADDR;
+            if(ipv4Addr == null)
+                throw new NullPointerException("Property ipv4Addr must not be null");
+            IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : DEFAULT_IPV4_NETMASK;
+            if(ipv4Netmask == null)
+                throw new NullPointerException("Property ipv4Netmask must not be null");
+
+
+            return new OFBsnInterfaceVer11(
+                    hwAddr,
+                    name,
+                    ipv4Addr,
+                    ipv4Netmask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnInterface> {
+        @Override
+        public OFBsnInterface readFrom(ChannelBuffer bb) throws OFParseError {
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            String name = ChannelUtils.readFixedLengthString(bb, 16);
+            IPv4Address ipv4Addr = IPv4Address.read4Bytes(bb);
+            IPv4Address ipv4Netmask = IPv4Address.read4Bytes(bb);
+
+            OFBsnInterfaceVer11 bsnInterfaceVer11 = new OFBsnInterfaceVer11(
+                    hwAddr,
+                      name,
+                      ipv4Addr,
+                      ipv4Netmask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnInterfaceVer11);
+            return bsnInterfaceVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnInterfaceVer11Funnel FUNNEL = new OFBsnInterfaceVer11Funnel();
+    static class OFBsnInterfaceVer11Funnel implements Funnel<OFBsnInterfaceVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnInterfaceVer11 message, PrimitiveSink sink) {
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putUnencodedChars(message.name);
+            message.ipv4Addr.putTo(sink);
+            message.ipv4Netmask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnInterfaceVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnInterfaceVer11 message) {
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 16);
+            message.ipv4Addr.write4Bytes(bb);
+            message.ipv4Netmask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnInterfaceVer11(");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("ipv4Addr=").append(ipv4Addr);
+        b.append(", ");
+        b.append("ipv4Netmask=").append(ipv4Netmask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnInterfaceVer11 other = (OFBsnInterfaceVer11) obj;
+
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (ipv4Addr == null) {
+            if (other.ipv4Addr != null)
+                return false;
+        } else if (!ipv4Addr.equals(other.ipv4Addr))
+            return false;
+        if (ipv4Netmask == null) {
+            if (other.ipv4Netmask != null)
+                return false;
+        } else if (!ipv4Netmask.equals(other.ipv4Netmask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((ipv4Addr == null) ? 0 : ipv4Addr.hashCode());
+        result = prime * result + ((ipv4Netmask == null) ? 0 : ipv4Netmask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxReplyVer11.java
new file mode 100644
index 0000000..7084853
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxReplyVer11.java
@@ -0,0 +1,462 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduRxReplyVer11 implements OFBsnPduRxReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 25;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduRxReplyVer11 DEFAULT = new OFBsnPduRxReplyVer11(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxReplyVer11(long xid, long status, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduRxReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxReply.Builder {
+        final OFBsnPduRxReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduRxReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduRxReplyVer11(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduRxReplyVer11(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxReply> {
+        @Override
+        public OFBsnPduRxReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 25)
+                throw new OFParseError("Wrong length: Expected=25(25), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x22L
+            int subtype = bb.readInt();
+            if(subtype != 0x22)
+                throw new OFParseError("Wrong subtype: Expected=0x22L(0x22L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduRxReplyVer11 bsnPduRxReplyVer11 = new OFBsnPduRxReplyVer11(
+                    xid,
+                      status,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxReplyVer11);
+            return bsnPduRxReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxReplyVer11Funnel FUNNEL = new OFBsnPduRxReplyVer11Funnel();
+    static class OFBsnPduRxReplyVer11Funnel implements Funnel<OFBsnPduRxReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 25
+            sink.putShort((short) 0x19);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x22L
+            sink.putInt(0x22);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 25
+            bb.writeShort((short) 0x19);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x22L
+            bb.writeInt(0x22);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxReplyVer11 other = (OFBsnPduRxReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxRequestVer11.java
new file mode 100644
index 0000000..fd79061
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxRequestVer11.java
@@ -0,0 +1,524 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnPduRxRequestVer11 implements OFBsnPduRxRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_TIMEOUT_MS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long timeoutMs;
+    private final OFPort portNo;
+    private final short slotNum;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnPduRxRequestVer11 DEFAULT = new OFBsnPduRxRequestVer11(
+        DEFAULT_XID, DEFAULT_TIMEOUT_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxRequestVer11(long xid, long timeoutMs, OFPort portNo, short slotNum, byte[] data) {
+        this.xid = xid;
+        this.timeoutMs = timeoutMs;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnPduRxRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxRequest.Builder {
+        final OFBsnPduRxRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeoutMsSet;
+        private long timeoutMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnPduRxRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setTimeoutMs(long timeoutMs) {
+        this.timeoutMs = timeoutMs;
+        this.timeoutMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long timeoutMs = this.timeoutMsSet ? this.timeoutMs : parentMessage.timeoutMs;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnPduRxRequestVer11(
+                    xid,
+                    timeoutMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeoutMsSet;
+        private long timeoutMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setTimeoutMs(long timeoutMs) {
+        this.timeoutMs = timeoutMs;
+        this.timeoutMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long timeoutMs = this.timeoutMsSet ? this.timeoutMs : DEFAULT_TIMEOUT_MS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnPduRxRequestVer11(
+                    xid,
+                    timeoutMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxRequest> {
+        @Override
+        public OFBsnPduRxRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x21L
+            int subtype = bb.readInt();
+            if(subtype != 0x21)
+                throw new OFParseError("Wrong subtype: Expected=0x21L(0x21L), got="+subtype);
+            long timeoutMs = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnPduRxRequestVer11 bsnPduRxRequestVer11 = new OFBsnPduRxRequestVer11(
+                    xid,
+                      timeoutMs,
+                      portNo,
+                      slotNum,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxRequestVer11);
+            return bsnPduRxRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxRequestVer11Funnel FUNNEL = new OFBsnPduRxRequestVer11Funnel();
+    static class OFBsnPduRxRequestVer11Funnel implements Funnel<OFBsnPduRxRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x21L
+            sink.putInt(0x21);
+            sink.putLong(message.timeoutMs);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+            // skip pad (3 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxRequestVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x21L
+            bb.writeInt(0x21);
+            bb.writeInt(U32.t(message.timeoutMs));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("timeoutMs=").append(timeoutMs);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxRequestVer11 other = (OFBsnPduRxRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( timeoutMs != other.timeoutMs)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (timeoutMs ^ (timeoutMs >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxTimeoutVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxTimeoutVer11.java
new file mode 100644
index 0000000..4320d2a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduRxTimeoutVer11.java
@@ -0,0 +1,415 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduRxTimeoutVer11 implements OFBsnPduRxTimeout {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxTimeoutVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 21;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduRxTimeoutVer11 DEFAULT = new OFBsnPduRxTimeoutVer11(
+        DEFAULT_XID, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxTimeoutVer11(long xid, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduRxTimeout.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxTimeout.Builder {
+        final OFBsnPduRxTimeoutVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduRxTimeoutVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxTimeout build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduRxTimeoutVer11(
+                    xid,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxTimeout.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxTimeout build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduRxTimeoutVer11(
+                    xid,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxTimeout> {
+        @Override
+        public OFBsnPduRxTimeout readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 21)
+                throw new OFParseError("Wrong length: Expected=21(21), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x23L
+            int subtype = bb.readInt();
+            if(subtype != 0x23)
+                throw new OFParseError("Wrong subtype: Expected=0x23L(0x23L), got="+subtype);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduRxTimeoutVer11 bsnPduRxTimeoutVer11 = new OFBsnPduRxTimeoutVer11(
+                    xid,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxTimeoutVer11);
+            return bsnPduRxTimeoutVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxTimeoutVer11Funnel FUNNEL = new OFBsnPduRxTimeoutVer11Funnel();
+    static class OFBsnPduRxTimeoutVer11Funnel implements Funnel<OFBsnPduRxTimeoutVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxTimeoutVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 21
+            sink.putShort((short) 0x15);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x23L
+            sink.putInt(0x23);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxTimeoutVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxTimeoutVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 21
+            bb.writeShort((short) 0x15);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x23L
+            bb.writeInt(0x23);
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxTimeoutVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxTimeoutVer11 other = (OFBsnPduRxTimeoutVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduSlotNumTSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduSlotNumTSerializerVer11.java
new file mode 100644
index 0000000..04d9857
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduSlotNumTSerializerVer11.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnPduSlotNumT;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnPduSlotNumTSerializerVer11 {
+
+    public final static byte PDU_SLOT_NUM_ANY_VAL = (byte) 0xff;
+
+    public static OFBsnPduSlotNumT readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnPduSlotNumT e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnPduSlotNumT e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnPduSlotNumT ofWireValue(byte val) {
+        switch(val) {
+            case PDU_SLOT_NUM_ANY_VAL:
+                return OFBsnPduSlotNumT.PDU_SLOT_NUM_ANY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnPduSlotNumT in version 1.1: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnPduSlotNumT e) {
+        switch(e) {
+            case PDU_SLOT_NUM_ANY:
+                return PDU_SLOT_NUM_ANY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnPduSlotNumT in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduTxReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduTxReplyVer11.java
new file mode 100644
index 0000000..cae271b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduTxReplyVer11.java
@@ -0,0 +1,462 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduTxReplyVer11 implements OFBsnPduTxReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 25;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduTxReplyVer11 DEFAULT = new OFBsnPduTxReplyVer11(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduTxReplyVer11(long xid, long status, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduTxReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduTxReply.Builder {
+        final OFBsnPduTxReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduTxReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduTxReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduTxReplyVer11(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduTxReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduTxReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduTxReplyVer11(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduTxReply> {
+        @Override
+        public OFBsnPduTxReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 25)
+                throw new OFParseError("Wrong length: Expected=25(25), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x20L
+            int subtype = bb.readInt();
+            if(subtype != 0x20)
+                throw new OFParseError("Wrong subtype: Expected=0x20L(0x20L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduTxReplyVer11 bsnPduTxReplyVer11 = new OFBsnPduTxReplyVer11(
+                    xid,
+                      status,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduTxReplyVer11);
+            return bsnPduTxReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduTxReplyVer11Funnel FUNNEL = new OFBsnPduTxReplyVer11Funnel();
+    static class OFBsnPduTxReplyVer11Funnel implements Funnel<OFBsnPduTxReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduTxReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 25
+            sink.putShort((short) 0x19);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x20L
+            sink.putInt(0x20);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduTxReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduTxReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 25
+            bb.writeShort((short) 0x19);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x20L
+            bb.writeInt(0x20);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduTxReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduTxReplyVer11 other = (OFBsnPduTxReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduTxRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduTxRequestVer11.java
new file mode 100644
index 0000000..add5f38
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnPduTxRequestVer11.java
@@ -0,0 +1,524 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnPduTxRequestVer11 implements OFBsnPduTxRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_TX_INTERVAL_MS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long txIntervalMs;
+    private final OFPort portNo;
+    private final short slotNum;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnPduTxRequestVer11 DEFAULT = new OFBsnPduTxRequestVer11(
+        DEFAULT_XID, DEFAULT_TX_INTERVAL_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduTxRequestVer11(long xid, long txIntervalMs, OFPort portNo, short slotNum, byte[] data) {
+        this.xid = xid;
+        this.txIntervalMs = txIntervalMs;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnPduTxRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduTxRequest.Builder {
+        final OFBsnPduTxRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean txIntervalMsSet;
+        private long txIntervalMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnPduTxRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) {
+        this.txIntervalMs = txIntervalMs;
+        this.txIntervalMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduTxRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : parentMessage.txIntervalMs;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnPduTxRequestVer11(
+                    xid,
+                    txIntervalMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduTxRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean txIntervalMsSet;
+        private long txIntervalMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) {
+        this.txIntervalMs = txIntervalMs;
+        this.txIntervalMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduTxRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : DEFAULT_TX_INTERVAL_MS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnPduTxRequestVer11(
+                    xid,
+                    txIntervalMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduTxRequest> {
+        @Override
+        public OFBsnPduTxRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1fL
+            int subtype = bb.readInt();
+            if(subtype != 0x1f)
+                throw new OFParseError("Wrong subtype: Expected=0x1fL(0x1fL), got="+subtype);
+            long txIntervalMs = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnPduTxRequestVer11 bsnPduTxRequestVer11 = new OFBsnPduTxRequestVer11(
+                    xid,
+                      txIntervalMs,
+                      portNo,
+                      slotNum,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduTxRequestVer11);
+            return bsnPduTxRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduTxRequestVer11Funnel FUNNEL = new OFBsnPduTxRequestVer11Funnel();
+    static class OFBsnPduTxRequestVer11Funnel implements Funnel<OFBsnPduTxRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduTxRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1fL
+            sink.putInt(0x1f);
+            sink.putLong(message.txIntervalMs);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+            // skip pad (3 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduTxRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduTxRequestVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1fL
+            bb.writeInt(0x1f);
+            bb.writeInt(U32.t(message.txIntervalMs));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduTxRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("txIntervalMs=").append(txIntervalMs);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduTxRequestVer11 other = (OFBsnPduTxRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( txIntervalMs != other.txIntervalMs)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (txIntervalMs ^ (txIntervalMs >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetMirroringVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetMirroringVer11.java
new file mode 100644
index 0000000..a142e3a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetMirroringVer11.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetMirroringVer11 implements OFBsnSetMirroring {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetMirroringVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnSetMirroringVer11 DEFAULT = new OFBsnSetMirroringVer11(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetMirroringVer11(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnSetMirroring.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetMirroring.Builder {
+        final OFBsnSetMirroringVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnSetMirroringVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetMirroring build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnSetMirroringVer11(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetMirroring.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetMirroring build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnSetMirroringVer11(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetMirroring> {
+        @Override
+        public OFBsnSetMirroring readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3L
+            int subtype = bb.readInt();
+            if(subtype != 0x3)
+                throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnSetMirroringVer11 bsnSetMirroringVer11 = new OFBsnSetMirroringVer11(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetMirroringVer11);
+            return bsnSetMirroringVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetMirroringVer11Funnel FUNNEL = new OFBsnSetMirroringVer11Funnel();
+    static class OFBsnSetMirroringVer11Funnel implements Funnel<OFBsnSetMirroringVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetMirroringVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            sink.putInt(0x3);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetMirroringVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetMirroringVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            bb.writeInt(0x3);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetMirroringVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetMirroringVer11 other = (OFBsnSetMirroringVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetPktinSuppressionReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetPktinSuppressionReplyVer11.java
new file mode 100644
index 0000000..b65fa2a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetPktinSuppressionReplyVer11.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetPktinSuppressionReplyVer11 implements OFBsnSetPktinSuppressionReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetPktinSuppressionReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnSetPktinSuppressionReplyVer11 DEFAULT = new OFBsnSetPktinSuppressionReplyVer11(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetPktinSuppressionReplyVer11(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnSetPktinSuppressionReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetPktinSuppressionReply.Builder {
+        final OFBsnSetPktinSuppressionReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnSetPktinSuppressionReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetPktinSuppressionReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnSetPktinSuppressionReplyVer11(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetPktinSuppressionReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetPktinSuppressionReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnSetPktinSuppressionReplyVer11(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetPktinSuppressionReply> {
+        @Override
+        public OFBsnSetPktinSuppressionReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x19L
+            int subtype = bb.readInt();
+            if(subtype != 0x19)
+                throw new OFParseError("Wrong subtype: Expected=0x19L(0x19L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnSetPktinSuppressionReplyVer11 bsnSetPktinSuppressionReplyVer11 = new OFBsnSetPktinSuppressionReplyVer11(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetPktinSuppressionReplyVer11);
+            return bsnSetPktinSuppressionReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetPktinSuppressionReplyVer11Funnel FUNNEL = new OFBsnSetPktinSuppressionReplyVer11Funnel();
+    static class OFBsnSetPktinSuppressionReplyVer11Funnel implements Funnel<OFBsnSetPktinSuppressionReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetPktinSuppressionReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x19L
+            sink.putInt(0x19);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetPktinSuppressionReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetPktinSuppressionReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x19L
+            bb.writeInt(0x19);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetPktinSuppressionReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetPktinSuppressionReplyVer11 other = (OFBsnSetPktinSuppressionReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetPktinSuppressionRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetPktinSuppressionRequestVer11.java
new file mode 100644
index 0000000..d4a4403
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnSetPktinSuppressionRequestVer11.java
@@ -0,0 +1,561 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetPktinSuppressionRequestVer11 implements OFBsnSetPktinSuppressionRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetPktinSuppressionRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static boolean DEFAULT_ENABLED = false;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final boolean enabled;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final U64 cookie;
+//
+    // Immutable default instance
+    final static OFBsnSetPktinSuppressionRequestVer11 DEFAULT = new OFBsnSetPktinSuppressionRequestVer11(
+        DEFAULT_XID, DEFAULT_ENABLED, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_COOKIE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetPktinSuppressionRequestVer11(long xid, boolean enabled, int idleTimeout, int hardTimeout, int priority, U64 cookie) {
+        this.xid = xid;
+        this.enabled = enabled;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.cookie = cookie;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+
+
+    public OFBsnSetPktinSuppressionRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetPktinSuppressionRequest.Builder {
+        final OFBsnSetPktinSuppressionRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private boolean enabled;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean cookieSet;
+        private U64 cookie;
+
+        BuilderWithParent(OFBsnSetPktinSuppressionRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setEnabled(boolean enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetPktinSuppressionRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                boolean enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+
+                //
+                return new OFBsnSetPktinSuppressionRequestVer11(
+                    xid,
+                    enabled,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    cookie
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetPktinSuppressionRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private boolean enabled;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean cookieSet;
+        private U64 cookie;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setEnabled(boolean enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetPktinSuppressionRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            boolean enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+
+
+            return new OFBsnSetPktinSuppressionRequestVer11(
+                    xid,
+                    enabled,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    cookie
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetPktinSuppressionRequest> {
+        @Override
+        public OFBsnSetPktinSuppressionRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xbL
+            int subtype = bb.readInt();
+            if(subtype != 0xb)
+                throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got="+subtype);
+            boolean enabled = (bb.readByte() != 0);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            U64 cookie = U64.ofRaw(bb.readLong());
+
+            OFBsnSetPktinSuppressionRequestVer11 bsnSetPktinSuppressionRequestVer11 = new OFBsnSetPktinSuppressionRequestVer11(
+                    xid,
+                      enabled,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      cookie
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetPktinSuppressionRequestVer11);
+            return bsnSetPktinSuppressionRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetPktinSuppressionRequestVer11Funnel FUNNEL = new OFBsnSetPktinSuppressionRequestVer11Funnel();
+    static class OFBsnSetPktinSuppressionRequestVer11Funnel implements Funnel<OFBsnSetPktinSuppressionRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetPktinSuppressionRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            sink.putInt(0xb);
+            sink.putBoolean(message.enabled);
+            // skip pad (1 bytes)
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.cookie.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetPktinSuppressionRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetPktinSuppressionRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            bb.writeInt(0xb);
+            bb.writeByte(message.enabled ? 1 : 0);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeLong(message.cookie.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetPktinSuppressionRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetPktinSuppressionRequestVer11 other = (OFBsnSetPktinSuppressionRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + (enabled ? 1231 : 1237);
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnStatsReplyVer11.java
new file mode 100644
index 0000000..f8f0e0e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnStatsReplyVer11.java
@@ -0,0 +1,73 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnStatsReplyVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFBsnStatsReplyVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnStatsReply> {
+        @Override
+        public OFBsnStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnStatsReplyVer11: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnStatsRequestVer11.java
new file mode 100644
index 0000000..d1e8589
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnStatsRequestVer11.java
@@ -0,0 +1,73 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnStatsRequestVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFBsnStatsRequestVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnStatsRequest<?>> {
+        @Override
+        public OFBsnStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnStatsRequestVer11: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnTlvsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnTlvsVer11.java
new file mode 100644
index 0000000..025e720
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnTlvsVer11.java
@@ -0,0 +1,200 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFBsnTlvsVer11 implements OFBsnTlvs {
+    public final static OFBsnTlvsVer11 INSTANCE = new OFBsnTlvsVer11();
+
+
+
+
+    public OFBsnTlvBroadcastQueryTimeout.Builder buildBroadcastQueryTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvBroadcastQueryTimeout not supported in version 1.1");
+    }
+    public OFBsnTlvBroadcastQueryTimeout broadcastQueryTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvBroadcastQueryTimeout not supported in version 1.1");
+    }
+
+    public OFBsnTlvCircuitId.Builder buildCircuitId() {
+        throw new UnsupportedOperationException("OFBsnTlvCircuitId not supported in version 1.1");
+    }
+    public OFBsnTlvCircuitId circuitId(byte[] value) {
+        throw new UnsupportedOperationException("OFBsnTlvCircuitId not supported in version 1.1");
+    }
+
+    public OFBsnTlvCrcEnabled.Builder buildCrcEnabled() {
+        throw new UnsupportedOperationException("OFBsnTlvCrcEnabled not supported in version 1.1");
+    }
+    public OFBsnTlvCrcEnabled crcEnabled(short value) {
+        throw new UnsupportedOperationException("OFBsnTlvCrcEnabled not supported in version 1.1");
+    }
+
+    public OFBsnTlvIdleNotification idleNotification() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleNotification not supported in version 1.1");
+    }
+
+    public OFBsnTlvIdleTime.Builder buildIdleTime() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTime not supported in version 1.1");
+    }
+    public OFBsnTlvIdleTime idleTime(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTime not supported in version 1.1");
+    }
+
+    public OFBsnTlvIdleTimeout.Builder buildIdleTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTimeout not supported in version 1.1");
+    }
+    public OFBsnTlvIdleTimeout idleTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTimeout not supported in version 1.1");
+    }
+
+    public OFBsnTlvIpv4.Builder buildIpv4() {
+        throw new UnsupportedOperationException("OFBsnTlvIpv4 not supported in version 1.1");
+    }
+    public OFBsnTlvIpv4 ipv4(IPv4Address value) {
+        throw new UnsupportedOperationException("OFBsnTlvIpv4 not supported in version 1.1");
+    }
+
+    public OFBsnTlvMac.Builder buildMac() {
+        throw new UnsupportedOperationException("OFBsnTlvMac not supported in version 1.1");
+    }
+    public OFBsnTlvMac mac(MacAddress value) {
+        throw new UnsupportedOperationException("OFBsnTlvMac not supported in version 1.1");
+    }
+
+    public OFBsnTlvMissPackets.Builder buildMissPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvMissPackets not supported in version 1.1");
+    }
+    public OFBsnTlvMissPackets missPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvMissPackets not supported in version 1.1");
+    }
+
+    public OFBsnTlvPort.Builder buildPort() {
+        throw new UnsupportedOperationException("OFBsnTlvPort not supported in version 1.1");
+    }
+    public OFBsnTlvPort port(OFPort value) {
+        throw new UnsupportedOperationException("OFBsnTlvPort not supported in version 1.1");
+    }
+
+    public OFBsnTlvQueueId.Builder buildQueueId() {
+        throw new UnsupportedOperationException("OFBsnTlvQueueId not supported in version 1.1");
+    }
+    public OFBsnTlvQueueId queueId(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvQueueId not supported in version 1.1");
+    }
+
+    public OFBsnTlvQueueWeight.Builder buildQueueWeight() {
+        throw new UnsupportedOperationException("OFBsnTlvQueueWeight not supported in version 1.1");
+    }
+    public OFBsnTlvQueueWeight queueWeight(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvQueueWeight not supported in version 1.1");
+    }
+
+    public OFBsnTlvReplyPackets.Builder buildReplyPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvReplyPackets not supported in version 1.1");
+    }
+    public OFBsnTlvReplyPackets replyPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvReplyPackets not supported in version 1.1");
+    }
+
+    public OFBsnTlvRequestPackets.Builder buildRequestPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvRequestPackets not supported in version 1.1");
+    }
+    public OFBsnTlvRequestPackets requestPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvRequestPackets not supported in version 1.1");
+    }
+
+    public OFBsnTlvRxPackets.Builder buildRxPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvRxPackets not supported in version 1.1");
+    }
+    public OFBsnTlvRxPackets rxPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvRxPackets not supported in version 1.1");
+    }
+
+    public OFBsnTlvTxPackets.Builder buildTxPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvTxPackets not supported in version 1.1");
+    }
+    public OFBsnTlvTxPackets txPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvTxPackets not supported in version 1.1");
+    }
+
+    public OFBsnTlvUdfAnchor.Builder buildUdfAnchor() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfAnchor not supported in version 1.1");
+    }
+    public OFBsnTlvUdfAnchor udfAnchor(OFBsnUdfAnchor value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfAnchor not supported in version 1.1");
+    }
+
+    public OFBsnTlvUdfId.Builder buildUdfId() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfId not supported in version 1.1");
+    }
+    public OFBsnTlvUdfId udfId(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfId not supported in version 1.1");
+    }
+
+    public OFBsnTlvUdfLength.Builder buildUdfLength() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfLength not supported in version 1.1");
+    }
+    public OFBsnTlvUdfLength udfLength(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfLength not supported in version 1.1");
+    }
+
+    public OFBsnTlvUdfOffset.Builder buildUdfOffset() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfOffset not supported in version 1.1");
+    }
+    public OFBsnTlvUdfOffset udfOffset(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfOffset not supported in version 1.1");
+    }
+
+    public OFBsnTlvUnicastQueryTimeout.Builder buildUnicastQueryTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvUnicastQueryTimeout not supported in version 1.1");
+    }
+    public OFBsnTlvUnicastQueryTimeout unicastQueryTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvUnicastQueryTimeout not supported in version 1.1");
+    }
+
+    public OFBsnTlvVlanVid.Builder buildVlanVid() {
+        throw new UnsupportedOperationException("OFBsnTlvVlanVid not supported in version 1.1");
+    }
+    public OFBsnTlvVlanVid vlanVid(VlanVid value) {
+        throw new UnsupportedOperationException("OFBsnTlvVlanVid not supported in version 1.1");
+    }
+
+    public OFBsnTlvVrf.Builder buildVrf() {
+        throw new UnsupportedOperationException("OFBsnTlvVrf not supported in version 1.1");
+    }
+    public OFBsnTlvVrf vrf(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvVrf not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFBsnTlv> getReader() {
+        throw new UnsupportedOperationException("Reader<OFBsnTlv> not supported in version 1.1");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortCreateReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortCreateReplyVer11.java
new file mode 100644
index 0000000..b643a27
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortCreateReplyVer11.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortCreateReplyVer11 implements OFBsnVirtualPortCreateReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortCreateReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static long DEFAULT_VPORT_NO = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final long vportNo;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortCreateReplyVer11 DEFAULT = new OFBsnVirtualPortCreateReplyVer11(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_VPORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortCreateReplyVer11(long xid, long status, long vportNo) {
+        this.xid = xid;
+        this.status = status;
+        this.vportNo = vportNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+
+
+    public OFBsnVirtualPortCreateReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortCreateReply.Builder {
+        final OFBsnVirtualPortCreateReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean vportNoSet;
+        private long vportNo;
+
+        BuilderWithParent(OFBsnVirtualPortCreateReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortCreateReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                long vportNo = this.vportNoSet ? this.vportNo : parentMessage.vportNo;
+
+                //
+                return new OFBsnVirtualPortCreateReplyVer11(
+                    xid,
+                    status,
+                    vportNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortCreateReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean vportNoSet;
+        private long vportNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortCreateReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            long vportNo = this.vportNoSet ? this.vportNo : DEFAULT_VPORT_NO;
+
+
+            return new OFBsnVirtualPortCreateReplyVer11(
+                    xid,
+                    status,
+                    vportNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortCreateReply> {
+        @Override
+        public OFBsnVirtualPortCreateReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x10L
+            int subtype = bb.readInt();
+            if(subtype != 0x10)
+                throw new OFParseError("Wrong subtype: Expected=0x10L(0x10L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            long vportNo = U32.f(bb.readInt());
+
+            OFBsnVirtualPortCreateReplyVer11 bsnVirtualPortCreateReplyVer11 = new OFBsnVirtualPortCreateReplyVer11(
+                    xid,
+                      status,
+                      vportNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortCreateReplyVer11);
+            return bsnVirtualPortCreateReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortCreateReplyVer11Funnel FUNNEL = new OFBsnVirtualPortCreateReplyVer11Funnel();
+    static class OFBsnVirtualPortCreateReplyVer11Funnel implements Funnel<OFBsnVirtualPortCreateReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortCreateReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x10L
+            sink.putInt(0x10);
+            sink.putLong(message.status);
+            sink.putLong(message.vportNo);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortCreateReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortCreateReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x10L
+            bb.writeInt(0x10);
+            bb.writeInt(U32.t(message.status));
+            bb.writeInt(U32.t(message.vportNo));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortCreateReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("vportNo=").append(vportNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortCreateReplyVer11 other = (OFBsnVirtualPortCreateReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if( vportNo != other.vportNo)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime *  (int) (vportNo ^ (vportNo >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortCreateRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortCreateRequestVer11.java
new file mode 100644
index 0000000..0d325a9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortCreateRequestVer11.java
@@ -0,0 +1,369 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortCreateRequestVer11 implements OFBsnVirtualPortCreateRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortCreateRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFBsnVport vport;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortCreateRequestVer11(long xid, OFBsnVport vport) {
+        this.xid = xid;
+        this.vport = vport;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+
+
+    public OFBsnVirtualPortCreateRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortCreateRequest.Builder {
+        final OFBsnVirtualPortCreateRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportSet;
+        private OFBsnVport vport;
+
+        BuilderWithParent(OFBsnVirtualPortCreateRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setVport(OFBsnVport vport) {
+        this.vport = vport;
+        this.vportSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortCreateRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBsnVport vport = this.vportSet ? this.vport : parentMessage.vport;
+                if(vport == null)
+                    throw new NullPointerException("Property vport must not be null");
+
+                //
+                return new OFBsnVirtualPortCreateRequestVer11(
+                    xid,
+                    vport
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortCreateRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportSet;
+        private OFBsnVport vport;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setVport(OFBsnVport vport) {
+        this.vport = vport;
+        this.vportSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortCreateRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.vportSet)
+                throw new IllegalStateException("Property vport doesn't have default value -- must be set");
+            if(vport == null)
+                throw new NullPointerException("Property vport must not be null");
+
+
+            return new OFBsnVirtualPortCreateRequestVer11(
+                    xid,
+                    vport
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortCreateRequest> {
+        @Override
+        public OFBsnVirtualPortCreateRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xfL
+            int subtype = bb.readInt();
+            if(subtype != 0xf)
+                throw new OFParseError("Wrong subtype: Expected=0xfL(0xfL), got="+subtype);
+            OFBsnVport vport = OFBsnVportVer11.READER.readFrom(bb);
+
+            OFBsnVirtualPortCreateRequestVer11 bsnVirtualPortCreateRequestVer11 = new OFBsnVirtualPortCreateRequestVer11(
+                    xid,
+                      vport
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortCreateRequestVer11);
+            return bsnVirtualPortCreateRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortCreateRequestVer11Funnel FUNNEL = new OFBsnVirtualPortCreateRequestVer11Funnel();
+    static class OFBsnVirtualPortCreateRequestVer11Funnel implements Funnel<OFBsnVirtualPortCreateRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortCreateRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            sink.putInt(0xf);
+            message.vport.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortCreateRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortCreateRequestVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            bb.writeInt(0xf);
+            message.vport.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortCreateRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vport=").append(vport);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortCreateRequestVer11 other = (OFBsnVirtualPortCreateRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (vport == null) {
+            if (other.vport != null)
+                return false;
+        } else if (!vport.equals(other.vport))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((vport == null) ? 0 : vport.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortRemoveReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortRemoveReplyVer11.java
new file mode 100644
index 0000000..17123ce
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortRemoveReplyVer11.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortRemoveReplyVer11 implements OFBsnVirtualPortRemoveReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortRemoveReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortRemoveReplyVer11 DEFAULT = new OFBsnVirtualPortRemoveReplyVer11(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortRemoveReplyVer11(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnVirtualPortRemoveReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortRemoveReply.Builder {
+        final OFBsnVirtualPortRemoveReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnVirtualPortRemoveReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortRemoveReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnVirtualPortRemoveReplyVer11(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortRemoveReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortRemoveReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnVirtualPortRemoveReplyVer11(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortRemoveReply> {
+        @Override
+        public OFBsnVirtualPortRemoveReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1aL
+            int subtype = bb.readInt();
+            if(subtype != 0x1a)
+                throw new OFParseError("Wrong subtype: Expected=0x1aL(0x1aL), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnVirtualPortRemoveReplyVer11 bsnVirtualPortRemoveReplyVer11 = new OFBsnVirtualPortRemoveReplyVer11(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortRemoveReplyVer11);
+            return bsnVirtualPortRemoveReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortRemoveReplyVer11Funnel FUNNEL = new OFBsnVirtualPortRemoveReplyVer11Funnel();
+    static class OFBsnVirtualPortRemoveReplyVer11Funnel implements Funnel<OFBsnVirtualPortRemoveReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortRemoveReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1aL
+            sink.putInt(0x1a);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortRemoveReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortRemoveReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1aL
+            bb.writeInt(0x1a);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortRemoveReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortRemoveReplyVer11 other = (OFBsnVirtualPortRemoveReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortRemoveRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortRemoveRequestVer11.java
new file mode 100644
index 0000000..c472a7e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVirtualPortRemoveRequestVer11.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortRemoveRequestVer11 implements OFBsnVirtualPortRemoveRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortRemoveRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_VPORT_NO = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long vportNo;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortRemoveRequestVer11 DEFAULT = new OFBsnVirtualPortRemoveRequestVer11(
+        DEFAULT_XID, DEFAULT_VPORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortRemoveRequestVer11(long xid, long vportNo) {
+        this.xid = xid;
+        this.vportNo = vportNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+
+
+    public OFBsnVirtualPortRemoveRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortRemoveRequest.Builder {
+        final OFBsnVirtualPortRemoveRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportNoSet;
+        private long vportNo;
+
+        BuilderWithParent(OFBsnVirtualPortRemoveRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortRemoveRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long vportNo = this.vportNoSet ? this.vportNo : parentMessage.vportNo;
+
+                //
+                return new OFBsnVirtualPortRemoveRequestVer11(
+                    xid,
+                    vportNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortRemoveRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportNoSet;
+        private long vportNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortRemoveRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long vportNo = this.vportNoSet ? this.vportNo : DEFAULT_VPORT_NO;
+
+
+            return new OFBsnVirtualPortRemoveRequestVer11(
+                    xid,
+                    vportNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortRemoveRequest> {
+        @Override
+        public OFBsnVirtualPortRemoveRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x11L
+            int subtype = bb.readInt();
+            if(subtype != 0x11)
+                throw new OFParseError("Wrong subtype: Expected=0x11L(0x11L), got="+subtype);
+            long vportNo = U32.f(bb.readInt());
+
+            OFBsnVirtualPortRemoveRequestVer11 bsnVirtualPortRemoveRequestVer11 = new OFBsnVirtualPortRemoveRequestVer11(
+                    xid,
+                      vportNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortRemoveRequestVer11);
+            return bsnVirtualPortRemoveRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortRemoveRequestVer11Funnel FUNNEL = new OFBsnVirtualPortRemoveRequestVer11Funnel();
+    static class OFBsnVirtualPortRemoveRequestVer11Funnel implements Funnel<OFBsnVirtualPortRemoveRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortRemoveRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x11L
+            sink.putInt(0x11);
+            sink.putLong(message.vportNo);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortRemoveRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortRemoveRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x11L
+            bb.writeInt(0x11);
+            bb.writeInt(U32.t(message.vportNo));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortRemoveRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vportNo=").append(vportNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortRemoveRequestVer11 other = (OFBsnVirtualPortRemoveRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( vportNo != other.vportNo)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (vportNo ^ (vportNo >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportL2GreFlagsSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportL2GreFlagsSerializerVer11.java
new file mode 100644
index 0000000..8ee6e70
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportL2GreFlagsSerializerVer11.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportL2GreFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFBsnVportL2GreFlagsSerializerVer11 {
+
+    public final static int BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL = 0x1;
+    public final static int BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL = 0x2;
+    public final static int BSN_VPORT_L2GRE_DSCP_COPY_VAL = 0x4;
+    public final static int BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL = 0x8;
+    public final static int BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL = 0x10;
+
+    public static Set<OFBsnVportL2GreFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFBsnVportL2GreFlags> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFBsnVportL2GreFlags> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFBsnVportL2GreFlags> ofWireValue(int val) {
+        EnumSet<OFBsnVportL2GreFlags> set = EnumSet.noneOf(OFBsnVportL2GreFlags.class);
+
+        if((val & BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID);
+        if((val & BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN);
+        if((val & BSN_VPORT_L2GRE_DSCP_COPY_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_COPY);
+        if((val & BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID);
+        if((val & BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFBsnVportL2GreFlags> set) {
+        int wireValue = 0;
+
+        for(OFBsnVportL2GreFlags e: set) {
+            switch(e) {
+                case BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_DSCP_ASSIGN:
+                    wireValue |= BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_DSCP_COPY:
+                    wireValue |= BSN_VPORT_L2GRE_DSCP_COPY_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_LOOPBACK_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFBsnVportL2GreFlags in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportL2GreVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportL2GreVer11.java
new file mode 100644
index 0000000..cf4c26b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportL2GreVer11.java
@@ -0,0 +1,839 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVportL2GreVer11 implements OFBsnVportL2Gre {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVportL2GreVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 64;
+
+        private final static Set<OFBsnVportL2GreFlags> DEFAULT_FLAGS = ImmutableSet.<OFBsnVportL2GreFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static OFPort DEFAULT_LOOPBACK_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_LOCAL_MAC = MacAddress.NONE;
+        private final static MacAddress DEFAULT_NH_MAC = MacAddress.NONE;
+        private final static IPv4Address DEFAULT_SRC_IP = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_DST_IP = IPv4Address.NONE;
+        private final static short DEFAULT_DSCP = (short) 0x0;
+        private final static short DEFAULT_TTL = (short) 0x0;
+        private final static long DEFAULT_VPN = 0x0L;
+        private final static long DEFAULT_RATE_LIMIT = 0x0L;
+        private final static String DEFAULT_IF_NAME = "";
+
+    // OF message fields
+    private final Set<OFBsnVportL2GreFlags> flags;
+    private final OFPort portNo;
+    private final OFPort loopbackPortNo;
+    private final MacAddress localMac;
+    private final MacAddress nhMac;
+    private final IPv4Address srcIp;
+    private final IPv4Address dstIp;
+    private final short dscp;
+    private final short ttl;
+    private final long vpn;
+    private final long rateLimit;
+    private final String ifName;
+//
+    // Immutable default instance
+    final static OFBsnVportL2GreVer11 DEFAULT = new OFBsnVportL2GreVer11(
+        DEFAULT_FLAGS, DEFAULT_PORT_NO, DEFAULT_LOOPBACK_PORT_NO, DEFAULT_LOCAL_MAC, DEFAULT_NH_MAC, DEFAULT_SRC_IP, DEFAULT_DST_IP, DEFAULT_DSCP, DEFAULT_TTL, DEFAULT_VPN, DEFAULT_RATE_LIMIT, DEFAULT_IF_NAME
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVportL2GreVer11(Set<OFBsnVportL2GreFlags> flags, OFPort portNo, OFPort loopbackPortNo, MacAddress localMac, MacAddress nhMac, IPv4Address srcIp, IPv4Address dstIp, short dscp, short ttl, long vpn, long rateLimit, String ifName) {
+        this.flags = flags;
+        this.portNo = portNo;
+        this.loopbackPortNo = loopbackPortNo;
+        this.localMac = localMac;
+        this.nhMac = nhMac;
+        this.srcIp = srcIp;
+        this.dstIp = dstIp;
+        this.dscp = dscp;
+        this.ttl = ttl;
+        this.vpn = vpn;
+        this.rateLimit = rateLimit;
+        this.ifName = ifName;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFBsnVportL2Gre.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVportL2Gre.Builder {
+        final OFBsnVportL2GreVer11 parentMessage;
+
+        // OF message fields
+        private boolean flagsSet;
+        private Set<OFBsnVportL2GreFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean loopbackPortNoSet;
+        private OFPort loopbackPortNo;
+        private boolean localMacSet;
+        private MacAddress localMac;
+        private boolean nhMacSet;
+        private MacAddress nhMac;
+        private boolean srcIpSet;
+        private IPv4Address srcIp;
+        private boolean dstIpSet;
+        private IPv4Address dstIp;
+        private boolean dscpSet;
+        private short dscp;
+        private boolean ttlSet;
+        private short ttl;
+        private boolean vpnSet;
+        private long vpn;
+        private boolean rateLimitSet;
+        private long rateLimit;
+        private boolean ifNameSet;
+        private String ifName;
+
+        BuilderWithParent(OFBsnVportL2GreVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setFlags(Set<OFBsnVportL2GreFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLoopbackPortNo(OFPort loopbackPortNo) {
+        this.loopbackPortNo = loopbackPortNo;
+        this.loopbackPortNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLocalMac(MacAddress localMac) {
+        this.localMac = localMac;
+        this.localMacSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setNhMac(MacAddress nhMac) {
+        this.nhMac = nhMac;
+        this.nhMacSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setSrcIp(IPv4Address srcIp) {
+        this.srcIp = srcIp;
+        this.srcIpSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDstIp(IPv4Address dstIp) {
+        this.dstIp = dstIp;
+        this.dstIpSet = true;
+        return this;
+    }
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDscp(short dscp) {
+        this.dscp = dscp;
+        this.dscpSet = true;
+        return this;
+    }
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setTtl(short ttl) {
+        this.ttl = ttl;
+        this.ttlSet = true;
+        return this;
+    }
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setVpn(long vpn) {
+        this.vpn = vpn;
+        this.vpnSet = true;
+        return this;
+    }
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setRateLimit(long rateLimit) {
+        this.rateLimit = rateLimit;
+        this.rateLimitSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFBsnVportL2Gre build() {
+                Set<OFBsnVportL2GreFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                OFPort loopbackPortNo = this.loopbackPortNoSet ? this.loopbackPortNo : parentMessage.loopbackPortNo;
+                if(loopbackPortNo == null)
+                    throw new NullPointerException("Property loopbackPortNo must not be null");
+                MacAddress localMac = this.localMacSet ? this.localMac : parentMessage.localMac;
+                if(localMac == null)
+                    throw new NullPointerException("Property localMac must not be null");
+                MacAddress nhMac = this.nhMacSet ? this.nhMac : parentMessage.nhMac;
+                if(nhMac == null)
+                    throw new NullPointerException("Property nhMac must not be null");
+                IPv4Address srcIp = this.srcIpSet ? this.srcIp : parentMessage.srcIp;
+                if(srcIp == null)
+                    throw new NullPointerException("Property srcIp must not be null");
+                IPv4Address dstIp = this.dstIpSet ? this.dstIp : parentMessage.dstIp;
+                if(dstIp == null)
+                    throw new NullPointerException("Property dstIp must not be null");
+                short dscp = this.dscpSet ? this.dscp : parentMessage.dscp;
+                short ttl = this.ttlSet ? this.ttl : parentMessage.ttl;
+                long vpn = this.vpnSet ? this.vpn : parentMessage.vpn;
+                long rateLimit = this.rateLimitSet ? this.rateLimit : parentMessage.rateLimit;
+                String ifName = this.ifNameSet ? this.ifName : parentMessage.ifName;
+                if(ifName == null)
+                    throw new NullPointerException("Property ifName must not be null");
+
+                //
+                return new OFBsnVportL2GreVer11(
+                    flags,
+                    portNo,
+                    loopbackPortNo,
+                    localMac,
+                    nhMac,
+                    srcIp,
+                    dstIp,
+                    dscp,
+                    ttl,
+                    vpn,
+                    rateLimit,
+                    ifName
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVportL2Gre.Builder {
+        // OF message fields
+        private boolean flagsSet;
+        private Set<OFBsnVportL2GreFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean loopbackPortNoSet;
+        private OFPort loopbackPortNo;
+        private boolean localMacSet;
+        private MacAddress localMac;
+        private boolean nhMacSet;
+        private MacAddress nhMac;
+        private boolean srcIpSet;
+        private IPv4Address srcIp;
+        private boolean dstIpSet;
+        private IPv4Address dstIp;
+        private boolean dscpSet;
+        private short dscp;
+        private boolean ttlSet;
+        private short ttl;
+        private boolean vpnSet;
+        private long vpn;
+        private boolean rateLimitSet;
+        private long rateLimit;
+        private boolean ifNameSet;
+        private String ifName;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setFlags(Set<OFBsnVportL2GreFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLoopbackPortNo(OFPort loopbackPortNo) {
+        this.loopbackPortNo = loopbackPortNo;
+        this.loopbackPortNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLocalMac(MacAddress localMac) {
+        this.localMac = localMac;
+        this.localMacSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setNhMac(MacAddress nhMac) {
+        this.nhMac = nhMac;
+        this.nhMacSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setSrcIp(IPv4Address srcIp) {
+        this.srcIp = srcIp;
+        this.srcIpSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDstIp(IPv4Address dstIp) {
+        this.dstIp = dstIp;
+        this.dstIpSet = true;
+        return this;
+    }
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDscp(short dscp) {
+        this.dscp = dscp;
+        this.dscpSet = true;
+        return this;
+    }
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setTtl(short ttl) {
+        this.ttl = ttl;
+        this.ttlSet = true;
+        return this;
+    }
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setVpn(long vpn) {
+        this.vpn = vpn;
+        this.vpnSet = true;
+        return this;
+    }
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setRateLimit(long rateLimit) {
+        this.rateLimit = rateLimit;
+        this.rateLimitSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFBsnVportL2Gre build() {
+            Set<OFBsnVportL2GreFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            OFPort loopbackPortNo = this.loopbackPortNoSet ? this.loopbackPortNo : DEFAULT_LOOPBACK_PORT_NO;
+            if(loopbackPortNo == null)
+                throw new NullPointerException("Property loopbackPortNo must not be null");
+            MacAddress localMac = this.localMacSet ? this.localMac : DEFAULT_LOCAL_MAC;
+            if(localMac == null)
+                throw new NullPointerException("Property localMac must not be null");
+            MacAddress nhMac = this.nhMacSet ? this.nhMac : DEFAULT_NH_MAC;
+            if(nhMac == null)
+                throw new NullPointerException("Property nhMac must not be null");
+            IPv4Address srcIp = this.srcIpSet ? this.srcIp : DEFAULT_SRC_IP;
+            if(srcIp == null)
+                throw new NullPointerException("Property srcIp must not be null");
+            IPv4Address dstIp = this.dstIpSet ? this.dstIp : DEFAULT_DST_IP;
+            if(dstIp == null)
+                throw new NullPointerException("Property dstIp must not be null");
+            short dscp = this.dscpSet ? this.dscp : DEFAULT_DSCP;
+            short ttl = this.ttlSet ? this.ttl : DEFAULT_TTL;
+            long vpn = this.vpnSet ? this.vpn : DEFAULT_VPN;
+            long rateLimit = this.rateLimitSet ? this.rateLimit : DEFAULT_RATE_LIMIT;
+            String ifName = this.ifNameSet ? this.ifName : DEFAULT_IF_NAME;
+            if(ifName == null)
+                throw new NullPointerException("Property ifName must not be null");
+
+
+            return new OFBsnVportL2GreVer11(
+                    flags,
+                    portNo,
+                    loopbackPortNo,
+                    localMac,
+                    nhMac,
+                    srcIp,
+                    dstIp,
+                    dscp,
+                    ttl,
+                    vpn,
+                    rateLimit,
+                    ifName
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVportL2Gre> {
+        @Override
+        public OFBsnVportL2Gre readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 64)
+                throw new OFParseError("Wrong length: Expected=64(64), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            Set<OFBsnVportL2GreFlags> flags = OFBsnVportL2GreFlagsSerializerVer11.readFrom(bb);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            OFPort loopbackPortNo = OFPort.read4Bytes(bb);
+            MacAddress localMac = MacAddress.read6Bytes(bb);
+            MacAddress nhMac = MacAddress.read6Bytes(bb);
+            IPv4Address srcIp = IPv4Address.read4Bytes(bb);
+            IPv4Address dstIp = IPv4Address.read4Bytes(bb);
+            short dscp = U8.f(bb.readByte());
+            short ttl = U8.f(bb.readByte());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long vpn = U32.f(bb.readInt());
+            long rateLimit = U32.f(bb.readInt());
+            String ifName = ChannelUtils.readFixedLengthString(bb, 16);
+
+            OFBsnVportL2GreVer11 bsnVportL2GreVer11 = new OFBsnVportL2GreVer11(
+                    flags,
+                      portNo,
+                      loopbackPortNo,
+                      localMac,
+                      nhMac,
+                      srcIp,
+                      dstIp,
+                      dscp,
+                      ttl,
+                      vpn,
+                      rateLimit,
+                      ifName
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVportL2GreVer11);
+            return bsnVportL2GreVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVportL2GreVer11Funnel FUNNEL = new OFBsnVportL2GreVer11Funnel();
+    static class OFBsnVportL2GreVer11Funnel implements Funnel<OFBsnVportL2GreVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVportL2GreVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 64
+            sink.putShort((short) 0x40);
+            OFBsnVportL2GreFlagsSerializerVer11.putTo(message.flags, sink);
+            message.portNo.putTo(sink);
+            message.loopbackPortNo.putTo(sink);
+            message.localMac.putTo(sink);
+            message.nhMac.putTo(sink);
+            message.srcIp.putTo(sink);
+            message.dstIp.putTo(sink);
+            sink.putShort(message.dscp);
+            sink.putShort(message.ttl);
+            // skip pad (2 bytes)
+            sink.putLong(message.vpn);
+            sink.putLong(message.rateLimit);
+            sink.putUnencodedChars(message.ifName);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVportL2GreVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVportL2GreVer11 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 64
+            bb.writeShort((short) 0x40);
+            OFBsnVportL2GreFlagsSerializerVer11.writeTo(bb, message.flags);
+            message.portNo.write4Bytes(bb);
+            message.loopbackPortNo.write4Bytes(bb);
+            message.localMac.write6Bytes(bb);
+            message.nhMac.write6Bytes(bb);
+            message.srcIp.write4Bytes(bb);
+            message.dstIp.write4Bytes(bb);
+            bb.writeByte(U8.t(message.dscp));
+            bb.writeByte(U8.t(message.ttl));
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.vpn));
+            bb.writeInt(U32.t(message.rateLimit));
+            ChannelUtils.writeFixedLengthString(bb, message.ifName, 16);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVportL2GreVer11(");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("loopbackPortNo=").append(loopbackPortNo);
+        b.append(", ");
+        b.append("localMac=").append(localMac);
+        b.append(", ");
+        b.append("nhMac=").append(nhMac);
+        b.append(", ");
+        b.append("srcIp=").append(srcIp);
+        b.append(", ");
+        b.append("dstIp=").append(dstIp);
+        b.append(", ");
+        b.append("dscp=").append(dscp);
+        b.append(", ");
+        b.append("ttl=").append(ttl);
+        b.append(", ");
+        b.append("vpn=").append(vpn);
+        b.append(", ");
+        b.append("rateLimit=").append(rateLimit);
+        b.append(", ");
+        b.append("ifName=").append(ifName);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVportL2GreVer11 other = (OFBsnVportL2GreVer11) obj;
+
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (loopbackPortNo == null) {
+            if (other.loopbackPortNo != null)
+                return false;
+        } else if (!loopbackPortNo.equals(other.loopbackPortNo))
+            return false;
+        if (localMac == null) {
+            if (other.localMac != null)
+                return false;
+        } else if (!localMac.equals(other.localMac))
+            return false;
+        if (nhMac == null) {
+            if (other.nhMac != null)
+                return false;
+        } else if (!nhMac.equals(other.nhMac))
+            return false;
+        if (srcIp == null) {
+            if (other.srcIp != null)
+                return false;
+        } else if (!srcIp.equals(other.srcIp))
+            return false;
+        if (dstIp == null) {
+            if (other.dstIp != null)
+                return false;
+        } else if (!dstIp.equals(other.dstIp))
+            return false;
+        if( dscp != other.dscp)
+            return false;
+        if( ttl != other.ttl)
+            return false;
+        if( vpn != other.vpn)
+            return false;
+        if( rateLimit != other.rateLimit)
+            return false;
+        if (ifName == null) {
+            if (other.ifName != null)
+                return false;
+        } else if (!ifName.equals(other.ifName))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((loopbackPortNo == null) ? 0 : loopbackPortNo.hashCode());
+        result = prime * result + ((localMac == null) ? 0 : localMac.hashCode());
+        result = prime * result + ((nhMac == null) ? 0 : nhMac.hashCode());
+        result = prime * result + ((srcIp == null) ? 0 : srcIp.hashCode());
+        result = prime * result + ((dstIp == null) ? 0 : dstIp.hashCode());
+        result = prime * result + dscp;
+        result = prime * result + ttl;
+        result = prime *  (int) (vpn ^ (vpn >>> 32));
+        result = prime *  (int) (rateLimit ^ (rateLimit >>> 32));
+        result = prime * result + ((ifName == null) ? 0 : ifName.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportQInQUntaggedSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportQInQUntaggedSerializerVer11.java
new file mode 100644
index 0000000..889da28
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportQInQUntaggedSerializerVer11.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportQInQUntagged;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVportQInQUntaggedSerializerVer11 {
+
+    public final static short BSN_VPORT_Q_IN_Q_UNTAGGED_VAL = (short) 0xffff;
+
+    public static OFBsnVportQInQUntagged readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVportQInQUntagged e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnVportQInQUntagged e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVportQInQUntagged ofWireValue(short val) {
+        switch(val) {
+            case BSN_VPORT_Q_IN_Q_UNTAGGED_VAL:
+                return OFBsnVportQInQUntagged.BSN_VPORT_Q_IN_Q_UNTAGGED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVportQInQUntagged in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVportQInQUntagged e) {
+        switch(e) {
+            case BSN_VPORT_Q_IN_Q_UNTAGGED:
+                return BSN_VPORT_Q_IN_Q_UNTAGGED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVportQInQUntagged in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportQInQVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportQInQVer11.java
new file mode 100644
index 0000000..287e161
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportQInQVer11.java
@@ -0,0 +1,502 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVportQInQVer11 implements OFBsnVportQInQ {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVportQInQVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_PORT_NO = 0x0L;
+        private final static int DEFAULT_INGRESS_TPID = 0x0;
+        private final static int DEFAULT_INGRESS_VLAN_ID = 0x0;
+        private final static int DEFAULT_EGRESS_TPID = 0x0;
+        private final static int DEFAULT_EGRESS_VLAN_ID = 0x0;
+        private final static String DEFAULT_IF_NAME = "";
+
+    // OF message fields
+    private final long portNo;
+    private final int ingressTpid;
+    private final int ingressVlanId;
+    private final int egressTpid;
+    private final int egressVlanId;
+    private final String ifName;
+//
+    // Immutable default instance
+    final static OFBsnVportQInQVer11 DEFAULT = new OFBsnVportQInQVer11(
+        DEFAULT_PORT_NO, DEFAULT_INGRESS_TPID, DEFAULT_INGRESS_VLAN_ID, DEFAULT_EGRESS_TPID, DEFAULT_EGRESS_VLAN_ID, DEFAULT_IF_NAME
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVportQInQVer11(long portNo, int ingressTpid, int ingressVlanId, int egressTpid, int egressVlanId, String ifName) {
+        this.portNo = portNo;
+        this.ingressTpid = ingressTpid;
+        this.ingressVlanId = ingressVlanId;
+        this.egressTpid = egressTpid;
+        this.egressVlanId = egressVlanId;
+        this.ifName = ifName;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFBsnVportQInQ.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVportQInQ.Builder {
+        final OFBsnVportQInQVer11 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private long portNo;
+        private boolean ingressTpidSet;
+        private int ingressTpid;
+        private boolean ingressVlanIdSet;
+        private int ingressVlanId;
+        private boolean egressTpidSet;
+        private int egressTpid;
+        private boolean egressVlanIdSet;
+        private int egressVlanId;
+        private boolean ifNameSet;
+        private String ifName;
+
+        BuilderWithParent(OFBsnVportQInQVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setPortNo(long portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressTpid(int ingressTpid) {
+        this.ingressTpid = ingressTpid;
+        this.ingressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressVlanId(int ingressVlanId) {
+        this.ingressVlanId = ingressVlanId;
+        this.ingressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressTpid(int egressTpid) {
+        this.egressTpid = egressTpid;
+        this.egressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressVlanId(int egressVlanId) {
+        this.egressVlanId = egressVlanId;
+        this.egressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFBsnVportQInQ build() {
+                long portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                int ingressTpid = this.ingressTpidSet ? this.ingressTpid : parentMessage.ingressTpid;
+                int ingressVlanId = this.ingressVlanIdSet ? this.ingressVlanId : parentMessage.ingressVlanId;
+                int egressTpid = this.egressTpidSet ? this.egressTpid : parentMessage.egressTpid;
+                int egressVlanId = this.egressVlanIdSet ? this.egressVlanId : parentMessage.egressVlanId;
+                String ifName = this.ifNameSet ? this.ifName : parentMessage.ifName;
+                if(ifName == null)
+                    throw new NullPointerException("Property ifName must not be null");
+
+                //
+                return new OFBsnVportQInQVer11(
+                    portNo,
+                    ingressTpid,
+                    ingressVlanId,
+                    egressTpid,
+                    egressVlanId,
+                    ifName
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVportQInQ.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private long portNo;
+        private boolean ingressTpidSet;
+        private int ingressTpid;
+        private boolean ingressVlanIdSet;
+        private int ingressVlanId;
+        private boolean egressTpidSet;
+        private int egressTpid;
+        private boolean egressVlanIdSet;
+        private int egressVlanId;
+        private boolean ifNameSet;
+        private String ifName;
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setPortNo(long portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressTpid(int ingressTpid) {
+        this.ingressTpid = ingressTpid;
+        this.ingressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressVlanId(int ingressVlanId) {
+        this.ingressVlanId = ingressVlanId;
+        this.ingressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressTpid(int egressTpid) {
+        this.egressTpid = egressTpid;
+        this.egressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressVlanId(int egressVlanId) {
+        this.egressVlanId = egressVlanId;
+        this.egressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFBsnVportQInQ build() {
+            long portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            int ingressTpid = this.ingressTpidSet ? this.ingressTpid : DEFAULT_INGRESS_TPID;
+            int ingressVlanId = this.ingressVlanIdSet ? this.ingressVlanId : DEFAULT_INGRESS_VLAN_ID;
+            int egressTpid = this.egressTpidSet ? this.egressTpid : DEFAULT_EGRESS_TPID;
+            int egressVlanId = this.egressVlanIdSet ? this.egressVlanId : DEFAULT_EGRESS_VLAN_ID;
+            String ifName = this.ifNameSet ? this.ifName : DEFAULT_IF_NAME;
+            if(ifName == null)
+                throw new NullPointerException("Property ifName must not be null");
+
+
+            return new OFBsnVportQInQVer11(
+                    portNo,
+                    ingressTpid,
+                    ingressVlanId,
+                    egressTpid,
+                    egressVlanId,
+                    ifName
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVportQInQ> {
+        @Override
+        public OFBsnVportQInQ readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=0x0(0x0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long portNo = U32.f(bb.readInt());
+            int ingressTpid = U16.f(bb.readShort());
+            int ingressVlanId = U16.f(bb.readShort());
+            int egressTpid = U16.f(bb.readShort());
+            int egressVlanId = U16.f(bb.readShort());
+            String ifName = ChannelUtils.readFixedLengthString(bb, 16);
+
+            OFBsnVportQInQVer11 bsnVportQInQVer11 = new OFBsnVportQInQVer11(
+                    portNo,
+                      ingressTpid,
+                      ingressVlanId,
+                      egressTpid,
+                      egressVlanId,
+                      ifName
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVportQInQVer11);
+            return bsnVportQInQVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVportQInQVer11Funnel FUNNEL = new OFBsnVportQInQVer11Funnel();
+    static class OFBsnVportQInQVer11Funnel implements Funnel<OFBsnVportQInQVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVportQInQVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 0x0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.portNo);
+            sink.putInt(message.ingressTpid);
+            sink.putInt(message.ingressVlanId);
+            sink.putInt(message.egressTpid);
+            sink.putInt(message.egressVlanId);
+            sink.putUnencodedChars(message.ifName);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVportQInQVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVportQInQVer11 message) {
+            // fixed value property type = 0x0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.portNo));
+            bb.writeShort(U16.t(message.ingressTpid));
+            bb.writeShort(U16.t(message.ingressVlanId));
+            bb.writeShort(U16.t(message.egressTpid));
+            bb.writeShort(U16.t(message.egressVlanId));
+            ChannelUtils.writeFixedLengthString(bb, message.ifName, 16);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVportQInQVer11(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("ingressTpid=").append(ingressTpid);
+        b.append(", ");
+        b.append("ingressVlanId=").append(ingressVlanId);
+        b.append(", ");
+        b.append("egressTpid=").append(egressTpid);
+        b.append(", ");
+        b.append("egressVlanId=").append(egressVlanId);
+        b.append(", ");
+        b.append("ifName=").append(ifName);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVportQInQVer11 other = (OFBsnVportQInQVer11) obj;
+
+        if( portNo != other.portNo)
+            return false;
+        if( ingressTpid != other.ingressTpid)
+            return false;
+        if( ingressVlanId != other.ingressVlanId)
+            return false;
+        if( egressTpid != other.egressTpid)
+            return false;
+        if( egressVlanId != other.egressVlanId)
+            return false;
+        if (ifName == null) {
+            if (other.ifName != null)
+                return false;
+        } else if (!ifName.equals(other.ifName))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (portNo ^ (portNo >>> 32));
+        result = prime * result + ingressTpid;
+        result = prime * result + ingressVlanId;
+        result = prime * result + egressTpid;
+        result = prime * result + egressVlanId;
+        result = prime * result + ((ifName == null) ? 0 : ifName.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportStatusSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportStatusSerializerVer11.java
new file mode 100644
index 0000000..08cd287
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportStatusSerializerVer11.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportStatus;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVportStatusSerializerVer11 {
+
+    public final static short BSN_VPORT_STATUS_OK_VAL = (short) 0x0;
+    public final static short BSN_VPORT_STATUS_FAILED_VAL = (short) 0x1;
+
+    public static OFBsnVportStatus readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(U8.f(bb.readByte()));
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVportStatus e) {
+        bb.writeByte(U8.t(toWireValue(e)));
+    }
+
+    public static void putTo(OFBsnVportStatus e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVportStatus ofWireValue(short val) {
+        switch(val) {
+            case BSN_VPORT_STATUS_OK_VAL:
+                return OFBsnVportStatus.BSN_VPORT_STATUS_OK;
+            case BSN_VPORT_STATUS_FAILED_VAL:
+                return OFBsnVportStatus.BSN_VPORT_STATUS_FAILED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVportStatus in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVportStatus e) {
+        switch(e) {
+            case BSN_VPORT_STATUS_OK:
+                return BSN_VPORT_STATUS_OK_VAL;
+            case BSN_VPORT_STATUS_FAILED:
+                return BSN_VPORT_STATUS_FAILED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVportStatus in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportVer11.java
new file mode 100644
index 0000000..ff47904
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBsnVportVer11.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnVportVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFBsnVportVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnVport> {
+        @Override
+        public OFBsnVport readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFBsnVportL2GreVer11
+                   return OFBsnVportL2GreVer11.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value 0x0=0x0 for class OFBsnVportQInQVer11
+                   return OFBsnVportQInQVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFBsnVportVer11: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBucketCounterVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBucketCounterVer11.java
new file mode 100644
index 0000000..3a7ba89
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBucketCounterVer11.java
@@ -0,0 +1,283 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBucketCounterVer11 implements OFBucketCounter {
+    private static final Logger logger = LoggerFactory.getLogger(OFBucketCounterVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final U64 packetCount;
+    private final U64 byteCount;
+//
+    // Immutable default instance
+    final static OFBucketCounterVer11 DEFAULT = new OFBucketCounterVer11(
+        DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBucketCounterVer11(U64 packetCount, U64 byteCount) {
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFBucketCounter.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBucketCounter.Builder {
+        final OFBucketCounterVer11 parentMessage;
+
+        // OF message fields
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+
+        BuilderWithParent(OFBucketCounterVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFBucketCounter build() {
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+
+                //
+                return new OFBucketCounterVer11(
+                    packetCount,
+                    byteCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFBucketCounter.Builder {
+        // OF message fields
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFBucketCounter build() {
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+
+
+            return new OFBucketCounterVer11(
+                    packetCount,
+                    byteCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBucketCounter> {
+        @Override
+        public OFBucketCounter readFrom(ChannelBuffer bb) throws OFParseError {
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+
+            OFBucketCounterVer11 bucketCounterVer11 = new OFBucketCounterVer11(
+                    packetCount,
+                      byteCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bucketCounterVer11);
+            return bucketCounterVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBucketCounterVer11Funnel FUNNEL = new OFBucketCounterVer11Funnel();
+    static class OFBucketCounterVer11Funnel implements Funnel<OFBucketCounterVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBucketCounterVer11 message, PrimitiveSink sink) {
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBucketCounterVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBucketCounterVer11 message) {
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBucketCounterVer11(");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBucketCounterVer11 other = (OFBucketCounterVer11) obj;
+
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBucketVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBucketVer11.java
new file mode 100644
index 0000000..600a472
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFBucketVer11.java
@@ -0,0 +1,411 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBucketVer11 implements OFBucket {
+    private static final Logger logger = LoggerFactory.getLogger(OFBucketVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static int DEFAULT_WEIGHT = 0x0;
+        private final static OFPort DEFAULT_WATCH_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_WATCH_GROUP = OFGroup.ALL;
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final int weight;
+    private final OFPort watchPort;
+    private final OFGroup watchGroup;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFBucketVer11 DEFAULT = new OFBucketVer11(
+        DEFAULT_WEIGHT, DEFAULT_WATCH_PORT, DEFAULT_WATCH_GROUP, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBucketVer11(int weight, OFPort watchPort, OFGroup watchGroup, List<OFAction> actions) {
+        this.weight = weight;
+        this.watchPort = watchPort;
+        this.watchGroup = watchGroup;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFBucket.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBucket.Builder {
+        final OFBucketVer11 parentMessage;
+
+        // OF message fields
+        private boolean weightSet;
+        private int weight;
+        private boolean watchPortSet;
+        private OFPort watchPort;
+        private boolean watchGroupSet;
+        private OFGroup watchGroup;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFBucketVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFBucket.Builder setWeight(int weight) {
+        this.weight = weight;
+        this.weightSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchPort(OFPort watchPort) {
+        this.watchPort = watchPort;
+        this.watchPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchGroup(OFGroup watchGroup) {
+        this.watchGroup = watchGroup;
+        this.watchGroupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFBucket.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFBucket build() {
+                int weight = this.weightSet ? this.weight : parentMessage.weight;
+                OFPort watchPort = this.watchPortSet ? this.watchPort : parentMessage.watchPort;
+                if(watchPort == null)
+                    throw new NullPointerException("Property watchPort must not be null");
+                OFGroup watchGroup = this.watchGroupSet ? this.watchGroup : parentMessage.watchGroup;
+                if(watchGroup == null)
+                    throw new NullPointerException("Property watchGroup must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFBucketVer11(
+                    weight,
+                    watchPort,
+                    watchGroup,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFBucket.Builder {
+        // OF message fields
+        private boolean weightSet;
+        private int weight;
+        private boolean watchPortSet;
+        private OFPort watchPort;
+        private boolean watchGroupSet;
+        private OFGroup watchGroup;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFBucket.Builder setWeight(int weight) {
+        this.weight = weight;
+        this.weightSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchPort(OFPort watchPort) {
+        this.watchPort = watchPort;
+        this.watchPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchGroup(OFGroup watchGroup) {
+        this.watchGroup = watchGroup;
+        this.watchGroupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFBucket.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFBucket build() {
+            int weight = this.weightSet ? this.weight : DEFAULT_WEIGHT;
+            OFPort watchPort = this.watchPortSet ? this.watchPort : DEFAULT_WATCH_PORT;
+            if(watchPort == null)
+                throw new NullPointerException("Property watchPort must not be null");
+            OFGroup watchGroup = this.watchGroupSet ? this.watchGroup : DEFAULT_WATCH_GROUP;
+            if(watchGroup == null)
+                throw new NullPointerException("Property watchGroup must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFBucketVer11(
+                    weight,
+                    watchPort,
+                    watchGroup,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBucket> {
+        @Override
+        public OFBucket readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int weight = U16.f(bb.readShort());
+            OFPort watchPort = OFPort.read4Bytes(bb);
+            OFGroup watchGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer11.READER);
+
+            OFBucketVer11 bucketVer11 = new OFBucketVer11(
+                    weight,
+                      watchPort,
+                      watchGroup,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bucketVer11);
+            return bucketVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBucketVer11Funnel FUNNEL = new OFBucketVer11Funnel();
+    static class OFBucketVer11Funnel implements Funnel<OFBucketVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBucketVer11 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            sink.putInt(message.weight);
+            message.watchPort.putTo(sink);
+            message.watchGroup.putTo(sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBucketVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFBucketVer11 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeShort(U16.t(message.weight));
+            message.watchPort.write4Bytes(bb);
+            message.watchGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBucketVer11(");
+        b.append("weight=").append(weight);
+        b.append(", ");
+        b.append("watchPort=").append(watchPort);
+        b.append(", ");
+        b.append("watchGroup=").append(watchGroup);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBucketVer11 other = (OFBucketVer11) obj;
+
+        if( weight != other.weight)
+            return false;
+        if (watchPort == null) {
+            if (other.watchPort != null)
+                return false;
+        } else if (!watchPort.equals(other.watchPort))
+            return false;
+        if (watchGroup == null) {
+            if (other.watchGroup != null)
+                return false;
+        } else if (!watchGroup.equals(other.watchGroup))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + weight;
+        result = prime * result + ((watchPort == null) ? 0 : watchPort.hashCode());
+        result = prime * result + ((watchGroup == null) ? 0 : watchGroup.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFCapabilitiesSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFCapabilitiesSerializerVer11.java
new file mode 100644
index 0000000..aec3c70
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFCapabilitiesSerializerVer11.java
@@ -0,0 +1,114 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFCapabilities;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFCapabilitiesSerializerVer11 {
+
+    public final static int FLOW_STATS_VAL = 0x1;
+    public final static int TABLE_STATS_VAL = 0x2;
+    public final static int PORT_STATS_VAL = 0x4;
+    public final static int IP_REASM_VAL = 0x20;
+    public final static int QUEUE_STATS_VAL = 0x40;
+    public final static int ARP_MATCH_IP_VAL = 0x80;
+    public final static int GROUP_STATS_VAL = 0x8;
+
+    public static Set<OFCapabilities> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFCapabilities> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFCapabilities> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFCapabilities> ofWireValue(int val) {
+        EnumSet<OFCapabilities> set = EnumSet.noneOf(OFCapabilities.class);
+
+        if((val & FLOW_STATS_VAL) != 0)
+            set.add(OFCapabilities.FLOW_STATS);
+        if((val & TABLE_STATS_VAL) != 0)
+            set.add(OFCapabilities.TABLE_STATS);
+        if((val & PORT_STATS_VAL) != 0)
+            set.add(OFCapabilities.PORT_STATS);
+        if((val & IP_REASM_VAL) != 0)
+            set.add(OFCapabilities.IP_REASM);
+        if((val & QUEUE_STATS_VAL) != 0)
+            set.add(OFCapabilities.QUEUE_STATS);
+        if((val & ARP_MATCH_IP_VAL) != 0)
+            set.add(OFCapabilities.ARP_MATCH_IP);
+        if((val & GROUP_STATS_VAL) != 0)
+            set.add(OFCapabilities.GROUP_STATS);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFCapabilities> set) {
+        int wireValue = 0;
+
+        for(OFCapabilities e: set) {
+            switch(e) {
+                case FLOW_STATS:
+                    wireValue |= FLOW_STATS_VAL;
+                    break;
+                case TABLE_STATS:
+                    wireValue |= TABLE_STATS_VAL;
+                    break;
+                case PORT_STATS:
+                    wireValue |= PORT_STATS_VAL;
+                    break;
+                case IP_REASM:
+                    wireValue |= IP_REASM_VAL;
+                    break;
+                case QUEUE_STATS:
+                    wireValue |= QUEUE_STATS_VAL;
+                    break;
+                case ARP_MATCH_IP:
+                    wireValue |= ARP_MATCH_IP_VAL;
+                    break;
+                case GROUP_STATS:
+                    wireValue |= GROUP_STATS_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFCapabilities in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFConfigFlagsSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFConfigFlagsSerializerVer11.java
new file mode 100644
index 0000000..50ac481
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFConfigFlagsSerializerVer11.java
@@ -0,0 +1,97 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFConfigFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFConfigFlagsSerializerVer11 {
+
+    public final static short FRAG_NORMAL_VAL = (short) 0x0;
+    public final static short FRAG_DROP_VAL = (short) 0x1;
+    public final static short FRAG_REASM_VAL = (short) 0x2;
+    public final static short FRAG_MASK_VAL = (short) 0x3;
+    public final static short INVALID_TTL_TO_CONTROLLER_VAL = (short) 0x4;
+
+    public static Set<OFConfigFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFConfigFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFConfigFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFConfigFlags> ofWireValue(short val) {
+        EnumSet<OFConfigFlags> set = EnumSet.noneOf(OFConfigFlags.class);
+
+        if((val & FRAG_MASK_VAL) == FRAG_NORMAL_VAL)
+            set.add(OFConfigFlags.FRAG_NORMAL);
+        else if((val & FRAG_MASK_VAL) == FRAG_DROP_VAL)
+            set.add(OFConfigFlags.FRAG_DROP);
+        else if((val & FRAG_MASK_VAL) == FRAG_REASM_VAL)
+            set.add(OFConfigFlags.FRAG_REASM);
+        if((val & INVALID_TTL_TO_CONTROLLER_VAL) != 0)
+            set.add(OFConfigFlags.INVALID_TTL_TO_CONTROLLER);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFConfigFlags> set) {
+        short wireValue = 0;
+
+        for(OFConfigFlags e: set) {
+            switch(e) {
+                case FRAG_NORMAL:
+                    wireValue |= FRAG_NORMAL_VAL;
+                    break;
+                case FRAG_DROP:
+                    wireValue |= FRAG_DROP_VAL;
+                    break;
+                case FRAG_REASM:
+                    wireValue |= FRAG_REASM_VAL;
+                    break;
+                case INVALID_TTL_TO_CONTROLLER:
+                    wireValue |= INVALID_TTL_TO_CONTROLLER_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFConfigFlags in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFDescStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFDescStatsReplyVer11.java
new file mode 100644
index 0000000..211471c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFDescStatsReplyVer11.java
@@ -0,0 +1,621 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFDescStatsReplyVer11 implements OFDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFDescStatsReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 1072;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static String DEFAULT_MFR_DESC = "";
+        private final static String DEFAULT_HW_DESC = "";
+        private final static String DEFAULT_SW_DESC = "";
+        private final static String DEFAULT_SERIAL_NUM = "";
+        private final static String DEFAULT_DP_DESC = "";
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final String mfrDesc;
+    private final String hwDesc;
+    private final String swDesc;
+    private final String serialNum;
+    private final String dpDesc;
+//
+    // Immutable default instance
+    final static OFDescStatsReplyVer11 DEFAULT = new OFDescStatsReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MFR_DESC, DEFAULT_HW_DESC, DEFAULT_SW_DESC, DEFAULT_SERIAL_NUM, DEFAULT_DP_DESC
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFDescStatsReplyVer11(long xid, Set<OFStatsReplyFlags> flags, String mfrDesc, String hwDesc, String swDesc, String serialNum, String dpDesc) {
+        this.xid = xid;
+        this.flags = flags;
+        this.mfrDesc = mfrDesc;
+        this.hwDesc = hwDesc;
+        this.swDesc = swDesc;
+        this.serialNum = serialNum;
+        this.dpDesc = dpDesc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+
+
+    public OFDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFDescStatsReply.Builder {
+        final OFDescStatsReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean mfrDescSet;
+        private String mfrDesc;
+        private boolean hwDescSet;
+        private String hwDesc;
+        private boolean swDescSet;
+        private String swDesc;
+        private boolean serialNumSet;
+        private String serialNum;
+        private boolean dpDescSet;
+        private String dpDesc;
+
+        BuilderWithParent(OFDescStatsReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
+        this.mfrDesc = mfrDesc;
+        this.mfrDescSet = true;
+        return this;
+    }
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
+        this.hwDesc = hwDesc;
+        this.hwDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSwDesc(String swDesc) {
+        this.swDesc = swDesc;
+        this.swDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSerialNum(String serialNum) {
+        this.serialNum = serialNum;
+        this.serialNumSet = true;
+        return this;
+    }
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
+        this.dpDesc = dpDesc;
+        this.dpDescSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                String mfrDesc = this.mfrDescSet ? this.mfrDesc : parentMessage.mfrDesc;
+                if(mfrDesc == null)
+                    throw new NullPointerException("Property mfrDesc must not be null");
+                String hwDesc = this.hwDescSet ? this.hwDesc : parentMessage.hwDesc;
+                if(hwDesc == null)
+                    throw new NullPointerException("Property hwDesc must not be null");
+                String swDesc = this.swDescSet ? this.swDesc : parentMessage.swDesc;
+                if(swDesc == null)
+                    throw new NullPointerException("Property swDesc must not be null");
+                String serialNum = this.serialNumSet ? this.serialNum : parentMessage.serialNum;
+                if(serialNum == null)
+                    throw new NullPointerException("Property serialNum must not be null");
+                String dpDesc = this.dpDescSet ? this.dpDesc : parentMessage.dpDesc;
+                if(dpDesc == null)
+                    throw new NullPointerException("Property dpDesc must not be null");
+
+                //
+                return new OFDescStatsReplyVer11(
+                    xid,
+                    flags,
+                    mfrDesc,
+                    hwDesc,
+                    swDesc,
+                    serialNum,
+                    dpDesc
+                );
+        }
+
+    }
+
+    static class Builder implements OFDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean mfrDescSet;
+        private String mfrDesc;
+        private boolean hwDescSet;
+        private String hwDesc;
+        private boolean swDescSet;
+        private String swDesc;
+        private boolean serialNumSet;
+        private String serialNum;
+        private boolean dpDescSet;
+        private String dpDesc;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
+        this.mfrDesc = mfrDesc;
+        this.mfrDescSet = true;
+        return this;
+    }
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
+        this.hwDesc = hwDesc;
+        this.hwDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSwDesc(String swDesc) {
+        this.swDesc = swDesc;
+        this.swDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSerialNum(String serialNum) {
+        this.serialNum = serialNum;
+        this.serialNumSet = true;
+        return this;
+    }
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
+        this.dpDesc = dpDesc;
+        this.dpDescSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            String mfrDesc = this.mfrDescSet ? this.mfrDesc : DEFAULT_MFR_DESC;
+            if(mfrDesc == null)
+                throw new NullPointerException("Property mfrDesc must not be null");
+            String hwDesc = this.hwDescSet ? this.hwDesc : DEFAULT_HW_DESC;
+            if(hwDesc == null)
+                throw new NullPointerException("Property hwDesc must not be null");
+            String swDesc = this.swDescSet ? this.swDesc : DEFAULT_SW_DESC;
+            if(swDesc == null)
+                throw new NullPointerException("Property swDesc must not be null");
+            String serialNum = this.serialNumSet ? this.serialNum : DEFAULT_SERIAL_NUM;
+            if(serialNum == null)
+                throw new NullPointerException("Property serialNum must not be null");
+            String dpDesc = this.dpDescSet ? this.dpDesc : DEFAULT_DP_DESC;
+            if(dpDesc == null)
+                throw new NullPointerException("Property dpDesc must not be null");
+
+
+            return new OFDescStatsReplyVer11(
+                    xid,
+                    flags,
+                    mfrDesc,
+                    hwDesc,
+                    swDesc,
+                    serialNum,
+                    dpDesc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFDescStatsReply> {
+        @Override
+        public OFDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 1072)
+                throw new OFParseError("Wrong length: Expected=1072(1072), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 0
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x0)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            String mfrDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String hwDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String swDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String serialNum = ChannelUtils.readFixedLengthString(bb, 32);
+            String dpDesc = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFDescStatsReplyVer11 descStatsReplyVer11 = new OFDescStatsReplyVer11(
+                    xid,
+                      flags,
+                      mfrDesc,
+                      hwDesc,
+                      swDesc,
+                      serialNum,
+                      dpDesc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", descStatsReplyVer11);
+            return descStatsReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFDescStatsReplyVer11Funnel FUNNEL = new OFDescStatsReplyVer11Funnel();
+    static class OFDescStatsReplyVer11Funnel implements Funnel<OFDescStatsReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFDescStatsReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 1072
+            sink.putShort((short) 0x430);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 0
+            sink.putShort((short) 0x0);
+            OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            sink.putUnencodedChars(message.mfrDesc);
+            sink.putUnencodedChars(message.hwDesc);
+            sink.putUnencodedChars(message.swDesc);
+            sink.putUnencodedChars(message.serialNum);
+            sink.putUnencodedChars(message.dpDesc);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFDescStatsReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFDescStatsReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 1072
+            bb.writeShort((short) 0x430);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 0
+            bb.writeShort((short) 0x0);
+            OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeFixedLengthString(bb, message.mfrDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.hwDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.swDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.serialNum, 32);
+            ChannelUtils.writeFixedLengthString(bb, message.dpDesc, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFDescStatsReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("mfrDesc=").append(mfrDesc);
+        b.append(", ");
+        b.append("hwDesc=").append(hwDesc);
+        b.append(", ");
+        b.append("swDesc=").append(swDesc);
+        b.append(", ");
+        b.append("serialNum=").append(serialNum);
+        b.append(", ");
+        b.append("dpDesc=").append(dpDesc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFDescStatsReplyVer11 other = (OFDescStatsReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (mfrDesc == null) {
+            if (other.mfrDesc != null)
+                return false;
+        } else if (!mfrDesc.equals(other.mfrDesc))
+            return false;
+        if (hwDesc == null) {
+            if (other.hwDesc != null)
+                return false;
+        } else if (!hwDesc.equals(other.hwDesc))
+            return false;
+        if (swDesc == null) {
+            if (other.swDesc != null)
+                return false;
+        } else if (!swDesc.equals(other.swDesc))
+            return false;
+        if (serialNum == null) {
+            if (other.serialNum != null)
+                return false;
+        } else if (!serialNum.equals(other.serialNum))
+            return false;
+        if (dpDesc == null) {
+            if (other.dpDesc != null)
+                return false;
+        } else if (!dpDesc.equals(other.dpDesc))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((mfrDesc == null) ? 0 : mfrDesc.hashCode());
+        result = prime * result + ((hwDesc == null) ? 0 : hwDesc.hashCode());
+        result = prime * result + ((swDesc == null) ? 0 : swDesc.hashCode());
+        result = prime * result + ((serialNum == null) ? 0 : serialNum.hashCode());
+        result = prime * result + ((dpDesc == null) ? 0 : dpDesc.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFDescStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFDescStatsRequestVer11.java
new file mode 100644
index 0000000..7cf9a8c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFDescStatsRequestVer11.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFDescStatsRequestVer11 implements OFDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFDescStatsRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFDescStatsRequestVer11 DEFAULT = new OFDescStatsRequestVer11(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFDescStatsRequestVer11(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFDescStatsRequest.Builder {
+        final OFDescStatsRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFDescStatsRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFDescStatsRequestVer11(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFDescStatsRequestVer11(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFDescStatsRequest> {
+        @Override
+        public OFDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 0
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x0)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFDescStatsRequestVer11 descStatsRequestVer11 = new OFDescStatsRequestVer11(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", descStatsRequestVer11);
+            return descStatsRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFDescStatsRequestVer11Funnel FUNNEL = new OFDescStatsRequestVer11Funnel();
+    static class OFDescStatsRequestVer11Funnel implements Funnel<OFDescStatsRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFDescStatsRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 0
+            sink.putShort((short) 0x0);
+            OFStatsRequestFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFDescStatsRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFDescStatsRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 0
+            bb.writeShort((short) 0x0);
+            OFStatsRequestFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFDescStatsRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFDescStatsRequestVer11 other = (OFDescStatsRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFEchoReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFEchoReplyVer11.java
new file mode 100644
index 0000000..d9352bb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFEchoReplyVer11.java
@@ -0,0 +1,325 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFEchoReplyVer11 implements OFEchoReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFEchoReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFEchoReplyVer11 DEFAULT = new OFEchoReplyVer11(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFEchoReplyVer11(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFEchoReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFEchoReply.Builder {
+        final OFEchoReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFEchoReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoReply.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFEchoReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFEchoReplyVer11(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFEchoReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoReply.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFEchoReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFEchoReplyVer11(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFEchoReply> {
+        @Override
+        public OFEchoReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 3
+            byte type = bb.readByte();
+            if(type != (byte) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFType.ECHO_REPLY(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFEchoReplyVer11 echoReplyVer11 = new OFEchoReplyVer11(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", echoReplyVer11);
+            return echoReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFEchoReplyVer11Funnel FUNNEL = new OFEchoReplyVer11Funnel();
+    static class OFEchoReplyVer11Funnel implements Funnel<OFEchoReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFEchoReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 3
+            sink.putByte((byte) 0x3);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFEchoReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFEchoReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 3
+            bb.writeByte((byte) 0x3);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFEchoReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFEchoReplyVer11 other = (OFEchoReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFEchoRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFEchoRequestVer11.java
new file mode 100644
index 0000000..c450f58
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFEchoRequestVer11.java
@@ -0,0 +1,325 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFEchoRequestVer11 implements OFEchoRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFEchoRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFEchoRequestVer11 DEFAULT = new OFEchoRequestVer11(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFEchoRequestVer11(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFEchoRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFEchoRequest.Builder {
+        final OFEchoRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFEchoRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFEchoRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFEchoRequestVer11(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFEchoRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFEchoRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFEchoRequestVer11(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFEchoRequest> {
+        @Override
+        public OFEchoRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 2
+            byte type = bb.readByte();
+            if(type != (byte) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFType.ECHO_REQUEST(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFEchoRequestVer11 echoRequestVer11 = new OFEchoRequestVer11(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", echoRequestVer11);
+            return echoRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFEchoRequestVer11Funnel FUNNEL = new OFEchoRequestVer11Funnel();
+    static class OFEchoRequestVer11Funnel implements Funnel<OFEchoRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFEchoRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 2
+            sink.putByte((byte) 0x2);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFEchoRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFEchoRequestVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 2
+            bb.writeByte((byte) 0x2);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFEchoRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFEchoRequestVer11 other = (OFEchoRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorMsgVer11.java
new file mode 100644
index 0000000..c67294f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorMsgVer11.java
@@ -0,0 +1,95 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFErrorMsgVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 10;
+
+
+    public final static OFErrorMsgVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFErrorMsg> {
+        @Override
+        public OFErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short errType = bb.readShort();
+            bb.readerIndex(start);
+            switch(errType) {
+               case (short) 0x2:
+                   // discriminator value OFErrorType.BAD_ACTION=2 for class OFBadActionErrorMsgVer11
+                   return OFBadActionErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFErrorType.BAD_REQUEST=1 for class OFBadRequestErrorMsgVer11
+                   return OFBadRequestErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFErrorType.FLOW_MOD_FAILED=5 for class OFFlowModFailedErrorMsgVer11
+                   return OFFlowModFailedErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFErrorType.HELLO_FAILED=0 for class OFHelloFailedErrorMsgVer11
+                   return OFHelloFailedErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFErrorType.PORT_MOD_FAILED=7 for class OFPortModFailedErrorMsgVer11
+                   return OFPortModFailedErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x9:
+                   // discriminator value OFErrorType.QUEUE_OP_FAILED=9 for class OFQueueOpFailedErrorMsgVer11
+                   return OFQueueOpFailedErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFErrorType.BAD_INSTRUCTION=3 for class OFBadInstructionErrorMsgVer11
+                   return OFBadInstructionErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFErrorType.BAD_MATCH=4 for class OFBadMatchErrorMsgVer11
+                   return OFBadMatchErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFErrorType.GROUP_MOD_FAILED=6 for class OFGroupModFailedErrorMsgVer11
+                   return OFGroupModFailedErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0xa:
+                   // discriminator value OFErrorType.SWITCH_CONFIG_FAILED=10 for class OFSwitchConfigFailedErrorMsgVer11
+                   return OFSwitchConfigFailedErrorMsgVer11.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFErrorType.TABLE_MOD_FAILED=8 for class OFTableModFailedErrorMsgVer11
+                   return OFTableModFailedErrorMsgVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator errType of class OFErrorMsgVer11: " + errType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorMsgsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorMsgsVer11.java
new file mode 100644
index 0000000..cad00e7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorMsgsVer11.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFErrorMsgsVer11 implements OFErrorMsgs {
+    public final static OFErrorMsgsVer11 INSTANCE = new OFErrorMsgsVer11();
+
+    private final XidGenerator xidGenerator = XidGenerators.global();
+
+
+
+    public OFBadActionErrorMsg.Builder buildBadActionErrorMsg() {
+        return new OFBadActionErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBadRequestErrorMsg.Builder buildBadRequestErrorMsg() {
+        return new OFBadRequestErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModFailedErrorMsg.Builder buildFlowModFailedErrorMsg() {
+        return new OFFlowModFailedErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFHelloFailedErrorMsg.Builder buildHelloFailedErrorMsg() {
+        return new OFHelloFailedErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFPortModFailedErrorMsg.Builder buildPortModFailedErrorMsg() {
+        return new OFPortModFailedErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFQueueOpFailedErrorMsg.Builder buildQueueOpFailedErrorMsg() {
+        return new OFQueueOpFailedErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBadInstructionErrorMsg.Builder buildBadInstructionErrorMsg() {
+        return new OFBadInstructionErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBadMatchErrorMsg.Builder buildBadMatchErrorMsg() {
+        return new OFBadMatchErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFGroupModFailedErrorMsg.Builder buildGroupModFailedErrorMsg() {
+        return new OFGroupModFailedErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFSwitchConfigFailedErrorMsg.Builder buildSwitchConfigFailedErrorMsg() {
+        return new OFSwitchConfigFailedErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFTableModFailedErrorMsg.Builder buildTableModFailedErrorMsg() {
+        return new OFTableModFailedErrorMsgVer11.Builder().setXid(nextXid());
+    }
+
+    public OFExperimenterErrorMsg.Builder buildExperimenterErrorMsg() {
+        throw new UnsupportedOperationException("OFExperimenterErrorMsg not supported in version 1.1");
+    }
+
+    public OFRoleRequestFailedErrorMsg.Builder buildRoleRequestFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFRoleRequestFailedErrorMsg not supported in version 1.1");
+    }
+
+    public OFMeterModFailedErrorMsg.Builder buildMeterModFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFMeterModFailedErrorMsg not supported in version 1.1");
+    }
+
+    public OFTableFeaturesFailedErrorMsg.Builder buildTableFeaturesFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFTableFeaturesFailedErrorMsg not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFErrorMsg> getReader() {
+        return OFErrorMsgVer11.READER;
+    }
+
+    public long nextXid() {
+        return xidGenerator.nextXid();
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorTypeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorTypeSerializerVer11.java
new file mode 100644
index 0000000..f5f4aa6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFErrorTypeSerializerVer11.java
@@ -0,0 +1,119 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFErrorType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFErrorTypeSerializerVer11 {
+
+    public final static short HELLO_FAILED_VAL = (short) 0x0;
+    public final static short BAD_REQUEST_VAL = (short) 0x1;
+    public final static short BAD_ACTION_VAL = (short) 0x2;
+    public final static short BAD_INSTRUCTION_VAL = (short) 0x3;
+    public final static short BAD_MATCH_VAL = (short) 0x4;
+    public final static short FLOW_MOD_FAILED_VAL = (short) 0x5;
+    public final static short GROUP_MOD_FAILED_VAL = (short) 0x6;
+    public final static short PORT_MOD_FAILED_VAL = (short) 0x7;
+    public final static short TABLE_MOD_FAILED_VAL = (short) 0x8;
+    public final static short QUEUE_OP_FAILED_VAL = (short) 0x9;
+    public final static short SWITCH_CONFIG_FAILED_VAL = (short) 0xa;
+
+    public static OFErrorType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFErrorType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFErrorType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFErrorType ofWireValue(short val) {
+        switch(val) {
+            case HELLO_FAILED_VAL:
+                return OFErrorType.HELLO_FAILED;
+            case BAD_REQUEST_VAL:
+                return OFErrorType.BAD_REQUEST;
+            case BAD_ACTION_VAL:
+                return OFErrorType.BAD_ACTION;
+            case BAD_INSTRUCTION_VAL:
+                return OFErrorType.BAD_INSTRUCTION;
+            case BAD_MATCH_VAL:
+                return OFErrorType.BAD_MATCH;
+            case FLOW_MOD_FAILED_VAL:
+                return OFErrorType.FLOW_MOD_FAILED;
+            case GROUP_MOD_FAILED_VAL:
+                return OFErrorType.GROUP_MOD_FAILED;
+            case PORT_MOD_FAILED_VAL:
+                return OFErrorType.PORT_MOD_FAILED;
+            case TABLE_MOD_FAILED_VAL:
+                return OFErrorType.TABLE_MOD_FAILED;
+            case QUEUE_OP_FAILED_VAL:
+                return OFErrorType.QUEUE_OP_FAILED;
+            case SWITCH_CONFIG_FAILED_VAL:
+                return OFErrorType.SWITCH_CONFIG_FAILED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFErrorType in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFErrorType e) {
+        switch(e) {
+            case HELLO_FAILED:
+                return HELLO_FAILED_VAL;
+            case BAD_REQUEST:
+                return BAD_REQUEST_VAL;
+            case BAD_ACTION:
+                return BAD_ACTION_VAL;
+            case BAD_INSTRUCTION:
+                return BAD_INSTRUCTION_VAL;
+            case BAD_MATCH:
+                return BAD_MATCH_VAL;
+            case FLOW_MOD_FAILED:
+                return FLOW_MOD_FAILED_VAL;
+            case GROUP_MOD_FAILED:
+                return GROUP_MOD_FAILED_VAL;
+            case PORT_MOD_FAILED:
+                return PORT_MOD_FAILED_VAL;
+            case TABLE_MOD_FAILED:
+                return TABLE_MOD_FAILED_VAL;
+            case QUEUE_OP_FAILED:
+                return QUEUE_OP_FAILED_VAL;
+            case SWITCH_CONFIG_FAILED:
+                return SWITCH_CONFIG_FAILED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFErrorType in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterStatsReplyVer11.java
new file mode 100644
index 0000000..8036774
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterStatsReplyVer11.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterStatsReplyVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFExperimenterStatsReplyVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenterStatsReply> {
+        @Override
+        public OFExperimenterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsReplyVer11
+                   return OFBsnStatsReplyVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterStatsReplyVer11: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterStatsRequestVer11.java
new file mode 100644
index 0000000..95f8f96
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterStatsRequestVer11.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterStatsRequestVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFExperimenterStatsRequestVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenterStatsRequest<?>> {
+        @Override
+        public OFExperimenterStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsRequestVer11
+                   return OFBsnStatsRequestVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterStatsRequestVer11: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterVer11.java
new file mode 100644
index 0000000..b6fdc6c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFExperimenterVer11.java
@@ -0,0 +1,68 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+
+    public final static OFExperimenterVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenter> {
+        @Override
+        public OFExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnHeaderVer11
+                   return OFBsnHeaderVer11.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFNiciraHeaderVer11
+                   return OFNiciraHeaderVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterVer11: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFactoryVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFactoryVer11.java
new file mode 100644
index 0000000..4494b6a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFactoryVer11.java
@@ -0,0 +1,1232 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.projectfloodlight.openflow.protocol.OFOxmList;
+
+
+public class OFFactoryVer11 implements OFFactory {
+    public final static OFFactoryVer11 INSTANCE = new OFFactoryVer11();
+
+    private final XidGenerator xidGenerator = XidGenerators.global();
+
+    public OFActions actions() {
+        return OFActionsVer11.INSTANCE;
+    }
+    public OFInstructions instructions() {
+        return OFInstructionsVer11.INSTANCE;
+    }
+    public OFMeterBands meterBands() {
+        return OFMeterBandsVer11.INSTANCE;
+    }
+    public OFOxms oxms() {
+        return OFOxmsVer11.INSTANCE;
+    }
+    public OFQueueProps queueProps() {
+        return OFQueuePropsVer11.INSTANCE;
+    }
+    public OFErrorMsgs errorMsgs() {
+        return OFErrorMsgsVer11.INSTANCE;
+    }
+    public OFActionIds actionIds() {
+        return OFActionIdsVer11.INSTANCE;
+    }
+    public OFInstructionIds instructionIds() {
+        return OFInstructionIdsVer11.INSTANCE;
+    }
+    public OFBsnTlvs bsnTlvs() {
+        return OFBsnTlvsVer11.INSTANCE;
+    }
+
+
+    public OFAggregateStatsReply.Builder buildAggregateStatsReply() {
+        return new OFAggregateStatsReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFAggregateStatsRequest.Builder buildAggregateStatsRequest() {
+        return new OFAggregateStatsRequestVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBarrierReply.Builder buildBarrierReply() {
+        return new OFBarrierReplyVer11.Builder().setXid(nextXid());
+    }
+    public OFBarrierReply barrierReply() {
+        return new OFBarrierReplyVer11(
+                nextXid()
+                    );
+    }
+
+    public OFBarrierRequest.Builder buildBarrierRequest() {
+        return new OFBarrierRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFBarrierRequest barrierRequest() {
+        return new OFBarrierRequestVer11(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwClearDataReply.Builder buildBsnBwClearDataReply() {
+        return new OFBsnBwClearDataReplyVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnBwClearDataReply bsnBwClearDataReply(long status) {
+        return new OFBsnBwClearDataReplyVer11(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnBwClearDataRequest.Builder buildBsnBwClearDataRequest() {
+        return new OFBsnBwClearDataRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnBwClearDataRequest bsnBwClearDataRequest() {
+        return new OFBsnBwClearDataRequestVer11(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwEnableGetReply.Builder buildBsnBwEnableGetReply() {
+        return new OFBsnBwEnableGetReplyVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableGetReply bsnBwEnableGetReply(long enabled) {
+        return new OFBsnBwEnableGetReplyVer11(
+                nextXid(),
+                      enabled
+                    );
+    }
+
+    public OFBsnBwEnableGetRequest.Builder buildBsnBwEnableGetRequest() {
+        return new OFBsnBwEnableGetRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableGetRequest bsnBwEnableGetRequest() {
+        return new OFBsnBwEnableGetRequestVer11(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwEnableSetReply.Builder buildBsnBwEnableSetReply() {
+        return new OFBsnBwEnableSetReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBsnBwEnableSetRequest.Builder buildBsnBwEnableSetRequest() {
+        return new OFBsnBwEnableSetRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableSetRequest bsnBwEnableSetRequest(long enable) {
+        return new OFBsnBwEnableSetRequestVer11(
+                nextXid(),
+                      enable
+                    );
+    }
+
+    public OFBsnGetInterfacesReply.Builder buildBsnGetInterfacesReply() {
+        return new OFBsnGetInterfacesReplyVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnGetInterfacesReply bsnGetInterfacesReply(List<OFBsnInterface> interfaces) {
+        return new OFBsnGetInterfacesReplyVer11(
+                nextXid(),
+                      interfaces
+                    );
+    }
+
+    public OFBsnGetInterfacesRequest.Builder buildBsnGetInterfacesRequest() {
+        return new OFBsnGetInterfacesRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnGetInterfacesRequest bsnGetInterfacesRequest() {
+        return new OFBsnGetInterfacesRequestVer11(
+                nextXid()
+                    );
+    }
+
+    public OFBsnGetIpMaskReply.Builder buildBsnGetIpMaskReply() {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskReply not supported in version 1.1");
+    }
+
+    public OFBsnGetIpMaskRequest.Builder buildBsnGetIpMaskRequest() {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskRequest not supported in version 1.1");
+    }
+    public OFBsnGetIpMaskRequest bsnGetIpMaskRequest(short index) {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskRequest not supported in version 1.1");
+    }
+
+    public OFBsnGetL2TableReply.Builder buildBsnGetL2TableReply() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableReply not supported in version 1.1");
+    }
+
+    public OFBsnGetL2TableRequest.Builder buildBsnGetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableRequest not supported in version 1.1");
+    }
+    public OFBsnGetL2TableRequest bsnGetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableRequest not supported in version 1.1");
+    }
+
+    public OFBsnGetMirroringReply.Builder buildBsnGetMirroringReply() {
+        return new OFBsnGetMirroringReplyVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnGetMirroringReply bsnGetMirroringReply(short reportMirrorPorts) {
+        return new OFBsnGetMirroringReplyVer11(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnGetMirroringRequest.Builder buildBsnGetMirroringRequest() {
+        return new OFBsnGetMirroringRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnGetMirroringRequest bsnGetMirroringRequest(short reportMirrorPorts) {
+        return new OFBsnGetMirroringRequestVer11(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnHybridGetReply.Builder buildBsnHybridGetReply() {
+        throw new UnsupportedOperationException("OFBsnHybridGetReply not supported in version 1.1");
+    }
+
+    public OFBsnHybridGetRequest.Builder buildBsnHybridGetRequest() {
+        throw new UnsupportedOperationException("OFBsnHybridGetRequest not supported in version 1.1");
+    }
+    public OFBsnHybridGetRequest bsnHybridGetRequest() {
+        throw new UnsupportedOperationException("OFBsnHybridGetRequest not supported in version 1.1");
+    }
+
+    public OFBsnInterface.Builder buildBsnInterface() {
+        return new OFBsnInterfaceVer11.Builder();
+    }
+
+    public OFBsnPduRxReply.Builder buildBsnPduRxReply() {
+        return new OFBsnPduRxReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduRxRequest.Builder buildBsnPduRxRequest() {
+        return new OFBsnPduRxRequestVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduRxTimeout.Builder buildBsnPduRxTimeout() {
+        return new OFBsnPduRxTimeoutVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduTxReply.Builder buildBsnPduTxReply() {
+        return new OFBsnPduTxReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduTxRequest.Builder buildBsnPduTxRequest() {
+        return new OFBsnPduTxRequestVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetIpMask.Builder buildBsnSetIpMask() {
+        throw new UnsupportedOperationException("OFBsnSetIpMask not supported in version 1.1");
+    }
+
+    public OFBsnSetL2TableReply.Builder buildBsnSetL2TableReply() {
+        throw new UnsupportedOperationException("OFBsnSetL2TableReply not supported in version 1.1");
+    }
+
+    public OFBsnSetL2TableRequest.Builder buildBsnSetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnSetL2TableRequest not supported in version 1.1");
+    }
+
+    public OFBsnSetMirroring.Builder buildBsnSetMirroring() {
+        return new OFBsnSetMirroringVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnSetMirroring bsnSetMirroring(short reportMirrorPorts) {
+        return new OFBsnSetMirroringVer11(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnSetPktinSuppressionReply.Builder buildBsnSetPktinSuppressionReply() {
+        return new OFBsnSetPktinSuppressionReplyVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnSetPktinSuppressionReply bsnSetPktinSuppressionReply(long status) {
+        return new OFBsnSetPktinSuppressionReplyVer11(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnSetPktinSuppressionRequest.Builder buildBsnSetPktinSuppressionRequest() {
+        return new OFBsnSetPktinSuppressionRequestVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBsnShellCommand.Builder buildBsnShellCommand() {
+        throw new UnsupportedOperationException("OFBsnShellCommand not supported in version 1.1");
+    }
+
+    public OFBsnShellOutput.Builder buildBsnShellOutput() {
+        throw new UnsupportedOperationException("OFBsnShellOutput not supported in version 1.1");
+    }
+    public OFBsnShellOutput bsnShellOutput(byte[] data) {
+        throw new UnsupportedOperationException("OFBsnShellOutput not supported in version 1.1");
+    }
+
+    public OFBsnShellStatus.Builder buildBsnShellStatus() {
+        throw new UnsupportedOperationException("OFBsnShellStatus not supported in version 1.1");
+    }
+    public OFBsnShellStatus bsnShellStatus(long status) {
+        throw new UnsupportedOperationException("OFBsnShellStatus not supported in version 1.1");
+    }
+
+    public OFBsnVirtualPortCreateReply.Builder buildBsnVirtualPortCreateReply() {
+        return new OFBsnVirtualPortCreateReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFBsnVirtualPortCreateRequest.Builder buildBsnVirtualPortCreateRequest() {
+        return new OFBsnVirtualPortCreateRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest(OFBsnVport vport) {
+        return new OFBsnVirtualPortCreateRequestVer11(
+                nextXid(),
+                      vport
+                    );
+    }
+
+    public OFBsnVirtualPortRemoveReply.Builder buildBsnVirtualPortRemoveReply() {
+        return new OFBsnVirtualPortRemoveReplyVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortRemoveReply bsnVirtualPortRemoveReply(long status) {
+        return new OFBsnVirtualPortRemoveReplyVer11(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnVirtualPortRemoveRequest.Builder buildBsnVirtualPortRemoveRequest() {
+        return new OFBsnVirtualPortRemoveRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortRemoveRequest bsnVirtualPortRemoveRequest(long vportNo) {
+        return new OFBsnVirtualPortRemoveRequestVer11(
+                nextXid(),
+                      vportNo
+                    );
+    }
+
+    public OFBsnVportL2Gre.Builder buildBsnVportL2Gre() {
+        return new OFBsnVportL2GreVer11.Builder();
+    }
+
+    public OFBsnVportQInQ.Builder buildBsnVportQInQ() {
+        return new OFBsnVportQInQVer11.Builder();
+    }
+
+    public OFDescStatsReply.Builder buildDescStatsReply() {
+        return new OFDescStatsReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFDescStatsRequest.Builder buildDescStatsRequest() {
+        return new OFDescStatsRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFDescStatsRequest descStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFDescStatsRequestVer11(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFEchoReply.Builder buildEchoReply() {
+        return new OFEchoReplyVer11.Builder().setXid(nextXid());
+    }
+    public OFEchoReply echoReply(byte[] data) {
+        return new OFEchoReplyVer11(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFEchoRequest.Builder buildEchoRequest() {
+        return new OFEchoRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFEchoRequest echoRequest(byte[] data) {
+        return new OFEchoRequestVer11(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFFeaturesReply.Builder buildFeaturesReply() {
+        return new OFFeaturesReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFeaturesRequest.Builder buildFeaturesRequest() {
+        return new OFFeaturesRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFFeaturesRequest featuresRequest() {
+        return new OFFeaturesRequestVer11(
+                nextXid()
+                    );
+    }
+
+    public OFFlowAdd.Builder buildFlowAdd() {
+        return new OFFlowAddVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFlowDelete.Builder buildFlowDelete() {
+        return new OFFlowDeleteVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFlowDeleteStrict.Builder buildFlowDeleteStrict() {
+        return new OFFlowDeleteStrictVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModify.Builder buildFlowModify() {
+        return new OFFlowModifyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModifyStrict.Builder buildFlowModifyStrict() {
+        return new OFFlowModifyStrictVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFlowRemoved.Builder buildFlowRemoved() {
+        return new OFFlowRemovedVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFlowStatsEntry.Builder buildFlowStatsEntry() {
+        return new OFFlowStatsEntryVer11.Builder();
+    }
+
+    public OFFlowStatsReply.Builder buildFlowStatsReply() {
+        return new OFFlowStatsReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFFlowStatsRequest.Builder buildFlowStatsRequest() {
+        return new OFFlowStatsRequestVer11.Builder().setXid(nextXid());
+    }
+
+    public OFGetConfigReply.Builder buildGetConfigReply() {
+        return new OFGetConfigReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFGetConfigRequest.Builder buildGetConfigRequest() {
+        return new OFGetConfigRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFGetConfigRequest getConfigRequest() {
+        return new OFGetConfigRequestVer11(
+                nextXid()
+                    );
+    }
+
+    public OFHello.Builder buildHello() {
+        return new OFHelloVer11.Builder().setXid(nextXid());
+    }
+    public OFHello hello(List<OFHelloElem> elements) {
+        return new OFHelloVer11(
+                nextXid()
+                    );
+    }
+
+    public OFMatchV1.Builder buildMatchV1() {
+        throw new UnsupportedOperationException("OFMatchV1 not supported in version 1.1");
+    }
+
+    public OFNiciraControllerRoleReply.Builder buildNiciraControllerRoleReply() {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleReply not supported in version 1.1");
+    }
+    public OFNiciraControllerRoleReply niciraControllerRoleReply(OFNiciraControllerRole role) {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleReply not supported in version 1.1");
+    }
+
+    public OFNiciraControllerRoleRequest.Builder buildNiciraControllerRoleRequest() {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleRequest not supported in version 1.1");
+    }
+    public OFNiciraControllerRoleRequest niciraControllerRoleRequest(OFNiciraControllerRole role) {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleRequest not supported in version 1.1");
+    }
+
+    public OFPacketIn.Builder buildPacketIn() {
+        return new OFPacketInVer11.Builder().setXid(nextXid());
+    }
+
+    public OFPacketOut.Builder buildPacketOut() {
+        return new OFPacketOutVer11.Builder().setXid(nextXid());
+    }
+
+    public OFPacketQueue.Builder buildPacketQueue() {
+        return new OFPacketQueueVer11.Builder();
+    }
+
+    public OFPortDesc.Builder buildPortDesc() {
+        return new OFPortDescVer11.Builder();
+    }
+
+    public OFPortMod.Builder buildPortMod() {
+        return new OFPortModVer11.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatsEntry.Builder buildPortStatsEntry() {
+        return new OFPortStatsEntryVer11.Builder();
+    }
+
+    public OFPortStatsReply.Builder buildPortStatsReply() {
+        return new OFPortStatsReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatsRequest.Builder buildPortStatsRequest() {
+        return new OFPortStatsRequestVer11.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatus.Builder buildPortStatus() {
+        return new OFPortStatusVer11.Builder().setXid(nextXid());
+    }
+
+    public OFQueueGetConfigReply.Builder buildQueueGetConfigReply() {
+        return new OFQueueGetConfigReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFQueueGetConfigRequest.Builder buildQueueGetConfigRequest() {
+        return new OFQueueGetConfigRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFQueueGetConfigRequest queueGetConfigRequest(OFPort port) {
+        return new OFQueueGetConfigRequestVer11(
+                nextXid(),
+                      port
+                    );
+    }
+
+    public OFQueueStatsEntry.Builder buildQueueStatsEntry() {
+        return new OFQueueStatsEntryVer11.Builder();
+    }
+
+    public OFQueueStatsReply.Builder buildQueueStatsReply() {
+        return new OFQueueStatsReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFQueueStatsRequest.Builder buildQueueStatsRequest() {
+        return new OFQueueStatsRequestVer11.Builder().setXid(nextXid());
+    }
+
+    public OFSetConfig.Builder buildSetConfig() {
+        return new OFSetConfigVer11.Builder().setXid(nextXid());
+    }
+
+    public OFTableMod.Builder buildTableMod() {
+        return new OFTableModVer11.Builder().setXid(nextXid());
+    }
+
+    public OFTableStatsEntry.Builder buildTableStatsEntry() {
+        return new OFTableStatsEntryVer11.Builder();
+    }
+
+    public OFTableStatsReply.Builder buildTableStatsReply() {
+        return new OFTableStatsReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFTableStatsRequest.Builder buildTableStatsRequest() {
+        return new OFTableStatsRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFTableStatsRequest tableStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFTableStatsRequestVer11(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBucket.Builder buildBucket() {
+        return new OFBucketVer11.Builder();
+    }
+
+    public OFBucketCounter.Builder buildBucketCounter() {
+        return new OFBucketCounterVer11.Builder();
+    }
+    public OFBucketCounter bucketCounter(U64 packetCount, U64 byteCount) {
+        return new OFBucketCounterVer11(
+                packetCount,
+                      byteCount
+                    );
+    }
+
+    public OFGroupAdd.Builder buildGroupAdd() {
+        return new OFGroupAddVer11.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDelete.Builder buildGroupDelete() {
+        return new OFGroupDeleteVer11.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDescStatsEntry.Builder buildGroupDescStatsEntry() {
+        return new OFGroupDescStatsEntryVer11.Builder();
+    }
+
+    public OFGroupDescStatsReply.Builder buildGroupDescStatsReply() {
+        return new OFGroupDescStatsReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDescStatsRequest.Builder buildGroupDescStatsRequest() {
+        return new OFGroupDescStatsRequestVer11.Builder().setXid(nextXid());
+    }
+    public OFGroupDescStatsRequest groupDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFGroupDescStatsRequestVer11(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFGroupModify.Builder buildGroupModify() {
+        return new OFGroupModifyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFGroupStatsEntry.Builder buildGroupStatsEntry() {
+        return new OFGroupStatsEntryVer11.Builder();
+    }
+
+    public OFGroupStatsReply.Builder buildGroupStatsReply() {
+        return new OFGroupStatsReplyVer11.Builder().setXid(nextXid());
+    }
+
+    public OFGroupStatsRequest.Builder buildGroupStatsRequest() {
+        return new OFGroupStatsRequestVer11.Builder().setXid(nextXid());
+    }
+
+    public OFMatchV2.Builder buildMatchV2() {
+        return new OFMatchV2Ver11.Builder();
+    }
+    public Match.Builder buildMatch() {
+        return new OFMatchV2Ver11.Builder();
+    }
+
+    final static Match MATCH_WILDCARD_ALL = OFMatchV2Ver11.DEFAULT;
+
+    public Match matchWildcardAll() {
+        return MATCH_WILDCARD_ALL;
+    }
+
+    public OFGroupFeaturesStatsReply.Builder buildGroupFeaturesStatsReply() {
+        throw new UnsupportedOperationException("OFGroupFeaturesStatsReply not supported in version 1.1");
+    }
+
+    public OFGroupFeaturesStatsRequest.Builder buildGroupFeaturesStatsRequest() {
+        throw new UnsupportedOperationException("OFGroupFeaturesStatsRequest not supported in version 1.1");
+    }
+    public OFGroupFeaturesStatsRequest groupFeaturesStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFGroupFeaturesStatsRequest not supported in version 1.1");
+    }
+
+    public OFMatchV3.Builder buildMatchV3() {
+        throw new UnsupportedOperationException("OFMatchV3 not supported in version 1.1");
+    }
+    public OFMatchV3 matchV3(OFOxmList oxmList) {
+        throw new UnsupportedOperationException("OFMatchV3 not supported in version 1.1");
+    }
+
+    public OFRoleReply.Builder buildRoleReply() {
+        throw new UnsupportedOperationException("OFRoleReply not supported in version 1.1");
+    }
+
+    public OFRoleRequest.Builder buildRoleRequest() {
+        throw new UnsupportedOperationException("OFRoleRequest not supported in version 1.1");
+    }
+
+    public OFAsyncGetReply.Builder buildAsyncGetReply() {
+        throw new UnsupportedOperationException("OFAsyncGetReply not supported in version 1.1");
+    }
+
+    public OFAsyncGetRequest.Builder buildAsyncGetRequest() {
+        throw new UnsupportedOperationException("OFAsyncGetRequest not supported in version 1.1");
+    }
+
+    public OFAsyncSet.Builder buildAsyncSet() {
+        throw new UnsupportedOperationException("OFAsyncSet not supported in version 1.1");
+    }
+
+    public OFBsnArpIdle.Builder buildBsnArpIdle() {
+        throw new UnsupportedOperationException("OFBsnArpIdle not supported in version 1.1");
+    }
+
+    public OFBsnControllerConnection.Builder buildBsnControllerConnection() {
+        throw new UnsupportedOperationException("OFBsnControllerConnection not supported in version 1.1");
+    }
+
+    public OFBsnControllerConnectionsReply.Builder buildBsnControllerConnectionsReply() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsReply not supported in version 1.1");
+    }
+    public OFBsnControllerConnectionsReply bsnControllerConnectionsReply(List<OFBsnControllerConnection> connections) {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsReply not supported in version 1.1");
+    }
+
+    public OFBsnControllerConnectionsRequest.Builder buildBsnControllerConnectionsRequest() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsRequest not supported in version 1.1");
+    }
+    public OFBsnControllerConnectionsRequest bsnControllerConnectionsRequest() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsRequest not supported in version 1.1");
+    }
+
+    public OFBsnDebugCounterDescStatsEntry.Builder buildBsnDebugCounterDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnDebugCounterDescStatsReply.Builder buildBsnDebugCounterDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnDebugCounterDescStatsRequest.Builder buildBsnDebugCounterDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsRequest not supported in version 1.1");
+    }
+    public OFBsnDebugCounterDescStatsRequest bsnDebugCounterDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnDebugCounterStatsEntry.Builder buildBsnDebugCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsEntry not supported in version 1.1");
+    }
+    public OFBsnDebugCounterStatsEntry bsnDebugCounterStatsEntry(U64 counterId, U64 value) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnDebugCounterStatsReply.Builder buildBsnDebugCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnDebugCounterStatsRequest.Builder buildBsnDebugCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsRequest not supported in version 1.1");
+    }
+    public OFBsnDebugCounterStatsRequest bsnDebugCounterStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnFlowChecksumBucketStatsEntry.Builder buildBsnFlowChecksumBucketStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsEntry not supported in version 1.1");
+    }
+    public OFBsnFlowChecksumBucketStatsEntry bsnFlowChecksumBucketStatsEntry(U64 checksum) {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnFlowChecksumBucketStatsReply.Builder buildBsnFlowChecksumBucketStatsReply() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnFlowChecksumBucketStatsRequest.Builder buildBsnFlowChecksumBucketStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnFlowIdle.Builder buildBsnFlowIdle() {
+        throw new UnsupportedOperationException("OFBsnFlowIdle not supported in version 1.1");
+    }
+
+    public OFBsnFlowIdleEnableGetReply.Builder buildBsnFlowIdleEnableGetReply() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetReply not supported in version 1.1");
+    }
+    public OFBsnFlowIdleEnableGetReply bsnFlowIdleEnableGetReply(long enabled) {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetReply not supported in version 1.1");
+    }
+
+    public OFBsnFlowIdleEnableGetRequest.Builder buildBsnFlowIdleEnableGetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetRequest not supported in version 1.1");
+    }
+    public OFBsnFlowIdleEnableGetRequest bsnFlowIdleEnableGetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetRequest not supported in version 1.1");
+    }
+
+    public OFBsnFlowIdleEnableSetReply.Builder buildBsnFlowIdleEnableSetReply() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetReply not supported in version 1.1");
+    }
+
+    public OFBsnFlowIdleEnableSetRequest.Builder buildBsnFlowIdleEnableSetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetRequest not supported in version 1.1");
+    }
+    public OFBsnFlowIdleEnableSetRequest bsnFlowIdleEnableSetRequest(long enable) {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetRequest not supported in version 1.1");
+    }
+
+    public OFBsnGentableBucketStatsEntry.Builder buildBsnGentableBucketStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsEntry not supported in version 1.1");
+    }
+    public OFBsnGentableBucketStatsEntry bsnGentableBucketStatsEntry(U128 checksum) {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnGentableBucketStatsReply.Builder buildBsnGentableBucketStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnGentableBucketStatsRequest.Builder buildBsnGentableBucketStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnGentableClearReply.Builder buildBsnGentableClearReply() {
+        throw new UnsupportedOperationException("OFBsnGentableClearReply not supported in version 1.1");
+    }
+
+    public OFBsnGentableClearRequest.Builder buildBsnGentableClearRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableClearRequest not supported in version 1.1");
+    }
+
+    public OFBsnGentableDescStatsEntry.Builder buildBsnGentableDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnGentableDescStatsReply.Builder buildBsnGentableDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnGentableDescStatsRequest.Builder buildBsnGentableDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsRequest not supported in version 1.1");
+    }
+    public OFBsnGentableDescStatsRequest bsnGentableDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnGentableEntryAdd.Builder buildBsnGentableEntryAdd() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryAdd not supported in version 1.1");
+    }
+
+    public OFBsnGentableEntryDelete.Builder buildBsnGentableEntryDelete() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDelete not supported in version 1.1");
+    }
+
+    public OFBsnGentableEntryDescStatsEntry.Builder buildBsnGentableEntryDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnGentableEntryDescStatsReply.Builder buildBsnGentableEntryDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnGentableEntryDescStatsRequest.Builder buildBsnGentableEntryDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnGentableEntryStatsEntry.Builder buildBsnGentableEntryStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsEntry not supported in version 1.1");
+    }
+    public OFBsnGentableEntryStatsEntry bsnGentableEntryStatsEntry(List<OFBsnTlv> key, List<OFBsnTlv> stats) {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnGentableEntryStatsReply.Builder buildBsnGentableEntryStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnGentableEntryStatsRequest.Builder buildBsnGentableEntryStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnGentableSetBucketsSize.Builder buildBsnGentableSetBucketsSize() {
+        throw new UnsupportedOperationException("OFBsnGentableSetBucketsSize not supported in version 1.1");
+    }
+
+    public OFBsnGentableStatsEntry.Builder buildBsnGentableStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnGentableStatsReply.Builder buildBsnGentableStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnGentableStatsRequest.Builder buildBsnGentableStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsRequest not supported in version 1.1");
+    }
+    public OFBsnGentableStatsRequest bsnGentableStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnGentableStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnGetSwitchPipelineReply.Builder buildBsnGetSwitchPipelineReply() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineReply not supported in version 1.1");
+    }
+    public OFBsnGetSwitchPipelineReply bsnGetSwitchPipelineReply(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineReply not supported in version 1.1");
+    }
+
+    public OFBsnGetSwitchPipelineRequest.Builder buildBsnGetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineRequest not supported in version 1.1");
+    }
+    public OFBsnGetSwitchPipelineRequest bsnGetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineRequest not supported in version 1.1");
+    }
+
+    public OFBsnImageDescStatsReply.Builder buildBsnImageDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnImageDescStatsRequest.Builder buildBsnImageDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsRequest not supported in version 1.1");
+    }
+    public OFBsnImageDescStatsRequest bsnImageDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnLacpConvergenceNotif.Builder buildBsnLacpConvergenceNotif() {
+        throw new UnsupportedOperationException("OFBsnLacpConvergenceNotif not supported in version 1.1");
+    }
+
+    public OFBsnLacpStatsEntry.Builder buildBsnLacpStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnLacpStatsReply.Builder buildBsnLacpStatsReply() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnLacpStatsRequest.Builder buildBsnLacpStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsRequest not supported in version 1.1");
+    }
+    public OFBsnLacpStatsRequest bsnLacpStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnLacpStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnLog.Builder buildBsnLog() {
+        throw new UnsupportedOperationException("OFBsnLog not supported in version 1.1");
+    }
+
+    public OFBsnPortCounterStatsEntry.Builder buildBsnPortCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsEntry not supported in version 1.1");
+    }
+    public OFBsnPortCounterStatsEntry bsnPortCounterStatsEntry(OFPort portNo, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnPortCounterStatsReply.Builder buildBsnPortCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnPortCounterStatsRequest.Builder buildBsnPortCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnRoleStatus.Builder buildBsnRoleStatus() {
+        throw new UnsupportedOperationException("OFBsnRoleStatus not supported in version 1.1");
+    }
+
+    public OFBsnSetAuxCxnsReply.Builder buildBsnSetAuxCxnsReply() {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsReply not supported in version 1.1");
+    }
+
+    public OFBsnSetAuxCxnsRequest.Builder buildBsnSetAuxCxnsRequest() {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsRequest not supported in version 1.1");
+    }
+    public OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest(long numAux) {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsRequest not supported in version 1.1");
+    }
+
+    public OFBsnSetLacpReply.Builder buildBsnSetLacpReply() {
+        throw new UnsupportedOperationException("OFBsnSetLacpReply not supported in version 1.1");
+    }
+
+    public OFBsnSetLacpRequest.Builder buildBsnSetLacpRequest() {
+        throw new UnsupportedOperationException("OFBsnSetLacpRequest not supported in version 1.1");
+    }
+
+    public OFBsnSetSwitchPipelineReply.Builder buildBsnSetSwitchPipelineReply() {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineReply not supported in version 1.1");
+    }
+    public OFBsnSetSwitchPipelineReply bsnSetSwitchPipelineReply(long status) {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineReply not supported in version 1.1");
+    }
+
+    public OFBsnSetSwitchPipelineRequest.Builder buildBsnSetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineRequest not supported in version 1.1");
+    }
+    public OFBsnSetSwitchPipelineRequest bsnSetSwitchPipelineRequest(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineRequest not supported in version 1.1");
+    }
+
+    public OFBsnSwitchPipelineStatsEntry.Builder buildBsnSwitchPipelineStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsEntry not supported in version 1.1");
+    }
+    public OFBsnSwitchPipelineStatsEntry bsnSwitchPipelineStatsEntry(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnSwitchPipelineStatsReply.Builder buildBsnSwitchPipelineStatsReply() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnSwitchPipelineStatsRequest.Builder buildBsnSwitchPipelineStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsRequest not supported in version 1.1");
+    }
+    public OFBsnSwitchPipelineStatsRequest bsnSwitchPipelineStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnTableChecksumStatsEntry.Builder buildBsnTableChecksumStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsEntry not supported in version 1.1");
+    }
+    public OFBsnTableChecksumStatsEntry bsnTableChecksumStatsEntry(TableId tableId, U64 checksum) {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnTableChecksumStatsReply.Builder buildBsnTableChecksumStatsReply() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnTableChecksumStatsRequest.Builder buildBsnTableChecksumStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsRequest not supported in version 1.1");
+    }
+    public OFBsnTableChecksumStatsRequest bsnTableChecksumStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnTableSetBucketsSize.Builder buildBsnTableSetBucketsSize() {
+        throw new UnsupportedOperationException("OFBsnTableSetBucketsSize not supported in version 1.1");
+    }
+
+    public OFBsnTimeReply.Builder buildBsnTimeReply() {
+        throw new UnsupportedOperationException("OFBsnTimeReply not supported in version 1.1");
+    }
+    public OFBsnTimeReply bsnTimeReply(U64 timeMs) {
+        throw new UnsupportedOperationException("OFBsnTimeReply not supported in version 1.1");
+    }
+
+    public OFBsnTimeRequest.Builder buildBsnTimeRequest() {
+        throw new UnsupportedOperationException("OFBsnTimeRequest not supported in version 1.1");
+    }
+    public OFBsnTimeRequest bsnTimeRequest() {
+        throw new UnsupportedOperationException("OFBsnTimeRequest not supported in version 1.1");
+    }
+
+    public OFBsnVlanCounterStatsEntry.Builder buildBsnVlanCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsEntry not supported in version 1.1");
+    }
+    public OFBsnVlanCounterStatsEntry bsnVlanCounterStatsEntry(int vlanVid, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnVlanCounterStatsReply.Builder buildBsnVlanCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnVlanCounterStatsRequest.Builder buildBsnVlanCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsRequest not supported in version 1.1");
+    }
+
+    public OFBsnVrfCounterStatsEntry.Builder buildBsnVrfCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsEntry not supported in version 1.1");
+    }
+    public OFBsnVrfCounterStatsEntry bsnVrfCounterStatsEntry(long vrf, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsEntry not supported in version 1.1");
+    }
+
+    public OFBsnVrfCounterStatsReply.Builder buildBsnVrfCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsReply not supported in version 1.1");
+    }
+
+    public OFBsnVrfCounterStatsRequest.Builder buildBsnVrfCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsRequest not supported in version 1.1");
+    }
+
+    public OFHelloElemVersionbitmap.Builder buildHelloElemVersionbitmap() {
+        throw new UnsupportedOperationException("OFHelloElemVersionbitmap not supported in version 1.1");
+    }
+    public OFHelloElemVersionbitmap helloElemVersionbitmap(List<U32> bitmaps) {
+        throw new UnsupportedOperationException("OFHelloElemVersionbitmap not supported in version 1.1");
+    }
+
+    public OFMeterBandStats.Builder buildMeterBandStats() {
+        throw new UnsupportedOperationException("OFMeterBandStats not supported in version 1.1");
+    }
+    public OFMeterBandStats meterBandStats(U64 packetBandCount, U64 byteBandCount) {
+        throw new UnsupportedOperationException("OFMeterBandStats not supported in version 1.1");
+    }
+
+    public OFMeterConfig.Builder buildMeterConfig() {
+        throw new UnsupportedOperationException("OFMeterConfig not supported in version 1.1");
+    }
+
+    public OFMeterConfigStatsReply.Builder buildMeterConfigStatsReply() {
+        throw new UnsupportedOperationException("OFMeterConfigStatsReply not supported in version 1.1");
+    }
+
+    public OFMeterConfigStatsRequest.Builder buildMeterConfigStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterConfigStatsRequest not supported in version 1.1");
+    }
+
+    public OFMeterFeatures.Builder buildMeterFeatures() {
+        throw new UnsupportedOperationException("OFMeterFeatures not supported in version 1.1");
+    }
+
+    public OFMeterFeaturesStatsReply.Builder buildMeterFeaturesStatsReply() {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsReply not supported in version 1.1");
+    }
+
+    public OFMeterFeaturesStatsRequest.Builder buildMeterFeaturesStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsRequest not supported in version 1.1");
+    }
+    public OFMeterFeaturesStatsRequest meterFeaturesStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsRequest not supported in version 1.1");
+    }
+
+    public OFMeterMod.Builder buildMeterMod() {
+        throw new UnsupportedOperationException("OFMeterMod not supported in version 1.1");
+    }
+
+    public OFMeterStats.Builder buildMeterStats() {
+        throw new UnsupportedOperationException("OFMeterStats not supported in version 1.1");
+    }
+
+    public OFMeterStatsReply.Builder buildMeterStatsReply() {
+        throw new UnsupportedOperationException("OFMeterStatsReply not supported in version 1.1");
+    }
+
+    public OFMeterStatsRequest.Builder buildMeterStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterStatsRequest not supported in version 1.1");
+    }
+
+    public OFPortDescStatsReply.Builder buildPortDescStatsReply() {
+        throw new UnsupportedOperationException("OFPortDescStatsReply not supported in version 1.1");
+    }
+
+    public OFPortDescStatsRequest.Builder buildPortDescStatsRequest() {
+        throw new UnsupportedOperationException("OFPortDescStatsRequest not supported in version 1.1");
+    }
+    public OFPortDescStatsRequest portDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFPortDescStatsRequest not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropApplyActions.Builder buildTableFeaturePropApplyActions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActions not supported in version 1.1");
+    }
+    public OFTableFeaturePropApplyActions tableFeaturePropApplyActions(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActions not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropApplyActionsMiss.Builder buildTableFeaturePropApplyActionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActionsMiss not supported in version 1.1");
+    }
+    public OFTableFeaturePropApplyActionsMiss tableFeaturePropApplyActionsMiss(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActionsMiss not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropApplySetfield.Builder buildTableFeaturePropApplySetfield() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfield not supported in version 1.1");
+    }
+    public OFTableFeaturePropApplySetfield tableFeaturePropApplySetfield(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfield not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropApplySetfieldMiss.Builder buildTableFeaturePropApplySetfieldMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfieldMiss not supported in version 1.1");
+    }
+    public OFTableFeaturePropApplySetfieldMiss tableFeaturePropApplySetfieldMiss(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfieldMiss not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropExperimenter.Builder buildTableFeaturePropExperimenter() {
+        throw new UnsupportedOperationException("OFTableFeaturePropExperimenter not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropExperimenterMiss.Builder buildTableFeaturePropExperimenterMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropExperimenterMiss not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropInstructions.Builder buildTableFeaturePropInstructions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructions not supported in version 1.1");
+    }
+    public OFTableFeaturePropInstructions tableFeaturePropInstructions(List<OFInstructionId> instructionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructions not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropInstructionsMiss.Builder buildTableFeaturePropInstructionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructionsMiss not supported in version 1.1");
+    }
+    public OFTableFeaturePropInstructionsMiss tableFeaturePropInstructionsMiss(List<OFInstructionId> instructionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructionsMiss not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropMatch.Builder buildTableFeaturePropMatch() {
+        throw new UnsupportedOperationException("OFTableFeaturePropMatch not supported in version 1.1");
+    }
+    public OFTableFeaturePropMatch tableFeaturePropMatch(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropMatch not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropNextTables.Builder buildTableFeaturePropNextTables() {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTables not supported in version 1.1");
+    }
+    public OFTableFeaturePropNextTables tableFeaturePropNextTables(List<U8> nextTableIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTables not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropNextTablesMiss.Builder buildTableFeaturePropNextTablesMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTablesMiss not supported in version 1.1");
+    }
+    public OFTableFeaturePropNextTablesMiss tableFeaturePropNextTablesMiss(List<U8> nextTableIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTablesMiss not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropWildcards.Builder buildTableFeaturePropWildcards() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWildcards not supported in version 1.1");
+    }
+    public OFTableFeaturePropWildcards tableFeaturePropWildcards(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWildcards not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropWriteActions.Builder buildTableFeaturePropWriteActions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActions not supported in version 1.1");
+    }
+    public OFTableFeaturePropWriteActions tableFeaturePropWriteActions(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActions not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropWriteActionsMiss.Builder buildTableFeaturePropWriteActionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActionsMiss not supported in version 1.1");
+    }
+    public OFTableFeaturePropWriteActionsMiss tableFeaturePropWriteActionsMiss(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActionsMiss not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropWriteSetfield.Builder buildTableFeaturePropWriteSetfield() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfield not supported in version 1.1");
+    }
+    public OFTableFeaturePropWriteSetfield tableFeaturePropWriteSetfield(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfield not supported in version 1.1");
+    }
+
+    public OFTableFeaturePropWriteSetfieldMiss.Builder buildTableFeaturePropWriteSetfieldMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfieldMiss not supported in version 1.1");
+    }
+    public OFTableFeaturePropWriteSetfieldMiss tableFeaturePropWriteSetfieldMiss(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfieldMiss not supported in version 1.1");
+    }
+
+    public OFTableFeatures.Builder buildTableFeatures() {
+        throw new UnsupportedOperationException("OFTableFeatures not supported in version 1.1");
+    }
+
+    public OFTableFeaturesStatsReply.Builder buildTableFeaturesStatsReply() {
+        throw new UnsupportedOperationException("OFTableFeaturesStatsReply not supported in version 1.1");
+    }
+
+    public OFTableFeaturesStatsRequest.Builder buildTableFeaturesStatsRequest() {
+        throw new UnsupportedOperationException("OFTableFeaturesStatsRequest not supported in version 1.1");
+    }
+
+    public OFUint64.Builder buildUint64() {
+        throw new UnsupportedOperationException("OFUint64 not supported in version 1.1");
+    }
+    public OFUint64 uint64(U64 value) {
+        throw new UnsupportedOperationException("OFUint64 not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFMessage> getReader() {
+        return OFMessageVer11.READER;
+    }
+
+    public long nextXid() {
+        return xidGenerator.nextXid();
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFeaturesReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFeaturesReplyVer11.java
new file mode 100644
index 0000000..225ea25
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFeaturesReplyVer11.java
@@ -0,0 +1,630 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFeaturesReplyVer11 implements OFFeaturesReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFFeaturesReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static DatapathId DEFAULT_DATAPATH_ID = DatapathId.NONE;
+        private final static long DEFAULT_N_BUFFERS = 0x0L;
+        private final static short DEFAULT_N_TABLES = (short) 0x0;
+        private final static Set<OFCapabilities> DEFAULT_CAPABILITIES = ImmutableSet.<OFCapabilities>of();
+        private final static long DEFAULT_RESERVED = 0x0L;
+        private final static List<OFPortDesc> DEFAULT_PORTS = ImmutableList.<OFPortDesc>of();
+
+    // OF message fields
+    private final long xid;
+    private final DatapathId datapathId;
+    private final long nBuffers;
+    private final short nTables;
+    private final Set<OFCapabilities> capabilities;
+    private final long reserved;
+    private final List<OFPortDesc> ports;
+//
+    // Immutable default instance
+    final static OFFeaturesReplyVer11 DEFAULT = new OFFeaturesReplyVer11(
+        DEFAULT_XID, DEFAULT_DATAPATH_ID, DEFAULT_N_BUFFERS, DEFAULT_N_TABLES, DEFAULT_CAPABILITIES, DEFAULT_RESERVED, DEFAULT_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFeaturesReplyVer11(long xid, DatapathId datapathId, long nBuffers, short nTables, Set<OFCapabilities> capabilities, long reserved, List<OFPortDesc> ports) {
+        this.xid = xid;
+        this.datapathId = datapathId;
+        this.nBuffers = nBuffers;
+        this.nTables = nTables;
+        this.capabilities = capabilities;
+        this.reserved = reserved;
+        this.ports = ports;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.1");
+    }
+
+
+
+    public OFFeaturesReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFeaturesReply.Builder {
+        final OFFeaturesReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean datapathIdSet;
+        private DatapathId datapathId;
+        private boolean nBuffersSet;
+        private long nBuffers;
+        private boolean nTablesSet;
+        private short nTables;
+        private boolean capabilitiesSet;
+        private Set<OFCapabilities> capabilities;
+        private boolean reservedSet;
+        private long reserved;
+        private boolean portsSet;
+        private List<OFPortDesc> ports;
+
+        BuilderWithParent(OFFeaturesReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setDatapathId(DatapathId datapathId) {
+        this.datapathId = datapathId;
+        this.datapathIdSet = true;
+        return this;
+    }
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNBuffers(long nBuffers) {
+        this.nBuffers = nBuffers;
+        this.nBuffersSet = true;
+        return this;
+    }
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNTables(short nTables) {
+        this.nTables = nTables;
+        this.nTablesSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setCapabilities(Set<OFCapabilities> capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setReserved(long reserved) {
+        this.reserved = reserved;
+        this.reservedSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setPorts(List<OFPortDesc> ports) {
+        this.ports = ports;
+        this.portsSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setActions(Set<OFActionType> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.1");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setAuxiliaryId(OFAuxId auxiliaryId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.1");
+    }
+
+
+        @Override
+        public OFFeaturesReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                DatapathId datapathId = this.datapathIdSet ? this.datapathId : parentMessage.datapathId;
+                if(datapathId == null)
+                    throw new NullPointerException("Property datapathId must not be null");
+                long nBuffers = this.nBuffersSet ? this.nBuffers : parentMessage.nBuffers;
+                short nTables = this.nTablesSet ? this.nTables : parentMessage.nTables;
+                Set<OFCapabilities> capabilities = this.capabilitiesSet ? this.capabilities : parentMessage.capabilities;
+                if(capabilities == null)
+                    throw new NullPointerException("Property capabilities must not be null");
+                long reserved = this.reservedSet ? this.reserved : parentMessage.reserved;
+                List<OFPortDesc> ports = this.portsSet ? this.ports : parentMessage.ports;
+                if(ports == null)
+                    throw new NullPointerException("Property ports must not be null");
+
+                //
+                return new OFFeaturesReplyVer11(
+                    xid,
+                    datapathId,
+                    nBuffers,
+                    nTables,
+                    capabilities,
+                    reserved,
+                    ports
+                );
+        }
+
+    }
+
+    static class Builder implements OFFeaturesReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean datapathIdSet;
+        private DatapathId datapathId;
+        private boolean nBuffersSet;
+        private long nBuffers;
+        private boolean nTablesSet;
+        private short nTables;
+        private boolean capabilitiesSet;
+        private Set<OFCapabilities> capabilities;
+        private boolean reservedSet;
+        private long reserved;
+        private boolean portsSet;
+        private List<OFPortDesc> ports;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setDatapathId(DatapathId datapathId) {
+        this.datapathId = datapathId;
+        this.datapathIdSet = true;
+        return this;
+    }
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNBuffers(long nBuffers) {
+        this.nBuffers = nBuffers;
+        this.nBuffersSet = true;
+        return this;
+    }
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNTables(short nTables) {
+        this.nTables = nTables;
+        this.nTablesSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setCapabilities(Set<OFCapabilities> capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setReserved(long reserved) {
+        this.reserved = reserved;
+        this.reservedSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setPorts(List<OFPortDesc> ports) {
+        this.ports = ports;
+        this.portsSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setActions(Set<OFActionType> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.1");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setAuxiliaryId(OFAuxId auxiliaryId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.1");
+    }
+//
+        @Override
+        public OFFeaturesReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            DatapathId datapathId = this.datapathIdSet ? this.datapathId : DEFAULT_DATAPATH_ID;
+            if(datapathId == null)
+                throw new NullPointerException("Property datapathId must not be null");
+            long nBuffers = this.nBuffersSet ? this.nBuffers : DEFAULT_N_BUFFERS;
+            short nTables = this.nTablesSet ? this.nTables : DEFAULT_N_TABLES;
+            Set<OFCapabilities> capabilities = this.capabilitiesSet ? this.capabilities : DEFAULT_CAPABILITIES;
+            if(capabilities == null)
+                throw new NullPointerException("Property capabilities must not be null");
+            long reserved = this.reservedSet ? this.reserved : DEFAULT_RESERVED;
+            List<OFPortDesc> ports = this.portsSet ? this.ports : DEFAULT_PORTS;
+            if(ports == null)
+                throw new NullPointerException("Property ports must not be null");
+
+
+            return new OFFeaturesReplyVer11(
+                    xid,
+                    datapathId,
+                    nBuffers,
+                    nTables,
+                    capabilities,
+                    reserved,
+                    ports
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFeaturesReply> {
+        @Override
+        public OFFeaturesReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 6
+            byte type = bb.readByte();
+            if(type != (byte) 0x6)
+                throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REPLY(6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            DatapathId datapathId = DatapathId.of(bb.readLong());
+            long nBuffers = U32.f(bb.readInt());
+            short nTables = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            Set<OFCapabilities> capabilities = OFCapabilitiesSerializerVer11.readFrom(bb);
+            long reserved = U32.f(bb.readInt());
+            List<OFPortDesc> ports = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPortDescVer11.READER);
+
+            OFFeaturesReplyVer11 featuresReplyVer11 = new OFFeaturesReplyVer11(
+                    xid,
+                      datapathId,
+                      nBuffers,
+                      nTables,
+                      capabilities,
+                      reserved,
+                      ports
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", featuresReplyVer11);
+            return featuresReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFeaturesReplyVer11Funnel FUNNEL = new OFFeaturesReplyVer11Funnel();
+    static class OFFeaturesReplyVer11Funnel implements Funnel<OFFeaturesReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFeaturesReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 6
+            sink.putByte((byte) 0x6);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.datapathId.putTo(sink);
+            sink.putLong(message.nBuffers);
+            sink.putShort(message.nTables);
+            // skip pad (3 bytes)
+            OFCapabilitiesSerializerVer11.putTo(message.capabilities, sink);
+            sink.putLong(message.reserved);
+            FunnelUtils.putList(message.ports, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFeaturesReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFeaturesReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 6
+            bb.writeByte((byte) 0x6);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.datapathId.getLong());
+            bb.writeInt(U32.t(message.nBuffers));
+            bb.writeByte(U8.t(message.nTables));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            OFCapabilitiesSerializerVer11.writeTo(bb, message.capabilities);
+            bb.writeInt(U32.t(message.reserved));
+            ChannelUtils.writeList(bb, message.ports);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFeaturesReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("datapathId=").append(datapathId);
+        b.append(", ");
+        b.append("nBuffers=").append(nBuffers);
+        b.append(", ");
+        b.append("nTables=").append(nTables);
+        b.append(", ");
+        b.append("capabilities=").append(capabilities);
+        b.append(", ");
+        b.append("reserved=").append(reserved);
+        b.append(", ");
+        b.append("ports=").append(ports);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFeaturesReplyVer11 other = (OFFeaturesReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (datapathId == null) {
+            if (other.datapathId != null)
+                return false;
+        } else if (!datapathId.equals(other.datapathId))
+            return false;
+        if( nBuffers != other.nBuffers)
+            return false;
+        if( nTables != other.nTables)
+            return false;
+        if (capabilities == null) {
+            if (other.capabilities != null)
+                return false;
+        } else if (!capabilities.equals(other.capabilities))
+            return false;
+        if( reserved != other.reserved)
+            return false;
+        if (ports == null) {
+            if (other.ports != null)
+                return false;
+        } else if (!ports.equals(other.ports))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((datapathId == null) ? 0 : datapathId.hashCode());
+        result = prime *  (int) (nBuffers ^ (nBuffers >>> 32));
+        result = prime * result + nTables;
+        result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode());
+        result = prime *  (int) (reserved ^ (reserved >>> 32));
+        result = prime * result + ((ports == null) ? 0 : ports.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFeaturesRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFeaturesRequestVer11.java
new file mode 100644
index 0000000..b836384
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFeaturesRequestVer11.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFeaturesRequestVer11 implements OFFeaturesRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFFeaturesRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFFeaturesRequestVer11 DEFAULT = new OFFeaturesRequestVer11(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFeaturesRequestVer11(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFFeaturesRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFeaturesRequest.Builder {
+        final OFFeaturesRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFFeaturesRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFeaturesRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFFeaturesRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFFeaturesRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFeaturesRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFFeaturesRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFeaturesRequest> {
+        @Override
+        public OFFeaturesRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 5
+            byte type = bb.readByte();
+            if(type != (byte) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REQUEST(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFFeaturesRequestVer11 featuresRequestVer11 = new OFFeaturesRequestVer11(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", featuresRequestVer11);
+            return featuresRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFeaturesRequestVer11Funnel FUNNEL = new OFFeaturesRequestVer11Funnel();
+    static class OFFeaturesRequestVer11Funnel implements Funnel<OFFeaturesRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFeaturesRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 5
+            sink.putByte((byte) 0x5);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFeaturesRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFeaturesRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 5
+            bb.writeByte((byte) 0x5);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFeaturesRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFeaturesRequestVer11 other = (OFFeaturesRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowAddVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowAddVer11.java
new file mode 100644
index 0000000..92de0f6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowAddVer11.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowAddVer11 implements OFFlowAdd {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowAddVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 136;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowAddVer11 DEFAULT = new OFFlowAddVer11(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowAddVer11(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+
+    public OFFlowAdd.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowAdd.Builder {
+        final OFFlowAddVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowAddVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+        @Override
+        public OFFlowAdd build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowAddVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowAdd.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+//
+        @Override
+        public OFFlowAdd build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowAddVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowAdd> {
+        @Override
+        public OFFlowAdd readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 0
+            short command = bb.readByte();
+            if(command != (short) 0x0)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.ADD(0), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer11.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer11.READER);
+
+            OFFlowAddVer11 flowAddVer11 = new OFFlowAddVer11(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowAddVer11);
+            return flowAddVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowAddVer11Funnel FUNNEL = new OFFlowAddVer11Funnel();
+    static class OFFlowAddVer11Funnel implements Funnel<OFFlowAddVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowAddVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 0
+            sink.putShort((short) 0x0);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowAddVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowAddVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 0
+            bb.writeByte((short) 0x0);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowAddVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowAddVer11 other = (OFFlowAddVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowDeleteStrictVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowDeleteStrictVer11.java
new file mode 100644
index 0000000..cfbc4fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowDeleteStrictVer11.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowDeleteStrictVer11 implements OFFlowDeleteStrict {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteStrictVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 136;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowDeleteStrictVer11 DEFAULT = new OFFlowDeleteStrictVer11(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowDeleteStrictVer11(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+
+    public OFFlowDeleteStrict.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowDeleteStrict.Builder {
+        final OFFlowDeleteStrictVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowDeleteStrictVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+        @Override
+        public OFFlowDeleteStrict build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowDeleteStrictVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowDeleteStrict.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+//
+        @Override
+        public OFFlowDeleteStrict build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowDeleteStrictVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowDeleteStrict> {
+        @Override
+        public OFFlowDeleteStrict readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 4
+            short command = bb.readByte();
+            if(command != (short) 0x4)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE_STRICT(4), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer11.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer11.READER);
+
+            OFFlowDeleteStrictVer11 flowDeleteStrictVer11 = new OFFlowDeleteStrictVer11(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowDeleteStrictVer11);
+            return flowDeleteStrictVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowDeleteStrictVer11Funnel FUNNEL = new OFFlowDeleteStrictVer11Funnel();
+    static class OFFlowDeleteStrictVer11Funnel implements Funnel<OFFlowDeleteStrictVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowDeleteStrictVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 4
+            sink.putShort((short) 0x4);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowDeleteStrictVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowDeleteStrictVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 4
+            bb.writeByte((short) 0x4);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowDeleteStrictVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowDeleteStrictVer11 other = (OFFlowDeleteStrictVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowDeleteVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowDeleteVer11.java
new file mode 100644
index 0000000..96ba5ef
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowDeleteVer11.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowDeleteVer11 implements OFFlowDelete {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 136;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowDeleteVer11 DEFAULT = new OFFlowDeleteVer11(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowDeleteVer11(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+
+    public OFFlowDelete.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowDelete.Builder {
+        final OFFlowDeleteVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowDeleteVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+        @Override
+        public OFFlowDelete build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowDeleteVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowDelete.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+//
+        @Override
+        public OFFlowDelete build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowDeleteVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowDelete> {
+        @Override
+        public OFFlowDelete readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 3
+            short command = bb.readByte();
+            if(command != (short) 0x3)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE(3), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer11.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer11.READER);
+
+            OFFlowDeleteVer11 flowDeleteVer11 = new OFFlowDeleteVer11(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowDeleteVer11);
+            return flowDeleteVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowDeleteVer11Funnel FUNNEL = new OFFlowDeleteVer11Funnel();
+    static class OFFlowDeleteVer11Funnel implements Funnel<OFFlowDeleteVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowDeleteVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 3
+            sink.putShort((short) 0x3);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowDeleteVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowDeleteVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 3
+            bb.writeByte((short) 0x3);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowDeleteVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowDeleteVer11 other = (OFFlowDeleteVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModCommandSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModCommandSerializerVer11.java
new file mode 100644
index 0000000..2ea2b04
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModCommandSerializerVer11.java
@@ -0,0 +1,89 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModCommand;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowModCommandSerializerVer11 {
+
+    public final static byte ADD_VAL = (byte) 0x0;
+    public final static byte MODIFY_VAL = (byte) 0x1;
+    public final static byte MODIFY_STRICT_VAL = (byte) 0x2;
+    public final static byte DELETE_VAL = (byte) 0x3;
+    public final static byte DELETE_STRICT_VAL = (byte) 0x4;
+
+    public static OFFlowModCommand readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowModCommand e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowModCommand e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFFlowModCommand ofWireValue(byte val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFFlowModCommand.ADD;
+            case MODIFY_VAL:
+                return OFFlowModCommand.MODIFY;
+            case MODIFY_STRICT_VAL:
+                return OFFlowModCommand.MODIFY_STRICT;
+            case DELETE_VAL:
+                return OFFlowModCommand.DELETE;
+            case DELETE_STRICT_VAL:
+                return OFFlowModCommand.DELETE_STRICT;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowModCommand in version 1.1: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFFlowModCommand e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            case MODIFY_STRICT:
+                return MODIFY_STRICT_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case DELETE_STRICT:
+                return DELETE_STRICT_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowModCommand in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFailedCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFailedCodeSerializerVer11.java
new file mode 100644
index 0000000..db1f1b5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFailedCodeSerializerVer11.java
@@ -0,0 +1,99 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowModFailedCodeSerializerVer11 {
+
+    public final static short UNKNOWN_VAL = (short) 0x0;
+    public final static short TABLE_FULL_VAL = (short) 0x1;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x2;
+    public final static short OVERLAP_VAL = (short) 0x3;
+    public final static short EPERM_VAL = (short) 0x4;
+    public final static short BAD_TIMEOUT_VAL = (short) 0x5;
+    public final static short BAD_COMMAND_VAL = (short) 0x6;
+
+    public static OFFlowModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFFlowModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case UNKNOWN_VAL:
+                return OFFlowModFailedCode.UNKNOWN;
+            case TABLE_FULL_VAL:
+                return OFFlowModFailedCode.TABLE_FULL;
+            case BAD_TABLE_ID_VAL:
+                return OFFlowModFailedCode.BAD_TABLE_ID;
+            case OVERLAP_VAL:
+                return OFFlowModFailedCode.OVERLAP;
+            case EPERM_VAL:
+                return OFFlowModFailedCode.EPERM;
+            case BAD_TIMEOUT_VAL:
+                return OFFlowModFailedCode.BAD_TIMEOUT;
+            case BAD_COMMAND_VAL:
+                return OFFlowModFailedCode.BAD_COMMAND;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowModFailedCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFFlowModFailedCode e) {
+        switch(e) {
+            case UNKNOWN:
+                return UNKNOWN_VAL;
+            case TABLE_FULL:
+                return TABLE_FULL_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            case OVERLAP:
+                return OVERLAP_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case BAD_TIMEOUT:
+                return BAD_TIMEOUT_VAL;
+            case BAD_COMMAND:
+                return BAD_COMMAND_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowModFailedCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFailedErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFailedErrorMsgVer11.java
new file mode 100644
index 0000000..2981af7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFailedErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModFailedErrorMsgVer11 implements OFFlowModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModFailedErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFFlowModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModFailedErrorMsgVer11(long xid, OFFlowModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFFlowModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModFailedErrorMsg.Builder {
+        final OFFlowModFailedErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFFlowModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFFlowModFailedErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setCode(OFFlowModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFFlowModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFFlowModFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFFlowModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setCode(OFFlowModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFFlowModFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModFailedErrorMsg> {
+        @Override
+        public OFFlowModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 5
+            short errType = bb.readShort();
+            if(errType != (short) 0x5)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.FLOW_MOD_FAILED(5), got="+errType);
+            OFFlowModFailedCode code = OFFlowModFailedCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFFlowModFailedErrorMsgVer11 flowModFailedErrorMsgVer11 = new OFFlowModFailedErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModFailedErrorMsgVer11);
+            return flowModFailedErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModFailedErrorMsgVer11Funnel FUNNEL = new OFFlowModFailedErrorMsgVer11Funnel();
+    static class OFFlowModFailedErrorMsgVer11Funnel implements Funnel<OFFlowModFailedErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModFailedErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 5
+            sink.putShort((short) 0x5);
+            OFFlowModFailedCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModFailedErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModFailedErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 5
+            bb.writeShort((short) 0x5);
+            OFFlowModFailedCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModFailedErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModFailedErrorMsgVer11 other = (OFFlowModFailedErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFlagsSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFlagsSerializerVer11.java
new file mode 100644
index 0000000..10a4a0e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModFlagsSerializerVer11.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFFlowModFlagsSerializerVer11 {
+
+    public final static short SEND_FLOW_REM_VAL = (short) 0x1;
+    public final static short CHECK_OVERLAP_VAL = (short) 0x2;
+
+    public static Set<OFFlowModFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFFlowModFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFFlowModFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFFlowModFlags> ofWireValue(short val) {
+        EnumSet<OFFlowModFlags> set = EnumSet.noneOf(OFFlowModFlags.class);
+
+        if((val & SEND_FLOW_REM_VAL) != 0)
+            set.add(OFFlowModFlags.SEND_FLOW_REM);
+        if((val & CHECK_OVERLAP_VAL) != 0)
+            set.add(OFFlowModFlags.CHECK_OVERLAP);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFFlowModFlags> set) {
+        short wireValue = 0;
+
+        for(OFFlowModFlags e: set) {
+            switch(e) {
+                case SEND_FLOW_REM:
+                    wireValue |= SEND_FLOW_REM_VAL;
+                    break;
+                case CHECK_OVERLAP:
+                    wireValue |= CHECK_OVERLAP_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFFlowModFlags in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModVer11.java
new file mode 100644
index 0000000..1688ab9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModVer11.java
@@ -0,0 +1,80 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFFlowModVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 136;
+
+
+    public final static OFFlowModVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFFlowMod> {
+        @Override
+        public OFFlowMod readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            U64.ofRaw(bb.readLong());
+            U64.ofRaw(bb.readLong());
+            TableId.readByte(bb);
+            short command = bb.readByte();
+            bb.readerIndex(start);
+            switch(command) {
+               case (short) 0x0:
+                   // discriminator value OFFlowModCommand.ADD=0 for class OFFlowAddVer11
+                   return OFFlowAddVer11.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFFlowModCommand.DELETE=3 for class OFFlowDeleteVer11
+                   return OFFlowDeleteVer11.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFFlowModCommand.DELETE_STRICT=4 for class OFFlowDeleteStrictVer11
+                   return OFFlowDeleteStrictVer11.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFFlowModCommand.MODIFY=1 for class OFFlowModifyVer11
+                   return OFFlowModifyVer11.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFFlowModCommand.MODIFY_STRICT=2 for class OFFlowModifyStrictVer11
+                   return OFFlowModifyStrictVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator command of class OFFlowModVer11: " + command);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModifyStrictVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModifyStrictVer11.java
new file mode 100644
index 0000000..934d775
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModifyStrictVer11.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModifyStrictVer11 implements OFFlowModifyStrict {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModifyStrictVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 136;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowModifyStrictVer11 DEFAULT = new OFFlowModifyStrictVer11(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModifyStrictVer11(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+
+    public OFFlowModifyStrict.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModifyStrict.Builder {
+        final OFFlowModifyStrictVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowModifyStrictVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+        @Override
+        public OFFlowModifyStrict build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowModifyStrictVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModifyStrict.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+//
+        @Override
+        public OFFlowModifyStrict build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowModifyStrictVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModifyStrict> {
+        @Override
+        public OFFlowModifyStrict readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 2
+            short command = bb.readByte();
+            if(command != (short) 0x2)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.MODIFY_STRICT(2), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer11.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer11.READER);
+
+            OFFlowModifyStrictVer11 flowModifyStrictVer11 = new OFFlowModifyStrictVer11(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModifyStrictVer11);
+            return flowModifyStrictVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModifyStrictVer11Funnel FUNNEL = new OFFlowModifyStrictVer11Funnel();
+    static class OFFlowModifyStrictVer11Funnel implements Funnel<OFFlowModifyStrictVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModifyStrictVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 2
+            sink.putShort((short) 0x2);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModifyStrictVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModifyStrictVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 2
+            bb.writeByte((short) 0x2);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModifyStrictVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModifyStrictVer11 other = (OFFlowModifyStrictVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModifyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModifyVer11.java
new file mode 100644
index 0000000..55f0068
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowModifyVer11.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModifyVer11 implements OFFlowModify {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModifyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 136;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowModifyVer11 DEFAULT = new OFFlowModifyVer11(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModifyVer11(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+
+    public OFFlowModify.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModify.Builder {
+        final OFFlowModifyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowModifyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModify.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModify.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModify.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModify.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowModify.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+
+        @Override
+        public OFFlowModify build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowModifyVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModify.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModify.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModify.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModify.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModify.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowModify.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+//
+        @Override
+        public OFFlowModify build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowModifyVer11(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModify> {
+        @Override
+        public OFFlowModify readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 1
+            short command = bb.readByte();
+            if(command != (short) 0x1)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.MODIFY(1), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer11.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer11.READER);
+
+            OFFlowModifyVer11 flowModifyVer11 = new OFFlowModifyVer11(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModifyVer11);
+            return flowModifyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModifyVer11Funnel FUNNEL = new OFFlowModifyVer11Funnel();
+    static class OFFlowModifyVer11Funnel implements Funnel<OFFlowModifyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModifyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 1
+            sink.putShort((short) 0x1);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModifyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModifyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 1
+            bb.writeByte((short) 0x1);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModifyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModifyVer11 other = (OFFlowModifyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowRemovedReasonSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowRemovedReasonSerializerVer11.java
new file mode 100644
index 0000000..9357623
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowRemovedReasonSerializerVer11.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowRemovedReasonSerializerVer11 {
+
+    public final static byte IDLE_TIMEOUT_VAL = (byte) 0x0;
+    public final static byte HARD_TIMEOUT_VAL = (byte) 0x1;
+    public final static byte DELETE_VAL = (byte) 0x2;
+    public final static byte GROUP_DELETE_VAL = (byte) 0x3;
+
+    public static OFFlowRemovedReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowRemovedReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowRemovedReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFFlowRemovedReason ofWireValue(byte val) {
+        switch(val) {
+            case IDLE_TIMEOUT_VAL:
+                return OFFlowRemovedReason.IDLE_TIMEOUT;
+            case HARD_TIMEOUT_VAL:
+                return OFFlowRemovedReason.HARD_TIMEOUT;
+            case DELETE_VAL:
+                return OFFlowRemovedReason.DELETE;
+            case GROUP_DELETE_VAL:
+                return OFFlowRemovedReason.GROUP_DELETE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowRemovedReason in version 1.1: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFFlowRemovedReason e) {
+        switch(e) {
+            case IDLE_TIMEOUT:
+                return IDLE_TIMEOUT_VAL;
+            case HARD_TIMEOUT:
+                return HARD_TIMEOUT_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case GROUP_DELETE:
+                return GROUP_DELETE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowRemovedReason in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowRemovedVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowRemovedVer11.java
new file mode 100644
index 0000000..f5c0b5a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowRemovedVer11.java
@@ -0,0 +1,801 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowRemovedVer11 implements OFFlowRemoved {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowRemovedVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 136;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static short DEFAULT_REASON = (short) 0x0;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final int priority;
+    private final short reason;
+    private final TableId tableId;
+    private final long durationSec;
+    private final long durationNsec;
+    private final int idleTimeout;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFFlowRemovedVer11 DEFAULT = new OFFlowRemovedVer11(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_PRIORITY, DEFAULT_REASON, DEFAULT_TABLE_ID, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_IDLE_TIMEOUT, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowRemovedVer11(long xid, U64 cookie, int priority, short reason, TableId tableId, long durationSec, long durationNsec, int idleTimeout, U64 packetCount, U64 byteCount, Match match) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.priority = priority;
+        this.reason = reason;
+        this.tableId = tableId;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.idleTimeout = idleTimeout;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.1");
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFFlowRemoved.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowRemoved.Builder {
+        final OFFlowRemovedVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean reasonSet;
+        private short reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFFlowRemovedVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setReason(short reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setHardTimeout(int hardTimeout) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.1");
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowRemoved build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                short reason = this.reasonSet ? this.reason : parentMessage.reason;
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFFlowRemovedVer11(
+                    xid,
+                    cookie,
+                    priority,
+                    reason,
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    idleTimeout,
+                    packetCount,
+                    byteCount,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowRemoved.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean reasonSet;
+        private short reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setReason(short reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setHardTimeout(int hardTimeout) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property hardTimeout not supported in version 1.1");
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowRemoved build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            short reason = this.reasonSet ? this.reason : DEFAULT_REASON;
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFFlowRemovedVer11(
+                    xid,
+                    cookie,
+                    priority,
+                    reason,
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    idleTimeout,
+                    packetCount,
+                    byteCount,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowRemoved> {
+        @Override
+        public OFFlowRemoved readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 11
+            byte type = bb.readByte();
+            if(type != (byte) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_REMOVED(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 136)
+                throw new OFParseError("Wrong length: Expected=136(136), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            int priority = U16.f(bb.readShort());
+            short reason = U8.f(bb.readByte());
+            TableId tableId = TableId.readByte(bb);
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            int idleTimeout = U16.f(bb.readShort());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+
+            OFFlowRemovedVer11 flowRemovedVer11 = new OFFlowRemovedVer11(
+                    xid,
+                      cookie,
+                      priority,
+                      reason,
+                      tableId,
+                      durationSec,
+                      durationNsec,
+                      idleTimeout,
+                      packetCount,
+                      byteCount,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowRemovedVer11);
+            return flowRemovedVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowRemovedVer11Funnel FUNNEL = new OFFlowRemovedVer11Funnel();
+    static class OFFlowRemovedVer11Funnel implements Funnel<OFFlowRemovedVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowRemovedVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 11
+            sink.putByte((byte) 0xb);
+            // fixed value property length = 136
+            sink.putShort((short) 0x88);
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            sink.putInt(message.priority);
+            sink.putShort(message.reason);
+            message.tableId.putTo(sink);
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            sink.putInt(message.idleTimeout);
+            // skip pad (2 bytes)
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowRemovedVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowRemovedVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 11
+            bb.writeByte((byte) 0xb);
+            // fixed value property length = 136
+            bb.writeShort((short) 0x88);
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeShort(U16.t(message.priority));
+            bb.writeByte(U8.t(message.reason));
+            message.tableId.writeByte(bb);
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            bb.writeShort(U16.t(message.idleTimeout));
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            message.match.writeTo(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowRemovedVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowRemovedVer11 other = (OFFlowRemovedVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( priority != other.priority)
+            return false;
+        if( reason != other.reason)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + priority;
+        result = prime * result + reason;
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + idleTimeout;
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsEntryVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsEntryVer11.java
new file mode 100644
index 0000000..70d05ae
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsEntryVer11.java
@@ -0,0 +1,812 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsEntryVer11 implements OFFlowStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsEntryVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 136;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final TableId tableId;
+    private final long durationSec;
+    private final long durationNsec;
+    private final int priority;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final U64 cookie;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowStatsEntryVer11 DEFAULT = new OFFlowStatsEntryVer11(
+        DEFAULT_TABLE_ID, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_PRIORITY, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_COOKIE, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsEntryVer11(TableId tableId, long durationSec, long durationNsec, int priority, int idleTimeout, int hardTimeout, U64 cookie, U64 packetCount, U64 byteCount, Match match, List<OFInstruction> instructions) {
+        this.tableId = tableId;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.priority = priority;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.cookie = cookie;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.1");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFFlowStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsEntry.Builder {
+        final OFFlowStatsEntryVer11 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean prioritySet;
+        private int priority;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowStatsEntryVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property flags not supported in version 1.1");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFFlowStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowStatsEntryVer11(
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    priority,
+                    idleTimeout,
+                    hardTimeout,
+                    cookie,
+                    packetCount,
+                    byteCount,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean prioritySet;
+        private int priority;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.1");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.1");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property flags not supported in version 1.1");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFFlowStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowStatsEntryVer11(
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    priority,
+                    idleTimeout,
+                    hardTimeout,
+                    cookie,
+                    packetCount,
+                    byteCount,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsEntry> {
+        @Override
+        public OFFlowStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            int priority = U16.f(bb.readShort());
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer11.READER);
+
+            OFFlowStatsEntryVer11 flowStatsEntryVer11 = new OFFlowStatsEntryVer11(
+                    tableId,
+                      durationSec,
+                      durationNsec,
+                      priority,
+                      idleTimeout,
+                      hardTimeout,
+                      cookie,
+                      packetCount,
+                      byteCount,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsEntryVer11);
+            return flowStatsEntryVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsEntryVer11Funnel FUNNEL = new OFFlowStatsEntryVer11Funnel();
+    static class OFFlowStatsEntryVer11Funnel implements Funnel<OFFlowStatsEntryVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsEntryVer11 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            message.tableId.putTo(sink);
+            // skip pad (1 bytes)
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            sink.putInt(message.priority);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            // skip pad (6 bytes)
+            message.cookie.putTo(sink);
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsEntryVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsEntryVer11 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.tableId.writeByte(bb);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            // pad: 6 bytes
+            bb.writeZero(6);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsEntryVer11(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsEntryVer11 other = (OFFlowStatsEntryVer11) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + priority;
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsReplyVer11.java
new file mode 100644
index 0000000..a513926
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsReplyVer11.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsReplyVer11 implements OFFlowStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFFlowStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFFlowStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFFlowStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFFlowStatsReplyVer11 DEFAULT = new OFFlowStatsReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsReplyVer11(long xid, Set<OFStatsReplyFlags> flags, List<OFFlowStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFFlowStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsReply.Builder {
+        final OFFlowStatsReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFFlowStatsEntry> entries;
+
+        BuilderWithParent(OFFlowStatsReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setEntries(List<OFFlowStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFFlowStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFFlowStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFFlowStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setEntries(List<OFFlowStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFFlowStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFFlowStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsReply> {
+        @Override
+        public OFFlowStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 1
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x1)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.FLOW(1), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFFlowStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFFlowStatsEntryVer11.READER);
+
+            OFFlowStatsReplyVer11 flowStatsReplyVer11 = new OFFlowStatsReplyVer11(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsReplyVer11);
+            return flowStatsReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsReplyVer11Funnel FUNNEL = new OFFlowStatsReplyVer11Funnel();
+    static class OFFlowStatsReplyVer11Funnel implements Funnel<OFFlowStatsReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 1
+            sink.putShort((short) 0x1);
+            OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 1
+            bb.writeShort((short) 0x1);
+            OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsReplyVer11 other = (OFFlowStatsReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsRequestVer11.java
new file mode 100644
index 0000000..4653e50
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowStatsRequestVer11.java
@@ -0,0 +1,685 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsRequestVer11 implements OFFlowStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 136;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer11.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final TableId tableId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFFlowStatsRequestVer11 DEFAULT = new OFFlowStatsRequestVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TABLE_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsRequestVer11(long xid, Set<OFStatsRequestFlags> flags, TableId tableId, OFPort outPort, OFGroup outGroup, U64 cookie, U64 cookieMask, Match match) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFFlowStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsRequest.Builder {
+        final OFFlowStatsRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFFlowStatsRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFFlowStatsRequestVer11(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFFlowStatsRequestVer11(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsRequest> {
+        @Override
+        public OFFlowStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 136)
+                throw new OFParseError("Wrong length: Expected=136(136), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 1
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x1)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.FLOW(1), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer11.readOFMatch(bb);
+
+            OFFlowStatsRequestVer11 flowStatsRequestVer11 = new OFFlowStatsRequestVer11(
+                    xid,
+                      flags,
+                      tableId,
+                      outPort,
+                      outGroup,
+                      cookie,
+                      cookieMask,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsRequestVer11);
+            return flowStatsRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsRequestVer11Funnel FUNNEL = new OFFlowStatsRequestVer11Funnel();
+    static class OFFlowStatsRequestVer11Funnel implements Funnel<OFFlowStatsRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 136
+            sink.putShort((short) 0x88);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 1
+            sink.putShort((short) 0x1);
+            OFStatsRequestFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            // skip pad (4 bytes)
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 136
+            bb.writeShort((short) 0x88);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 1
+            bb.writeShort((short) 0x1);
+            OFStatsRequestFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.match.writeTo(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsRequestVer11 other = (OFFlowStatsRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowWildcardsSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowWildcardsSerializerVer11.java
new file mode 100644
index 0000000..c53e568
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFFlowWildcardsSerializerVer11.java
@@ -0,0 +1,138 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowWildcards;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFFlowWildcardsSerializerVer11 {
+
+    public final static int IN_PORT_VAL = 0x1;
+    public final static int DL_VLAN_VAL = 0x2;
+    public final static int DL_TYPE_VAL = 0x8;
+    public final static int NW_PROTO_VAL = 0x20;
+    public final static int TP_SRC_VAL = 0x40;
+    public final static int TP_DST_VAL = 0x80;
+    public final static int DL_VLAN_PCP_VAL = 0x4;
+    public final static int NW_TOS_VAL = 0x10;
+    public final static int ALL_VAL = 0x3ff;
+    public final static int MPLS_LABEL_VAL = 0x100;
+    public final static int MPLS_TC_VAL = 0x200;
+
+    public static Set<OFFlowWildcards> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFFlowWildcards> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFFlowWildcards> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFFlowWildcards> ofWireValue(int val) {
+        EnumSet<OFFlowWildcards> set = EnumSet.noneOf(OFFlowWildcards.class);
+
+        if((val & IN_PORT_VAL) != 0)
+            set.add(OFFlowWildcards.IN_PORT);
+        if((val & DL_VLAN_VAL) != 0)
+            set.add(OFFlowWildcards.DL_VLAN);
+        if((val & DL_TYPE_VAL) != 0)
+            set.add(OFFlowWildcards.DL_TYPE);
+        if((val & NW_PROTO_VAL) != 0)
+            set.add(OFFlowWildcards.NW_PROTO);
+        if((val & TP_SRC_VAL) != 0)
+            set.add(OFFlowWildcards.TP_SRC);
+        if((val & TP_DST_VAL) != 0)
+            set.add(OFFlowWildcards.TP_DST);
+        if((val & DL_VLAN_PCP_VAL) != 0)
+            set.add(OFFlowWildcards.DL_VLAN_PCP);
+        if((val & NW_TOS_VAL) != 0)
+            set.add(OFFlowWildcards.NW_TOS);
+        if((val & ALL_VAL) != 0)
+            set.add(OFFlowWildcards.ALL);
+        if((val & MPLS_LABEL_VAL) != 0)
+            set.add(OFFlowWildcards.MPLS_LABEL);
+        if((val & MPLS_TC_VAL) != 0)
+            set.add(OFFlowWildcards.MPLS_TC);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFFlowWildcards> set) {
+        int wireValue = 0;
+
+        for(OFFlowWildcards e: set) {
+            switch(e) {
+                case IN_PORT:
+                    wireValue |= IN_PORT_VAL;
+                    break;
+                case DL_VLAN:
+                    wireValue |= DL_VLAN_VAL;
+                    break;
+                case DL_TYPE:
+                    wireValue |= DL_TYPE_VAL;
+                    break;
+                case NW_PROTO:
+                    wireValue |= NW_PROTO_VAL;
+                    break;
+                case TP_SRC:
+                    wireValue |= TP_SRC_VAL;
+                    break;
+                case TP_DST:
+                    wireValue |= TP_DST_VAL;
+                    break;
+                case DL_VLAN_PCP:
+                    wireValue |= DL_VLAN_PCP_VAL;
+                    break;
+                case NW_TOS:
+                    wireValue |= NW_TOS_VAL;
+                    break;
+                case ALL:
+                    wireValue |= ALL_VAL;
+                    break;
+                case MPLS_LABEL:
+                    wireValue |= MPLS_LABEL_VAL;
+                    break;
+                case MPLS_TC:
+                    wireValue |= MPLS_TC_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFFlowWildcards in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGetConfigReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGetConfigReplyVer11.java
new file mode 100644
index 0000000..2816c87
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGetConfigReplyVer11.java
@@ -0,0 +1,370 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGetConfigReplyVer11 implements OFGetConfigReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGetConfigReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFConfigFlags> DEFAULT_FLAGS = ImmutableSet.<OFConfigFlags>of();
+        private final static int DEFAULT_MISS_SEND_LEN = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFConfigFlags> flags;
+    private final int missSendLen;
+//
+    // Immutable default instance
+    final static OFGetConfigReplyVer11 DEFAULT = new OFGetConfigReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MISS_SEND_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGetConfigReplyVer11(long xid, Set<OFConfigFlags> flags, int missSendLen) {
+        this.xid = xid;
+        this.flags = flags;
+        this.missSendLen = missSendLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+
+
+    public OFGetConfigReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGetConfigReply.Builder {
+        final OFGetConfigReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+        BuilderWithParent(OFGetConfigReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGetConfigReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFConfigFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int missSendLen = this.missSendLenSet ? this.missSendLen : parentMessage.missSendLen;
+
+                //
+                return new OFGetConfigReplyVer11(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFGetConfigReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGetConfigReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFConfigFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int missSendLen = this.missSendLenSet ? this.missSendLen : DEFAULT_MISS_SEND_LEN;
+
+
+            return new OFGetConfigReplyVer11(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGetConfigReply> {
+        @Override
+        public OFGetConfigReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 8
+            byte type = bb.readByte();
+            if(type != (byte) 0x8)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REPLY(8), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Set<OFConfigFlags> flags = OFConfigFlagsSerializerVer11.readFrom(bb);
+            int missSendLen = U16.f(bb.readShort());
+
+            OFGetConfigReplyVer11 getConfigReplyVer11 = new OFGetConfigReplyVer11(
+                    xid,
+                      flags,
+                      missSendLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", getConfigReplyVer11);
+            return getConfigReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGetConfigReplyVer11Funnel FUNNEL = new OFGetConfigReplyVer11Funnel();
+    static class OFGetConfigReplyVer11Funnel implements Funnel<OFGetConfigReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGetConfigReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 8
+            sink.putByte((byte) 0x8);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            OFConfigFlagsSerializerVer11.putTo(message.flags, sink);
+            sink.putInt(message.missSendLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGetConfigReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGetConfigReplyVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 8
+            bb.writeByte((byte) 0x8);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            OFConfigFlagsSerializerVer11.writeTo(bb, message.flags);
+            bb.writeShort(U16.t(message.missSendLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGetConfigReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("missSendLen=").append(missSendLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGetConfigReplyVer11 other = (OFGetConfigReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( missSendLen != other.missSendLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + missSendLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGetConfigRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGetConfigRequestVer11.java
new file mode 100644
index 0000000..c295fcc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGetConfigRequestVer11.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGetConfigRequestVer11 implements OFGetConfigRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGetConfigRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFGetConfigRequestVer11 DEFAULT = new OFGetConfigRequestVer11(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGetConfigRequestVer11(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFGetConfigRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGetConfigRequest.Builder {
+        final OFGetConfigRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFGetConfigRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGetConfigRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFGetConfigRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFGetConfigRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGetConfigRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFGetConfigRequestVer11(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGetConfigRequest> {
+        @Override
+        public OFGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 7
+            byte type = bb.readByte();
+            if(type != (byte) 0x7)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REQUEST(7), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFGetConfigRequestVer11 getConfigRequestVer11 = new OFGetConfigRequestVer11(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", getConfigRequestVer11);
+            return getConfigRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGetConfigRequestVer11Funnel FUNNEL = new OFGetConfigRequestVer11Funnel();
+    static class OFGetConfigRequestVer11Funnel implements Funnel<OFGetConfigRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGetConfigRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 7
+            sink.putByte((byte) 0x7);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGetConfigRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGetConfigRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 7
+            bb.writeByte((byte) 0x7);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGetConfigRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGetConfigRequestVer11 other = (OFGetConfigRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupAddVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupAddVer11.java
new file mode 100644
index 0000000..2f0751c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupAddVer11.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupAddVer11 implements OFGroupAdd {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupAddVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupAddVer11(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupAdd.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupAdd.Builder {
+        final OFGroupAddVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupAddVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupAdd build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupAddVer11(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupAdd.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupAdd build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupAddVer11(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupAdd> {
+        @Override
+        public OFGroupAdd readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 0
+            short command = bb.readShort();
+            if(command != (short) 0x0)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.ADD(0), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer11.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer11.READER);
+
+            OFGroupAddVer11 groupAddVer11 = new OFGroupAddVer11(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupAddVer11);
+            return groupAddVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupAddVer11Funnel FUNNEL = new OFGroupAddVer11Funnel();
+    static class OFGroupAddVer11Funnel implements Funnel<OFGroupAddVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupAddVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 0
+            sink.putShort((short) 0x0);
+            OFGroupTypeSerializerVer11.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupAddVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupAddVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 0
+            bb.writeShort((short) 0x0);
+            OFGroupTypeSerializerVer11.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupAddVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupAddVer11 other = (OFGroupAddVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDeleteVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDeleteVer11.java
new file mode 100644
index 0000000..a80363b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDeleteVer11.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDeleteVer11 implements OFGroupDelete {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDeleteVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDeleteVer11(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupDelete.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDelete.Builder {
+        final OFGroupDeleteVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupDeleteVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDelete build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupDeleteVer11(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDelete.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDelete build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupDeleteVer11(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDelete> {
+        @Override
+        public OFGroupDelete readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 2
+            short command = bb.readShort();
+            if(command != (short) 0x2)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.DELETE(2), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer11.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer11.READER);
+
+            OFGroupDeleteVer11 groupDeleteVer11 = new OFGroupDeleteVer11(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDeleteVer11);
+            return groupDeleteVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDeleteVer11Funnel FUNNEL = new OFGroupDeleteVer11Funnel();
+    static class OFGroupDeleteVer11Funnel implements Funnel<OFGroupDeleteVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDeleteVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 2
+            sink.putShort((short) 0x2);
+            OFGroupTypeSerializerVer11.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDeleteVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDeleteVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 2
+            bb.writeShort((short) 0x2);
+            OFGroupTypeSerializerVer11.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDeleteVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDeleteVer11 other = (OFGroupDeleteVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsEntryVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsEntryVer11.java
new file mode 100644
index 0000000..5f8810a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsEntryVer11.java
@@ -0,0 +1,360 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsEntryVer11 implements OFGroupDescStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsEntryVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsEntryVer11(OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFGroupDescStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsEntry.Builder {
+        final OFGroupDescStatsEntryVer11 parentMessage;
+
+        // OF message fields
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupDescStatsEntryVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFGroupDescStatsEntry build() {
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupDescStatsEntryVer11(
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsEntry.Builder {
+        // OF message fields
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFGroupDescStatsEntry build() {
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupDescStatsEntryVer11(
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsEntry> {
+        @Override
+        public OFGroupDescStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFGroupType groupType = OFGroupTypeSerializerVer11.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer11.READER);
+
+            OFGroupDescStatsEntryVer11 groupDescStatsEntryVer11 = new OFGroupDescStatsEntryVer11(
+                    groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsEntryVer11);
+            return groupDescStatsEntryVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsEntryVer11Funnel FUNNEL = new OFGroupDescStatsEntryVer11Funnel();
+    static class OFGroupDescStatsEntryVer11Funnel implements Funnel<OFGroupDescStatsEntryVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsEntryVer11 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            OFGroupTypeSerializerVer11.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsEntryVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsEntryVer11 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            OFGroupTypeSerializerVer11.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsEntryVer11(");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsEntryVer11 other = (OFGroupDescStatsEntryVer11) obj;
+
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsReplyVer11.java
new file mode 100644
index 0000000..3abffb2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsReplyVer11.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsReplyVer11 implements OFGroupDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFGroupDescStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFGroupDescStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFGroupDescStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFGroupDescStatsReplyVer11 DEFAULT = new OFGroupDescStatsReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsReplyVer11(long xid, Set<OFStatsReplyFlags> flags, List<OFGroupDescStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFGroupDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsReply.Builder {
+        final OFGroupDescStatsReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupDescStatsEntry> entries;
+
+        BuilderWithParent(OFGroupDescStatsReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setEntries(List<OFGroupDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFGroupDescStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFGroupDescStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupDescStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setEntries(List<OFGroupDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFGroupDescStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFGroupDescStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsReply> {
+        @Override
+        public OFGroupDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 7
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x7)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_DESC(7), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFGroupDescStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFGroupDescStatsEntryVer11.READER);
+
+            OFGroupDescStatsReplyVer11 groupDescStatsReplyVer11 = new OFGroupDescStatsReplyVer11(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsReplyVer11);
+            return groupDescStatsReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsReplyVer11Funnel FUNNEL = new OFGroupDescStatsReplyVer11Funnel();
+    static class OFGroupDescStatsReplyVer11Funnel implements Funnel<OFGroupDescStatsReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 7
+            sink.putShort((short) 0x7);
+            OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 7
+            bb.writeShort((short) 0x7);
+            OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsReplyVer11 other = (OFGroupDescStatsReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsRequestVer11.java
new file mode 100644
index 0000000..17f5894
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupDescStatsRequestVer11.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsRequestVer11 implements OFGroupDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFGroupDescStatsRequestVer11 DEFAULT = new OFGroupDescStatsRequestVer11(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsRequestVer11(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFGroupDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsRequest.Builder {
+        final OFGroupDescStatsRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFGroupDescStatsRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFGroupDescStatsRequestVer11(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFGroupDescStatsRequestVer11(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsRequest> {
+        @Override
+        public OFGroupDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 7
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x7)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_DESC(7), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFGroupDescStatsRequestVer11 groupDescStatsRequestVer11 = new OFGroupDescStatsRequestVer11(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsRequestVer11);
+            return groupDescStatsRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsRequestVer11Funnel FUNNEL = new OFGroupDescStatsRequestVer11Funnel();
+    static class OFGroupDescStatsRequestVer11Funnel implements Funnel<OFGroupDescStatsRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 7
+            sink.putShort((short) 0x7);
+            OFStatsRequestFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 7
+            bb.writeShort((short) 0x7);
+            OFStatsRequestFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsRequestVer11 other = (OFGroupDescStatsRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModCommandSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModCommandSerializerVer11.java
new file mode 100644
index 0000000..24b7643
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModCommandSerializerVer11.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupModCommand;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupModCommandSerializerVer11 {
+
+    public final static short ADD_VAL = (short) 0x0;
+    public final static short MODIFY_VAL = (short) 0x1;
+    public final static short DELETE_VAL = (short) 0x2;
+
+    public static OFGroupModCommand readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupModCommand e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupModCommand e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFGroupModCommand ofWireValue(short val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFGroupModCommand.ADD;
+            case MODIFY_VAL:
+                return OFGroupModCommand.MODIFY;
+            case DELETE_VAL:
+                return OFGroupModCommand.DELETE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupModCommand in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFGroupModCommand e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupModCommand in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModFailedCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModFailedCodeSerializerVer11.java
new file mode 100644
index 0000000..575aa8a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModFailedCodeSerializerVer11.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupModFailedCodeSerializerVer11 {
+
+    public final static short GROUP_EXISTS_VAL = (short) 0x0;
+    public final static short INVALID_GROUP_VAL = (short) 0x1;
+    public final static short WEIGHT_UNSUPPORTED_VAL = (short) 0x2;
+    public final static short OUT_OF_GROUPS_VAL = (short) 0x3;
+    public final static short OUT_OF_BUCKETS_VAL = (short) 0x4;
+    public final static short CHAINING_UNSUPPORTED_VAL = (short) 0x5;
+    public final static short WATCH_UNSUPPORTED_VAL = (short) 0x6;
+    public final static short LOOP_VAL = (short) 0x7;
+    public final static short UNKNOWN_GROUP_VAL = (short) 0x8;
+
+    public static OFGroupModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFGroupModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case GROUP_EXISTS_VAL:
+                return OFGroupModFailedCode.GROUP_EXISTS;
+            case INVALID_GROUP_VAL:
+                return OFGroupModFailedCode.INVALID_GROUP;
+            case WEIGHT_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.WEIGHT_UNSUPPORTED;
+            case OUT_OF_GROUPS_VAL:
+                return OFGroupModFailedCode.OUT_OF_GROUPS;
+            case OUT_OF_BUCKETS_VAL:
+                return OFGroupModFailedCode.OUT_OF_BUCKETS;
+            case CHAINING_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.CHAINING_UNSUPPORTED;
+            case WATCH_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.WATCH_UNSUPPORTED;
+            case LOOP_VAL:
+                return OFGroupModFailedCode.LOOP;
+            case UNKNOWN_GROUP_VAL:
+                return OFGroupModFailedCode.UNKNOWN_GROUP;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupModFailedCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFGroupModFailedCode e) {
+        switch(e) {
+            case GROUP_EXISTS:
+                return GROUP_EXISTS_VAL;
+            case INVALID_GROUP:
+                return INVALID_GROUP_VAL;
+            case WEIGHT_UNSUPPORTED:
+                return WEIGHT_UNSUPPORTED_VAL;
+            case OUT_OF_GROUPS:
+                return OUT_OF_GROUPS_VAL;
+            case OUT_OF_BUCKETS:
+                return OUT_OF_BUCKETS_VAL;
+            case CHAINING_UNSUPPORTED:
+                return CHAINING_UNSUPPORTED_VAL;
+            case WATCH_UNSUPPORTED:
+                return WATCH_UNSUPPORTED_VAL;
+            case LOOP:
+                return LOOP_VAL;
+            case UNKNOWN_GROUP:
+                return UNKNOWN_GROUP_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupModFailedCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModFailedErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModFailedErrorMsgVer11.java
new file mode 100644
index 0000000..3654e87
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModFailedErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupModFailedErrorMsgVer11 implements OFGroupModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupModFailedErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupModFailedErrorMsgVer11(long xid, OFGroupModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFGroupModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupModFailedErrorMsg.Builder {
+        final OFGroupModFailedErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFGroupModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFGroupModFailedErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setCode(OFGroupModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFGroupModFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFGroupModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setCode(OFGroupModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFGroupModFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupModFailedErrorMsg> {
+        @Override
+        public OFGroupModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 6
+            short errType = bb.readShort();
+            if(errType != (short) 0x6)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.GROUP_MOD_FAILED(6), got="+errType);
+            OFGroupModFailedCode code = OFGroupModFailedCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFGroupModFailedErrorMsgVer11 groupModFailedErrorMsgVer11 = new OFGroupModFailedErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupModFailedErrorMsgVer11);
+            return groupModFailedErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupModFailedErrorMsgVer11Funnel FUNNEL = new OFGroupModFailedErrorMsgVer11Funnel();
+    static class OFGroupModFailedErrorMsgVer11Funnel implements Funnel<OFGroupModFailedErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupModFailedErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 6
+            sink.putShort((short) 0x6);
+            OFGroupModFailedCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupModFailedErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupModFailedErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 6
+            bb.writeShort((short) 0x6);
+            OFGroupModFailedCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupModFailedErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupModFailedErrorMsgVer11 other = (OFGroupModFailedErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModVer11.java
new file mode 100644
index 0000000..1bca634
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModVer11.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFGroupModVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFGroupModVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFGroupMod> {
+        @Override
+        public OFGroupMod readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short command = bb.readShort();
+            bb.readerIndex(start);
+            switch(command) {
+               case (short) 0x0:
+                   // discriminator value OFGroupModCommand.ADD=0 for class OFGroupAddVer11
+                   return OFGroupAddVer11.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFGroupModCommand.DELETE=2 for class OFGroupDeleteVer11
+                   return OFGroupDeleteVer11.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFGroupModCommand.MODIFY=1 for class OFGroupModifyVer11
+                   return OFGroupModifyVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator command of class OFGroupModVer11: " + command);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModifyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModifyVer11.java
new file mode 100644
index 0000000..1cf6650
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupModifyVer11.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupModifyVer11 implements OFGroupModify {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupModifyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupModifyVer11(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupModify.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupModify.Builder {
+        final OFGroupModifyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupModifyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupModify.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupModify build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupModifyVer11(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupModify.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupModify.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupModify build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupModifyVer11(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupModify> {
+        @Override
+        public OFGroupModify readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 1
+            short command = bb.readShort();
+            if(command != (short) 0x1)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.MODIFY(1), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer11.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer11.READER);
+
+            OFGroupModifyVer11 groupModifyVer11 = new OFGroupModifyVer11(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupModifyVer11);
+            return groupModifyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupModifyVer11Funnel FUNNEL = new OFGroupModifyVer11Funnel();
+    static class OFGroupModifyVer11Funnel implements Funnel<OFGroupModifyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupModifyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 1
+            sink.putShort((short) 0x1);
+            OFGroupTypeSerializerVer11.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupModifyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupModifyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 1
+            bb.writeShort((short) 0x1);
+            OFGroupTypeSerializerVer11.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupModifyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupModifyVer11 other = (OFGroupModifyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsEntryVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsEntryVer11.java
new file mode 100644
index 0000000..13b761c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsEntryVer11.java
@@ -0,0 +1,516 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsEntryVer11 implements OFGroupStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsEntryVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 32;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static long DEFAULT_REF_COUNT = 0x0L;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static List<OFBucketCounter> DEFAULT_BUCKET_STATS = ImmutableList.<OFBucketCounter>of();
+
+    // OF message fields
+    private final OFGroup group;
+    private final long refCount;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final List<OFBucketCounter> bucketStats;
+//
+    // Immutable default instance
+    final static OFGroupStatsEntryVer11 DEFAULT = new OFGroupStatsEntryVer11(
+        DEFAULT_GROUP_ID, DEFAULT_REF_COUNT, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_BUCKET_STATS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsEntryVer11(OFGroup group, long refCount, U64 packetCount, U64 byteCount, List<OFBucketCounter> bucketStats) {
+        this.group = group;
+        this.refCount = refCount;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.bucketStats = bucketStats;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFGroupStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsEntry.Builder {
+        final OFGroupStatsEntryVer11 parentMessage;
+
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean refCountSet;
+        private long refCount;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean bucketStatsSet;
+        private List<OFBucketCounter> bucketStats;
+
+        BuilderWithParent(OFGroupStatsEntryVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setRefCount(long refCount) {
+        this.refCount = refCount;
+        this.refCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setBucketStats(List<OFBucketCounter> bucketStats) {
+        this.bucketStats = bucketStats;
+        this.bucketStatsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFGroupStatsEntry build() {
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                long refCount = this.refCountSet ? this.refCount : parentMessage.refCount;
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                List<OFBucketCounter> bucketStats = this.bucketStatsSet ? this.bucketStats : parentMessage.bucketStats;
+                if(bucketStats == null)
+                    throw new NullPointerException("Property bucketStats must not be null");
+
+                //
+                return new OFGroupStatsEntryVer11(
+                    group,
+                    refCount,
+                    packetCount,
+                    byteCount,
+                    bucketStats
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsEntry.Builder {
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean refCountSet;
+        private long refCount;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean bucketStatsSet;
+        private List<OFBucketCounter> bucketStats;
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setRefCount(long refCount) {
+        this.refCount = refCount;
+        this.refCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setBucketStats(List<OFBucketCounter> bucketStats) {
+        this.bucketStats = bucketStats;
+        this.bucketStatsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFGroupStatsEntry build() {
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            long refCount = this.refCountSet ? this.refCount : DEFAULT_REF_COUNT;
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            List<OFBucketCounter> bucketStats = this.bucketStatsSet ? this.bucketStats : DEFAULT_BUCKET_STATS;
+            if(bucketStats == null)
+                throw new NullPointerException("Property bucketStats must not be null");
+
+
+            return new OFGroupStatsEntryVer11(
+                    group,
+                    refCount,
+                    packetCount,
+                    byteCount,
+                    bucketStats
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsEntry> {
+        @Override
+        public OFGroupStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            long refCount = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            List<OFBucketCounter> bucketStats = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketCounterVer11.READER);
+
+            OFGroupStatsEntryVer11 groupStatsEntryVer11 = new OFGroupStatsEntryVer11(
+                    group,
+                      refCount,
+                      packetCount,
+                      byteCount,
+                      bucketStats
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsEntryVer11);
+            return groupStatsEntryVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsEntryVer11Funnel FUNNEL = new OFGroupStatsEntryVer11Funnel();
+    static class OFGroupStatsEntryVer11Funnel implements Funnel<OFGroupStatsEntryVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsEntryVer11 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            // skip pad (2 bytes)
+            message.group.putTo(sink);
+            sink.putLong(message.refCount);
+            // skip pad (4 bytes)
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            FunnelUtils.putList(message.bucketStats, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsEntryVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsEntryVer11 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.group.write4Bytes(bb);
+            bb.writeInt(U32.t(message.refCount));
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            ChannelUtils.writeList(bb, message.bucketStats);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsEntryVer11(");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("refCount=").append(refCount);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("bucketStats=").append(bucketStats);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsEntryVer11 other = (OFGroupStatsEntryVer11) obj;
+
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if( refCount != other.refCount)
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (bucketStats == null) {
+            if (other.bucketStats != null)
+                return false;
+        } else if (!bucketStats.equals(other.bucketStats))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime *  (int) (refCount ^ (refCount >>> 32));
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((bucketStats == null) ? 0 : bucketStats.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsReplyVer11.java
new file mode 100644
index 0000000..b55588d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsReplyVer11.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsReplyVer11 implements OFGroupStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFGroupStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFGroupStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFGroupStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFGroupStatsReplyVer11 DEFAULT = new OFGroupStatsReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsReplyVer11(long xid, Set<OFStatsReplyFlags> flags, List<OFGroupStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFGroupStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsReply.Builder {
+        final OFGroupStatsReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupStatsEntry> entries;
+
+        BuilderWithParent(OFGroupStatsReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setEntries(List<OFGroupStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFGroupStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFGroupStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setEntries(List<OFGroupStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFGroupStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFGroupStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsReply> {
+        @Override
+        public OFGroupStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 6
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x6)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP(6), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFGroupStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFGroupStatsEntryVer11.READER);
+
+            OFGroupStatsReplyVer11 groupStatsReplyVer11 = new OFGroupStatsReplyVer11(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsReplyVer11);
+            return groupStatsReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsReplyVer11Funnel FUNNEL = new OFGroupStatsReplyVer11Funnel();
+    static class OFGroupStatsReplyVer11Funnel implements Funnel<OFGroupStatsReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 6
+            sink.putShort((short) 0x6);
+            OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 6
+            bb.writeShort((short) 0x6);
+            OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsReplyVer11 other = (OFGroupStatsReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsRequestVer11.java
new file mode 100644
index 0000000..59f5bf9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupStatsRequestVer11.java
@@ -0,0 +1,410 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsRequestVer11 implements OFGroupStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFGroup group;
+//
+    // Immutable default instance
+    final static OFGroupStatsRequestVer11 DEFAULT = new OFGroupStatsRequestVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_GROUP_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsRequestVer11(long xid, Set<OFStatsRequestFlags> flags, OFGroup group) {
+        this.xid = xid;
+        this.flags = flags;
+        this.group = group;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+
+
+    public OFGroupStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsRequest.Builder {
+        final OFGroupStatsRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean groupSet;
+        private OFGroup group;
+
+        BuilderWithParent(OFGroupStatsRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+
+                //
+                return new OFGroupStatsRequestVer11(
+                    xid,
+                    flags,
+                    group
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean groupSet;
+        private OFGroup group;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+
+
+            return new OFGroupStatsRequestVer11(
+                    xid,
+                    flags,
+                    group
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsRequest> {
+        @Override
+        public OFGroupStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 6
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x6)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP(6), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFGroupStatsRequestVer11 groupStatsRequestVer11 = new OFGroupStatsRequestVer11(
+                    xid,
+                      flags,
+                      group
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsRequestVer11);
+            return groupStatsRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsRequestVer11Funnel FUNNEL = new OFGroupStatsRequestVer11Funnel();
+    static class OFGroupStatsRequestVer11Funnel implements Funnel<OFGroupStatsRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 6
+            sink.putShort((short) 0x6);
+            OFStatsRequestFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.group.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 6
+            bb.writeShort((short) 0x6);
+            OFStatsRequestFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.group.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsRequestVer11 other = (OFGroupStatsRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupTypeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupTypeSerializerVer11.java
new file mode 100644
index 0000000..0801791
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFGroupTypeSerializerVer11.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupTypeSerializerVer11 {
+
+    public final static byte ALL_VAL = (byte) 0x0;
+    public final static byte SELECT_VAL = (byte) 0x1;
+    public final static byte INDIRECT_VAL = (byte) 0x2;
+    public final static byte FF_VAL = (byte) 0x3;
+
+    public static OFGroupType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupType e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupType e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFGroupType ofWireValue(byte val) {
+        switch(val) {
+            case ALL_VAL:
+                return OFGroupType.ALL;
+            case SELECT_VAL:
+                return OFGroupType.SELECT;
+            case INDIRECT_VAL:
+                return OFGroupType.INDIRECT;
+            case FF_VAL:
+                return OFGroupType.FF;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupType in version 1.1: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFGroupType e) {
+        switch(e) {
+            case ALL:
+                return ALL_VAL;
+            case SELECT:
+                return SELECT_VAL;
+            case INDIRECT:
+                return INDIRECT_VAL;
+            case FF:
+                return FF_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupType in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloFailedCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloFailedCodeSerializerVer11.java
new file mode 100644
index 0000000..113aad6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloFailedCodeSerializerVer11.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFHelloFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFHelloFailedCodeSerializerVer11 {
+
+    public final static short INCOMPATIBLE_VAL = (short) 0x0;
+    public final static short EPERM_VAL = (short) 0x1;
+
+    public static OFHelloFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFHelloFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFHelloFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFHelloFailedCode ofWireValue(short val) {
+        switch(val) {
+            case INCOMPATIBLE_VAL:
+                return OFHelloFailedCode.INCOMPATIBLE;
+            case EPERM_VAL:
+                return OFHelloFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFHelloFailedCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFHelloFailedCode e) {
+        switch(e) {
+            case INCOMPATIBLE:
+                return INCOMPATIBLE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFHelloFailedCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloFailedErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloFailedErrorMsgVer11.java
new file mode 100644
index 0000000..6a69c0d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloFailedErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloFailedErrorMsgVer11 implements OFHelloFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloFailedErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFHelloFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloFailedErrorMsgVer11(long xid, OFHelloFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFHelloFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHelloFailedErrorMsg.Builder {
+        final OFHelloFailedErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFHelloFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFHelloFailedErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setCode(OFHelloFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFHelloFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFHelloFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFHelloFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFHelloFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFHelloFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setCode(OFHelloFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFHelloFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFHelloFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHelloFailedErrorMsg> {
+        @Override
+        public OFHelloFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 0
+            short errType = bb.readShort();
+            if(errType != (short) 0x0)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.HELLO_FAILED(0), got="+errType);
+            OFHelloFailedCode code = OFHelloFailedCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFHelloFailedErrorMsgVer11 helloFailedErrorMsgVer11 = new OFHelloFailedErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloFailedErrorMsgVer11);
+            return helloFailedErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloFailedErrorMsgVer11Funnel FUNNEL = new OFHelloFailedErrorMsgVer11Funnel();
+    static class OFHelloFailedErrorMsgVer11Funnel implements Funnel<OFHelloFailedErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloFailedErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 0
+            sink.putShort((short) 0x0);
+            OFHelloFailedCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloFailedErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloFailedErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 0
+            bb.writeShort((short) 0x0);
+            OFHelloFailedCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloFailedErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloFailedErrorMsgVer11 other = (OFHelloFailedErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloVer11.java
new file mode 100644
index 0000000..b1608b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFHelloVer11.java
@@ -0,0 +1,292 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloVer11 implements OFHello {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFHelloVer11 DEFAULT = new OFHelloVer11(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloVer11(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.1");
+    }
+
+
+
+    public OFHello.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHello.Builder {
+        final OFHelloVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFHelloVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHello.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.1");
+    }
+
+    @Override
+    public OFHello.Builder setElements(List<OFHelloElem> elements) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property elements not supported in version 1.1");
+    }
+
+
+        @Override
+        public OFHello build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFHelloVer11(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFHello.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHello.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.1");
+    }
+
+    @Override
+    public OFHello.Builder setElements(List<OFHelloElem> elements) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property elements not supported in version 1.1");
+    }
+//
+        @Override
+        public OFHello build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFHelloVer11(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHello> {
+        @Override
+        public OFHello readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 0
+            byte type = bb.readByte();
+            if(type != (byte) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFType.HELLO(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFHelloVer11 helloVer11 = new OFHelloVer11(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloVer11);
+            return helloVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloVer11Funnel FUNNEL = new OFHelloVer11Funnel();
+    static class OFHelloVer11Funnel implements Funnel<OFHelloVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 0
+            sink.putByte((byte) 0x0);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 0
+            bb.writeByte((byte) 0x0);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloVer11(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloVer11 other = (OFHelloVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionApplyActionsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionApplyActionsVer11.java
new file mode 100644
index 0000000..0a70421
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionApplyActionsVer11.java
@@ -0,0 +1,279 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionApplyActionsVer11 implements OFInstructionApplyActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionApplyActionsVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFInstructionApplyActionsVer11 DEFAULT = new OFInstructionApplyActionsVer11(
+        DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionApplyActionsVer11(List<OFAction> actions) {
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFInstructionApplyActions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionApplyActions.Builder {
+        final OFInstructionApplyActionsVer11 parentMessage;
+
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFInstructionApplyActionsVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionApplyActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFInstructionApplyActions build() {
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFInstructionApplyActionsVer11(
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionApplyActions.Builder {
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionApplyActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFInstructionApplyActions build() {
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFInstructionApplyActionsVer11(
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionApplyActions> {
+        @Override
+        public OFInstructionApplyActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 4
+            short type = bb.readShort();
+            if(type != (short) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.APPLY_ACTIONS(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer11.READER);
+
+            OFInstructionApplyActionsVer11 instructionApplyActionsVer11 = new OFInstructionApplyActionsVer11(
+                    actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionApplyActionsVer11);
+            return instructionApplyActionsVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionApplyActionsVer11Funnel FUNNEL = new OFInstructionApplyActionsVer11Funnel();
+    static class OFInstructionApplyActionsVer11Funnel implements Funnel<OFInstructionApplyActionsVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionApplyActionsVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 4
+            sink.putShort((short) 0x4);
+            // FIXME: skip funnel of length
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionApplyActionsVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionApplyActionsVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 4
+            bb.writeShort((short) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionApplyActionsVer11(");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionApplyActionsVer11 other = (OFInstructionApplyActionsVer11) obj;
+
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionClearActionsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionClearActionsVer11.java
new file mode 100644
index 0000000..3969806
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionClearActionsVer11.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionClearActionsVer11 implements OFInstructionClearActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionClearActionsVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionClearActionsVer11 DEFAULT = new OFInstructionClearActionsVer11(
+
+    );
+
+    final static OFInstructionClearActionsVer11 INSTANCE = new OFInstructionClearActionsVer11();
+    // private empty constructor - use shared instance!
+    private OFInstructionClearActionsVer11() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.CLEAR_ACTIONS;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionClearActions.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionClearActionsVer11 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionClearActions> {
+        @Override
+        public OFInstructionClearActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 5
+            short type = bb.readShort();
+            if(type != (short) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.CLEAR_ACTIONS(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionClearActionsVer11Funnel FUNNEL = new OFInstructionClearActionsVer11Funnel();
+    static class OFInstructionClearActionsVer11Funnel implements Funnel<OFInstructionClearActionsVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionClearActionsVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 5
+            sink.putShort((short) 0x5);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionClearActionsVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionClearActionsVer11 message) {
+            // fixed value property type = 5
+            bb.writeShort((short) 0x5);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionClearActionsVer11(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionExperimenterVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionExperimenterVer11.java
new file mode 100644
index 0000000..7afb102
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionExperimenterVer11.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionExperimenterVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFInstructionExperimenterVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstructionExperimenter> {
+        @Override
+        public OFInstructionExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFInstructionExperimenterVer11: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionGotoTableVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionGotoTableVer11.java
new file mode 100644
index 0000000..269ba84
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionGotoTableVer11.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionGotoTableVer11 implements OFInstructionGotoTable {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionGotoTableVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 8;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+
+    // OF message fields
+    private final TableId tableId;
+//
+    // Immutable default instance
+    final static OFInstructionGotoTableVer11 DEFAULT = new OFInstructionGotoTableVer11(
+        DEFAULT_TABLE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionGotoTableVer11(TableId tableId) {
+        this.tableId = tableId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFInstructionGotoTable.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionGotoTable.Builder {
+        final OFInstructionGotoTableVer11 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+
+        BuilderWithParent(OFInstructionGotoTableVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFInstructionGotoTable.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFInstructionGotoTable build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+
+                //
+                return new OFInstructionGotoTableVer11(
+                    tableId
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionGotoTable.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFInstructionGotoTable.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFInstructionGotoTable build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+
+
+            return new OFInstructionGotoTableVer11(
+                    tableId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionGotoTable> {
+        @Override
+        public OFInstructionGotoTable readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.GOTO_TABLE(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFInstructionGotoTableVer11 instructionGotoTableVer11 = new OFInstructionGotoTableVer11(
+                    tableId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionGotoTableVer11);
+            return instructionGotoTableVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionGotoTableVer11Funnel FUNNEL = new OFInstructionGotoTableVer11Funnel();
+    static class OFInstructionGotoTableVer11Funnel implements Funnel<OFInstructionGotoTableVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionGotoTableVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionGotoTableVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionGotoTableVer11 message) {
+            // fixed value property type = 1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionGotoTableVer11(");
+        b.append("tableId=").append(tableId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionGotoTableVer11 other = (OFInstructionGotoTableVer11) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionIdsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionIdsVer11.java
new file mode 100644
index 0000000..b3eaf56
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionIdsVer11.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFInstructionIdsVer11 implements OFInstructionIds {
+    public final static OFInstructionIdsVer11 INSTANCE = new OFInstructionIdsVer11();
+
+
+
+
+    public OFInstructionIdApplyActions applyActions() {
+        throw new UnsupportedOperationException("OFInstructionIdApplyActions not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnArpOffload bsnArpOffload() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnArpOffload not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnDeny bsnDeny() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDeny not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnDhcpOffload bsnDhcpOffload() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDhcpOffload not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableSplitHorizonCheck not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnDisableSrcMacCheck bsnDisableSrcMacCheck() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableSrcMacCheck not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnDisableVlanCounters bsnDisableVlanCounters() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableVlanCounters not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnPacketOfDeath bsnPacketOfDeath() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPacketOfDeath not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnPermit bsnPermit() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPermit not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnPrioritizePdus bsnPrioritizePdus() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPrioritizePdus not supported in version 1.1");
+    }
+
+    public OFInstructionIdBsnRequireVlanXlate bsnRequireVlanXlate() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnRequireVlanXlate not supported in version 1.1");
+    }
+
+    public OFInstructionIdClearActions clearActions() {
+        throw new UnsupportedOperationException("OFInstructionIdClearActions not supported in version 1.1");
+    }
+
+    public OFInstructionIdGotoTable gotoTable() {
+        throw new UnsupportedOperationException("OFInstructionIdGotoTable not supported in version 1.1");
+    }
+
+    public OFInstructionIdMeter meter() {
+        throw new UnsupportedOperationException("OFInstructionIdMeter not supported in version 1.1");
+    }
+
+    public OFInstructionIdWriteActions writeActions() {
+        throw new UnsupportedOperationException("OFInstructionIdWriteActions not supported in version 1.1");
+    }
+
+    public OFInstructionIdWriteMetadata writeMetadata() {
+        throw new UnsupportedOperationException("OFInstructionIdWriteMetadata not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFInstructionId> getReader() {
+        throw new UnsupportedOperationException("Reader<OFInstructionId> not supported in version 1.1");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionTypeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionTypeSerializerVer11.java
new file mode 100644
index 0000000..61dbe34
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionTypeSerializerVer11.java
@@ -0,0 +1,108 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFInstructionType;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFInstructionTypeSerializerVer11 {
+
+    public final static short GOTO_TABLE_VAL = (short) 0x1;
+    public final static short WRITE_METADATA_VAL = (short) 0x2;
+    public final static short WRITE_ACTIONS_VAL = (short) 0x3;
+    public final static short APPLY_ACTIONS_VAL = (short) 0x4;
+    public final static short CLEAR_ACTIONS_VAL = (short) 0x5;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static Set<OFInstructionType> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFInstructionType> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFInstructionType> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFInstructionType> ofWireValue(short val) {
+        EnumSet<OFInstructionType> set = EnumSet.noneOf(OFInstructionType.class);
+
+        if((val & GOTO_TABLE_VAL) != 0)
+            set.add(OFInstructionType.GOTO_TABLE);
+        if((val & WRITE_METADATA_VAL) != 0)
+            set.add(OFInstructionType.WRITE_METADATA);
+        if((val & WRITE_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.WRITE_ACTIONS);
+        if((val & APPLY_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.APPLY_ACTIONS);
+        if((val & CLEAR_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.CLEAR_ACTIONS);
+        if((val & EXPERIMENTER_VAL) != 0)
+            set.add(OFInstructionType.EXPERIMENTER);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFInstructionType> set) {
+        short wireValue = 0;
+
+        for(OFInstructionType e: set) {
+            switch(e) {
+                case GOTO_TABLE:
+                    wireValue |= GOTO_TABLE_VAL;
+                    break;
+                case WRITE_METADATA:
+                    wireValue |= WRITE_METADATA_VAL;
+                    break;
+                case WRITE_ACTIONS:
+                    wireValue |= WRITE_ACTIONS_VAL;
+                    break;
+                case APPLY_ACTIONS:
+                    wireValue |= APPLY_ACTIONS_VAL;
+                    break;
+                case CLEAR_ACTIONS:
+                    wireValue |= CLEAR_ACTIONS_VAL;
+                    break;
+                case EXPERIMENTER:
+                    wireValue |= EXPERIMENTER_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFInstructionType in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionVer11.java
new file mode 100644
index 0000000..6081bc1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionVer11.java
@@ -0,0 +1,68 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFInstructionVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstruction> {
+        @Override
+        public OFInstruction readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x4:
+                   // discriminator value OFInstructionType.APPLY_ACTIONS=4 for class OFInstructionApplyActionsVer11
+                   return OFInstructionApplyActionsVer11.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFInstructionType.CLEAR_ACTIONS=5 for class OFInstructionClearActionsVer11
+                   return OFInstructionClearActionsVer11.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFInstructionType.EXPERIMENTER=65535 for class OFInstructionExperimenterVer11
+                   return OFInstructionExperimenterVer11.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFInstructionType.GOTO_TABLE=1 for class OFInstructionGotoTableVer11
+                   return OFInstructionGotoTableVer11.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFInstructionType.WRITE_ACTIONS=3 for class OFInstructionWriteActionsVer11
+                   return OFInstructionWriteActionsVer11.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFInstructionType.WRITE_METADATA=2 for class OFInstructionWriteMetadataVer11
+                   return OFInstructionWriteMetadataVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFInstructionVer11: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionWriteActionsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionWriteActionsVer11.java
new file mode 100644
index 0000000..0736e5d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionWriteActionsVer11.java
@@ -0,0 +1,279 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionWriteActionsVer11 implements OFInstructionWriteActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionWriteActionsVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFInstructionWriteActionsVer11 DEFAULT = new OFInstructionWriteActionsVer11(
+        DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionWriteActionsVer11(List<OFAction> actions) {
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFInstructionWriteActions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionWriteActions.Builder {
+        final OFInstructionWriteActionsVer11 parentMessage;
+
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFInstructionWriteActionsVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionWriteActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFInstructionWriteActions build() {
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFInstructionWriteActionsVer11(
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionWriteActions.Builder {
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionWriteActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFInstructionWriteActions build() {
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFInstructionWriteActionsVer11(
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionWriteActions> {
+        @Override
+        public OFInstructionWriteActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 3
+            short type = bb.readShort();
+            if(type != (short) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_ACTIONS(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer11.READER);
+
+            OFInstructionWriteActionsVer11 instructionWriteActionsVer11 = new OFInstructionWriteActionsVer11(
+                    actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionWriteActionsVer11);
+            return instructionWriteActionsVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionWriteActionsVer11Funnel FUNNEL = new OFInstructionWriteActionsVer11Funnel();
+    static class OFInstructionWriteActionsVer11Funnel implements Funnel<OFInstructionWriteActionsVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionWriteActionsVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 3
+            sink.putShort((short) 0x3);
+            // FIXME: skip funnel of length
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionWriteActionsVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionWriteActionsVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 3
+            bb.writeShort((short) 0x3);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionWriteActionsVer11(");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionWriteActionsVer11 other = (OFInstructionWriteActionsVer11) obj;
+
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionWriteMetadataVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionWriteMetadataVer11.java
new file mode 100644
index 0000000..c001f80
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionWriteMetadataVer11.java
@@ -0,0 +1,326 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionWriteMetadataVer11 implements OFInstructionWriteMetadata {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionWriteMetadataVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 24;
+
+        private final static U64 DEFAULT_METADATA = U64.ZERO;
+        private final static U64 DEFAULT_METADATA_MASK = U64.ZERO;
+
+    // OF message fields
+    private final U64 metadata;
+    private final U64 metadataMask;
+//
+    // Immutable default instance
+    final static OFInstructionWriteMetadataVer11 DEFAULT = new OFInstructionWriteMetadataVer11(
+        DEFAULT_METADATA, DEFAULT_METADATA_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionWriteMetadataVer11(U64 metadata, U64 metadataMask) {
+        this.metadata = metadata;
+        this.metadataMask = metadataMask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFInstructionWriteMetadata.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionWriteMetadata.Builder {
+        final OFInstructionWriteMetadataVer11 parentMessage;
+
+        // OF message fields
+        private boolean metadataSet;
+        private U64 metadata;
+        private boolean metadataMaskSet;
+        private U64 metadataMask;
+
+        BuilderWithParent(OFInstructionWriteMetadataVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadata(U64 metadata) {
+        this.metadata = metadata;
+        this.metadataSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadataMask(U64 metadataMask) {
+        this.metadataMask = metadataMask;
+        this.metadataMaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFInstructionWriteMetadata build() {
+                U64 metadata = this.metadataSet ? this.metadata : parentMessage.metadata;
+                if(metadata == null)
+                    throw new NullPointerException("Property metadata must not be null");
+                U64 metadataMask = this.metadataMaskSet ? this.metadataMask : parentMessage.metadataMask;
+                if(metadataMask == null)
+                    throw new NullPointerException("Property metadataMask must not be null");
+
+                //
+                return new OFInstructionWriteMetadataVer11(
+                    metadata,
+                    metadataMask
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionWriteMetadata.Builder {
+        // OF message fields
+        private boolean metadataSet;
+        private U64 metadata;
+        private boolean metadataMaskSet;
+        private U64 metadataMask;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadata(U64 metadata) {
+        this.metadata = metadata;
+        this.metadataSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadataMask(U64 metadataMask) {
+        this.metadataMask = metadataMask;
+        this.metadataMaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFInstructionWriteMetadata build() {
+            U64 metadata = this.metadataSet ? this.metadata : DEFAULT_METADATA;
+            if(metadata == null)
+                throw new NullPointerException("Property metadata must not be null");
+            U64 metadataMask = this.metadataMaskSet ? this.metadataMask : DEFAULT_METADATA_MASK;
+            if(metadataMask == null)
+                throw new NullPointerException("Property metadataMask must not be null");
+
+
+            return new OFInstructionWriteMetadataVer11(
+                    metadata,
+                    metadataMask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionWriteMetadata> {
+        @Override
+        public OFInstructionWriteMetadata readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_METADATA(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 metadata = U64.ofRaw(bb.readLong());
+            U64 metadataMask = U64.ofRaw(bb.readLong());
+
+            OFInstructionWriteMetadataVer11 instructionWriteMetadataVer11 = new OFInstructionWriteMetadataVer11(
+                    metadata,
+                      metadataMask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionWriteMetadataVer11);
+            return instructionWriteMetadataVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionWriteMetadataVer11Funnel FUNNEL = new OFInstructionWriteMetadataVer11Funnel();
+    static class OFInstructionWriteMetadataVer11Funnel implements Funnel<OFInstructionWriteMetadataVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionWriteMetadataVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            // skip pad (4 bytes)
+            message.metadata.putTo(sink);
+            message.metadataMask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionWriteMetadataVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionWriteMetadataVer11 message) {
+            // fixed value property type = 2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.metadata.getValue());
+            bb.writeLong(message.metadataMask.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionWriteMetadataVer11(");
+        b.append("metadata=").append(metadata);
+        b.append(", ");
+        b.append("metadataMask=").append(metadataMask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionWriteMetadataVer11 other = (OFInstructionWriteMetadataVer11) obj;
+
+        if (metadata == null) {
+            if (other.metadata != null)
+                return false;
+        } else if (!metadata.equals(other.metadata))
+            return false;
+        if (metadataMask == null) {
+            if (other.metadataMask != null)
+                return false;
+        } else if (!metadataMask.equals(other.metadataMask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
+        result = prime * result + ((metadataMask == null) ? 0 : metadataMask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionsVer11.java
new file mode 100644
index 0000000..f37fbfd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFInstructionsVer11.java
@@ -0,0 +1,131 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+
+
+public class OFInstructionsVer11 implements OFInstructions {
+    public final static OFInstructionsVer11 INSTANCE = new OFInstructionsVer11();
+
+
+
+
+    public OFInstructionApplyActions.Builder buildApplyActions() {
+        return new OFInstructionApplyActionsVer11.Builder();
+    }
+    public OFInstructionApplyActions applyActions(List<OFAction> actions) {
+        return new OFInstructionApplyActionsVer11(
+                actions
+                    );
+    }
+
+    public OFInstructionClearActions clearActions() {
+        return OFInstructionClearActionsVer11.INSTANCE;
+    }
+
+    public OFInstructionGotoTable.Builder buildGotoTable() {
+        return new OFInstructionGotoTableVer11.Builder();
+    }
+    public OFInstructionGotoTable gotoTable(TableId tableId) {
+        return new OFInstructionGotoTableVer11(
+                tableId
+                    );
+    }
+
+    public OFInstructionWriteActions.Builder buildWriteActions() {
+        return new OFInstructionWriteActionsVer11.Builder();
+    }
+    public OFInstructionWriteActions writeActions(List<OFAction> actions) {
+        return new OFInstructionWriteActionsVer11(
+                actions
+                    );
+    }
+
+    public OFInstructionWriteMetadata.Builder buildWriteMetadata() {
+        return new OFInstructionWriteMetadataVer11.Builder();
+    }
+    public OFInstructionWriteMetadata writeMetadata(U64 metadata, U64 metadataMask) {
+        return new OFInstructionWriteMetadataVer11(
+                metadata,
+                      metadataMask
+                    );
+    }
+
+    public OFInstructionBsnArpOffload bsnArpOffload() {
+        throw new UnsupportedOperationException("OFInstructionBsnArpOffload not supported in version 1.1");
+    }
+
+    public OFInstructionBsnDeny bsnDeny() {
+        throw new UnsupportedOperationException("OFInstructionBsnDeny not supported in version 1.1");
+    }
+
+    public OFInstructionBsnDhcpOffload bsnDhcpOffload() {
+        throw new UnsupportedOperationException("OFInstructionBsnDhcpOffload not supported in version 1.1");
+    }
+
+    public OFInstructionBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableSplitHorizonCheck not supported in version 1.1");
+    }
+
+    public OFInstructionBsnDisableSrcMacCheck bsnDisableSrcMacCheck() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableSrcMacCheck not supported in version 1.1");
+    }
+
+    public OFInstructionBsnDisableVlanCounters bsnDisableVlanCounters() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableVlanCounters not supported in version 1.1");
+    }
+
+    public OFInstructionBsnPacketOfDeath bsnPacketOfDeath() {
+        throw new UnsupportedOperationException("OFInstructionBsnPacketOfDeath not supported in version 1.1");
+    }
+
+    public OFInstructionBsnPermit bsnPermit() {
+        throw new UnsupportedOperationException("OFInstructionBsnPermit not supported in version 1.1");
+    }
+
+    public OFInstructionBsnPrioritizePdus bsnPrioritizePdus() {
+        throw new UnsupportedOperationException("OFInstructionBsnPrioritizePdus not supported in version 1.1");
+    }
+
+    public OFInstructionBsnRequireVlanXlate bsnRequireVlanXlate() {
+        throw new UnsupportedOperationException("OFInstructionBsnRequireVlanXlate not supported in version 1.1");
+    }
+
+    public OFInstructionMeter.Builder buildMeter() {
+        throw new UnsupportedOperationException("OFInstructionMeter not supported in version 1.1");
+    }
+    public OFInstructionMeter meter(long meterId) {
+        throw new UnsupportedOperationException("OFInstructionMeter not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFInstruction> getReader() {
+        return OFInstructionVer11.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMatchTypeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMatchTypeSerializerVer11.java
new file mode 100644
index 0000000..9cbe8c8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMatchTypeSerializerVer11.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFMatchType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFMatchTypeSerializerVer11 {
+
+    public final static short STANDARD_VAL = (short) 0x0;
+
+    public static OFMatchType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFMatchType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFMatchType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFMatchType ofWireValue(short val) {
+        switch(val) {
+            case STANDARD_VAL:
+                return OFMatchType.STANDARD;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFMatchType in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFMatchType e) {
+        switch(e) {
+            case STANDARD:
+                return STANDARD_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFMatchType in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMatchV2Ver11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMatchV2Ver11.java
new file mode 100644
index 0000000..65d5520
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMatchV2Ver11.java
@@ -0,0 +1,1478 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMatchV2Ver11 implements OFMatchV2 {
+    private static final Logger logger = LoggerFactory.getLogger(OFMatchV2Ver11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 88;
+
+        private final static OFPort DEFAULT_IN_PORT = OFPort.ANY;
+        private final static int DEFAULT_WILDCARDS = OFFlowWildcardsSerializerVer11.ALL_VAL;
+        private final static MacAddress DEFAULT_ETH_SRC = MacAddress.NONE;
+        private final static MacAddress DEFAULT_ETH_SRC_MASK = MacAddress.NONE;
+        private final static MacAddress DEFAULT_ETH_DST = MacAddress.NONE;
+        private final static MacAddress DEFAULT_ETH_DST_MASK = MacAddress.NONE;
+        private final static int DEFAULT_VLAN_VID = 0x0;
+        private final static short DEFAULT_VLAN_PCP = (short) 0x0;
+        private final static int DEFAULT_ETH_TYPE = 0x0;
+        private final static short DEFAULT_IP_DSCP = (short) 0x0;
+        private final static short DEFAULT_IP_PROTO = (short) 0x0;
+        private final static IPv4Address DEFAULT_IPV4_SRC = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_IPV4_SRC_MASK = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_IPV4_DST = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_IPV4_DST_MASK = IPv4Address.NONE;
+        private final static int DEFAULT_TCP_SRC = 0x0;
+        private final static int DEFAULT_TCP_DST = 0x0;
+        private final static long DEFAULT_MPLS_LABEL = 0x0L;
+        private final static short DEFAULT_MPLS_TC = (short) 0x0;
+        private final static U64 DEFAULT_METADATA = U64.ZERO;
+        private final static U64 DEFAULT_METADATA_MASK = U64.ZERO;
+
+    // OF message fields
+    private final OFPort inPort;
+    private final int wildcards;
+    private final MacAddress ethSrc;
+    private final MacAddress ethSrcMask;
+    private final MacAddress ethDst;
+    private final MacAddress ethDstMask;
+    private final int vlanVid;
+    private final short vlanPcp;
+    private final int ethType;
+    private final short ipDscp;
+    private final short ipProto;
+    private final IPv4Address ipv4Src;
+    private final IPv4Address ipv4SrcMask;
+    private final IPv4Address ipv4Dst;
+    private final IPv4Address ipv4DstMask;
+    private final int tcpSrc;
+    private final int tcpDst;
+    private final long mplsLabel;
+    private final short mplsTc;
+    private final U64 metadata;
+    private final U64 metadataMask;
+//
+    // Immutable default instance
+    final static OFMatchV2Ver11 DEFAULT = new OFMatchV2Ver11(
+        DEFAULT_IN_PORT, DEFAULT_WILDCARDS, DEFAULT_ETH_SRC, DEFAULT_ETH_SRC_MASK, DEFAULT_ETH_DST, DEFAULT_ETH_DST_MASK, DEFAULT_VLAN_VID, DEFAULT_VLAN_PCP, DEFAULT_ETH_TYPE, DEFAULT_IP_DSCP, DEFAULT_IP_PROTO, DEFAULT_IPV4_SRC, DEFAULT_IPV4_SRC_MASK, DEFAULT_IPV4_DST, DEFAULT_IPV4_DST_MASK, DEFAULT_TCP_SRC, DEFAULT_TCP_DST, DEFAULT_MPLS_LABEL, DEFAULT_MPLS_TC, DEFAULT_METADATA, DEFAULT_METADATA_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMatchV2Ver11(OFPort inPort, int wildcards, MacAddress ethSrc, MacAddress ethSrcMask, MacAddress ethDst, MacAddress ethDstMask, int vlanVid, short vlanPcp, int ethType, short ipDscp, short ipProto, IPv4Address ipv4Src, IPv4Address ipv4SrcMask, IPv4Address ipv4Dst, IPv4Address ipv4DstMask, int tcpSrc, int tcpDst, long mplsLabel, short mplsTc, U64 metadata, U64 metadataMask) {
+        this.inPort = inPort;
+        this.wildcards = wildcards;
+        this.ethSrc = ethSrc;
+        this.ethSrcMask = ethSrcMask;
+        this.ethDst = ethDst;
+        this.ethDstMask = ethDstMask;
+        this.vlanVid = vlanVid;
+        this.vlanPcp = vlanPcp;
+        this.ethType = ethType;
+        this.ipDscp = ipDscp;
+        this.ipProto = ipProto;
+        this.ipv4Src = ipv4Src;
+        this.ipv4SrcMask = ipv4SrcMask;
+        this.ipv4Dst = ipv4Dst;
+        this.ipv4DstMask = ipv4DstMask;
+        this.tcpSrc = tcpSrc;
+        this.tcpDst = tcpDst;
+        this.mplsLabel = mplsLabel;
+        this.mplsTc = mplsTc;
+        this.metadata = metadata;
+        this.metadataMask = metadataMask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public MacAddress getEthSrc() {
+        return ethSrc;
+    }
+
+    @Override
+    public MacAddress getEthSrcMask() {
+        return ethSrcMask;
+    }
+
+    @Override
+    public MacAddress getEthDst() {
+        return ethDst;
+    }
+
+    @Override
+    public MacAddress getEthDstMask() {
+        return ethDstMask;
+    }
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public short getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public int getEthType() {
+        return ethType;
+    }
+
+    @Override
+    public short getIpDscp() {
+        return ipDscp;
+    }
+
+    @Override
+    public short getIpProto() {
+        return ipProto;
+    }
+
+    @Override
+    public IPv4Address getIpv4Src() {
+        return ipv4Src;
+    }
+
+    @Override
+    public IPv4Address getIpv4SrcMask() {
+        return ipv4SrcMask;
+    }
+
+    @Override
+    public IPv4Address getIpv4Dst() {
+        return ipv4Dst;
+    }
+
+    @Override
+    public IPv4Address getIpv4DstMask() {
+        return ipv4DstMask;
+    }
+
+    @Override
+    public int getTcpSrc() {
+        return tcpSrc;
+    }
+
+    @Override
+    public int getTcpDst() {
+        return tcpDst;
+    }
+
+    @Override
+    public long getMplsLabel() {
+        return mplsLabel;
+    }
+
+    @Override
+    public short getMplsTc() {
+        return mplsTc;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    @Override
+    public <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isExact(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isFullyWildcarded(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isPartiallyMasked(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public Iterable<MatchField<?>> getMatchFields() {
+        throw new UnsupportedOperationException();
+    }
+
+    public OFMatchV2.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMatchV2.Builder {
+        final OFMatchV2Ver11 parentMessage;
+
+        // OF message fields
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean ethSrcSet;
+        private MacAddress ethSrc;
+        private boolean ethSrcMaskSet;
+        private MacAddress ethSrcMask;
+        private boolean ethDstSet;
+        private MacAddress ethDst;
+        private boolean ethDstMaskSet;
+        private MacAddress ethDstMask;
+        private boolean vlanVidSet;
+        private int vlanVid;
+        private boolean vlanPcpSet;
+        private short vlanPcp;
+        private boolean ethTypeSet;
+        private int ethType;
+        private boolean ipDscpSet;
+        private short ipDscp;
+        private boolean ipProtoSet;
+        private short ipProto;
+        private boolean ipv4SrcSet;
+        private IPv4Address ipv4Src;
+        private boolean ipv4SrcMaskSet;
+        private IPv4Address ipv4SrcMask;
+        private boolean ipv4DstSet;
+        private IPv4Address ipv4Dst;
+        private boolean ipv4DstMaskSet;
+        private IPv4Address ipv4DstMask;
+        private boolean tcpSrcSet;
+        private int tcpSrc;
+        private boolean tcpDstSet;
+        private int tcpDst;
+        private boolean mplsLabelSet;
+        private long mplsLabel;
+        private boolean mplsTcSet;
+        private short mplsTc;
+        private boolean metadataSet;
+        private U64 metadata;
+        private boolean metadataMaskSet;
+        private U64 metadataMask;
+
+        BuilderWithParent(OFMatchV2Ver11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFMatchV2.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFMatchV2.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthSrc() {
+        return ethSrc;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthSrc(MacAddress ethSrc) {
+        this.ethSrc = ethSrc;
+        this.ethSrcSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthSrcMask() {
+        return ethSrcMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthSrcMask(MacAddress ethSrcMask) {
+        this.ethSrcMask = ethSrcMask;
+        this.ethSrcMaskSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthDst() {
+        return ethDst;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthDst(MacAddress ethDst) {
+        this.ethDst = ethDst;
+        this.ethDstSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthDstMask() {
+        return ethDstMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthDstMask(MacAddress ethDstMask) {
+        this.ethDstMask = ethDstMask;
+        this.ethDstMaskSet = true;
+        return this;
+    }
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFMatchV2.Builder setVlanVid(int vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public short getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFMatchV2.Builder setVlanPcp(short vlanPcp) {
+        this.vlanPcp = vlanPcp;
+        this.vlanPcpSet = true;
+        return this;
+    }
+    @Override
+    public int getEthType() {
+        return ethType;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthType(int ethType) {
+        this.ethType = ethType;
+        this.ethTypeSet = true;
+        return this;
+    }
+    @Override
+    public short getIpDscp() {
+        return ipDscp;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpDscp(short ipDscp) {
+        this.ipDscp = ipDscp;
+        this.ipDscpSet = true;
+        return this;
+    }
+    @Override
+    public short getIpProto() {
+        return ipProto;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpProto(short ipProto) {
+        this.ipProto = ipProto;
+        this.ipProtoSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Src() {
+        return ipv4Src;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpv4Src(IPv4Address ipv4Src) {
+        this.ipv4Src = ipv4Src;
+        this.ipv4SrcSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4SrcMask() {
+        return ipv4SrcMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpv4SrcMask(IPv4Address ipv4SrcMask) {
+        this.ipv4SrcMask = ipv4SrcMask;
+        this.ipv4SrcMaskSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Dst() {
+        return ipv4Dst;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpv4Dst(IPv4Address ipv4Dst) {
+        this.ipv4Dst = ipv4Dst;
+        this.ipv4DstSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4DstMask() {
+        return ipv4DstMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpv4DstMask(IPv4Address ipv4DstMask) {
+        this.ipv4DstMask = ipv4DstMask;
+        this.ipv4DstMaskSet = true;
+        return this;
+    }
+    @Override
+    public int getTcpSrc() {
+        return tcpSrc;
+    }
+
+    @Override
+    public OFMatchV2.Builder setTcpSrc(int tcpSrc) {
+        this.tcpSrc = tcpSrc;
+        this.tcpSrcSet = true;
+        return this;
+    }
+    @Override
+    public int getTcpDst() {
+        return tcpDst;
+    }
+
+    @Override
+    public OFMatchV2.Builder setTcpDst(int tcpDst) {
+        this.tcpDst = tcpDst;
+        this.tcpDstSet = true;
+        return this;
+    }
+    @Override
+    public long getMplsLabel() {
+        return mplsLabel;
+    }
+
+    @Override
+    public OFMatchV2.Builder setMplsLabel(long mplsLabel) {
+        this.mplsLabel = mplsLabel;
+        this.mplsLabelSet = true;
+        return this;
+    }
+    @Override
+    public short getMplsTc() {
+        return mplsTc;
+    }
+
+    @Override
+    public OFMatchV2.Builder setMplsTc(short mplsTc) {
+        this.mplsTc = mplsTc;
+        this.mplsTcSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public OFMatchV2.Builder setMetadata(U64 metadata) {
+        this.metadata = metadata;
+        this.metadataSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setMetadataMask(U64 metadataMask) {
+        this.metadataMask = metadataMask;
+        this.metadataMaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFMatchV2 build() {
+                OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort;
+                if(inPort == null)
+                    throw new NullPointerException("Property inPort must not be null");
+                int wildcards = this.wildcardsSet ? this.wildcards : parentMessage.wildcards;
+                MacAddress ethSrc = this.ethSrcSet ? this.ethSrc : parentMessage.ethSrc;
+                if(ethSrc == null)
+                    throw new NullPointerException("Property ethSrc must not be null");
+                MacAddress ethSrcMask = this.ethSrcMaskSet ? this.ethSrcMask : parentMessage.ethSrcMask;
+                if(ethSrcMask == null)
+                    throw new NullPointerException("Property ethSrcMask must not be null");
+                MacAddress ethDst = this.ethDstSet ? this.ethDst : parentMessage.ethDst;
+                if(ethDst == null)
+                    throw new NullPointerException("Property ethDst must not be null");
+                MacAddress ethDstMask = this.ethDstMaskSet ? this.ethDstMask : parentMessage.ethDstMask;
+                if(ethDstMask == null)
+                    throw new NullPointerException("Property ethDstMask must not be null");
+                int vlanVid = this.vlanVidSet ? this.vlanVid : parentMessage.vlanVid;
+                short vlanPcp = this.vlanPcpSet ? this.vlanPcp : parentMessage.vlanPcp;
+                int ethType = this.ethTypeSet ? this.ethType : parentMessage.ethType;
+                short ipDscp = this.ipDscpSet ? this.ipDscp : parentMessage.ipDscp;
+                short ipProto = this.ipProtoSet ? this.ipProto : parentMessage.ipProto;
+                IPv4Address ipv4Src = this.ipv4SrcSet ? this.ipv4Src : parentMessage.ipv4Src;
+                if(ipv4Src == null)
+                    throw new NullPointerException("Property ipv4Src must not be null");
+                IPv4Address ipv4SrcMask = this.ipv4SrcMaskSet ? this.ipv4SrcMask : parentMessage.ipv4SrcMask;
+                if(ipv4SrcMask == null)
+                    throw new NullPointerException("Property ipv4SrcMask must not be null");
+                IPv4Address ipv4Dst = this.ipv4DstSet ? this.ipv4Dst : parentMessage.ipv4Dst;
+                if(ipv4Dst == null)
+                    throw new NullPointerException("Property ipv4Dst must not be null");
+                IPv4Address ipv4DstMask = this.ipv4DstMaskSet ? this.ipv4DstMask : parentMessage.ipv4DstMask;
+                if(ipv4DstMask == null)
+                    throw new NullPointerException("Property ipv4DstMask must not be null");
+                int tcpSrc = this.tcpSrcSet ? this.tcpSrc : parentMessage.tcpSrc;
+                int tcpDst = this.tcpDstSet ? this.tcpDst : parentMessage.tcpDst;
+                long mplsLabel = this.mplsLabelSet ? this.mplsLabel : parentMessage.mplsLabel;
+                short mplsTc = this.mplsTcSet ? this.mplsTc : parentMessage.mplsTc;
+                U64 metadata = this.metadataSet ? this.metadata : parentMessage.metadata;
+                if(metadata == null)
+                    throw new NullPointerException("Property metadata must not be null");
+                U64 metadataMask = this.metadataMaskSet ? this.metadataMask : parentMessage.metadataMask;
+                if(metadataMask == null)
+                    throw new NullPointerException("Property metadataMask must not be null");
+
+                //
+                return new OFMatchV2Ver11(
+                    inPort,
+                    wildcards,
+                    ethSrc,
+                    ethSrcMask,
+                    ethDst,
+                    ethDstMask,
+                    vlanVid,
+                    vlanPcp,
+                    ethType,
+                    ipDscp,
+                    ipProto,
+                    ipv4Src,
+                    ipv4SrcMask,
+                    ipv4Dst,
+                    ipv4DstMask,
+                    tcpSrc,
+                    tcpDst,
+                    mplsLabel,
+                    mplsTc,
+                    metadata,
+                    metadataMask
+                );
+        }
+
+    @Override
+    public <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isExact(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isFullyWildcarded(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isPartiallyMasked(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setExact(
+            MatchField<F> field, F value) {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, F value, F mask) {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, Masked<F> valueWithMask) {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    }
+
+    static class Builder implements OFMatchV2.Builder {
+        // OF message fields
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean ethSrcSet;
+        private MacAddress ethSrc;
+        private boolean ethSrcMaskSet;
+        private MacAddress ethSrcMask;
+        private boolean ethDstSet;
+        private MacAddress ethDst;
+        private boolean ethDstMaskSet;
+        private MacAddress ethDstMask;
+        private boolean vlanVidSet;
+        private int vlanVid;
+        private boolean vlanPcpSet;
+        private short vlanPcp;
+        private boolean ethTypeSet;
+        private int ethType;
+        private boolean ipDscpSet;
+        private short ipDscp;
+        private boolean ipProtoSet;
+        private short ipProto;
+        private boolean ipv4SrcSet;
+        private IPv4Address ipv4Src;
+        private boolean ipv4SrcMaskSet;
+        private IPv4Address ipv4SrcMask;
+        private boolean ipv4DstSet;
+        private IPv4Address ipv4Dst;
+        private boolean ipv4DstMaskSet;
+        private IPv4Address ipv4DstMask;
+        private boolean tcpSrcSet;
+        private int tcpSrc;
+        private boolean tcpDstSet;
+        private int tcpDst;
+        private boolean mplsLabelSet;
+        private long mplsLabel;
+        private boolean mplsTcSet;
+        private short mplsTc;
+        private boolean metadataSet;
+        private U64 metadata;
+        private boolean metadataMaskSet;
+        private U64 metadataMask;
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFMatchV2.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFMatchV2.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthSrc() {
+        return ethSrc;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthSrc(MacAddress ethSrc) {
+        this.ethSrc = ethSrc;
+        this.ethSrcSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthSrcMask() {
+        return ethSrcMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthSrcMask(MacAddress ethSrcMask) {
+        this.ethSrcMask = ethSrcMask;
+        this.ethSrcMaskSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthDst() {
+        return ethDst;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthDst(MacAddress ethDst) {
+        this.ethDst = ethDst;
+        this.ethDstSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getEthDstMask() {
+        return ethDstMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthDstMask(MacAddress ethDstMask) {
+        this.ethDstMask = ethDstMask;
+        this.ethDstMaskSet = true;
+        return this;
+    }
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFMatchV2.Builder setVlanVid(int vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public short getVlanPcp() {
+        return vlanPcp;
+    }
+
+    @Override
+    public OFMatchV2.Builder setVlanPcp(short vlanPcp) {
+        this.vlanPcp = vlanPcp;
+        this.vlanPcpSet = true;
+        return this;
+    }
+    @Override
+    public int getEthType() {
+        return ethType;
+    }
+
+    @Override
+    public OFMatchV2.Builder setEthType(int ethType) {
+        this.ethType = ethType;
+        this.ethTypeSet = true;
+        return this;
+    }
+    @Override
+    public short getIpDscp() {
+        return ipDscp;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpDscp(short ipDscp) {
+        this.ipDscp = ipDscp;
+        this.ipDscpSet = true;
+        return this;
+    }
+    @Override
+    public short getIpProto() {
+        return ipProto;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpProto(short ipProto) {
+        this.ipProto = ipProto;
+        this.ipProtoSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Src() {
+        return ipv4Src;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpv4Src(IPv4Address ipv4Src) {
+        this.ipv4Src = ipv4Src;
+        this.ipv4SrcSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4SrcMask() {
+        return ipv4SrcMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpv4SrcMask(IPv4Address ipv4SrcMask) {
+        this.ipv4SrcMask = ipv4SrcMask;
+        this.ipv4SrcMaskSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Dst() {
+        return ipv4Dst;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpv4Dst(IPv4Address ipv4Dst) {
+        this.ipv4Dst = ipv4Dst;
+        this.ipv4DstSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4DstMask() {
+        return ipv4DstMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setIpv4DstMask(IPv4Address ipv4DstMask) {
+        this.ipv4DstMask = ipv4DstMask;
+        this.ipv4DstMaskSet = true;
+        return this;
+    }
+    @Override
+    public int getTcpSrc() {
+        return tcpSrc;
+    }
+
+    @Override
+    public OFMatchV2.Builder setTcpSrc(int tcpSrc) {
+        this.tcpSrc = tcpSrc;
+        this.tcpSrcSet = true;
+        return this;
+    }
+    @Override
+    public int getTcpDst() {
+        return tcpDst;
+    }
+
+    @Override
+    public OFMatchV2.Builder setTcpDst(int tcpDst) {
+        this.tcpDst = tcpDst;
+        this.tcpDstSet = true;
+        return this;
+    }
+    @Override
+    public long getMplsLabel() {
+        return mplsLabel;
+    }
+
+    @Override
+    public OFMatchV2.Builder setMplsLabel(long mplsLabel) {
+        this.mplsLabel = mplsLabel;
+        this.mplsLabelSet = true;
+        return this;
+    }
+    @Override
+    public short getMplsTc() {
+        return mplsTc;
+    }
+
+    @Override
+    public OFMatchV2.Builder setMplsTc(short mplsTc) {
+        this.mplsTc = mplsTc;
+        this.mplsTcSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public OFMatchV2.Builder setMetadata(U64 metadata) {
+        this.metadata = metadata;
+        this.metadataSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFMatchV2.Builder setMetadataMask(U64 metadataMask) {
+        this.metadataMask = metadataMask;
+        this.metadataMaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFMatchV2 build() {
+            OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT;
+            if(inPort == null)
+                throw new NullPointerException("Property inPort must not be null");
+            int wildcards = this.wildcardsSet ? this.wildcards : DEFAULT_WILDCARDS;
+            MacAddress ethSrc = this.ethSrcSet ? this.ethSrc : DEFAULT_ETH_SRC;
+            if(ethSrc == null)
+                throw new NullPointerException("Property ethSrc must not be null");
+            MacAddress ethSrcMask = this.ethSrcMaskSet ? this.ethSrcMask : DEFAULT_ETH_SRC_MASK;
+            if(ethSrcMask == null)
+                throw new NullPointerException("Property ethSrcMask must not be null");
+            MacAddress ethDst = this.ethDstSet ? this.ethDst : DEFAULT_ETH_DST;
+            if(ethDst == null)
+                throw new NullPointerException("Property ethDst must not be null");
+            MacAddress ethDstMask = this.ethDstMaskSet ? this.ethDstMask : DEFAULT_ETH_DST_MASK;
+            if(ethDstMask == null)
+                throw new NullPointerException("Property ethDstMask must not be null");
+            int vlanVid = this.vlanVidSet ? this.vlanVid : DEFAULT_VLAN_VID;
+            short vlanPcp = this.vlanPcpSet ? this.vlanPcp : DEFAULT_VLAN_PCP;
+            int ethType = this.ethTypeSet ? this.ethType : DEFAULT_ETH_TYPE;
+            short ipDscp = this.ipDscpSet ? this.ipDscp : DEFAULT_IP_DSCP;
+            short ipProto = this.ipProtoSet ? this.ipProto : DEFAULT_IP_PROTO;
+            IPv4Address ipv4Src = this.ipv4SrcSet ? this.ipv4Src : DEFAULT_IPV4_SRC;
+            if(ipv4Src == null)
+                throw new NullPointerException("Property ipv4Src must not be null");
+            IPv4Address ipv4SrcMask = this.ipv4SrcMaskSet ? this.ipv4SrcMask : DEFAULT_IPV4_SRC_MASK;
+            if(ipv4SrcMask == null)
+                throw new NullPointerException("Property ipv4SrcMask must not be null");
+            IPv4Address ipv4Dst = this.ipv4DstSet ? this.ipv4Dst : DEFAULT_IPV4_DST;
+            if(ipv4Dst == null)
+                throw new NullPointerException("Property ipv4Dst must not be null");
+            IPv4Address ipv4DstMask = this.ipv4DstMaskSet ? this.ipv4DstMask : DEFAULT_IPV4_DST_MASK;
+            if(ipv4DstMask == null)
+                throw new NullPointerException("Property ipv4DstMask must not be null");
+            int tcpSrc = this.tcpSrcSet ? this.tcpSrc : DEFAULT_TCP_SRC;
+            int tcpDst = this.tcpDstSet ? this.tcpDst : DEFAULT_TCP_DST;
+            long mplsLabel = this.mplsLabelSet ? this.mplsLabel : DEFAULT_MPLS_LABEL;
+            short mplsTc = this.mplsTcSet ? this.mplsTc : DEFAULT_MPLS_TC;
+            U64 metadata = this.metadataSet ? this.metadata : DEFAULT_METADATA;
+            if(metadata == null)
+                throw new NullPointerException("Property metadata must not be null");
+            U64 metadataMask = this.metadataMaskSet ? this.metadataMask : DEFAULT_METADATA_MASK;
+            if(metadataMask == null)
+                throw new NullPointerException("Property metadataMask must not be null");
+
+
+            return new OFMatchV2Ver11(
+                    inPort,
+                    wildcards,
+                    ethSrc,
+                    ethSrcMask,
+                    ethDst,
+                    ethDstMask,
+                    vlanVid,
+                    vlanPcp,
+                    ethType,
+                    ipDscp,
+                    ipProto,
+                    ipv4Src,
+                    ipv4SrcMask,
+                    ipv4Dst,
+                    ipv4DstMask,
+                    tcpSrc,
+                    tcpDst,
+                    mplsLabel,
+                    mplsTc,
+                    metadata,
+                    metadataMask
+                );
+        }
+
+    @Override
+    public <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isExact(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isFullyWildcarded(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public boolean isPartiallyMasked(MatchField<?> field) {
+        // FIXME yotam - please replace with real implementation
+        return false;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setExact(
+            MatchField<F> field, F value) {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, F value, F mask) {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, Masked<F> valueWithMask) {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+        // FIXME yotam - please replace with real implementation
+        return null;
+    }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMatchV2> {
+        @Override
+        public OFMatchV2 readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=0x0(0x0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 88)
+                throw new OFParseError("Wrong length: Expected=88(88), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFPort inPort = OFPort.read4Bytes(bb);
+            int wildcards = bb.readInt();
+            MacAddress ethSrc = MacAddress.read6Bytes(bb);
+            MacAddress ethSrcMask = MacAddress.read6Bytes(bb);
+            MacAddress ethDst = MacAddress.read6Bytes(bb);
+            MacAddress ethDstMask = MacAddress.read6Bytes(bb);
+            int vlanVid = U16.f(bb.readShort());
+            short vlanPcp = U8.f(bb.readByte());
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int ethType = U16.f(bb.readShort());
+            short ipDscp = U8.f(bb.readByte());
+            short ipProto = U8.f(bb.readByte());
+            IPv4Address ipv4Src = IPv4Address.read4Bytes(bb);
+            IPv4Address ipv4SrcMask = IPv4Address.read4Bytes(bb);
+            IPv4Address ipv4Dst = IPv4Address.read4Bytes(bb);
+            IPv4Address ipv4DstMask = IPv4Address.read4Bytes(bb);
+            int tcpSrc = U16.f(bb.readShort());
+            int tcpDst = U16.f(bb.readShort());
+            long mplsLabel = U32.f(bb.readInt());
+            short mplsTc = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            U64 metadata = U64.ofRaw(bb.readLong());
+            U64 metadataMask = U64.ofRaw(bb.readLong());
+
+            OFMatchV2Ver11 matchV2Ver11 = new OFMatchV2Ver11(
+                    inPort,
+                      wildcards,
+                      ethSrc,
+                      ethSrcMask,
+                      ethDst,
+                      ethDstMask,
+                      vlanVid,
+                      vlanPcp,
+                      ethType,
+                      ipDscp,
+                      ipProto,
+                      ipv4Src,
+                      ipv4SrcMask,
+                      ipv4Dst,
+                      ipv4DstMask,
+                      tcpSrc,
+                      tcpDst,
+                      mplsLabel,
+                      mplsTc,
+                      metadata,
+                      metadataMask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", matchV2Ver11);
+            return matchV2Ver11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMatchV2Ver11Funnel FUNNEL = new OFMatchV2Ver11Funnel();
+    static class OFMatchV2Ver11Funnel implements Funnel<OFMatchV2Ver11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMatchV2Ver11 message, PrimitiveSink sink) {
+            // fixed value property type = 0x0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 88
+            sink.putShort((short) 0x58);
+            message.inPort.putTo(sink);
+            sink.putInt(message.wildcards);
+            message.ethSrc.putTo(sink);
+            message.ethSrcMask.putTo(sink);
+            message.ethDst.putTo(sink);
+            message.ethDstMask.putTo(sink);
+            sink.putInt(message.vlanVid);
+            sink.putShort(message.vlanPcp);
+            // skip pad (1 bytes)
+            sink.putInt(message.ethType);
+            sink.putShort(message.ipDscp);
+            sink.putShort(message.ipProto);
+            message.ipv4Src.putTo(sink);
+            message.ipv4SrcMask.putTo(sink);
+            message.ipv4Dst.putTo(sink);
+            message.ipv4DstMask.putTo(sink);
+            sink.putInt(message.tcpSrc);
+            sink.putInt(message.tcpDst);
+            sink.putLong(message.mplsLabel);
+            sink.putShort(message.mplsTc);
+            // skip pad (3 bytes)
+            message.metadata.putTo(sink);
+            message.metadataMask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMatchV2Ver11> {
+        @Override
+        public void write(ChannelBuffer bb, OFMatchV2Ver11 message) {
+            // fixed value property type = 0x0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 88
+            bb.writeShort((short) 0x58);
+            message.inPort.write4Bytes(bb);
+            bb.writeInt(message.wildcards);
+            message.ethSrc.write6Bytes(bb);
+            message.ethSrcMask.write6Bytes(bb);
+            message.ethDst.write6Bytes(bb);
+            message.ethDstMask.write6Bytes(bb);
+            bb.writeShort(U16.t(message.vlanVid));
+            bb.writeByte(U8.t(message.vlanPcp));
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.ethType));
+            bb.writeByte(U8.t(message.ipDscp));
+            bb.writeByte(U8.t(message.ipProto));
+            message.ipv4Src.write4Bytes(bb);
+            message.ipv4SrcMask.write4Bytes(bb);
+            message.ipv4Dst.write4Bytes(bb);
+            message.ipv4DstMask.write4Bytes(bb);
+            bb.writeShort(U16.t(message.tcpSrc));
+            bb.writeShort(U16.t(message.tcpDst));
+            bb.writeInt(U32.t(message.mplsLabel));
+            bb.writeByte(U8.t(message.mplsTc));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeLong(message.metadata.getValue());
+            bb.writeLong(message.metadataMask.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMatchV2Ver11(");
+        b.append("inPort=").append(inPort);
+        b.append(", ");
+        b.append("wildcards=").append(wildcards);
+        b.append(", ");
+        b.append("ethSrc=").append(ethSrc);
+        b.append(", ");
+        b.append("ethSrcMask=").append(ethSrcMask);
+        b.append(", ");
+        b.append("ethDst=").append(ethDst);
+        b.append(", ");
+        b.append("ethDstMask=").append(ethDstMask);
+        b.append(", ");
+        b.append("vlanVid=").append(vlanVid);
+        b.append(", ");
+        b.append("vlanPcp=").append(vlanPcp);
+        b.append(", ");
+        b.append("ethType=").append(ethType);
+        b.append(", ");
+        b.append("ipDscp=").append(ipDscp);
+        b.append(", ");
+        b.append("ipProto=").append(ipProto);
+        b.append(", ");
+        b.append("ipv4Src=").append(ipv4Src);
+        b.append(", ");
+        b.append("ipv4SrcMask=").append(ipv4SrcMask);
+        b.append(", ");
+        b.append("ipv4Dst=").append(ipv4Dst);
+        b.append(", ");
+        b.append("ipv4DstMask=").append(ipv4DstMask);
+        b.append(", ");
+        b.append("tcpSrc=").append(tcpSrc);
+        b.append(", ");
+        b.append("tcpDst=").append(tcpDst);
+        b.append(", ");
+        b.append("mplsLabel=").append(mplsLabel);
+        b.append(", ");
+        b.append("mplsTc=").append(mplsTc);
+        b.append(", ");
+        b.append("metadata=").append(metadata);
+        b.append(", ");
+        b.append("metadataMask=").append(metadataMask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMatchV2Ver11 other = (OFMatchV2Ver11) obj;
+
+        if (inPort == null) {
+            if (other.inPort != null)
+                return false;
+        } else if (!inPort.equals(other.inPort))
+            return false;
+        if( wildcards != other.wildcards)
+            return false;
+        if (ethSrc == null) {
+            if (other.ethSrc != null)
+                return false;
+        } else if (!ethSrc.equals(other.ethSrc))
+            return false;
+        if (ethSrcMask == null) {
+            if (other.ethSrcMask != null)
+                return false;
+        } else if (!ethSrcMask.equals(other.ethSrcMask))
+            return false;
+        if (ethDst == null) {
+            if (other.ethDst != null)
+                return false;
+        } else if (!ethDst.equals(other.ethDst))
+            return false;
+        if (ethDstMask == null) {
+            if (other.ethDstMask != null)
+                return false;
+        } else if (!ethDstMask.equals(other.ethDstMask))
+            return false;
+        if( vlanVid != other.vlanVid)
+            return false;
+        if( vlanPcp != other.vlanPcp)
+            return false;
+        if( ethType != other.ethType)
+            return false;
+        if( ipDscp != other.ipDscp)
+            return false;
+        if( ipProto != other.ipProto)
+            return false;
+        if (ipv4Src == null) {
+            if (other.ipv4Src != null)
+                return false;
+        } else if (!ipv4Src.equals(other.ipv4Src))
+            return false;
+        if (ipv4SrcMask == null) {
+            if (other.ipv4SrcMask != null)
+                return false;
+        } else if (!ipv4SrcMask.equals(other.ipv4SrcMask))
+            return false;
+        if (ipv4Dst == null) {
+            if (other.ipv4Dst != null)
+                return false;
+        } else if (!ipv4Dst.equals(other.ipv4Dst))
+            return false;
+        if (ipv4DstMask == null) {
+            if (other.ipv4DstMask != null)
+                return false;
+        } else if (!ipv4DstMask.equals(other.ipv4DstMask))
+            return false;
+        if( tcpSrc != other.tcpSrc)
+            return false;
+        if( tcpDst != other.tcpDst)
+            return false;
+        if( mplsLabel != other.mplsLabel)
+            return false;
+        if( mplsTc != other.mplsTc)
+            return false;
+        if (metadata == null) {
+            if (other.metadata != null)
+                return false;
+        } else if (!metadata.equals(other.metadata))
+            return false;
+        if (metadataMask == null) {
+            if (other.metadataMask != null)
+                return false;
+        } else if (!metadataMask.equals(other.metadataMask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((inPort == null) ? 0 : inPort.hashCode());
+        result = prime * result + wildcards;
+        result = prime * result + ((ethSrc == null) ? 0 : ethSrc.hashCode());
+        result = prime * result + ((ethSrcMask == null) ? 0 : ethSrcMask.hashCode());
+        result = prime * result + ((ethDst == null) ? 0 : ethDst.hashCode());
+        result = prime * result + ((ethDstMask == null) ? 0 : ethDstMask.hashCode());
+        result = prime * result + vlanVid;
+        result = prime * result + vlanPcp;
+        result = prime * result + ethType;
+        result = prime * result + ipDscp;
+        result = prime * result + ipProto;
+        result = prime * result + ((ipv4Src == null) ? 0 : ipv4Src.hashCode());
+        result = prime * result + ((ipv4SrcMask == null) ? 0 : ipv4SrcMask.hashCode());
+        result = prime * result + ((ipv4Dst == null) ? 0 : ipv4Dst.hashCode());
+        result = prime * result + ((ipv4DstMask == null) ? 0 : ipv4DstMask.hashCode());
+        result = prime * result + tcpSrc;
+        result = prime * result + tcpDst;
+        result = prime *  (int) (mplsLabel ^ (mplsLabel >>> 32));
+        result = prime * result + mplsTc;
+        result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
+        result = prime * result + ((metadataMask == null) ? 0 : metadataMask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMessageVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMessageVer11.java
new file mode 100644
index 0000000..9bed4eb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMessageVer11.java
@@ -0,0 +1,127 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFMessageVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFMessageVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFMessage> {
+        @Override
+        public OFMessage readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            byte type = bb.readByte();
+            bb.readerIndex(start);
+            switch(type) {
+               case (byte) 0x13:
+                   // discriminator value OFType.STATS_REPLY=19 for class OFStatsReplyVer11
+                   return OFStatsReplyVer11.READER.readFrom(bb);
+               case (byte) 0x12:
+                   // discriminator value OFType.STATS_REQUEST=18 for class OFStatsRequestVer11
+                   return OFStatsRequestVer11.READER.readFrom(bb);
+               case (byte) 0x1:
+                   // discriminator value OFType.ERROR=1 for class OFErrorMsgVer11
+                   return OFErrorMsgVer11.READER.readFrom(bb);
+               case (byte) 0x15:
+                   // discriminator value OFType.BARRIER_REPLY=21 for class OFBarrierReplyVer11
+                   return OFBarrierReplyVer11.READER.readFrom(bb);
+               case (byte) 0x14:
+                   // discriminator value OFType.BARRIER_REQUEST=20 for class OFBarrierRequestVer11
+                   return OFBarrierRequestVer11.READER.readFrom(bb);
+               case (byte) 0x4:
+                   // discriminator value OFType.EXPERIMENTER=4 for class OFExperimenterVer11
+                   return OFExperimenterVer11.READER.readFrom(bb);
+               case (byte) 0x3:
+                   // discriminator value OFType.ECHO_REPLY=3 for class OFEchoReplyVer11
+                   return OFEchoReplyVer11.READER.readFrom(bb);
+               case (byte) 0x2:
+                   // discriminator value OFType.ECHO_REQUEST=2 for class OFEchoRequestVer11
+                   return OFEchoRequestVer11.READER.readFrom(bb);
+               case (byte) 0x6:
+                   // discriminator value OFType.FEATURES_REPLY=6 for class OFFeaturesReplyVer11
+                   return OFFeaturesReplyVer11.READER.readFrom(bb);
+               case (byte) 0x5:
+                   // discriminator value OFType.FEATURES_REQUEST=5 for class OFFeaturesRequestVer11
+                   return OFFeaturesRequestVer11.READER.readFrom(bb);
+               case (byte) 0xe:
+                   // discriminator value OFType.FLOW_MOD=14 for class OFFlowModVer11
+                   return OFFlowModVer11.READER.readFrom(bb);
+               case (byte) 0xb:
+                   // discriminator value OFType.FLOW_REMOVED=11 for class OFFlowRemovedVer11
+                   return OFFlowRemovedVer11.READER.readFrom(bb);
+               case (byte) 0x8:
+                   // discriminator value OFType.GET_CONFIG_REPLY=8 for class OFGetConfigReplyVer11
+                   return OFGetConfigReplyVer11.READER.readFrom(bb);
+               case (byte) 0x7:
+                   // discriminator value OFType.GET_CONFIG_REQUEST=7 for class OFGetConfigRequestVer11
+                   return OFGetConfigRequestVer11.READER.readFrom(bb);
+               case (byte) 0x0:
+                   // discriminator value OFType.HELLO=0 for class OFHelloVer11
+                   return OFHelloVer11.READER.readFrom(bb);
+               case (byte) 0xa:
+                   // discriminator value OFType.PACKET_IN=10 for class OFPacketInVer11
+                   return OFPacketInVer11.READER.readFrom(bb);
+               case (byte) 0xd:
+                   // discriminator value OFType.PACKET_OUT=13 for class OFPacketOutVer11
+                   return OFPacketOutVer11.READER.readFrom(bb);
+               case (byte) 0x10:
+                   // discriminator value OFType.PORT_MOD=16 for class OFPortModVer11
+                   return OFPortModVer11.READER.readFrom(bb);
+               case (byte) 0xc:
+                   // discriminator value OFType.PORT_STATUS=12 for class OFPortStatusVer11
+                   return OFPortStatusVer11.READER.readFrom(bb);
+               case (byte) 0x17:
+                   // discriminator value OFType.QUEUE_GET_CONFIG_REPLY=23 for class OFQueueGetConfigReplyVer11
+                   return OFQueueGetConfigReplyVer11.READER.readFrom(bb);
+               case (byte) 0x16:
+                   // discriminator value OFType.QUEUE_GET_CONFIG_REQUEST=22 for class OFQueueGetConfigRequestVer11
+                   return OFQueueGetConfigRequestVer11.READER.readFrom(bb);
+               case (byte) 0x9:
+                   // discriminator value OFType.SET_CONFIG=9 for class OFSetConfigVer11
+                   return OFSetConfigVer11.READER.readFrom(bb);
+               case (byte) 0x11:
+                   // discriminator value OFType.TABLE_MOD=17 for class OFTableModVer11
+                   return OFTableModVer11.READER.readFrom(bb);
+               case (byte) 0xf:
+                   // discriminator value OFType.GROUP_MOD=15 for class OFGroupModVer11
+                   return OFGroupModVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFMessageVer11: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMeterBandsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMeterBandsVer11.java
new file mode 100644
index 0000000..9a594e2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFMeterBandsVer11.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFMeterBandsVer11 implements OFMeterBands {
+    public final static OFMeterBandsVer11 INSTANCE = new OFMeterBandsVer11();
+
+
+
+
+    public OFMeterBandDrop.Builder buildDrop() {
+        throw new UnsupportedOperationException("OFMeterBandDrop not supported in version 1.1");
+    }
+    public OFMeterBandDrop drop(long rate, long burstSize) {
+        throw new UnsupportedOperationException("OFMeterBandDrop not supported in version 1.1");
+    }
+
+    public OFMeterBandDscpRemark.Builder buildDscpRemark() {
+        throw new UnsupportedOperationException("OFMeterBandDscpRemark not supported in version 1.1");
+    }
+
+    public OFMeterBandExperimenter.Builder buildExperimenter() {
+        throw new UnsupportedOperationException("OFMeterBandExperimenter not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFMeterBand> getReader() {
+        throw new UnsupportedOperationException("Reader<OFMeterBand> not supported in version 1.1");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFNiciraHeaderVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFNiciraHeaderVer11.java
new file mode 100644
index 0000000..41a609d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFNiciraHeaderVer11.java
@@ -0,0 +1,66 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFNiciraHeaderVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFNiciraHeaderVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFNiciraHeader> {
+        @Override
+        public OFNiciraHeader readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFNiciraHeaderVer11: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFOxmsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFOxmsVer11.java
new file mode 100644
index 0000000..4ec242c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFOxmsVer11.java
@@ -0,0 +1,1165 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFOxmsVer11 implements OFOxms {
+    public final static OFOxmsVer11 INSTANCE = new OFOxmsVer11();
+
+
+
+
+    public OFOxmArpOp.Builder buildArpOp() {
+        throw new UnsupportedOperationException("OFOxmArpOp not supported in version 1.1");
+    }
+    public OFOxmArpOp arpOp(ArpOpcode value) {
+        throw new UnsupportedOperationException("OFOxmArpOp not supported in version 1.1");
+    }
+
+    public OFOxmArpOpMasked.Builder buildArpOpMasked() {
+        throw new UnsupportedOperationException("OFOxmArpOpMasked not supported in version 1.1");
+    }
+    public OFOxmArpOpMasked arpOpMasked(ArpOpcode value, ArpOpcode mask) {
+        throw new UnsupportedOperationException("OFOxmArpOpMasked not supported in version 1.1");
+    }
+
+    public OFOxmArpSha.Builder buildArpSha() {
+        throw new UnsupportedOperationException("OFOxmArpSha not supported in version 1.1");
+    }
+    public OFOxmArpSha arpSha(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmArpSha not supported in version 1.1");
+    }
+
+    public OFOxmArpShaMasked.Builder buildArpShaMasked() {
+        throw new UnsupportedOperationException("OFOxmArpShaMasked not supported in version 1.1");
+    }
+    public OFOxmArpShaMasked arpShaMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmArpShaMasked not supported in version 1.1");
+    }
+
+    public OFOxmArpSpa.Builder buildArpSpa() {
+        throw new UnsupportedOperationException("OFOxmArpSpa not supported in version 1.1");
+    }
+    public OFOxmArpSpa arpSpa(IPv4Address value) {
+        throw new UnsupportedOperationException("OFOxmArpSpa not supported in version 1.1");
+    }
+
+    public OFOxmArpSpaMasked.Builder buildArpSpaMasked() {
+        throw new UnsupportedOperationException("OFOxmArpSpaMasked not supported in version 1.1");
+    }
+    public OFOxmArpSpaMasked arpSpaMasked(IPv4Address value, IPv4Address mask) {
+        throw new UnsupportedOperationException("OFOxmArpSpaMasked not supported in version 1.1");
+    }
+
+    public OFOxmArpTha.Builder buildArpTha() {
+        throw new UnsupportedOperationException("OFOxmArpTha not supported in version 1.1");
+    }
+    public OFOxmArpTha arpTha(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmArpTha not supported in version 1.1");
+    }
+
+    public OFOxmArpThaMasked.Builder buildArpThaMasked() {
+        throw new UnsupportedOperationException("OFOxmArpThaMasked not supported in version 1.1");
+    }
+    public OFOxmArpThaMasked arpThaMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmArpThaMasked not supported in version 1.1");
+    }
+
+    public OFOxmArpTpa.Builder buildArpTpa() {
+        throw new UnsupportedOperationException("OFOxmArpTpa not supported in version 1.1");
+    }
+    public OFOxmArpTpa arpTpa(IPv4Address value) {
+        throw new UnsupportedOperationException("OFOxmArpTpa not supported in version 1.1");
+    }
+
+    public OFOxmArpTpaMasked.Builder buildArpTpaMasked() {
+        throw new UnsupportedOperationException("OFOxmArpTpaMasked not supported in version 1.1");
+    }
+    public OFOxmArpTpaMasked arpTpaMasked(IPv4Address value, IPv4Address mask) {
+        throw new UnsupportedOperationException("OFOxmArpTpaMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnEgrPortGroupId.Builder buildBsnEgrPortGroupId() {
+        throw new UnsupportedOperationException("OFOxmBsnEgrPortGroupId not supported in version 1.1");
+    }
+    public OFOxmBsnEgrPortGroupId bsnEgrPortGroupId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnEgrPortGroupId not supported in version 1.1");
+    }
+
+    public OFOxmBsnEgrPortGroupIdMasked.Builder buildBsnEgrPortGroupIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnEgrPortGroupIdMasked not supported in version 1.1");
+    }
+    public OFOxmBsnEgrPortGroupIdMasked bsnEgrPortGroupIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnEgrPortGroupIdMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnGlobalVrfAllowed.Builder buildBsnGlobalVrfAllowed() {
+        throw new UnsupportedOperationException("OFOxmBsnGlobalVrfAllowed not supported in version 1.1");
+    }
+    public OFOxmBsnGlobalVrfAllowed bsnGlobalVrfAllowed(OFBooleanValue value) {
+        throw new UnsupportedOperationException("OFOxmBsnGlobalVrfAllowed not supported in version 1.1");
+    }
+
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder buildBsnGlobalVrfAllowedMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnGlobalVrfAllowedMasked not supported in version 1.1");
+    }
+    public OFOxmBsnGlobalVrfAllowedMasked bsnGlobalVrfAllowedMasked(OFBooleanValue value, OFBooleanValue mask) {
+        throw new UnsupportedOperationException("OFOxmBsnGlobalVrfAllowedMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnInPorts128.Builder buildBsnInPorts128() {
+        throw new UnsupportedOperationException("OFOxmBsnInPorts128 not supported in version 1.1");
+    }
+    public OFOxmBsnInPorts128 bsnInPorts128(OFBitMask128 value) {
+        throw new UnsupportedOperationException("OFOxmBsnInPorts128 not supported in version 1.1");
+    }
+
+    public OFOxmBsnInPorts128Masked.Builder buildBsnInPorts128Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnInPorts128Masked not supported in version 1.1");
+    }
+    public OFOxmBsnInPorts128Masked bsnInPorts128Masked(OFBitMask128 value, OFBitMask128 mask) {
+        throw new UnsupportedOperationException("OFOxmBsnInPorts128Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnL3DstClassId.Builder buildBsnL3DstClassId() {
+        throw new UnsupportedOperationException("OFOxmBsnL3DstClassId not supported in version 1.1");
+    }
+    public OFOxmBsnL3DstClassId bsnL3DstClassId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnL3DstClassId not supported in version 1.1");
+    }
+
+    public OFOxmBsnL3DstClassIdMasked.Builder buildBsnL3DstClassIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnL3DstClassIdMasked not supported in version 1.1");
+    }
+    public OFOxmBsnL3DstClassIdMasked bsnL3DstClassIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnL3DstClassIdMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnL3InterfaceClassId.Builder buildBsnL3InterfaceClassId() {
+        throw new UnsupportedOperationException("OFOxmBsnL3InterfaceClassId not supported in version 1.1");
+    }
+    public OFOxmBsnL3InterfaceClassId bsnL3InterfaceClassId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnL3InterfaceClassId not supported in version 1.1");
+    }
+
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder buildBsnL3InterfaceClassIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnL3InterfaceClassIdMasked not supported in version 1.1");
+    }
+    public OFOxmBsnL3InterfaceClassIdMasked bsnL3InterfaceClassIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnL3InterfaceClassIdMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnL3SrcClassId.Builder buildBsnL3SrcClassId() {
+        throw new UnsupportedOperationException("OFOxmBsnL3SrcClassId not supported in version 1.1");
+    }
+    public OFOxmBsnL3SrcClassId bsnL3SrcClassId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnL3SrcClassId not supported in version 1.1");
+    }
+
+    public OFOxmBsnL3SrcClassIdMasked.Builder buildBsnL3SrcClassIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnL3SrcClassIdMasked not supported in version 1.1");
+    }
+    public OFOxmBsnL3SrcClassIdMasked bsnL3SrcClassIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnL3SrcClassIdMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnLagId.Builder buildBsnLagId() {
+        throw new UnsupportedOperationException("OFOxmBsnLagId not supported in version 1.1");
+    }
+    public OFOxmBsnLagId bsnLagId(LagId value) {
+        throw new UnsupportedOperationException("OFOxmBsnLagId not supported in version 1.1");
+    }
+
+    public OFOxmBsnLagIdMasked.Builder buildBsnLagIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnLagIdMasked not supported in version 1.1");
+    }
+    public OFOxmBsnLagIdMasked bsnLagIdMasked(LagId value, LagId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnLagIdMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnTcpFlags.Builder buildBsnTcpFlags() {
+        throw new UnsupportedOperationException("OFOxmBsnTcpFlags not supported in version 1.1");
+    }
+    public OFOxmBsnTcpFlags bsnTcpFlags(U16 value) {
+        throw new UnsupportedOperationException("OFOxmBsnTcpFlags not supported in version 1.1");
+    }
+
+    public OFOxmBsnTcpFlagsMasked.Builder buildBsnTcpFlagsMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnTcpFlagsMasked not supported in version 1.1");
+    }
+    public OFOxmBsnTcpFlagsMasked bsnTcpFlagsMasked(U16 value, U16 mask) {
+        throw new UnsupportedOperationException("OFOxmBsnTcpFlagsMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf0.Builder buildBsnUdf0() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf0 not supported in version 1.1");
+    }
+    public OFOxmBsnUdf0 bsnUdf0(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf0 not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf0Masked.Builder buildBsnUdf0Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf0Masked not supported in version 1.1");
+    }
+    public OFOxmBsnUdf0Masked bsnUdf0Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf0Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf1.Builder buildBsnUdf1() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf1 not supported in version 1.1");
+    }
+    public OFOxmBsnUdf1 bsnUdf1(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf1 not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf1Masked.Builder buildBsnUdf1Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf1Masked not supported in version 1.1");
+    }
+    public OFOxmBsnUdf1Masked bsnUdf1Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf1Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf2.Builder buildBsnUdf2() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf2 not supported in version 1.1");
+    }
+    public OFOxmBsnUdf2 bsnUdf2(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf2 not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf2Masked.Builder buildBsnUdf2Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf2Masked not supported in version 1.1");
+    }
+    public OFOxmBsnUdf2Masked bsnUdf2Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf2Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf3.Builder buildBsnUdf3() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf3 not supported in version 1.1");
+    }
+    public OFOxmBsnUdf3 bsnUdf3(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf3 not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf3Masked.Builder buildBsnUdf3Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf3Masked not supported in version 1.1");
+    }
+    public OFOxmBsnUdf3Masked bsnUdf3Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf3Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf4.Builder buildBsnUdf4() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf4 not supported in version 1.1");
+    }
+    public OFOxmBsnUdf4 bsnUdf4(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf4 not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf4Masked.Builder buildBsnUdf4Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf4Masked not supported in version 1.1");
+    }
+    public OFOxmBsnUdf4Masked bsnUdf4Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf4Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf5.Builder buildBsnUdf5() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf5 not supported in version 1.1");
+    }
+    public OFOxmBsnUdf5 bsnUdf5(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf5 not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf5Masked.Builder buildBsnUdf5Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf5Masked not supported in version 1.1");
+    }
+    public OFOxmBsnUdf5Masked bsnUdf5Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf5Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf6.Builder buildBsnUdf6() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf6 not supported in version 1.1");
+    }
+    public OFOxmBsnUdf6 bsnUdf6(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf6 not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf6Masked.Builder buildBsnUdf6Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf6Masked not supported in version 1.1");
+    }
+    public OFOxmBsnUdf6Masked bsnUdf6Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf6Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf7.Builder buildBsnUdf7() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf7 not supported in version 1.1");
+    }
+    public OFOxmBsnUdf7 bsnUdf7(UDF value) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf7 not supported in version 1.1");
+    }
+
+    public OFOxmBsnUdf7Masked.Builder buildBsnUdf7Masked() {
+        throw new UnsupportedOperationException("OFOxmBsnUdf7Masked not supported in version 1.1");
+    }
+    public OFOxmBsnUdf7Masked bsnUdf7Masked(UDF value, UDF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnUdf7Masked not supported in version 1.1");
+    }
+
+    public OFOxmBsnVlanXlatePortGroupId.Builder buildBsnVlanXlatePortGroupId() {
+        throw new UnsupportedOperationException("OFOxmBsnVlanXlatePortGroupId not supported in version 1.1");
+    }
+    public OFOxmBsnVlanXlatePortGroupId bsnVlanXlatePortGroupId(ClassId value) {
+        throw new UnsupportedOperationException("OFOxmBsnVlanXlatePortGroupId not supported in version 1.1");
+    }
+
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder buildBsnVlanXlatePortGroupIdMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnVlanXlatePortGroupIdMasked not supported in version 1.1");
+    }
+    public OFOxmBsnVlanXlatePortGroupIdMasked bsnVlanXlatePortGroupIdMasked(ClassId value, ClassId mask) {
+        throw new UnsupportedOperationException("OFOxmBsnVlanXlatePortGroupIdMasked not supported in version 1.1");
+    }
+
+    public OFOxmBsnVrf.Builder buildBsnVrf() {
+        throw new UnsupportedOperationException("OFOxmBsnVrf not supported in version 1.1");
+    }
+    public OFOxmBsnVrf bsnVrf(VRF value) {
+        throw new UnsupportedOperationException("OFOxmBsnVrf not supported in version 1.1");
+    }
+
+    public OFOxmBsnVrfMasked.Builder buildBsnVrfMasked() {
+        throw new UnsupportedOperationException("OFOxmBsnVrfMasked not supported in version 1.1");
+    }
+    public OFOxmBsnVrfMasked bsnVrfMasked(VRF value, VRF mask) {
+        throw new UnsupportedOperationException("OFOxmBsnVrfMasked not supported in version 1.1");
+    }
+
+    public OFOxmEthDst.Builder buildEthDst() {
+        throw new UnsupportedOperationException("OFOxmEthDst not supported in version 1.1");
+    }
+    public OFOxmEthDst ethDst(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmEthDst not supported in version 1.1");
+    }
+
+    public OFOxmEthDstMasked.Builder buildEthDstMasked() {
+        throw new UnsupportedOperationException("OFOxmEthDstMasked not supported in version 1.1");
+    }
+    public OFOxmEthDstMasked ethDstMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmEthDstMasked not supported in version 1.1");
+    }
+
+    public OFOxmEthSrc.Builder buildEthSrc() {
+        throw new UnsupportedOperationException("OFOxmEthSrc not supported in version 1.1");
+    }
+    public OFOxmEthSrc ethSrc(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmEthSrc not supported in version 1.1");
+    }
+
+    public OFOxmEthSrcMasked.Builder buildEthSrcMasked() {
+        throw new UnsupportedOperationException("OFOxmEthSrcMasked not supported in version 1.1");
+    }
+    public OFOxmEthSrcMasked ethSrcMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmEthSrcMasked not supported in version 1.1");
+    }
+
+    public OFOxmEthType.Builder buildEthType() {
+        throw new UnsupportedOperationException("OFOxmEthType not supported in version 1.1");
+    }
+    public OFOxmEthType ethType(EthType value) {
+        throw new UnsupportedOperationException("OFOxmEthType not supported in version 1.1");
+    }
+
+    public OFOxmEthTypeMasked.Builder buildEthTypeMasked() {
+        throw new UnsupportedOperationException("OFOxmEthTypeMasked not supported in version 1.1");
+    }
+    public OFOxmEthTypeMasked ethTypeMasked(EthType value, EthType mask) {
+        throw new UnsupportedOperationException("OFOxmEthTypeMasked not supported in version 1.1");
+    }
+
+    public OFOxmIcmpv4Code.Builder buildIcmpv4Code() {
+        throw new UnsupportedOperationException("OFOxmIcmpv4Code not supported in version 1.1");
+    }
+    public OFOxmIcmpv4Code icmpv4Code(ICMPv4Code value) {
+        throw new UnsupportedOperationException("OFOxmIcmpv4Code not supported in version 1.1");
+    }
+
+    public OFOxmIcmpv4CodeMasked.Builder buildIcmpv4CodeMasked() {
+        throw new UnsupportedOperationException("OFOxmIcmpv4CodeMasked not supported in version 1.1");
+    }
+    public OFOxmIcmpv4CodeMasked icmpv4CodeMasked(ICMPv4Code value, ICMPv4Code mask) {
+        throw new UnsupportedOperationException("OFOxmIcmpv4CodeMasked not supported in version 1.1");
+    }
+
+    public OFOxmIcmpv4Type.Builder buildIcmpv4Type() {
+        throw new UnsupportedOperationException("OFOxmIcmpv4Type not supported in version 1.1");
+    }
+    public OFOxmIcmpv4Type icmpv4Type(ICMPv4Type value) {
+        throw new UnsupportedOperationException("OFOxmIcmpv4Type not supported in version 1.1");
+    }
+
+    public OFOxmIcmpv4TypeMasked.Builder buildIcmpv4TypeMasked() {
+        throw new UnsupportedOperationException("OFOxmIcmpv4TypeMasked not supported in version 1.1");
+    }
+    public OFOxmIcmpv4TypeMasked icmpv4TypeMasked(ICMPv4Type value, ICMPv4Type mask) {
+        throw new UnsupportedOperationException("OFOxmIcmpv4TypeMasked not supported in version 1.1");
+    }
+
+    public OFOxmIcmpv6Code.Builder buildIcmpv6Code() {
+        throw new UnsupportedOperationException("OFOxmIcmpv6Code not supported in version 1.1");
+    }
+    public OFOxmIcmpv6Code icmpv6Code(U8 value) {
+        throw new UnsupportedOperationException("OFOxmIcmpv6Code not supported in version 1.1");
+    }
+
+    public OFOxmIcmpv6CodeMasked.Builder buildIcmpv6CodeMasked() {
+        throw new UnsupportedOperationException("OFOxmIcmpv6CodeMasked not supported in version 1.1");
+    }
+    public OFOxmIcmpv6CodeMasked icmpv6CodeMasked(U8 value, U8 mask) {
+        throw new UnsupportedOperationException("OFOxmIcmpv6CodeMasked not supported in version 1.1");
+    }
+
+    public OFOxmIcmpv6Type.Builder buildIcmpv6Type() {
+        throw new UnsupportedOperationException("OFOxmIcmpv6Type not supported in version 1.1");
+    }
+    public OFOxmIcmpv6Type icmpv6Type(U8 value) {
+        throw new UnsupportedOperationException("OFOxmIcmpv6Type not supported in version 1.1");
+    }
+
+    public OFOxmIcmpv6TypeMasked.Builder buildIcmpv6TypeMasked() {
+        throw new UnsupportedOperationException("OFOxmIcmpv6TypeMasked not supported in version 1.1");
+    }
+    public OFOxmIcmpv6TypeMasked icmpv6TypeMasked(U8 value, U8 mask) {
+        throw new UnsupportedOperationException("OFOxmIcmpv6TypeMasked not supported in version 1.1");
+    }
+
+    public OFOxmInPhyPort.Builder buildInPhyPort() {
+        throw new UnsupportedOperationException("OFOxmInPhyPort not supported in version 1.1");
+    }
+    public OFOxmInPhyPort inPhyPort(OFPort value) {
+        throw new UnsupportedOperationException("OFOxmInPhyPort not supported in version 1.1");
+    }
+
+    public OFOxmInPhyPortMasked.Builder buildInPhyPortMasked() {
+        throw new UnsupportedOperationException("OFOxmInPhyPortMasked not supported in version 1.1");
+    }
+    public OFOxmInPhyPortMasked inPhyPortMasked(OFPort value, OFPort mask) {
+        throw new UnsupportedOperationException("OFOxmInPhyPortMasked not supported in version 1.1");
+    }
+
+    public OFOxmInPort.Builder buildInPort() {
+        throw new UnsupportedOperationException("OFOxmInPort not supported in version 1.1");
+    }
+    public OFOxmInPort inPort(OFPort value) {
+        throw new UnsupportedOperationException("OFOxmInPort not supported in version 1.1");
+    }
+
+    public OFOxmInPortMasked.Builder buildInPortMasked() {
+        throw new UnsupportedOperationException("OFOxmInPortMasked not supported in version 1.1");
+    }
+    public OFOxmInPortMasked inPortMasked(OFPort value, OFPort mask) {
+        throw new UnsupportedOperationException("OFOxmInPortMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpDscp.Builder buildIpDscp() {
+        throw new UnsupportedOperationException("OFOxmIpDscp not supported in version 1.1");
+    }
+    public OFOxmIpDscp ipDscp(IpDscp value) {
+        throw new UnsupportedOperationException("OFOxmIpDscp not supported in version 1.1");
+    }
+
+    public OFOxmIpDscpMasked.Builder buildIpDscpMasked() {
+        throw new UnsupportedOperationException("OFOxmIpDscpMasked not supported in version 1.1");
+    }
+    public OFOxmIpDscpMasked ipDscpMasked(IpDscp value, IpDscp mask) {
+        throw new UnsupportedOperationException("OFOxmIpDscpMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpEcn.Builder buildIpEcn() {
+        throw new UnsupportedOperationException("OFOxmIpEcn not supported in version 1.1");
+    }
+    public OFOxmIpEcn ipEcn(IpEcn value) {
+        throw new UnsupportedOperationException("OFOxmIpEcn not supported in version 1.1");
+    }
+
+    public OFOxmIpEcnMasked.Builder buildIpEcnMasked() {
+        throw new UnsupportedOperationException("OFOxmIpEcnMasked not supported in version 1.1");
+    }
+    public OFOxmIpEcnMasked ipEcnMasked(IpEcn value, IpEcn mask) {
+        throw new UnsupportedOperationException("OFOxmIpEcnMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpProto.Builder buildIpProto() {
+        throw new UnsupportedOperationException("OFOxmIpProto not supported in version 1.1");
+    }
+    public OFOxmIpProto ipProto(IpProtocol value) {
+        throw new UnsupportedOperationException("OFOxmIpProto not supported in version 1.1");
+    }
+
+    public OFOxmIpProtoMasked.Builder buildIpProtoMasked() {
+        throw new UnsupportedOperationException("OFOxmIpProtoMasked not supported in version 1.1");
+    }
+    public OFOxmIpProtoMasked ipProtoMasked(IpProtocol value, IpProtocol mask) {
+        throw new UnsupportedOperationException("OFOxmIpProtoMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpv4Dst.Builder buildIpv4Dst() {
+        throw new UnsupportedOperationException("OFOxmIpv4Dst not supported in version 1.1");
+    }
+    public OFOxmIpv4Dst ipv4Dst(IPv4Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv4Dst not supported in version 1.1");
+    }
+
+    public OFOxmIpv4DstMasked.Builder buildIpv4DstMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv4DstMasked not supported in version 1.1");
+    }
+    public OFOxmIpv4DstMasked ipv4DstMasked(IPv4Address value, IPv4Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv4DstMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpv4Src.Builder buildIpv4Src() {
+        throw new UnsupportedOperationException("OFOxmIpv4Src not supported in version 1.1");
+    }
+    public OFOxmIpv4Src ipv4Src(IPv4Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv4Src not supported in version 1.1");
+    }
+
+    public OFOxmIpv4SrcMasked.Builder buildIpv4SrcMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv4SrcMasked not supported in version 1.1");
+    }
+    public OFOxmIpv4SrcMasked ipv4SrcMasked(IPv4Address value, IPv4Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv4SrcMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpv6Dst.Builder buildIpv6Dst() {
+        throw new UnsupportedOperationException("OFOxmIpv6Dst not supported in version 1.1");
+    }
+    public OFOxmIpv6Dst ipv6Dst(IPv6Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv6Dst not supported in version 1.1");
+    }
+
+    public OFOxmIpv6DstMasked.Builder buildIpv6DstMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6DstMasked not supported in version 1.1");
+    }
+    public OFOxmIpv6DstMasked ipv6DstMasked(IPv6Address value, IPv6Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6DstMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpv6Flabel.Builder buildIpv6Flabel() {
+        throw new UnsupportedOperationException("OFOxmIpv6Flabel not supported in version 1.1");
+    }
+    public OFOxmIpv6Flabel ipv6Flabel(IPv6FlowLabel value) {
+        throw new UnsupportedOperationException("OFOxmIpv6Flabel not supported in version 1.1");
+    }
+
+    public OFOxmIpv6FlabelMasked.Builder buildIpv6FlabelMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6FlabelMasked not supported in version 1.1");
+    }
+    public OFOxmIpv6FlabelMasked ipv6FlabelMasked(IPv6FlowLabel value, IPv6FlowLabel mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6FlabelMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpv6NdSll.Builder buildIpv6NdSll() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdSll not supported in version 1.1");
+    }
+    public OFOxmIpv6NdSll ipv6NdSll(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdSll not supported in version 1.1");
+    }
+
+    public OFOxmIpv6NdSllMasked.Builder buildIpv6NdSllMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdSllMasked not supported in version 1.1");
+    }
+    public OFOxmIpv6NdSllMasked ipv6NdSllMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdSllMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpv6NdTarget.Builder buildIpv6NdTarget() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTarget not supported in version 1.1");
+    }
+    public OFOxmIpv6NdTarget ipv6NdTarget(IPv6Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTarget not supported in version 1.1");
+    }
+
+    public OFOxmIpv6NdTargetMasked.Builder buildIpv6NdTargetMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTargetMasked not supported in version 1.1");
+    }
+    public OFOxmIpv6NdTargetMasked ipv6NdTargetMasked(IPv6Address value, IPv6Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTargetMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpv6NdTll.Builder buildIpv6NdTll() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTll not supported in version 1.1");
+    }
+    public OFOxmIpv6NdTll ipv6NdTll(MacAddress value) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTll not supported in version 1.1");
+    }
+
+    public OFOxmIpv6NdTllMasked.Builder buildIpv6NdTllMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTllMasked not supported in version 1.1");
+    }
+    public OFOxmIpv6NdTllMasked ipv6NdTllMasked(MacAddress value, MacAddress mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6NdTllMasked not supported in version 1.1");
+    }
+
+    public OFOxmIpv6Src.Builder buildIpv6Src() {
+        throw new UnsupportedOperationException("OFOxmIpv6Src not supported in version 1.1");
+    }
+    public OFOxmIpv6Src ipv6Src(IPv6Address value) {
+        throw new UnsupportedOperationException("OFOxmIpv6Src not supported in version 1.1");
+    }
+
+    public OFOxmIpv6SrcMasked.Builder buildIpv6SrcMasked() {
+        throw new UnsupportedOperationException("OFOxmIpv6SrcMasked not supported in version 1.1");
+    }
+    public OFOxmIpv6SrcMasked ipv6SrcMasked(IPv6Address value, IPv6Address mask) {
+        throw new UnsupportedOperationException("OFOxmIpv6SrcMasked not supported in version 1.1");
+    }
+
+    public OFOxmMetadata.Builder buildMetadata() {
+        throw new UnsupportedOperationException("OFOxmMetadata not supported in version 1.1");
+    }
+    public OFOxmMetadata metadata(OFMetadata value) {
+        throw new UnsupportedOperationException("OFOxmMetadata not supported in version 1.1");
+    }
+
+    public OFOxmMetadataMasked.Builder buildMetadataMasked() {
+        throw new UnsupportedOperationException("OFOxmMetadataMasked not supported in version 1.1");
+    }
+    public OFOxmMetadataMasked metadataMasked(OFMetadata value, OFMetadata mask) {
+        throw new UnsupportedOperationException("OFOxmMetadataMasked not supported in version 1.1");
+    }
+
+    public OFOxmMplsLabel.Builder buildMplsLabel() {
+        throw new UnsupportedOperationException("OFOxmMplsLabel not supported in version 1.1");
+    }
+    public OFOxmMplsLabel mplsLabel(U32 value) {
+        throw new UnsupportedOperationException("OFOxmMplsLabel not supported in version 1.1");
+    }
+
+    public OFOxmMplsLabelMasked.Builder buildMplsLabelMasked() {
+        throw new UnsupportedOperationException("OFOxmMplsLabelMasked not supported in version 1.1");
+    }
+    public OFOxmMplsLabelMasked mplsLabelMasked(U32 value, U32 mask) {
+        throw new UnsupportedOperationException("OFOxmMplsLabelMasked not supported in version 1.1");
+    }
+
+    public OFOxmMplsTc.Builder buildMplsTc() {
+        throw new UnsupportedOperationException("OFOxmMplsTc not supported in version 1.1");
+    }
+    public OFOxmMplsTc mplsTc(U8 value) {
+        throw new UnsupportedOperationException("OFOxmMplsTc not supported in version 1.1");
+    }
+
+    public OFOxmMplsTcMasked.Builder buildMplsTcMasked() {
+        throw new UnsupportedOperationException("OFOxmMplsTcMasked not supported in version 1.1");
+    }
+    public OFOxmMplsTcMasked mplsTcMasked(U8 value, U8 mask) {
+        throw new UnsupportedOperationException("OFOxmMplsTcMasked not supported in version 1.1");
+    }
+
+    public OFOxmSctpDst.Builder buildSctpDst() {
+        throw new UnsupportedOperationException("OFOxmSctpDst not supported in version 1.1");
+    }
+    public OFOxmSctpDst sctpDst(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmSctpDst not supported in version 1.1");
+    }
+
+    public OFOxmSctpDstMasked.Builder buildSctpDstMasked() {
+        throw new UnsupportedOperationException("OFOxmSctpDstMasked not supported in version 1.1");
+    }
+    public OFOxmSctpDstMasked sctpDstMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmSctpDstMasked not supported in version 1.1");
+    }
+
+    public OFOxmSctpSrc.Builder buildSctpSrc() {
+        throw new UnsupportedOperationException("OFOxmSctpSrc not supported in version 1.1");
+    }
+    public OFOxmSctpSrc sctpSrc(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmSctpSrc not supported in version 1.1");
+    }
+
+    public OFOxmSctpSrcMasked.Builder buildSctpSrcMasked() {
+        throw new UnsupportedOperationException("OFOxmSctpSrcMasked not supported in version 1.1");
+    }
+    public OFOxmSctpSrcMasked sctpSrcMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmSctpSrcMasked not supported in version 1.1");
+    }
+
+    public OFOxmTcpDst.Builder buildTcpDst() {
+        throw new UnsupportedOperationException("OFOxmTcpDst not supported in version 1.1");
+    }
+    public OFOxmTcpDst tcpDst(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmTcpDst not supported in version 1.1");
+    }
+
+    public OFOxmTcpDstMasked.Builder buildTcpDstMasked() {
+        throw new UnsupportedOperationException("OFOxmTcpDstMasked not supported in version 1.1");
+    }
+    public OFOxmTcpDstMasked tcpDstMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmTcpDstMasked not supported in version 1.1");
+    }
+
+    public OFOxmTcpSrc.Builder buildTcpSrc() {
+        throw new UnsupportedOperationException("OFOxmTcpSrc not supported in version 1.1");
+    }
+    public OFOxmTcpSrc tcpSrc(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmTcpSrc not supported in version 1.1");
+    }
+
+    public OFOxmTcpSrcMasked.Builder buildTcpSrcMasked() {
+        throw new UnsupportedOperationException("OFOxmTcpSrcMasked not supported in version 1.1");
+    }
+    public OFOxmTcpSrcMasked tcpSrcMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmTcpSrcMasked not supported in version 1.1");
+    }
+
+    public OFOxmUdpDst.Builder buildUdpDst() {
+        throw new UnsupportedOperationException("OFOxmUdpDst not supported in version 1.1");
+    }
+    public OFOxmUdpDst udpDst(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmUdpDst not supported in version 1.1");
+    }
+
+    public OFOxmUdpDstMasked.Builder buildUdpDstMasked() {
+        throw new UnsupportedOperationException("OFOxmUdpDstMasked not supported in version 1.1");
+    }
+    public OFOxmUdpDstMasked udpDstMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmUdpDstMasked not supported in version 1.1");
+    }
+
+    public OFOxmUdpSrc.Builder buildUdpSrc() {
+        throw new UnsupportedOperationException("OFOxmUdpSrc not supported in version 1.1");
+    }
+    public OFOxmUdpSrc udpSrc(TransportPort value) {
+        throw new UnsupportedOperationException("OFOxmUdpSrc not supported in version 1.1");
+    }
+
+    public OFOxmUdpSrcMasked.Builder buildUdpSrcMasked() {
+        throw new UnsupportedOperationException("OFOxmUdpSrcMasked not supported in version 1.1");
+    }
+    public OFOxmUdpSrcMasked udpSrcMasked(TransportPort value, TransportPort mask) {
+        throw new UnsupportedOperationException("OFOxmUdpSrcMasked not supported in version 1.1");
+    }
+
+    public OFOxmVlanPcp.Builder buildVlanPcp() {
+        throw new UnsupportedOperationException("OFOxmVlanPcp not supported in version 1.1");
+    }
+    public OFOxmVlanPcp vlanPcp(VlanPcp value) {
+        throw new UnsupportedOperationException("OFOxmVlanPcp not supported in version 1.1");
+    }
+
+    public OFOxmVlanPcpMasked.Builder buildVlanPcpMasked() {
+        throw new UnsupportedOperationException("OFOxmVlanPcpMasked not supported in version 1.1");
+    }
+    public OFOxmVlanPcpMasked vlanPcpMasked(VlanPcp value, VlanPcp mask) {
+        throw new UnsupportedOperationException("OFOxmVlanPcpMasked not supported in version 1.1");
+    }
+
+    public OFOxmVlanVid.Builder buildVlanVid() {
+        throw new UnsupportedOperationException("OFOxmVlanVid not supported in version 1.1");
+    }
+    public OFOxmVlanVid vlanVid(OFVlanVidMatch value) {
+        throw new UnsupportedOperationException("OFOxmVlanVid not supported in version 1.1");
+    }
+
+    public OFOxmVlanVidMasked.Builder buildVlanVidMasked() {
+        throw new UnsupportedOperationException("OFOxmVlanVidMasked not supported in version 1.1");
+    }
+    public OFOxmVlanVidMasked vlanVidMasked(OFVlanVidMatch value, OFVlanVidMatch mask) {
+        throw new UnsupportedOperationException("OFOxmVlanVidMasked not supported in version 1.1");
+    }
+
+    public OFOxmTunnelId.Builder buildTunnelId() {
+        throw new UnsupportedOperationException("OFOxmTunnelId not supported in version 1.1");
+    }
+    public OFOxmTunnelId tunnelId(U64 value) {
+        throw new UnsupportedOperationException("OFOxmTunnelId not supported in version 1.1");
+    }
+
+    public OFOxmTunnelIdMasked.Builder buildTunnelIdMasked() {
+        throw new UnsupportedOperationException("OFOxmTunnelIdMasked not supported in version 1.1");
+    }
+    public OFOxmTunnelIdMasked tunnelIdMasked(U64 value, U64 mask) {
+        throw new UnsupportedOperationException("OFOxmTunnelIdMasked not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFOxm<?>> getReader() {
+        throw new UnsupportedOperationException("Reader<OFOxm<?>> not supported in version 1.1");
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromValue(F value, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOp((ArpOpcode)((Object)value)));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpSha((MacAddress)((Object)value)));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpa((IPv4Address)((Object)value)));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpTha((MacAddress)((Object)value)));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpa((IPv4Address)((Object)value)));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupId((ClassId)((Object)value)));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowed((OFBooleanValue)((Object)value)));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128((OFBitMask128)((Object)value)));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassId((ClassId)((Object)value)));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassId((ClassId)((Object)value)));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassId((ClassId)((Object)value)));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagId((LagId)((Object)value)));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlags((U16)((Object)value)));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0((UDF)((Object)value)));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1((UDF)((Object)value)));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2((UDF)((Object)value)));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3((UDF)((Object)value)));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4((UDF)((Object)value)));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5((UDF)((Object)value)));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6((UDF)((Object)value)));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7((UDF)((Object)value)));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupId((ClassId)((Object)value)));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrf((VRF)((Object)value)));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDst((MacAddress)((Object)value)));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrc((MacAddress)((Object)value)));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethType((EthType)((Object)value)));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4Code((ICMPv4Code)((Object)value)));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4Type((ICMPv4Type)((Object)value)));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6Code((U8)((Object)value)));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6Type((U8)((Object)value)));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPort((OFPort)((Object)value)));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPort((OFPort)((Object)value)));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscp((IpDscp)((Object)value)));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcn((IpEcn)((Object)value)));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProto((IpProtocol)((Object)value)));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4Dst((IPv4Address)((Object)value)));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4Src((IPv4Address)((Object)value)));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6Dst((IPv6Address)((Object)value)));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6Flabel((IPv6FlowLabel)((Object)value)));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSll((MacAddress)((Object)value)));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTarget((IPv6Address)((Object)value)));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTll((MacAddress)((Object)value)));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6Src((IPv6Address)((Object)value)));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadata((OFMetadata)((Object)value)));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabel((U32)((Object)value)));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTc((U8)((Object)value)));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDst((TransportPort)((Object)value)));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrc((TransportPort)((Object)value)));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDst((TransportPort)((Object)value)));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrc((TransportPort)((Object)value)));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDst((TransportPort)((Object)value)));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrc((TransportPort)((Object)value)));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcp((VlanPcp)((Object)value)));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVid((OFVlanVidMatch)((Object)value)));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelId((U64)((Object)value)));
+            default:
+                throw new IllegalArgumentException("No OXM known for match field " + field);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromValueAndMask(F value, F mask, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOpMasked((ArpOpcode)((Object)value), (ArpOpcode)((Object)mask)));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpShaMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpaMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpThaMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpaMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowedMasked((OFBooleanValue)((Object)value), (OFBooleanValue)((Object)mask)));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128Masked((OFBitMask128)((Object)value), (OFBitMask128)((Object)mask)));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagIdMasked((LagId)((Object)value), (LagId)((Object)mask)));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlagsMasked((U16)((Object)value), (U16)((Object)mask)));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrfMasked((VRF)((Object)value), (VRF)((Object)mask)));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDstMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrcMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethTypeMasked((EthType)((Object)value), (EthType)((Object)mask)));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4CodeMasked((ICMPv4Code)((Object)value), (ICMPv4Code)((Object)mask)));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4TypeMasked((ICMPv4Type)((Object)value), (ICMPv4Type)((Object)mask)));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6CodeMasked((U8)((Object)value), (U8)((Object)mask)));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6TypeMasked((U8)((Object)value), (U8)((Object)mask)));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPortMasked((OFPort)((Object)value), (OFPort)((Object)mask)));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPortMasked((OFPort)((Object)value), (OFPort)((Object)mask)));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscpMasked((IpDscp)((Object)value), (IpDscp)((Object)mask)));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcnMasked((IpEcn)((Object)value), (IpEcn)((Object)mask)));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProtoMasked((IpProtocol)((Object)value), (IpProtocol)((Object)mask)));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4DstMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4SrcMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6DstMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6FlabelMasked((IPv6FlowLabel)((Object)value), (IPv6FlowLabel)((Object)mask)));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSllMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTargetMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTllMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6SrcMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadataMasked((OFMetadata)((Object)value), (OFMetadata)((Object)mask)));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabelMasked((U32)((Object)value), (U32)((Object)mask)));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTcMasked((U8)((Object)value), (U8)((Object)mask)));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcpMasked((VlanPcp)((Object)value), (VlanPcp)((Object)mask)));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVidMasked((OFVlanVidMatch)((Object)value), (OFVlanVidMatch)((Object)mask)));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelIdMasked((U64)((Object)value), (U64)((Object)mask)));
+            default:
+                throw new IllegalArgumentException("No OXM known for match field " + field);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromMasked(Masked<F> masked, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOpMasked((ArpOpcode)((Object)(masked.getValue())), (ArpOpcode)((Object)(masked.getMask()))));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpShaMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpaMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpThaMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpaMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowedMasked((OFBooleanValue)((Object)(masked.getValue())), (OFBooleanValue)((Object)(masked.getMask()))));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128Masked((OFBitMask128)((Object)(masked.getValue())), (OFBitMask128)((Object)(masked.getMask()))));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagIdMasked((LagId)((Object)(masked.getValue())), (LagId)((Object)(masked.getMask()))));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlagsMasked((U16)((Object)(masked.getValue())), (U16)((Object)(masked.getMask()))));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrfMasked((VRF)((Object)(masked.getValue())), (VRF)((Object)(masked.getMask()))));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDstMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrcMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethTypeMasked((EthType)((Object)(masked.getValue())), (EthType)((Object)(masked.getMask()))));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4CodeMasked((ICMPv4Code)((Object)(masked.getValue())), (ICMPv4Code)((Object)(masked.getMask()))));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4TypeMasked((ICMPv4Type)((Object)(masked.getValue())), (ICMPv4Type)((Object)(masked.getMask()))));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6CodeMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6TypeMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPortMasked((OFPort)((Object)(masked.getValue())), (OFPort)((Object)(masked.getMask()))));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPortMasked((OFPort)((Object)(masked.getValue())), (OFPort)((Object)(masked.getMask()))));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscpMasked((IpDscp)((Object)(masked.getValue())), (IpDscp)((Object)(masked.getMask()))));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcnMasked((IpEcn)((Object)(masked.getValue())), (IpEcn)((Object)(masked.getMask()))));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProtoMasked((IpProtocol)((Object)(masked.getValue())), (IpProtocol)((Object)(masked.getMask()))));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4DstMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4SrcMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6DstMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6FlabelMasked((IPv6FlowLabel)((Object)(masked.getValue())), (IPv6FlowLabel)((Object)(masked.getMask()))));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSllMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTargetMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTllMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6SrcMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadataMasked((OFMetadata)((Object)(masked.getValue())), (OFMetadata)((Object)(masked.getMask()))));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabelMasked((U32)((Object)(masked.getValue())), (U32)((Object)(masked.getMask()))));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTcMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcpMasked((VlanPcp)((Object)(masked.getValue())), (VlanPcp)((Object)(masked.getMask()))));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVidMasked((OFVlanVidMatch)((Object)(masked.getValue())), (OFVlanVidMatch)((Object)(masked.getMask()))));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelIdMasked((U64)((Object)(masked.getValue())), (U64)((Object)(masked.getMask()))));
+            default:
+                return null;
+        }
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketInReasonSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketInReasonSerializerVer11.java
new file mode 100644
index 0000000..c84236d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketInReasonSerializerVer11.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPacketInReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPacketInReasonSerializerVer11 {
+
+    public final static byte NO_MATCH_VAL = (byte) 0x0;
+    public final static byte ACTION_VAL = (byte) 0x1;
+
+    public static OFPacketInReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPacketInReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFPacketInReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFPacketInReason ofWireValue(byte val) {
+        switch(val) {
+            case NO_MATCH_VAL:
+                return OFPacketInReason.NO_MATCH;
+            case ACTION_VAL:
+                return OFPacketInReason.ACTION;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPacketInReason in version 1.1: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFPacketInReason e) {
+        switch(e) {
+            case NO_MATCH:
+                return NO_MATCH_VAL;
+            case ACTION:
+                return ACTION_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPacketInReason in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketInVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketInVer11.java
new file mode 100644
index 0000000..ededbb1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketInVer11.java
@@ -0,0 +1,684 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFPacketInVer11 implements OFPacketIn {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketInVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_IN_PORT = OFPort.ANY;
+        private final static OFPort DEFAULT_IN_PHY_PORT = OFPort.ANY;
+        private final static int DEFAULT_TOTAL_LEN = 0x0;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final OFBufferId bufferId;
+    private final OFPort inPort;
+    private final OFPort inPhyPort;
+    private final int totalLen;
+    private final OFPacketInReason reason;
+    private final TableId tableId;
+    private final byte[] data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketInVer11(long xid, OFBufferId bufferId, OFPort inPort, OFPort inPhyPort, int totalLen, OFPacketInReason reason, TableId tableId, byte[] data) {
+        this.xid = xid;
+        this.bufferId = bufferId;
+        this.inPort = inPort;
+        this.inPhyPort = inPhyPort;
+        this.totalLen = totalLen;
+        this.reason = reason;
+        this.tableId = tableId;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public Match getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.1");
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPort getInPhyPort() {
+        return inPhyPort;
+    }
+
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.1");
+    }
+
+
+
+    public OFPacketIn.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketIn.Builder {
+        final OFPacketInVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean inPhyPortSet;
+        private OFPort inPhyPort;
+        private boolean totalLenSet;
+        private int totalLen;
+        private boolean reasonSet;
+        private OFPacketInReason reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFPacketInVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketIn.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTotalLen(int totalLen) {
+        this.totalLen = totalLen;
+        this.totalLenSet = true;
+        return this;
+    }
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPacketIn.Builder setReason(OFPacketInReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.1");
+    }
+
+    @Override
+    public OFPacketIn.Builder setMatch(Match match) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property match not supported in version 1.1");
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketIn.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPhyPort() {
+        return inPhyPort;
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) {
+        this.inPhyPort = inPhyPort;
+        this.inPhyPortSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.1");
+    }
+
+    @Override
+    public OFPacketIn.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.1");
+    }
+
+
+        @Override
+        public OFPacketIn build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort;
+                if(inPort == null)
+                    throw new NullPointerException("Property inPort must not be null");
+                OFPort inPhyPort = this.inPhyPortSet ? this.inPhyPort : parentMessage.inPhyPort;
+                if(inPhyPort == null)
+                    throw new NullPointerException("Property inPhyPort must not be null");
+                int totalLen = this.totalLenSet ? this.totalLen : parentMessage.totalLen;
+                OFPacketInReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPacketInVer11(
+                    xid,
+                    bufferId,
+                    inPort,
+                    inPhyPort,
+                    totalLen,
+                    reason,
+                    tableId,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketIn.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean inPhyPortSet;
+        private OFPort inPhyPort;
+        private boolean totalLenSet;
+        private int totalLen;
+        private boolean reasonSet;
+        private OFPacketInReason reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketIn.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTotalLen(int totalLen) {
+        this.totalLen = totalLen;
+        this.totalLenSet = true;
+        return this;
+    }
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPacketIn.Builder setReason(OFPacketInReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.1");
+    }
+
+    @Override
+    public OFPacketIn.Builder setMatch(Match match) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property match not supported in version 1.1");
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketIn.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPhyPort() {
+        return inPhyPort;
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) {
+        this.inPhyPort = inPhyPort;
+        this.inPhyPortSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.1");
+    }
+
+    @Override
+    public OFPacketIn.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.1");
+    }
+//
+        @Override
+        public OFPacketIn build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT;
+            if(inPort == null)
+                throw new NullPointerException("Property inPort must not be null");
+            OFPort inPhyPort = this.inPhyPortSet ? this.inPhyPort : DEFAULT_IN_PHY_PORT;
+            if(inPhyPort == null)
+                throw new NullPointerException("Property inPhyPort must not be null");
+            int totalLen = this.totalLenSet ? this.totalLen : DEFAULT_TOTAL_LEN;
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPacketInVer11(
+                    xid,
+                    bufferId,
+                    inPort,
+                    inPhyPort,
+                    totalLen,
+                    reason,
+                    tableId,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketIn> {
+        @Override
+        public OFPacketIn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 10
+            byte type = bb.readByte();
+            if(type != (byte) 0xa)
+                throw new OFParseError("Wrong type: Expected=OFType.PACKET_IN(10), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort inPort = OFPort.read4Bytes(bb);
+            OFPort inPhyPort = OFPort.read4Bytes(bb);
+            int totalLen = U16.f(bb.readShort());
+            OFPacketInReason reason = OFPacketInReasonSerializerVer11.readFrom(bb);
+            TableId tableId = TableId.readByte(bb);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFPacketInVer11 packetInVer11 = new OFPacketInVer11(
+                    xid,
+                      bufferId,
+                      inPort,
+                      inPhyPort,
+                      totalLen,
+                      reason,
+                      tableId,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetInVer11);
+            return packetInVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketInVer11Funnel FUNNEL = new OFPacketInVer11Funnel();
+    static class OFPacketInVer11Funnel implements Funnel<OFPacketInVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketInVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 10
+            sink.putByte((byte) 0xa);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.bufferId.putTo(sink);
+            message.inPort.putTo(sink);
+            message.inPhyPort.putTo(sink);
+            sink.putInt(message.totalLen);
+            OFPacketInReasonSerializerVer11.putTo(message.reason, sink);
+            message.tableId.putTo(sink);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketInVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketInVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 10
+            bb.writeByte((byte) 0xa);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(message.bufferId.getInt());
+            message.inPort.write4Bytes(bb);
+            message.inPhyPort.write4Bytes(bb);
+            bb.writeShort(U16.t(message.totalLen));
+            OFPacketInReasonSerializerVer11.writeTo(bb, message.reason);
+            message.tableId.writeByte(bb);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketInVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("inPort=").append(inPort);
+        b.append(", ");
+        b.append("inPhyPort=").append(inPhyPort);
+        b.append(", ");
+        b.append("totalLen=").append(totalLen);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketInVer11 other = (OFPacketInVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (inPort == null) {
+            if (other.inPort != null)
+                return false;
+        } else if (!inPort.equals(other.inPort))
+            return false;
+        if (inPhyPort == null) {
+            if (other.inPhyPort != null)
+                return false;
+        } else if (!inPhyPort.equals(other.inPhyPort))
+            return false;
+        if( totalLen != other.totalLen)
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((inPort == null) ? 0 : inPort.hashCode());
+        result = prime * result + ((inPhyPort == null) ? 0 : inPhyPort.hashCode());
+        result = prime * result + totalLen;
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketOutVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketOutVer11.java
new file mode 100644
index 0000000..e2ecf2e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketOutVer11.java
@@ -0,0 +1,504 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFPacketOutVer11 implements OFPacketOut {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketOutVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_IN_PORT = OFPort.ANY;
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final OFBufferId bufferId;
+    private final OFPort inPort;
+    private final List<OFAction> actions;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFPacketOutVer11 DEFAULT = new OFPacketOutVer11(
+        DEFAULT_XID, DEFAULT_BUFFER_ID, DEFAULT_IN_PORT, DEFAULT_ACTIONS, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketOutVer11(long xid, OFBufferId bufferId, OFPort inPort, List<OFAction> actions, byte[] data) {
+        this.xid = xid;
+        this.bufferId = bufferId;
+        this.inPort = inPort;
+        this.actions = actions;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFPacketOut.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketOut.Builder {
+        final OFPacketOutVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFPacketOutVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketOut.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketOut.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketOut.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFPacketOut.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketOut.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPacketOut build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort;
+                if(inPort == null)
+                    throw new NullPointerException("Property inPort must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPacketOutVer11(
+                    xid,
+                    bufferId,
+                    inPort,
+                    actions,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketOut.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketOut.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketOut.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketOut.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFPacketOut.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketOut.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPacketOut build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT;
+            if(inPort == null)
+                throw new NullPointerException("Property inPort must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPacketOutVer11(
+                    xid,
+                    bufferId,
+                    inPort,
+                    actions,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketOut> {
+        @Override
+        public OFPacketOut readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 13
+            byte type = bb.readByte();
+            if(type != (byte) 0xd)
+                throw new OFParseError("Wrong type: Expected=OFType.PACKET_OUT(13), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort inPort = OFPort.read4Bytes(bb);
+            int actionsLen = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            List<OFAction> actions = ChannelUtils.readList(bb, actionsLen, OFActionVer11.READER);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFPacketOutVer11 packetOutVer11 = new OFPacketOutVer11(
+                    xid,
+                      bufferId,
+                      inPort,
+                      actions,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetOutVer11);
+            return packetOutVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketOutVer11Funnel FUNNEL = new OFPacketOutVer11Funnel();
+    static class OFPacketOutVer11Funnel implements Funnel<OFPacketOutVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketOutVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 13
+            sink.putByte((byte) 0xd);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.bufferId.putTo(sink);
+            message.inPort.putTo(sink);
+            // FIXME: skip funnel of actionsLen
+            // skip pad (6 bytes)
+            FunnelUtils.putList(message.actions, sink);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketOutVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketOutVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 13
+            bb.writeByte((byte) 0xd);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(message.bufferId.getInt());
+            message.inPort.write4Bytes(bb);
+            // actionsLen is length indicator for actions, will be
+            // udpated when actions has been written
+            int actionsLenIndex = bb.writerIndex();
+            bb.writeShort(0);
+            // pad: 6 bytes
+            bb.writeZero(6);
+            int actionsStartIndex = bb.writerIndex();
+            ChannelUtils.writeList(bb, message.actions);
+            // update field length member actionsLen
+            int actionsLength = bb.writerIndex() - actionsStartIndex;
+            bb.setShort(actionsLenIndex, actionsLength);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketOutVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("inPort=").append(inPort);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketOutVer11 other = (OFPacketOutVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (inPort == null) {
+            if (other.inPort != null)
+                return false;
+        } else if (!inPort.equals(other.inPort))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((inPort == null) ? 0 : inPort.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketQueueVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketQueueVer11.java
new file mode 100644
index 0000000..cef5b2c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPacketQueueVer11.java
@@ -0,0 +1,326 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPacketQueueVer11 implements OFPacketQueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketQueueVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+        private final static List<OFQueueProp> DEFAULT_PROPERTIES = ImmutableList.<OFQueueProp>of();
+
+    // OF message fields
+    private final long queueId;
+    private final List<OFQueueProp> properties;
+//
+    // Immutable default instance
+    final static OFPacketQueueVer11 DEFAULT = new OFPacketQueueVer11(
+        DEFAULT_QUEUE_ID, DEFAULT_PROPERTIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketQueueVer11(long queueId, List<OFQueueProp> properties) {
+        this.queueId = queueId;
+        this.properties = properties;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPort getPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property port not supported in version 1.1");
+    }
+
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFPacketQueue.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketQueue.Builder {
+        final OFPacketQueueVer11 parentMessage;
+
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean propertiesSet;
+        private List<OFQueueProp> properties;
+
+        BuilderWithParent(OFPacketQueueVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property port not supported in version 1.1");
+    }
+
+    @Override
+    public OFPacketQueue.Builder setPort(OFPort port) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property port not supported in version 1.1");
+    }
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setProperties(List<OFQueueProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFPacketQueue build() {
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+                List<OFQueueProp> properties = this.propertiesSet ? this.properties : parentMessage.properties;
+                if(properties == null)
+                    throw new NullPointerException("Property properties must not be null");
+
+                //
+                return new OFPacketQueueVer11(
+                    queueId,
+                    properties
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketQueue.Builder {
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean propertiesSet;
+        private List<OFQueueProp> properties;
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property port not supported in version 1.1");
+    }
+
+    @Override
+    public OFPacketQueue.Builder setPort(OFPort port) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property port not supported in version 1.1");
+    }
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setProperties(List<OFQueueProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFPacketQueue build() {
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+            List<OFQueueProp> properties = this.propertiesSet ? this.properties : DEFAULT_PROPERTIES;
+            if(properties == null)
+                throw new NullPointerException("Property properties must not be null");
+
+
+            return new OFPacketQueueVer11(
+                    queueId,
+                    properties
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketQueue> {
+        @Override
+        public OFPacketQueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            long queueId = U32.f(bb.readInt());
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            List<OFQueueProp> properties = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFQueuePropVer11.READER);
+
+            OFPacketQueueVer11 packetQueueVer11 = new OFPacketQueueVer11(
+                    queueId,
+                      properties
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetQueueVer11);
+            return packetQueueVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketQueueVer11Funnel FUNNEL = new OFPacketQueueVer11Funnel();
+    static class OFPacketQueueVer11Funnel implements Funnel<OFPacketQueueVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketQueueVer11 message, PrimitiveSink sink) {
+            sink.putLong(message.queueId);
+            // FIXME: skip funnel of length
+            // skip pad (2 bytes)
+            FunnelUtils.putList(message.properties, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketQueueVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketQueueVer11 message) {
+            int startIndex = bb.writerIndex();
+            bb.writeInt(U32.t(message.queueId));
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeList(bb, message.properties);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketQueueVer11(");
+        b.append("queueId=").append(queueId);
+        b.append(", ");
+        b.append("properties=").append(properties);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketQueueVer11 other = (OFPacketQueueVer11) obj;
+
+        if( queueId != other.queueId)
+            return false;
+        if (properties == null) {
+            if (other.properties != null)
+                return false;
+        } else if (!properties.equals(other.properties))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortConfigSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortConfigSerializerVer11.java
new file mode 100644
index 0000000..f90d256
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortConfigSerializerVer11.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortConfig;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortConfigSerializerVer11 {
+
+    public final static int PORT_DOWN_VAL = 0x1;
+    public final static int NO_RECV_VAL = 0x4;
+    public final static int NO_FWD_VAL = 0x20;
+    public final static int NO_PACKET_IN_VAL = 0x40;
+    public final static int BSN_MIRROR_DEST_VAL = (int) 0x80000000;
+
+    public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortConfig> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortConfig> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortConfig> ofWireValue(int val) {
+        EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);
+
+        if((val & PORT_DOWN_VAL) != 0)
+            set.add(OFPortConfig.PORT_DOWN);
+        if((val & NO_RECV_VAL) != 0)
+            set.add(OFPortConfig.NO_RECV);
+        if((val & NO_FWD_VAL) != 0)
+            set.add(OFPortConfig.NO_FWD);
+        if((val & NO_PACKET_IN_VAL) != 0)
+            set.add(OFPortConfig.NO_PACKET_IN);
+        if((val & BSN_MIRROR_DEST_VAL) != 0)
+            set.add(OFPortConfig.BSN_MIRROR_DEST);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortConfig> set) {
+        int wireValue = 0;
+
+        for(OFPortConfig e: set) {
+            switch(e) {
+                case PORT_DOWN:
+                    wireValue |= PORT_DOWN_VAL;
+                    break;
+                case NO_RECV:
+                    wireValue |= NO_RECV_VAL;
+                    break;
+                case NO_FWD:
+                    wireValue |= NO_FWD_VAL;
+                    break;
+                case NO_PACKET_IN:
+                    wireValue |= NO_PACKET_IN_VAL;
+                    break;
+                case BSN_MIRROR_DEST:
+                    wireValue |= BSN_MIRROR_DEST_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortDescVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortDescVer11.java
new file mode 100644
index 0000000..6969e0e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortDescVer11.java
@@ -0,0 +1,766 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortDescVer11 implements OFPortDesc {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortDescVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 64;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static String DEFAULT_NAME = "";
+        private final static Set<OFPortConfig> DEFAULT_CONFIG = ImmutableSet.<OFPortConfig>of();
+        private final static Set<OFPortState> DEFAULT_STATE = ImmutableSet.<OFPortState>of();
+        private final static Set<OFPortFeatures> DEFAULT_CURR = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_ADVERTISED = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_SUPPORTED = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_PEER = ImmutableSet.<OFPortFeatures>of();
+        private final static long DEFAULT_CURR_SPEED = 0x0L;
+        private final static long DEFAULT_MAX_SPEED = 0x0L;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final MacAddress hwAddr;
+    private final String name;
+    private final Set<OFPortConfig> config;
+    private final Set<OFPortState> state;
+    private final Set<OFPortFeatures> curr;
+    private final Set<OFPortFeatures> advertised;
+    private final Set<OFPortFeatures> supported;
+    private final Set<OFPortFeatures> peer;
+    private final long currSpeed;
+    private final long maxSpeed;
+//
+    // Immutable default instance
+    final static OFPortDescVer11 DEFAULT = new OFPortDescVer11(
+        DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_CONFIG, DEFAULT_STATE, DEFAULT_CURR, DEFAULT_ADVERTISED, DEFAULT_SUPPORTED, DEFAULT_PEER, DEFAULT_CURR_SPEED, DEFAULT_MAX_SPEED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortDescVer11(OFPort portNo, MacAddress hwAddr, String name, Set<OFPortConfig> config, Set<OFPortState> state, Set<OFPortFeatures> curr, Set<OFPortFeatures> advertised, Set<OFPortFeatures> supported, Set<OFPortFeatures> peer, long currSpeed, long maxSpeed) {
+        this.portNo = portNo;
+        this.hwAddr = hwAddr;
+        this.name = name;
+        this.config = config;
+        this.state = state;
+        this.curr = curr;
+        this.advertised = advertised;
+        this.supported = supported;
+        this.peer = peer;
+        this.currSpeed = currSpeed;
+        this.maxSpeed = maxSpeed;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFPortDesc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortDesc.Builder {
+        final OFPortDescVer11 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean configSet;
+        private Set<OFPortConfig> config;
+        private boolean stateSet;
+        private Set<OFPortState> state;
+        private boolean currSet;
+        private Set<OFPortFeatures> curr;
+        private boolean advertisedSet;
+        private Set<OFPortFeatures> advertised;
+        private boolean supportedSet;
+        private Set<OFPortFeatures> supported;
+        private boolean peerSet;
+        private Set<OFPortFeatures> peer;
+        private boolean currSpeedSet;
+        private long currSpeed;
+        private boolean maxSpeedSet;
+        private long maxSpeed;
+
+        BuilderWithParent(OFPortDescVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFPortDesc.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public OFPortDesc.Builder setState(Set<OFPortState> state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) {
+        this.curr = curr;
+        this.currSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) {
+        this.advertised = advertised;
+        this.advertisedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) {
+        this.supported = supported;
+        this.supportedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) {
+        this.peer = peer;
+        this.peerSet = true;
+        return this;
+    }
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurrSpeed(long currSpeed) {
+        this.currSpeed = currSpeed;
+        this.currSpeedSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setMaxSpeed(long maxSpeed) {
+        this.maxSpeed = maxSpeed;
+        this.maxSpeedSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFPortDesc build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                Set<OFPortConfig> config = this.configSet ? this.config : parentMessage.config;
+                if(config == null)
+                    throw new NullPointerException("Property config must not be null");
+                Set<OFPortState> state = this.stateSet ? this.state : parentMessage.state;
+                if(state == null)
+                    throw new NullPointerException("Property state must not be null");
+                Set<OFPortFeatures> curr = this.currSet ? this.curr : parentMessage.curr;
+                if(curr == null)
+                    throw new NullPointerException("Property curr must not be null");
+                Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : parentMessage.advertised;
+                if(advertised == null)
+                    throw new NullPointerException("Property advertised must not be null");
+                Set<OFPortFeatures> supported = this.supportedSet ? this.supported : parentMessage.supported;
+                if(supported == null)
+                    throw new NullPointerException("Property supported must not be null");
+                Set<OFPortFeatures> peer = this.peerSet ? this.peer : parentMessage.peer;
+                if(peer == null)
+                    throw new NullPointerException("Property peer must not be null");
+                long currSpeed = this.currSpeedSet ? this.currSpeed : parentMessage.currSpeed;
+                long maxSpeed = this.maxSpeedSet ? this.maxSpeed : parentMessage.maxSpeed;
+
+                //
+                return new OFPortDescVer11(
+                    portNo,
+                    hwAddr,
+                    name,
+                    config,
+                    state,
+                    curr,
+                    advertised,
+                    supported,
+                    peer,
+                    currSpeed,
+                    maxSpeed
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortDesc.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean configSet;
+        private Set<OFPortConfig> config;
+        private boolean stateSet;
+        private Set<OFPortState> state;
+        private boolean currSet;
+        private Set<OFPortFeatures> curr;
+        private boolean advertisedSet;
+        private Set<OFPortFeatures> advertised;
+        private boolean supportedSet;
+        private Set<OFPortFeatures> supported;
+        private boolean peerSet;
+        private Set<OFPortFeatures> peer;
+        private boolean currSpeedSet;
+        private long currSpeed;
+        private boolean maxSpeedSet;
+        private long maxSpeed;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFPortDesc.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public OFPortDesc.Builder setState(Set<OFPortState> state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) {
+        this.curr = curr;
+        this.currSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) {
+        this.advertised = advertised;
+        this.advertisedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) {
+        this.supported = supported;
+        this.supportedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) {
+        this.peer = peer;
+        this.peerSet = true;
+        return this;
+    }
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurrSpeed(long currSpeed) {
+        this.currSpeed = currSpeed;
+        this.currSpeedSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setMaxSpeed(long maxSpeed) {
+        this.maxSpeed = maxSpeed;
+        this.maxSpeedSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFPortDesc build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            Set<OFPortConfig> config = this.configSet ? this.config : DEFAULT_CONFIG;
+            if(config == null)
+                throw new NullPointerException("Property config must not be null");
+            Set<OFPortState> state = this.stateSet ? this.state : DEFAULT_STATE;
+            if(state == null)
+                throw new NullPointerException("Property state must not be null");
+            Set<OFPortFeatures> curr = this.currSet ? this.curr : DEFAULT_CURR;
+            if(curr == null)
+                throw new NullPointerException("Property curr must not be null");
+            Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : DEFAULT_ADVERTISED;
+            if(advertised == null)
+                throw new NullPointerException("Property advertised must not be null");
+            Set<OFPortFeatures> supported = this.supportedSet ? this.supported : DEFAULT_SUPPORTED;
+            if(supported == null)
+                throw new NullPointerException("Property supported must not be null");
+            Set<OFPortFeatures> peer = this.peerSet ? this.peer : DEFAULT_PEER;
+            if(peer == null)
+                throw new NullPointerException("Property peer must not be null");
+            long currSpeed = this.currSpeedSet ? this.currSpeed : DEFAULT_CURR_SPEED;
+            long maxSpeed = this.maxSpeedSet ? this.maxSpeed : DEFAULT_MAX_SPEED;
+
+
+            return new OFPortDescVer11(
+                    portNo,
+                    hwAddr,
+                    name,
+                    config,
+                    state,
+                    curr,
+                    advertised,
+                    supported,
+                    peer,
+                    currSpeed,
+                    maxSpeed
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortDesc> {
+        @Override
+        public OFPortDesc readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            String name = ChannelUtils.readFixedLengthString(bb, 16);
+            Set<OFPortConfig> config = OFPortConfigSerializerVer11.readFrom(bb);
+            Set<OFPortState> state = OFPortStateSerializerVer11.readFrom(bb);
+            Set<OFPortFeatures> curr = OFPortFeaturesSerializerVer11.readFrom(bb);
+            Set<OFPortFeatures> advertised = OFPortFeaturesSerializerVer11.readFrom(bb);
+            Set<OFPortFeatures> supported = OFPortFeaturesSerializerVer11.readFrom(bb);
+            Set<OFPortFeatures> peer = OFPortFeaturesSerializerVer11.readFrom(bb);
+            long currSpeed = U32.f(bb.readInt());
+            long maxSpeed = U32.f(bb.readInt());
+
+            OFPortDescVer11 portDescVer11 = new OFPortDescVer11(
+                    portNo,
+                      hwAddr,
+                      name,
+                      config,
+                      state,
+                      curr,
+                      advertised,
+                      supported,
+                      peer,
+                      currSpeed,
+                      maxSpeed
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portDescVer11);
+            return portDescVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortDescVer11Funnel FUNNEL = new OFPortDescVer11Funnel();
+    static class OFPortDescVer11Funnel implements Funnel<OFPortDescVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortDescVer11 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putUnencodedChars(message.name);
+            OFPortConfigSerializerVer11.putTo(message.config, sink);
+            OFPortStateSerializerVer11.putTo(message.state, sink);
+            OFPortFeaturesSerializerVer11.putTo(message.curr, sink);
+            OFPortFeaturesSerializerVer11.putTo(message.advertised, sink);
+            OFPortFeaturesSerializerVer11.putTo(message.supported, sink);
+            OFPortFeaturesSerializerVer11.putTo(message.peer, sink);
+            sink.putLong(message.currSpeed);
+            sink.putLong(message.maxSpeed);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortDescVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortDescVer11 message) {
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 16);
+            OFPortConfigSerializerVer11.writeTo(bb, message.config);
+            OFPortStateSerializerVer11.writeTo(bb, message.state);
+            OFPortFeaturesSerializerVer11.writeTo(bb, message.curr);
+            OFPortFeaturesSerializerVer11.writeTo(bb, message.advertised);
+            OFPortFeaturesSerializerVer11.writeTo(bb, message.supported);
+            OFPortFeaturesSerializerVer11.writeTo(bb, message.peer);
+            bb.writeInt(U32.t(message.currSpeed));
+            bb.writeInt(U32.t(message.maxSpeed));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortDescVer11(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("state=").append(state);
+        b.append(", ");
+        b.append("curr=").append(curr);
+        b.append(", ");
+        b.append("advertised=").append(advertised);
+        b.append(", ");
+        b.append("supported=").append(supported);
+        b.append(", ");
+        b.append("peer=").append(peer);
+        b.append(", ");
+        b.append("currSpeed=").append(currSpeed);
+        b.append(", ");
+        b.append("maxSpeed=").append(maxSpeed);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortDescVer11 other = (OFPortDescVer11) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (config == null) {
+            if (other.config != null)
+                return false;
+        } else if (!config.equals(other.config))
+            return false;
+        if (state == null) {
+            if (other.state != null)
+                return false;
+        } else if (!state.equals(other.state))
+            return false;
+        if (curr == null) {
+            if (other.curr != null)
+                return false;
+        } else if (!curr.equals(other.curr))
+            return false;
+        if (advertised == null) {
+            if (other.advertised != null)
+                return false;
+        } else if (!advertised.equals(other.advertised))
+            return false;
+        if (supported == null) {
+            if (other.supported != null)
+                return false;
+        } else if (!supported.equals(other.supported))
+            return false;
+        if (peer == null) {
+            if (other.peer != null)
+                return false;
+        } else if (!peer.equals(other.peer))
+            return false;
+        if( currSpeed != other.currSpeed)
+            return false;
+        if( maxSpeed != other.maxSpeed)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((config == null) ? 0 : config.hashCode());
+        result = prime * result + ((state == null) ? 0 : state.hashCode());
+        result = prime * result + ((curr == null) ? 0 : curr.hashCode());
+        result = prime * result + ((advertised == null) ? 0 : advertised.hashCode());
+        result = prime * result + ((supported == null) ? 0 : supported.hashCode());
+        result = prime * result + ((peer == null) ? 0 : peer.hashCode());
+        result = prime *  (int) (currSpeed ^ (currSpeed >>> 32));
+        result = prime *  (int) (maxSpeed ^ (maxSpeed >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortFeaturesSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortFeaturesSerializerVer11.java
new file mode 100644
index 0000000..61168a3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortFeaturesSerializerVer11.java
@@ -0,0 +1,168 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortFeatures;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortFeaturesSerializerVer11 {
+
+    public final static int PF_10MB_HD_VAL = 0x1;
+    public final static int PF_10MB_FD_VAL = 0x2;
+    public final static int PF_100MB_HD_VAL = 0x4;
+    public final static int PF_100MB_FD_VAL = 0x8;
+    public final static int PF_1GB_HD_VAL = 0x10;
+    public final static int PF_1GB_FD_VAL = 0x20;
+    public final static int PF_10GB_FD_VAL = 0x40;
+    public final static int PF_COPPER_VAL = 0x800;
+    public final static int PF_FIBER_VAL = 0x1000;
+    public final static int PF_AUTONEG_VAL = 0x2000;
+    public final static int PF_PAUSE_VAL = 0x4000;
+    public final static int PF_PAUSE_ASYM_VAL = 0x8000;
+    public final static int PF_40GB_FD_VAL = 0x80;
+    public final static int PF_100GB_FD_VAL = 0x100;
+    public final static int PF_1TB_FD_VAL = 0x200;
+    public final static int PF_OTHER_VAL = 0x400;
+
+    public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortFeatures> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortFeatures> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortFeatures> ofWireValue(int val) {
+        EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);
+
+        if((val & PF_10MB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10MB_HD);
+        if((val & PF_10MB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10MB_FD);
+        if((val & PF_100MB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100MB_HD);
+        if((val & PF_100MB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100MB_FD);
+        if((val & PF_1GB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1GB_HD);
+        if((val & PF_1GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1GB_FD);
+        if((val & PF_10GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10GB_FD);
+        if((val & PF_COPPER_VAL) != 0)
+            set.add(OFPortFeatures.PF_COPPER);
+        if((val & PF_FIBER_VAL) != 0)
+            set.add(OFPortFeatures.PF_FIBER);
+        if((val & PF_AUTONEG_VAL) != 0)
+            set.add(OFPortFeatures.PF_AUTONEG);
+        if((val & PF_PAUSE_VAL) != 0)
+            set.add(OFPortFeatures.PF_PAUSE);
+        if((val & PF_PAUSE_ASYM_VAL) != 0)
+            set.add(OFPortFeatures.PF_PAUSE_ASYM);
+        if((val & PF_40GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_40GB_FD);
+        if((val & PF_100GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100GB_FD);
+        if((val & PF_1TB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1TB_FD);
+        if((val & PF_OTHER_VAL) != 0)
+            set.add(OFPortFeatures.PF_OTHER);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortFeatures> set) {
+        int wireValue = 0;
+
+        for(OFPortFeatures e: set) {
+            switch(e) {
+                case PF_10MB_HD:
+                    wireValue |= PF_10MB_HD_VAL;
+                    break;
+                case PF_10MB_FD:
+                    wireValue |= PF_10MB_FD_VAL;
+                    break;
+                case PF_100MB_HD:
+                    wireValue |= PF_100MB_HD_VAL;
+                    break;
+                case PF_100MB_FD:
+                    wireValue |= PF_100MB_FD_VAL;
+                    break;
+                case PF_1GB_HD:
+                    wireValue |= PF_1GB_HD_VAL;
+                    break;
+                case PF_1GB_FD:
+                    wireValue |= PF_1GB_FD_VAL;
+                    break;
+                case PF_10GB_FD:
+                    wireValue |= PF_10GB_FD_VAL;
+                    break;
+                case PF_COPPER:
+                    wireValue |= PF_COPPER_VAL;
+                    break;
+                case PF_FIBER:
+                    wireValue |= PF_FIBER_VAL;
+                    break;
+                case PF_AUTONEG:
+                    wireValue |= PF_AUTONEG_VAL;
+                    break;
+                case PF_PAUSE:
+                    wireValue |= PF_PAUSE_VAL;
+                    break;
+                case PF_PAUSE_ASYM:
+                    wireValue |= PF_PAUSE_ASYM_VAL;
+                    break;
+                case PF_40GB_FD:
+                    wireValue |= PF_40GB_FD_VAL;
+                    break;
+                case PF_100GB_FD:
+                    wireValue |= PF_100GB_FD_VAL;
+                    break;
+                case PF_1TB_FD:
+                    wireValue |= PF_1TB_FD_VAL;
+                    break;
+                case PF_OTHER:
+                    wireValue |= PF_OTHER_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortFeatures in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModFailedCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModFailedCodeSerializerVer11.java
new file mode 100644
index 0000000..c4849b6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModFailedCodeSerializerVer11.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPortModFailedCodeSerializerVer11 {
+
+    public final static short BAD_PORT_VAL = (short) 0x0;
+    public final static short BAD_HW_ADDR_VAL = (short) 0x1;
+    public final static short BAD_CONFIG_VAL = (short) 0x2;
+    public final static short BAD_ADVERTISE_VAL = (short) 0x3;
+
+    public static OFPortModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPortModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFPortModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFPortModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_PORT_VAL:
+                return OFPortModFailedCode.BAD_PORT;
+            case BAD_HW_ADDR_VAL:
+                return OFPortModFailedCode.BAD_HW_ADDR;
+            case BAD_CONFIG_VAL:
+                return OFPortModFailedCode.BAD_CONFIG;
+            case BAD_ADVERTISE_VAL:
+                return OFPortModFailedCode.BAD_ADVERTISE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPortModFailedCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFPortModFailedCode e) {
+        switch(e) {
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_HW_ADDR:
+                return BAD_HW_ADDR_VAL;
+            case BAD_CONFIG:
+                return BAD_CONFIG_VAL;
+            case BAD_ADVERTISE:
+                return BAD_ADVERTISE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPortModFailedCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModFailedErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModFailedErrorMsgVer11.java
new file mode 100644
index 0000000..af17157
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModFailedErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortModFailedErrorMsgVer11 implements OFPortModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortModFailedErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFPortModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortModFailedErrorMsgVer11(long xid, OFPortModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFPortModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortModFailedErrorMsg.Builder {
+        final OFPortModFailedErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFPortModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFPortModFailedErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setCode(OFPortModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPortModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPortModFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFPortModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setCode(OFPortModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPortModFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortModFailedErrorMsg> {
+        @Override
+        public OFPortModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 7
+            short errType = bb.readShort();
+            if(errType != (short) 0x7)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.PORT_MOD_FAILED(7), got="+errType);
+            OFPortModFailedCode code = OFPortModFailedCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFPortModFailedErrorMsgVer11 portModFailedErrorMsgVer11 = new OFPortModFailedErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portModFailedErrorMsgVer11);
+            return portModFailedErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortModFailedErrorMsgVer11Funnel FUNNEL = new OFPortModFailedErrorMsgVer11Funnel();
+    static class OFPortModFailedErrorMsgVer11Funnel implements Funnel<OFPortModFailedErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortModFailedErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 7
+            sink.putShort((short) 0x7);
+            OFPortModFailedCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortModFailedErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortModFailedErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 7
+            bb.writeShort((short) 0x7);
+            OFPortModFailedCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortModFailedErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortModFailedErrorMsgVer11 other = (OFPortModFailedErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModVer11.java
new file mode 100644
index 0000000..fcce6fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortModVer11.java
@@ -0,0 +1,532 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortModVer11 implements OFPortMod {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortModVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 40;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static long DEFAULT_CONFIG = 0x0L;
+        private final static long DEFAULT_MASK = 0x0L;
+        private final static long DEFAULT_ADVERTISE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort portNo;
+    private final MacAddress hwAddr;
+    private final long config;
+    private final long mask;
+    private final long advertise;
+//
+    // Immutable default instance
+    final static OFPortModVer11 DEFAULT = new OFPortModVer11(
+        DEFAULT_XID, DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_CONFIG, DEFAULT_MASK, DEFAULT_ADVERTISE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortModVer11(long xid, OFPort portNo, MacAddress hwAddr, long config, long mask, long advertise) {
+        this.xid = xid;
+        this.portNo = portNo;
+        this.hwAddr = hwAddr;
+        this.config = config;
+        this.mask = mask;
+        this.advertise = advertise;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+
+
+    public OFPortMod.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortMod.Builder {
+        final OFPortModVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean configSet;
+        private long config;
+        private boolean maskSet;
+        private long mask;
+        private boolean advertiseSet;
+        private long advertise;
+
+        BuilderWithParent(OFPortModVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortMod.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortMod.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFPortMod.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+    @Override
+    public OFPortMod.Builder setAdvertise(long advertise) {
+        this.advertise = advertise;
+        this.advertiseSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortMod build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                long config = this.configSet ? this.config : parentMessage.config;
+                long mask = this.maskSet ? this.mask : parentMessage.mask;
+                long advertise = this.advertiseSet ? this.advertise : parentMessage.advertise;
+
+                //
+                return new OFPortModVer11(
+                    xid,
+                    portNo,
+                    hwAddr,
+                    config,
+                    mask,
+                    advertise
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortMod.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean configSet;
+        private long config;
+        private boolean maskSet;
+        private long mask;
+        private boolean advertiseSet;
+        private long advertise;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortMod.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortMod.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFPortMod.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+    @Override
+    public OFPortMod.Builder setAdvertise(long advertise) {
+        this.advertise = advertise;
+        this.advertiseSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortMod build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+            long mask = this.maskSet ? this.mask : DEFAULT_MASK;
+            long advertise = this.advertiseSet ? this.advertise : DEFAULT_ADVERTISE;
+
+
+            return new OFPortModVer11(
+                    xid,
+                    portNo,
+                    hwAddr,
+                    config,
+                    mask,
+                    advertise
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortMod> {
+        @Override
+        public OFPortMod readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.PORT_MOD(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 40)
+                throw new OFParseError("Wrong length: Expected=40(40), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long config = U32.f(bb.readInt());
+            long mask = U32.f(bb.readInt());
+            long advertise = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFPortModVer11 portModVer11 = new OFPortModVer11(
+                    xid,
+                      portNo,
+                      hwAddr,
+                      config,
+                      mask,
+                      advertise
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portModVer11);
+            return portModVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortModVer11Funnel FUNNEL = new OFPortModVer11Funnel();
+    static class OFPortModVer11Funnel implements Funnel<OFPortModVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortModVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 40
+            sink.putShort((short) 0x28);
+            sink.putLong(message.xid);
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.config);
+            sink.putLong(message.mask);
+            sink.putLong(message.advertise);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortModVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortModVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 40
+            bb.writeShort((short) 0x28);
+            bb.writeInt(U32.t(message.xid));
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.config));
+            bb.writeInt(U32.t(message.mask));
+            bb.writeInt(U32.t(message.advertise));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortModVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(", ");
+        b.append("advertise=").append(advertise);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortModVer11 other = (OFPortModVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if( config != other.config)
+            return false;
+        if( mask != other.mask)
+            return false;
+        if( advertise != other.advertise)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime *  (int) (config ^ (config >>> 32));
+        result = prime *  (int) (mask ^ (mask >>> 32));
+        result = prime *  (int) (advertise ^ (advertise >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortReasonSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortReasonSerializerVer11.java
new file mode 100644
index 0000000..e8e3460
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortReasonSerializerVer11.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPortReasonSerializerVer11 {
+
+    public final static byte ADD_VAL = (byte) 0x0;
+    public final static byte DELETE_VAL = (byte) 0x1;
+    public final static byte MODIFY_VAL = (byte) 0x2;
+
+    public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPortReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFPortReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFPortReason ofWireValue(byte val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFPortReason.ADD;
+            case DELETE_VAL:
+                return OFPortReason.DELETE;
+            case MODIFY_VAL:
+                return OFPortReason.MODIFY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.1: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFPortReason e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStateSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStateSerializerVer11.java
new file mode 100644
index 0000000..d2edb0d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStateSerializerVer11.java
@@ -0,0 +1,90 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortState;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortStateSerializerVer11 {
+
+    public final static int LINK_DOWN_VAL = 0x1;
+    public final static int BLOCKED_VAL = 0x2;
+    public final static int LIVE_VAL = 0x4;
+
+    public static Set<OFPortState> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortState> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortState> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortState> ofWireValue(int val) {
+        EnumSet<OFPortState> set = EnumSet.noneOf(OFPortState.class);
+
+        if((val & LINK_DOWN_VAL) != 0)
+            set.add(OFPortState.LINK_DOWN);
+        if((val & BLOCKED_VAL) != 0)
+            set.add(OFPortState.BLOCKED);
+        if((val & LIVE_VAL) != 0)
+            set.add(OFPortState.LIVE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortState> set) {
+        int wireValue = 0;
+
+        for(OFPortState e: set) {
+            switch(e) {
+                case LINK_DOWN:
+                    wireValue |= LINK_DOWN_VAL;
+                    break;
+                case BLOCKED:
+                    wireValue |= BLOCKED_VAL;
+                    break;
+                case LIVE:
+                    wireValue |= LIVE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsEntryVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsEntryVer11.java
new file mode 100644
index 0000000..4af002b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsEntryVer11.java
@@ -0,0 +1,928 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsEntryVer11 implements OFPortStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsEntryVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 104;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static U64 DEFAULT_RX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_RX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_RX_DROPPED = U64.ZERO;
+        private final static U64 DEFAULT_TX_DROPPED = U64.ZERO;
+        private final static U64 DEFAULT_RX_ERRORS = U64.ZERO;
+        private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
+        private final static U64 DEFAULT_RX_FRAME_ERR = U64.ZERO;
+        private final static U64 DEFAULT_RX_OVER_ERR = U64.ZERO;
+        private final static U64 DEFAULT_RX_CRC_ERR = U64.ZERO;
+        private final static U64 DEFAULT_COLLISIONS = U64.ZERO;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final U64 rxPackets;
+    private final U64 txPackets;
+    private final U64 rxBytes;
+    private final U64 txBytes;
+    private final U64 rxDropped;
+    private final U64 txDropped;
+    private final U64 rxErrors;
+    private final U64 txErrors;
+    private final U64 rxFrameErr;
+    private final U64 rxOverErr;
+    private final U64 rxCrcErr;
+    private final U64 collisions;
+//
+    // Immutable default instance
+    final static OFPortStatsEntryVer11 DEFAULT = new OFPortStatsEntryVer11(
+        DEFAULT_PORT_NO, DEFAULT_RX_PACKETS, DEFAULT_TX_PACKETS, DEFAULT_RX_BYTES, DEFAULT_TX_BYTES, DEFAULT_RX_DROPPED, DEFAULT_TX_DROPPED, DEFAULT_RX_ERRORS, DEFAULT_TX_ERRORS, DEFAULT_RX_FRAME_ERR, DEFAULT_RX_OVER_ERR, DEFAULT_RX_CRC_ERR, DEFAULT_COLLISIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsEntryVer11(OFPort portNo, U64 rxPackets, U64 txPackets, U64 rxBytes, U64 txBytes, U64 rxDropped, U64 txDropped, U64 rxErrors, U64 txErrors, U64 rxFrameErr, U64 rxOverErr, U64 rxCrcErr, U64 collisions) {
+        this.portNo = portNo;
+        this.rxPackets = rxPackets;
+        this.txPackets = txPackets;
+        this.rxBytes = rxBytes;
+        this.txBytes = txBytes;
+        this.rxDropped = rxDropped;
+        this.txDropped = txDropped;
+        this.rxErrors = rxErrors;
+        this.txErrors = txErrors;
+        this.rxFrameErr = rxFrameErr;
+        this.rxOverErr = rxOverErr;
+        this.rxCrcErr = rxCrcErr;
+        this.collisions = collisions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFPortStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsEntry.Builder {
+        final OFPortStatsEntryVer11 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean rxPacketsSet;
+        private U64 rxPackets;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean rxBytesSet;
+        private U64 rxBytes;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean rxDroppedSet;
+        private U64 rxDropped;
+        private boolean txDroppedSet;
+        private U64 txDropped;
+        private boolean rxErrorsSet;
+        private U64 rxErrors;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean rxFrameErrSet;
+        private U64 rxFrameErr;
+        private boolean rxOverErrSet;
+        private U64 rxOverErr;
+        private boolean rxCrcErrSet;
+        private U64 rxCrcErr;
+        private boolean collisionsSet;
+        private U64 collisions;
+
+        BuilderWithParent(OFPortStatsEntryVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxPackets(U64 rxPackets) {
+        this.rxPackets = rxPackets;
+        this.rxPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxBytes(U64 rxBytes) {
+        this.rxBytes = rxBytes;
+        this.rxBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxDropped(U64 rxDropped) {
+        this.rxDropped = rxDropped;
+        this.rxDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxDropped(U64 txDropped) {
+        this.txDropped = txDropped;
+        this.txDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxErrors(U64 rxErrors) {
+        this.rxErrors = rxErrors;
+        this.rxErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxFrameErr(U64 rxFrameErr) {
+        this.rxFrameErr = rxFrameErr;
+        this.rxFrameErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxOverErr(U64 rxOverErr) {
+        this.rxOverErr = rxOverErr;
+        this.rxOverErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxCrcErr(U64 rxCrcErr) {
+        this.rxCrcErr = rxCrcErr;
+        this.rxCrcErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setCollisions(U64 collisions) {
+        this.collisions = collisions;
+        this.collisionsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFPortStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                U64 rxPackets = this.rxPacketsSet ? this.rxPackets : parentMessage.rxPackets;
+                if(rxPackets == null)
+                    throw new NullPointerException("Property rxPackets must not be null");
+                U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
+                if(txPackets == null)
+                    throw new NullPointerException("Property txPackets must not be null");
+                U64 rxBytes = this.rxBytesSet ? this.rxBytes : parentMessage.rxBytes;
+                if(rxBytes == null)
+                    throw new NullPointerException("Property rxBytes must not be null");
+                U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
+                if(txBytes == null)
+                    throw new NullPointerException("Property txBytes must not be null");
+                U64 rxDropped = this.rxDroppedSet ? this.rxDropped : parentMessage.rxDropped;
+                if(rxDropped == null)
+                    throw new NullPointerException("Property rxDropped must not be null");
+                U64 txDropped = this.txDroppedSet ? this.txDropped : parentMessage.txDropped;
+                if(txDropped == null)
+                    throw new NullPointerException("Property txDropped must not be null");
+                U64 rxErrors = this.rxErrorsSet ? this.rxErrors : parentMessage.rxErrors;
+                if(rxErrors == null)
+                    throw new NullPointerException("Property rxErrors must not be null");
+                U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
+                if(txErrors == null)
+                    throw new NullPointerException("Property txErrors must not be null");
+                U64 rxFrameErr = this.rxFrameErrSet ? this.rxFrameErr : parentMessage.rxFrameErr;
+                if(rxFrameErr == null)
+                    throw new NullPointerException("Property rxFrameErr must not be null");
+                U64 rxOverErr = this.rxOverErrSet ? this.rxOverErr : parentMessage.rxOverErr;
+                if(rxOverErr == null)
+                    throw new NullPointerException("Property rxOverErr must not be null");
+                U64 rxCrcErr = this.rxCrcErrSet ? this.rxCrcErr : parentMessage.rxCrcErr;
+                if(rxCrcErr == null)
+                    throw new NullPointerException("Property rxCrcErr must not be null");
+                U64 collisions = this.collisionsSet ? this.collisions : parentMessage.collisions;
+                if(collisions == null)
+                    throw new NullPointerException("Property collisions must not be null");
+
+                //
+                return new OFPortStatsEntryVer11(
+                    portNo,
+                    rxPackets,
+                    txPackets,
+                    rxBytes,
+                    txBytes,
+                    rxDropped,
+                    txDropped,
+                    rxErrors,
+                    txErrors,
+                    rxFrameErr,
+                    rxOverErr,
+                    rxCrcErr,
+                    collisions
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean rxPacketsSet;
+        private U64 rxPackets;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean rxBytesSet;
+        private U64 rxBytes;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean rxDroppedSet;
+        private U64 rxDropped;
+        private boolean txDroppedSet;
+        private U64 txDropped;
+        private boolean rxErrorsSet;
+        private U64 rxErrors;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean rxFrameErrSet;
+        private U64 rxFrameErr;
+        private boolean rxOverErrSet;
+        private U64 rxOverErr;
+        private boolean rxCrcErrSet;
+        private U64 rxCrcErr;
+        private boolean collisionsSet;
+        private U64 collisions;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxPackets(U64 rxPackets) {
+        this.rxPackets = rxPackets;
+        this.rxPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxBytes(U64 rxBytes) {
+        this.rxBytes = rxBytes;
+        this.rxBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxDropped(U64 rxDropped) {
+        this.rxDropped = rxDropped;
+        this.rxDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxDropped(U64 txDropped) {
+        this.txDropped = txDropped;
+        this.txDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxErrors(U64 rxErrors) {
+        this.rxErrors = rxErrors;
+        this.rxErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxFrameErr(U64 rxFrameErr) {
+        this.rxFrameErr = rxFrameErr;
+        this.rxFrameErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxOverErr(U64 rxOverErr) {
+        this.rxOverErr = rxOverErr;
+        this.rxOverErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxCrcErr(U64 rxCrcErr) {
+        this.rxCrcErr = rxCrcErr;
+        this.rxCrcErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setCollisions(U64 collisions) {
+        this.collisions = collisions;
+        this.collisionsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFPortStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            U64 rxPackets = this.rxPacketsSet ? this.rxPackets : DEFAULT_RX_PACKETS;
+            if(rxPackets == null)
+                throw new NullPointerException("Property rxPackets must not be null");
+            U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
+            if(txPackets == null)
+                throw new NullPointerException("Property txPackets must not be null");
+            U64 rxBytes = this.rxBytesSet ? this.rxBytes : DEFAULT_RX_BYTES;
+            if(rxBytes == null)
+                throw new NullPointerException("Property rxBytes must not be null");
+            U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
+            if(txBytes == null)
+                throw new NullPointerException("Property txBytes must not be null");
+            U64 rxDropped = this.rxDroppedSet ? this.rxDropped : DEFAULT_RX_DROPPED;
+            if(rxDropped == null)
+                throw new NullPointerException("Property rxDropped must not be null");
+            U64 txDropped = this.txDroppedSet ? this.txDropped : DEFAULT_TX_DROPPED;
+            if(txDropped == null)
+                throw new NullPointerException("Property txDropped must not be null");
+            U64 rxErrors = this.rxErrorsSet ? this.rxErrors : DEFAULT_RX_ERRORS;
+            if(rxErrors == null)
+                throw new NullPointerException("Property rxErrors must not be null");
+            U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
+            if(txErrors == null)
+                throw new NullPointerException("Property txErrors must not be null");
+            U64 rxFrameErr = this.rxFrameErrSet ? this.rxFrameErr : DEFAULT_RX_FRAME_ERR;
+            if(rxFrameErr == null)
+                throw new NullPointerException("Property rxFrameErr must not be null");
+            U64 rxOverErr = this.rxOverErrSet ? this.rxOverErr : DEFAULT_RX_OVER_ERR;
+            if(rxOverErr == null)
+                throw new NullPointerException("Property rxOverErr must not be null");
+            U64 rxCrcErr = this.rxCrcErrSet ? this.rxCrcErr : DEFAULT_RX_CRC_ERR;
+            if(rxCrcErr == null)
+                throw new NullPointerException("Property rxCrcErr must not be null");
+            U64 collisions = this.collisionsSet ? this.collisions : DEFAULT_COLLISIONS;
+            if(collisions == null)
+                throw new NullPointerException("Property collisions must not be null");
+
+
+            return new OFPortStatsEntryVer11(
+                    portNo,
+                    rxPackets,
+                    txPackets,
+                    rxBytes,
+                    txBytes,
+                    rxDropped,
+                    txDropped,
+                    rxErrors,
+                    txErrors,
+                    rxFrameErr,
+                    rxOverErr,
+                    rxCrcErr,
+                    collisions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsEntry> {
+        @Override
+        public OFPortStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 rxPackets = U64.ofRaw(bb.readLong());
+            U64 txPackets = U64.ofRaw(bb.readLong());
+            U64 rxBytes = U64.ofRaw(bb.readLong());
+            U64 txBytes = U64.ofRaw(bb.readLong());
+            U64 rxDropped = U64.ofRaw(bb.readLong());
+            U64 txDropped = U64.ofRaw(bb.readLong());
+            U64 rxErrors = U64.ofRaw(bb.readLong());
+            U64 txErrors = U64.ofRaw(bb.readLong());
+            U64 rxFrameErr = U64.ofRaw(bb.readLong());
+            U64 rxOverErr = U64.ofRaw(bb.readLong());
+            U64 rxCrcErr = U64.ofRaw(bb.readLong());
+            U64 collisions = U64.ofRaw(bb.readLong());
+
+            OFPortStatsEntryVer11 portStatsEntryVer11 = new OFPortStatsEntryVer11(
+                    portNo,
+                      rxPackets,
+                      txPackets,
+                      rxBytes,
+                      txBytes,
+                      rxDropped,
+                      txDropped,
+                      rxErrors,
+                      txErrors,
+                      rxFrameErr,
+                      rxOverErr,
+                      rxCrcErr,
+                      collisions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsEntryVer11);
+            return portStatsEntryVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsEntryVer11Funnel FUNNEL = new OFPortStatsEntryVer11Funnel();
+    static class OFPortStatsEntryVer11Funnel implements Funnel<OFPortStatsEntryVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsEntryVer11 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.rxPackets.putTo(sink);
+            message.txPackets.putTo(sink);
+            message.rxBytes.putTo(sink);
+            message.txBytes.putTo(sink);
+            message.rxDropped.putTo(sink);
+            message.txDropped.putTo(sink);
+            message.rxErrors.putTo(sink);
+            message.txErrors.putTo(sink);
+            message.rxFrameErr.putTo(sink);
+            message.rxOverErr.putTo(sink);
+            message.rxCrcErr.putTo(sink);
+            message.collisions.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsEntryVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsEntryVer11 message) {
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.rxPackets.getValue());
+            bb.writeLong(message.txPackets.getValue());
+            bb.writeLong(message.rxBytes.getValue());
+            bb.writeLong(message.txBytes.getValue());
+            bb.writeLong(message.rxDropped.getValue());
+            bb.writeLong(message.txDropped.getValue());
+            bb.writeLong(message.rxErrors.getValue());
+            bb.writeLong(message.txErrors.getValue());
+            bb.writeLong(message.rxFrameErr.getValue());
+            bb.writeLong(message.rxOverErr.getValue());
+            bb.writeLong(message.rxCrcErr.getValue());
+            bb.writeLong(message.collisions.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsEntryVer11(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("rxPackets=").append(rxPackets);
+        b.append(", ");
+        b.append("txPackets=").append(txPackets);
+        b.append(", ");
+        b.append("rxBytes=").append(rxBytes);
+        b.append(", ");
+        b.append("txBytes=").append(txBytes);
+        b.append(", ");
+        b.append("rxDropped=").append(rxDropped);
+        b.append(", ");
+        b.append("txDropped=").append(txDropped);
+        b.append(", ");
+        b.append("rxErrors=").append(rxErrors);
+        b.append(", ");
+        b.append("txErrors=").append(txErrors);
+        b.append(", ");
+        b.append("rxFrameErr=").append(rxFrameErr);
+        b.append(", ");
+        b.append("rxOverErr=").append(rxOverErr);
+        b.append(", ");
+        b.append("rxCrcErr=").append(rxCrcErr);
+        b.append(", ");
+        b.append("collisions=").append(collisions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsEntryVer11 other = (OFPortStatsEntryVer11) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (rxPackets == null) {
+            if (other.rxPackets != null)
+                return false;
+        } else if (!rxPackets.equals(other.rxPackets))
+            return false;
+        if (txPackets == null) {
+            if (other.txPackets != null)
+                return false;
+        } else if (!txPackets.equals(other.txPackets))
+            return false;
+        if (rxBytes == null) {
+            if (other.rxBytes != null)
+                return false;
+        } else if (!rxBytes.equals(other.rxBytes))
+            return false;
+        if (txBytes == null) {
+            if (other.txBytes != null)
+                return false;
+        } else if (!txBytes.equals(other.txBytes))
+            return false;
+        if (rxDropped == null) {
+            if (other.rxDropped != null)
+                return false;
+        } else if (!rxDropped.equals(other.rxDropped))
+            return false;
+        if (txDropped == null) {
+            if (other.txDropped != null)
+                return false;
+        } else if (!txDropped.equals(other.txDropped))
+            return false;
+        if (rxErrors == null) {
+            if (other.rxErrors != null)
+                return false;
+        } else if (!rxErrors.equals(other.rxErrors))
+            return false;
+        if (txErrors == null) {
+            if (other.txErrors != null)
+                return false;
+        } else if (!txErrors.equals(other.txErrors))
+            return false;
+        if (rxFrameErr == null) {
+            if (other.rxFrameErr != null)
+                return false;
+        } else if (!rxFrameErr.equals(other.rxFrameErr))
+            return false;
+        if (rxOverErr == null) {
+            if (other.rxOverErr != null)
+                return false;
+        } else if (!rxOverErr.equals(other.rxOverErr))
+            return false;
+        if (rxCrcErr == null) {
+            if (other.rxCrcErr != null)
+                return false;
+        } else if (!rxCrcErr.equals(other.rxCrcErr))
+            return false;
+        if (collisions == null) {
+            if (other.collisions != null)
+                return false;
+        } else if (!collisions.equals(other.collisions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((rxPackets == null) ? 0 : rxPackets.hashCode());
+        result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
+        result = prime * result + ((rxBytes == null) ? 0 : rxBytes.hashCode());
+        result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
+        result = prime * result + ((rxDropped == null) ? 0 : rxDropped.hashCode());
+        result = prime * result + ((txDropped == null) ? 0 : txDropped.hashCode());
+        result = prime * result + ((rxErrors == null) ? 0 : rxErrors.hashCode());
+        result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
+        result = prime * result + ((rxFrameErr == null) ? 0 : rxFrameErr.hashCode());
+        result = prime * result + ((rxOverErr == null) ? 0 : rxOverErr.hashCode());
+        result = prime * result + ((rxCrcErr == null) ? 0 : rxCrcErr.hashCode());
+        result = prime * result + ((collisions == null) ? 0 : collisions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsReplyVer11.java
new file mode 100644
index 0000000..8e85c42
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsReplyVer11.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsReplyVer11 implements OFPortStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFPortStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFPortStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFPortStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFPortStatsReplyVer11 DEFAULT = new OFPortStatsReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsReplyVer11(long xid, Set<OFStatsReplyFlags> flags, List<OFPortStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFPortStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsReply.Builder {
+        final OFPortStatsReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortStatsEntry> entries;
+
+        BuilderWithParent(OFPortStatsReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setEntries(List<OFPortStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFPortStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFPortStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setEntries(List<OFPortStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFPortStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFPortStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsReply> {
+        @Override
+        public OFPortStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 4
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x4)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFPortStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPortStatsEntryVer11.READER);
+
+            OFPortStatsReplyVer11 portStatsReplyVer11 = new OFPortStatsReplyVer11(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsReplyVer11);
+            return portStatsReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsReplyVer11Funnel FUNNEL = new OFPortStatsReplyVer11Funnel();
+    static class OFPortStatsReplyVer11Funnel implements Funnel<OFPortStatsReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 4
+            sink.putShort((short) 0x4);
+            OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 4
+            bb.writeShort((short) 0x4);
+            OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsReplyVer11 other = (OFPortStatsReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsRequestVer11.java
new file mode 100644
index 0000000..993749b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatsRequestVer11.java
@@ -0,0 +1,410 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsRequestVer11 implements OFPortStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+//
+    // Immutable default instance
+    final static OFPortStatsRequestVer11 DEFAULT = new OFPortStatsRequestVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsRequestVer11(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+
+
+    public OFPortStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsRequest.Builder {
+        final OFPortStatsRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+        BuilderWithParent(OFPortStatsRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+
+                //
+                return new OFPortStatsRequestVer11(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+
+
+            return new OFPortStatsRequestVer11(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsRequest> {
+        @Override
+        public OFPortStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 4
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x4)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFPortStatsRequestVer11 portStatsRequestVer11 = new OFPortStatsRequestVer11(
+                    xid,
+                      flags,
+                      portNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsRequestVer11);
+            return portStatsRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsRequestVer11Funnel FUNNEL = new OFPortStatsRequestVer11Funnel();
+    static class OFPortStatsRequestVer11Funnel implements Funnel<OFPortStatsRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 4
+            sink.putShort((short) 0x4);
+            OFStatsRequestFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 4
+            bb.writeShort((short) 0x4);
+            OFStatsRequestFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsRequestVer11 other = (OFPortStatsRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatusVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatusVer11.java
new file mode 100644
index 0000000..b2aee7e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFPortStatusVer11.java
@@ -0,0 +1,377 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatusVer11 implements OFPortStatus {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatusVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 80;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFPortReason reason;
+    private final OFPortDesc desc;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatusVer11(long xid, OFPortReason reason, OFPortDesc desc) {
+        this.xid = xid;
+        this.reason = reason;
+        this.desc = desc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+
+
+    public OFPortStatus.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatus.Builder {
+        final OFPortStatusVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reasonSet;
+        private OFPortReason reason;
+        private boolean descSet;
+        private OFPortDesc desc;
+
+        BuilderWithParent(OFPortStatusVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortStatus.Builder setReason(OFPortReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+    @Override
+    public OFPortStatus.Builder setDesc(OFPortDesc desc) {
+        this.desc = desc;
+        this.descSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatus build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPortReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                OFPortDesc desc = this.descSet ? this.desc : parentMessage.desc;
+                if(desc == null)
+                    throw new NullPointerException("Property desc must not be null");
+
+                //
+                return new OFPortStatusVer11(
+                    xid,
+                    reason,
+                    desc
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatus.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reasonSet;
+        private OFPortReason reason;
+        private boolean descSet;
+        private OFPortDesc desc;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortStatus.Builder setReason(OFPortReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+    @Override
+    public OFPortStatus.Builder setDesc(OFPortDesc desc) {
+        this.desc = desc;
+        this.descSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatus build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            if(!this.descSet)
+                throw new IllegalStateException("Property desc doesn't have default value -- must be set");
+            if(desc == null)
+                throw new NullPointerException("Property desc must not be null");
+
+
+            return new OFPortStatusVer11(
+                    xid,
+                    reason,
+                    desc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatus> {
+        @Override
+        public OFPortStatus readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 12
+            byte type = bb.readByte();
+            if(type != (byte) 0xc)
+                throw new OFParseError("Wrong type: Expected=OFType.PORT_STATUS(12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 80)
+                throw new OFParseError("Wrong length: Expected=80(80), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPortReason reason = OFPortReasonSerializerVer11.readFrom(bb);
+            // pad: 7 bytes
+            bb.skipBytes(7);
+            OFPortDesc desc = OFPortDescVer11.READER.readFrom(bb);
+
+            OFPortStatusVer11 portStatusVer11 = new OFPortStatusVer11(
+                    xid,
+                      reason,
+                      desc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatusVer11);
+            return portStatusVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatusVer11Funnel FUNNEL = new OFPortStatusVer11Funnel();
+    static class OFPortStatusVer11Funnel implements Funnel<OFPortStatusVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatusVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 12
+            sink.putByte((byte) 0xc);
+            // fixed value property length = 80
+            sink.putShort((short) 0x50);
+            sink.putLong(message.xid);
+            OFPortReasonSerializerVer11.putTo(message.reason, sink);
+            // skip pad (7 bytes)
+            message.desc.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatusVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatusVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 12
+            bb.writeByte((byte) 0xc);
+            // fixed value property length = 80
+            bb.writeShort((short) 0x50);
+            bb.writeInt(U32.t(message.xid));
+            OFPortReasonSerializerVer11.writeTo(bb, message.reason);
+            // pad: 7 bytes
+            bb.writeZero(7);
+            message.desc.writeTo(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatusVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("desc=").append(desc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatusVer11 other = (OFPortStatusVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (desc == null) {
+            if (other.desc != null)
+                return false;
+        } else if (!desc.equals(other.desc))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + ((desc == null) ? 0 : desc.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueGetConfigReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueGetConfigReplyVer11.java
new file mode 100644
index 0000000..2c06456
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueGetConfigReplyVer11.java
@@ -0,0 +1,388 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueGetConfigReplyVer11 implements OFQueueGetConfigReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueGetConfigReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static List<OFPacketQueue> DEFAULT_QUEUES = ImmutableList.<OFPacketQueue>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFPort port;
+    private final List<OFPacketQueue> queues;
+//
+    // Immutable default instance
+    final static OFQueueGetConfigReplyVer11 DEFAULT = new OFQueueGetConfigReplyVer11(
+        DEFAULT_XID, DEFAULT_PORT, DEFAULT_QUEUES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueGetConfigReplyVer11(long xid, OFPort port, List<OFPacketQueue> queues) {
+        this.xid = xid;
+        this.port = port;
+        this.queues = queues;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+
+
+    public OFQueueGetConfigReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueGetConfigReply.Builder {
+        final OFQueueGetConfigReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+        private boolean queuesSet;
+        private List<OFPacketQueue> queues;
+
+        BuilderWithParent(OFQueueGetConfigReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setQueues(List<OFPacketQueue> queues) {
+        this.queues = queues;
+        this.queuesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueGetConfigReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                List<OFPacketQueue> queues = this.queuesSet ? this.queues : parentMessage.queues;
+                if(queues == null)
+                    throw new NullPointerException("Property queues must not be null");
+
+                //
+                return new OFQueueGetConfigReplyVer11(
+                    xid,
+                    port,
+                    queues
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueGetConfigReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+        private boolean queuesSet;
+        private List<OFPacketQueue> queues;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setQueues(List<OFPacketQueue> queues) {
+        this.queues = queues;
+        this.queuesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueGetConfigReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            List<OFPacketQueue> queues = this.queuesSet ? this.queues : DEFAULT_QUEUES;
+            if(queues == null)
+                throw new NullPointerException("Property queues must not be null");
+
+
+            return new OFQueueGetConfigReplyVer11(
+                    xid,
+                    port,
+                    queues
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueGetConfigReply> {
+        @Override
+        public OFQueueGetConfigReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 23
+            byte type = bb.readByte();
+            if(type != (byte) 0x17)
+                throw new OFParseError("Wrong type: Expected=OFType.QUEUE_GET_CONFIG_REPLY(23), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort port = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFPacketQueue> queues = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPacketQueueVer11.READER);
+
+            OFQueueGetConfigReplyVer11 queueGetConfigReplyVer11 = new OFQueueGetConfigReplyVer11(
+                    xid,
+                      port,
+                      queues
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueGetConfigReplyVer11);
+            return queueGetConfigReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueGetConfigReplyVer11Funnel FUNNEL = new OFQueueGetConfigReplyVer11Funnel();
+    static class OFQueueGetConfigReplyVer11Funnel implements Funnel<OFQueueGetConfigReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueGetConfigReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 23
+            sink.putByte((byte) 0x17);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.port.putTo(sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.queues, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueGetConfigReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueGetConfigReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 23
+            bb.writeByte((byte) 0x17);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.port.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.queues);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueGetConfigReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("queues=").append(queues);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueGetConfigReplyVer11 other = (OFQueueGetConfigReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if (queues == null) {
+            if (other.queues != null)
+                return false;
+        } else if (!queues.equals(other.queues))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + ((queues == null) ? 0 : queues.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueGetConfigRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueGetConfigRequestVer11.java
new file mode 100644
index 0000000..23fef72
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueGetConfigRequestVer11.java
@@ -0,0 +1,327 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueGetConfigRequestVer11 implements OFQueueGetConfigRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueGetConfigRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort port;
+//
+    // Immutable default instance
+    final static OFQueueGetConfigRequestVer11 DEFAULT = new OFQueueGetConfigRequestVer11(
+        DEFAULT_XID, DEFAULT_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueGetConfigRequestVer11(long xid, OFPort port) {
+        this.xid = xid;
+        this.port = port;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+
+
+    public OFQueueGetConfigRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueGetConfigRequest.Builder {
+        final OFQueueGetConfigRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+
+        BuilderWithParent(OFQueueGetConfigRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueGetConfigRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+
+                //
+                return new OFQueueGetConfigRequestVer11(
+                    xid,
+                    port
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueGetConfigRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueGetConfigRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+
+
+            return new OFQueueGetConfigRequestVer11(
+                    xid,
+                    port
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueGetConfigRequest> {
+        @Override
+        public OFQueueGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 22
+            byte type = bb.readByte();
+            if(type != (byte) 0x16)
+                throw new OFParseError("Wrong type: Expected=OFType.QUEUE_GET_CONFIG_REQUEST(22), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort port = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFQueueGetConfigRequestVer11 queueGetConfigRequestVer11 = new OFQueueGetConfigRequestVer11(
+                    xid,
+                      port
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueGetConfigRequestVer11);
+            return queueGetConfigRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueGetConfigRequestVer11Funnel FUNNEL = new OFQueueGetConfigRequestVer11Funnel();
+    static class OFQueueGetConfigRequestVer11Funnel implements Funnel<OFQueueGetConfigRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueGetConfigRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 22
+            sink.putByte((byte) 0x16);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            message.port.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueGetConfigRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueGetConfigRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 22
+            bb.writeByte((byte) 0x16);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            message.port.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueGetConfigRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueGetConfigRequestVer11 other = (OFQueueGetConfigRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueOpFailedCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueOpFailedCodeSerializerVer11.java
new file mode 100644
index 0000000..1034ae8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueOpFailedCodeSerializerVer11.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFQueueOpFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFQueueOpFailedCodeSerializerVer11 {
+
+    public final static short BAD_PORT_VAL = (short) 0x0;
+    public final static short BAD_QUEUE_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+
+    public static OFQueueOpFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFQueueOpFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFQueueOpFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFQueueOpFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_PORT_VAL:
+                return OFQueueOpFailedCode.BAD_PORT;
+            case BAD_QUEUE_VAL:
+                return OFQueueOpFailedCode.BAD_QUEUE;
+            case EPERM_VAL:
+                return OFQueueOpFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFQueueOpFailedCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFQueueOpFailedCode e) {
+        switch(e) {
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_QUEUE:
+                return BAD_QUEUE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFQueueOpFailedCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueOpFailedErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueOpFailedErrorMsgVer11.java
new file mode 100644
index 0000000..11f1aae
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueOpFailedErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueOpFailedErrorMsgVer11 implements OFQueueOpFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueOpFailedErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFQueueOpFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueOpFailedErrorMsgVer11(long xid, OFQueueOpFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFQueueOpFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueOpFailedErrorMsg.Builder {
+        final OFQueueOpFailedErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFQueueOpFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFQueueOpFailedErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setCode(OFQueueOpFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueOpFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFQueueOpFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFQueueOpFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueOpFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFQueueOpFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setCode(OFQueueOpFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueOpFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFQueueOpFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueOpFailedErrorMsg> {
+        @Override
+        public OFQueueOpFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 9
+            short errType = bb.readShort();
+            if(errType != (short) 0x9)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.QUEUE_OP_FAILED(9), got="+errType);
+            OFQueueOpFailedCode code = OFQueueOpFailedCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFQueueOpFailedErrorMsgVer11 queueOpFailedErrorMsgVer11 = new OFQueueOpFailedErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueOpFailedErrorMsgVer11);
+            return queueOpFailedErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueOpFailedErrorMsgVer11Funnel FUNNEL = new OFQueueOpFailedErrorMsgVer11Funnel();
+    static class OFQueueOpFailedErrorMsgVer11Funnel implements Funnel<OFQueueOpFailedErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueOpFailedErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 9
+            sink.putShort((short) 0x9);
+            OFQueueOpFailedCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueOpFailedErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueOpFailedErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 9
+            bb.writeShort((short) 0x9);
+            OFQueueOpFailedCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueOpFailedErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueOpFailedErrorMsgVer11 other = (OFQueueOpFailedErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropMinRateVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropMinRateVer11.java
new file mode 100644
index 0000000..5f49800
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropMinRateVer11.java
@@ -0,0 +1,270 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueuePropMinRateVer11 implements OFQueuePropMinRate {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueuePropMinRateVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static int DEFAULT_RATE = 0x0;
+
+    // OF message fields
+    private final int rate;
+//
+    // Immutable default instance
+    final static OFQueuePropMinRateVer11 DEFAULT = new OFQueuePropMinRateVer11(
+        DEFAULT_RATE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueuePropMinRateVer11(int rate) {
+        this.rate = rate;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFQueuePropMinRate.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueuePropMinRate.Builder {
+        final OFQueuePropMinRateVer11 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+        BuilderWithParent(OFQueuePropMinRateVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMinRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFQueuePropMinRate build() {
+                int rate = this.rateSet ? this.rate : parentMessage.rate;
+
+                //
+                return new OFQueuePropMinRateVer11(
+                    rate
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueuePropMinRate.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMinRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFQueuePropMinRate build() {
+            int rate = this.rateSet ? this.rate : DEFAULT_RATE;
+
+
+            return new OFQueuePropMinRateVer11(
+                    rate
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueuePropMinRate> {
+        @Override
+        public OFQueuePropMinRate readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int rate = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFQueuePropMinRateVer11 queuePropMinRateVer11 = new OFQueuePropMinRateVer11(
+                    rate
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queuePropMinRateVer11);
+            return queuePropMinRateVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueuePropMinRateVer11Funnel FUNNEL = new OFQueuePropMinRateVer11Funnel();
+    static class OFQueuePropMinRateVer11Funnel implements Funnel<OFQueuePropMinRateVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueuePropMinRateVer11 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // skip pad (4 bytes)
+            sink.putInt(message.rate);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueuePropMinRateVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueuePropMinRateVer11 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeShort(U16.t(message.rate));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueuePropMinRateVer11(");
+        b.append("rate=").append(rate);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueuePropMinRateVer11 other = (OFQueuePropMinRateVer11) obj;
+
+        if( rate != other.rate)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + rate;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropVer11.java
new file mode 100644
index 0000000..350b8a7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropVer11.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFQueuePropVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFQueuePropVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFQueueProp> {
+        @Override
+        public OFQueueProp readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFQueuePropMinRateVer11
+                   return OFQueuePropMinRateVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFQueuePropVer11: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropertiesSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropertiesSerializerVer11.java
new file mode 100644
index 0000000..d04b479
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropertiesSerializerVer11.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFQueueProperties;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFQueuePropertiesSerializerVer11 {
+
+    public final static short NONE_VAL = (short) 0x0;
+    public final static short MIN_RATE_VAL = (short) 0x1;
+
+    public static OFQueueProperties readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFQueueProperties e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFQueueProperties e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFQueueProperties ofWireValue(short val) {
+        switch(val) {
+            case NONE_VAL:
+                return OFQueueProperties.NONE;
+            case MIN_RATE_VAL:
+                return OFQueueProperties.MIN_RATE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFQueueProperties in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFQueueProperties e) {
+        switch(e) {
+            case NONE:
+                return NONE_VAL;
+            case MIN_RATE:
+                return MIN_RATE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFQueueProperties in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropsVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropsVer11.java
new file mode 100644
index 0000000..9461b66
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueuePropsVer11.java
@@ -0,0 +1,58 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFQueuePropsVer11 implements OFQueueProps {
+    public final static OFQueuePropsVer11 INSTANCE = new OFQueuePropsVer11();
+
+
+
+
+    public OFQueuePropMinRate.Builder buildMinRate() {
+        return new OFQueuePropMinRateVer11.Builder();
+    }
+    public OFQueuePropMinRate minRate(int rate) {
+        return new OFQueuePropMinRateVer11(
+                rate
+                    );
+    }
+
+    public OFQueuePropMaxRate.Builder buildMaxRate() {
+        throw new UnsupportedOperationException("OFQueuePropMaxRate not supported in version 1.1");
+    }
+    public OFQueuePropMaxRate maxRate(int rate) {
+        throw new UnsupportedOperationException("OFQueuePropMaxRate not supported in version 1.1");
+    }
+
+    public OFMessageReader<OFQueueProp> getReader() {
+        return OFQueuePropVer11.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_11;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsEntryVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsEntryVer11.java
new file mode 100644
index 0000000..3f9c59b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsEntryVer11.java
@@ -0,0 +1,484 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsEntryVer11 implements OFQueueStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsEntryVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 32;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+        private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final long queueId;
+    private final U64 txBytes;
+    private final U64 txPackets;
+    private final U64 txErrors;
+//
+    // Immutable default instance
+    final static OFQueueStatsEntryVer11 DEFAULT = new OFQueueStatsEntryVer11(
+        DEFAULT_PORT_NO, DEFAULT_QUEUE_ID, DEFAULT_TX_BYTES, DEFAULT_TX_PACKETS, DEFAULT_TX_ERRORS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsEntryVer11(OFPort portNo, long queueId, U64 txBytes, U64 txPackets, U64 txErrors) {
+        this.portNo = portNo;
+        this.queueId = queueId;
+        this.txBytes = txBytes;
+        this.txPackets = txPackets;
+        this.txErrors = txErrors;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFQueueStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsEntry.Builder {
+        final OFQueueStatsEntryVer11 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+
+        BuilderWithParent(OFQueueStatsEntryVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFQueueStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+                U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
+                if(txBytes == null)
+                    throw new NullPointerException("Property txBytes must not be null");
+                U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
+                if(txPackets == null)
+                    throw new NullPointerException("Property txPackets must not be null");
+                U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
+                if(txErrors == null)
+                    throw new NullPointerException("Property txErrors must not be null");
+
+                //
+                return new OFQueueStatsEntryVer11(
+                    portNo,
+                    queueId,
+                    txBytes,
+                    txPackets,
+                    txErrors
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.1");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.1");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFQueueStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+            U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
+            if(txBytes == null)
+                throw new NullPointerException("Property txBytes must not be null");
+            U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
+            if(txPackets == null)
+                throw new NullPointerException("Property txPackets must not be null");
+            U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
+            if(txErrors == null)
+                throw new NullPointerException("Property txErrors must not be null");
+
+
+            return new OFQueueStatsEntryVer11(
+                    portNo,
+                    queueId,
+                    txBytes,
+                    txPackets,
+                    txErrors
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsEntry> {
+        @Override
+        public OFQueueStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            long queueId = U32.f(bb.readInt());
+            U64 txBytes = U64.ofRaw(bb.readLong());
+            U64 txPackets = U64.ofRaw(bb.readLong());
+            U64 txErrors = U64.ofRaw(bb.readLong());
+
+            OFQueueStatsEntryVer11 queueStatsEntryVer11 = new OFQueueStatsEntryVer11(
+                    portNo,
+                      queueId,
+                      txBytes,
+                      txPackets,
+                      txErrors
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsEntryVer11);
+            return queueStatsEntryVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsEntryVer11Funnel FUNNEL = new OFQueueStatsEntryVer11Funnel();
+    static class OFQueueStatsEntryVer11Funnel implements Funnel<OFQueueStatsEntryVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsEntryVer11 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            sink.putLong(message.queueId);
+            message.txBytes.putTo(sink);
+            message.txPackets.putTo(sink);
+            message.txErrors.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsEntryVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsEntryVer11 message) {
+            message.portNo.write4Bytes(bb);
+            bb.writeInt(U32.t(message.queueId));
+            bb.writeLong(message.txBytes.getValue());
+            bb.writeLong(message.txPackets.getValue());
+            bb.writeLong(message.txErrors.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsEntryVer11(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(", ");
+        b.append("txBytes=").append(txBytes);
+        b.append(", ");
+        b.append("txPackets=").append(txPackets);
+        b.append(", ");
+        b.append("txErrors=").append(txErrors);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsEntryVer11 other = (OFQueueStatsEntryVer11) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        if (txBytes == null) {
+            if (other.txBytes != null)
+                return false;
+        } else if (!txBytes.equals(other.txBytes))
+            return false;
+        if (txPackets == null) {
+            if (other.txPackets != null)
+                return false;
+        } else if (!txPackets.equals(other.txPackets))
+            return false;
+        if (txErrors == null) {
+            if (other.txErrors != null)
+                return false;
+        } else if (!txErrors.equals(other.txErrors))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
+        result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
+        result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsReplyVer11.java
new file mode 100644
index 0000000..7053409
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsReplyVer11.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsReplyVer11 implements OFQueueStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFQueueStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFQueueStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFQueueStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFQueueStatsReplyVer11 DEFAULT = new OFQueueStatsReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsReplyVer11(long xid, Set<OFStatsReplyFlags> flags, List<OFQueueStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFQueueStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsReply.Builder {
+        final OFQueueStatsReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFQueueStatsEntry> entries;
+
+        BuilderWithParent(OFQueueStatsReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setEntries(List<OFQueueStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFQueueStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFQueueStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFQueueStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setEntries(List<OFQueueStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFQueueStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFQueueStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsReply> {
+        @Override
+        public OFQueueStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 5
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x5)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.QUEUE(5), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFQueueStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFQueueStatsEntryVer11.READER);
+
+            OFQueueStatsReplyVer11 queueStatsReplyVer11 = new OFQueueStatsReplyVer11(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsReplyVer11);
+            return queueStatsReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsReplyVer11Funnel FUNNEL = new OFQueueStatsReplyVer11Funnel();
+    static class OFQueueStatsReplyVer11Funnel implements Funnel<OFQueueStatsReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 5
+            sink.putShort((short) 0x5);
+            OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 5
+            bb.writeShort((short) 0x5);
+            OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsReplyVer11 other = (OFQueueStatsReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsRequestVer11.java
new file mode 100644
index 0000000..3eece41
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFQueueStatsRequestVer11.java
@@ -0,0 +1,452 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsRequestVer11 implements OFQueueStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+    private final long queueId;
+//
+    // Immutable default instance
+    final static OFQueueStatsRequestVer11 DEFAULT = new OFQueueStatsRequestVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO, DEFAULT_QUEUE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsRequestVer11(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo, long queueId) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+        this.queueId = queueId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+
+
+    public OFQueueStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsRequest.Builder {
+        final OFQueueStatsRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+
+        BuilderWithParent(OFQueueStatsRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+
+                //
+                return new OFQueueStatsRequestVer11(
+                    xid,
+                    flags,
+                    portNo,
+                    queueId
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+
+
+            return new OFQueueStatsRequestVer11(
+                    xid,
+                    flags,
+                    portNo,
+                    queueId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsRequest> {
+        @Override
+        public OFQueueStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 5
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x5)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.QUEUE(5), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            long queueId = U32.f(bb.readInt());
+
+            OFQueueStatsRequestVer11 queueStatsRequestVer11 = new OFQueueStatsRequestVer11(
+                    xid,
+                      flags,
+                      portNo,
+                      queueId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsRequestVer11);
+            return queueStatsRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsRequestVer11Funnel FUNNEL = new OFQueueStatsRequestVer11Funnel();
+    static class OFQueueStatsRequestVer11Funnel implements Funnel<OFQueueStatsRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 5
+            sink.putShort((short) 0x5);
+            OFStatsRequestFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.portNo.putTo(sink);
+            sink.putLong(message.queueId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 5
+            bb.writeShort((short) 0x5);
+            OFStatsRequestFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.portNo.write4Bytes(bb);
+            bb.writeInt(U32.t(message.queueId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsRequestVer11 other = (OFQueueStatsRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSetConfigVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSetConfigVer11.java
new file mode 100644
index 0000000..c465158
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSetConfigVer11.java
@@ -0,0 +1,370 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFSetConfigVer11 implements OFSetConfig {
+    private static final Logger logger = LoggerFactory.getLogger(OFSetConfigVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFConfigFlags> DEFAULT_FLAGS = ImmutableSet.<OFConfigFlags>of();
+        private final static int DEFAULT_MISS_SEND_LEN = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFConfigFlags> flags;
+    private final int missSendLen;
+//
+    // Immutable default instance
+    final static OFSetConfigVer11 DEFAULT = new OFSetConfigVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MISS_SEND_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFSetConfigVer11(long xid, Set<OFConfigFlags> flags, int missSendLen) {
+        this.xid = xid;
+        this.flags = flags;
+        this.missSendLen = missSendLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+
+
+    public OFSetConfig.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFSetConfig.Builder {
+        final OFSetConfigVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+        BuilderWithParent(OFSetConfigVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSetConfig.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFSetConfig.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFSetConfig.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFSetConfig build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFConfigFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int missSendLen = this.missSendLenSet ? this.missSendLen : parentMessage.missSendLen;
+
+                //
+                return new OFSetConfigVer11(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFSetConfig.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSetConfig.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFSetConfig.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFSetConfig.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFSetConfig build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFConfigFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int missSendLen = this.missSendLenSet ? this.missSendLen : DEFAULT_MISS_SEND_LEN;
+
+
+            return new OFSetConfigVer11(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFSetConfig> {
+        @Override
+        public OFSetConfig readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 9
+            byte type = bb.readByte();
+            if(type != (byte) 0x9)
+                throw new OFParseError("Wrong type: Expected=OFType.SET_CONFIG(9), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Set<OFConfigFlags> flags = OFConfigFlagsSerializerVer11.readFrom(bb);
+            int missSendLen = U16.f(bb.readShort());
+
+            OFSetConfigVer11 setConfigVer11 = new OFSetConfigVer11(
+                    xid,
+                      flags,
+                      missSendLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", setConfigVer11);
+            return setConfigVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFSetConfigVer11Funnel FUNNEL = new OFSetConfigVer11Funnel();
+    static class OFSetConfigVer11Funnel implements Funnel<OFSetConfigVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFSetConfigVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 9
+            sink.putByte((byte) 0x9);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            OFConfigFlagsSerializerVer11.putTo(message.flags, sink);
+            sink.putInt(message.missSendLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFSetConfigVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFSetConfigVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 9
+            bb.writeByte((byte) 0x9);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            OFConfigFlagsSerializerVer11.writeTo(bb, message.flags);
+            bb.writeShort(U16.t(message.missSendLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFSetConfigVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("missSendLen=").append(missSendLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFSetConfigVer11 other = (OFSetConfigVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( missSendLen != other.missSendLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + missSendLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsReplyFlagsSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsReplyFlagsSerializerVer11.java
new file mode 100644
index 0000000..3d91b4d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsReplyFlagsSerializerVer11.java
@@ -0,0 +1,78 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFStatsReplyFlagsSerializerVer11 {
+
+    public final static short REPLY_MORE_VAL = (short) 0x1;
+
+    public static Set<OFStatsReplyFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFStatsReplyFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFStatsReplyFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFStatsReplyFlags> ofWireValue(short val) {
+        EnumSet<OFStatsReplyFlags> set = EnumSet.noneOf(OFStatsReplyFlags.class);
+
+        if((val & REPLY_MORE_VAL) != 0)
+            set.add(OFStatsReplyFlags.REPLY_MORE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFStatsReplyFlags> set) {
+        short wireValue = 0;
+
+        for(OFStatsReplyFlags e: set) {
+            switch(e) {
+                case REPLY_MORE:
+                    wireValue |= REPLY_MORE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFStatsReplyFlags in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsReplyVer11.java
new file mode 100644
index 0000000..9368b22
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsReplyVer11.java
@@ -0,0 +1,89 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFStatsReplyVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFStatsReplyVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFStatsReply> {
+        @Override
+        public OFStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short statsType = bb.readShort();
+            bb.readerIndex(start);
+            switch(statsType) {
+               case (short) 0x2:
+                   // discriminator value OFStatsType.AGGREGATE=2 for class OFAggregateStatsReplyVer11
+                   return OFAggregateStatsReplyVer11.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFStatsType.EXPERIMENTER=65535 for class OFExperimenterStatsReplyVer11
+                   return OFExperimenterStatsReplyVer11.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFStatsType.DESC=0 for class OFDescStatsReplyVer11
+                   return OFDescStatsReplyVer11.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFStatsType.FLOW=1 for class OFFlowStatsReplyVer11
+                   return OFFlowStatsReplyVer11.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFStatsType.PORT=4 for class OFPortStatsReplyVer11
+                   return OFPortStatsReplyVer11.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFStatsType.QUEUE=5 for class OFQueueStatsReplyVer11
+                   return OFQueueStatsReplyVer11.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFStatsType.TABLE=3 for class OFTableStatsReplyVer11
+                   return OFTableStatsReplyVer11.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFStatsType.GROUP_DESC=7 for class OFGroupDescStatsReplyVer11
+                   return OFGroupDescStatsReplyVer11.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFStatsType.GROUP=6 for class OFGroupStatsReplyVer11
+                   return OFGroupStatsReplyVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator statsType of class OFStatsReplyVer11: " + statsType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsRequestFlagsSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsRequestFlagsSerializerVer11.java
new file mode 100644
index 0000000..e249701
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsRequestFlagsSerializerVer11.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsRequestFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFStatsRequestFlagsSerializerVer11 {
+
+
+    public static Set<OFStatsRequestFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFStatsRequestFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFStatsRequestFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFStatsRequestFlags> ofWireValue(short val) {
+        EnumSet<OFStatsRequestFlags> set = EnumSet.noneOf(OFStatsRequestFlags.class);
+
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFStatsRequestFlags> set) {
+        short wireValue = 0;
+
+        for(OFStatsRequestFlags e: set) {
+            switch(e) {
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFStatsRequestFlags in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsRequestVer11.java
new file mode 100644
index 0000000..32d4a63
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsRequestVer11.java
@@ -0,0 +1,89 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFStatsRequestVer11 {
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFStatsRequestVer11.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFStatsRequest<?>> {
+        @Override
+        public OFStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short statsType = bb.readShort();
+            bb.readerIndex(start);
+            switch(statsType) {
+               case (short) 0x2:
+                   // discriminator value OFStatsType.AGGREGATE=2 for class OFAggregateStatsRequestVer11
+                   return OFAggregateStatsRequestVer11.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFStatsType.EXPERIMENTER=65535 for class OFExperimenterStatsRequestVer11
+                   return OFExperimenterStatsRequestVer11.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFStatsType.DESC=0 for class OFDescStatsRequestVer11
+                   return OFDescStatsRequestVer11.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFStatsType.FLOW=1 for class OFFlowStatsRequestVer11
+                   return OFFlowStatsRequestVer11.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFStatsType.PORT=4 for class OFPortStatsRequestVer11
+                   return OFPortStatsRequestVer11.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFStatsType.QUEUE=5 for class OFQueueStatsRequestVer11
+                   return OFQueueStatsRequestVer11.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFStatsType.TABLE=3 for class OFTableStatsRequestVer11
+                   return OFTableStatsRequestVer11.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFStatsType.GROUP_DESC=7 for class OFGroupDescStatsRequestVer11
+                   return OFGroupDescStatsRequestVer11.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFStatsType.GROUP=6 for class OFGroupStatsRequestVer11
+                   return OFGroupStatsRequestVer11.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator statsType of class OFStatsRequestVer11: " + statsType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsTypeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsTypeSerializerVer11.java
new file mode 100644
index 0000000..bc1cbb0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFStatsTypeSerializerVer11.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFStatsTypeSerializerVer11 {
+
+    public final static short DESC_VAL = (short) 0x0;
+    public final static short FLOW_VAL = (short) 0x1;
+    public final static short AGGREGATE_VAL = (short) 0x2;
+    public final static short TABLE_VAL = (short) 0x3;
+    public final static short PORT_VAL = (short) 0x4;
+    public final static short QUEUE_VAL = (short) 0x5;
+    public final static short GROUP_VAL = (short) 0x6;
+    public final static short GROUP_DESC_VAL = (short) 0x7;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFStatsType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFStatsType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFStatsType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFStatsType ofWireValue(short val) {
+        switch(val) {
+            case DESC_VAL:
+                return OFStatsType.DESC;
+            case FLOW_VAL:
+                return OFStatsType.FLOW;
+            case AGGREGATE_VAL:
+                return OFStatsType.AGGREGATE;
+            case TABLE_VAL:
+                return OFStatsType.TABLE;
+            case PORT_VAL:
+                return OFStatsType.PORT;
+            case QUEUE_VAL:
+                return OFStatsType.QUEUE;
+            case GROUP_VAL:
+                return OFStatsType.GROUP;
+            case GROUP_DESC_VAL:
+                return OFStatsType.GROUP_DESC;
+            case EXPERIMENTER_VAL:
+                return OFStatsType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFStatsType e) {
+        switch(e) {
+            case DESC:
+                return DESC_VAL;
+            case FLOW:
+                return FLOW_VAL;
+            case AGGREGATE:
+                return AGGREGATE_VAL;
+            case TABLE:
+                return TABLE_VAL;
+            case PORT:
+                return PORT_VAL;
+            case QUEUE:
+                return QUEUE_VAL;
+            case GROUP:
+                return GROUP_VAL;
+            case GROUP_DESC:
+                return GROUP_DESC_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSwitchConfigFailedCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSwitchConfigFailedCodeSerializerVer11.java
new file mode 100644
index 0000000..0ace5e3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSwitchConfigFailedCodeSerializerVer11.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFSwitchConfigFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFSwitchConfigFailedCodeSerializerVer11 {
+
+    public final static short BAD_FLAGS_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+
+    public static OFSwitchConfigFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFSwitchConfigFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFSwitchConfigFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFSwitchConfigFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_FLAGS_VAL:
+                return OFSwitchConfigFailedCode.BAD_FLAGS;
+            case BAD_LEN_VAL:
+                return OFSwitchConfigFailedCode.BAD_LEN;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFSwitchConfigFailedCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFSwitchConfigFailedCode e) {
+        switch(e) {
+            case BAD_FLAGS:
+                return BAD_FLAGS_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFSwitchConfigFailedCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSwitchConfigFailedErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSwitchConfigFailedErrorMsgVer11.java
new file mode 100644
index 0000000..bbd1450
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFSwitchConfigFailedErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFSwitchConfigFailedErrorMsgVer11 implements OFSwitchConfigFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFSwitchConfigFailedErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFSwitchConfigFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFSwitchConfigFailedErrorMsgVer11(long xid, OFSwitchConfigFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFSwitchConfigFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFSwitchConfigFailedErrorMsg.Builder {
+        final OFSwitchConfigFailedErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFSwitchConfigFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFSwitchConfigFailedErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setCode(OFSwitchConfigFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFSwitchConfigFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFSwitchConfigFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFSwitchConfigFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFSwitchConfigFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFSwitchConfigFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setCode(OFSwitchConfigFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFSwitchConfigFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFSwitchConfigFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFSwitchConfigFailedErrorMsg> {
+        @Override
+        public OFSwitchConfigFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 10
+            short errType = bb.readShort();
+            if(errType != (short) 0xa)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.SWITCH_CONFIG_FAILED(10), got="+errType);
+            OFSwitchConfigFailedCode code = OFSwitchConfigFailedCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFSwitchConfigFailedErrorMsgVer11 switchConfigFailedErrorMsgVer11 = new OFSwitchConfigFailedErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", switchConfigFailedErrorMsgVer11);
+            return switchConfigFailedErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFSwitchConfigFailedErrorMsgVer11Funnel FUNNEL = new OFSwitchConfigFailedErrorMsgVer11Funnel();
+    static class OFSwitchConfigFailedErrorMsgVer11Funnel implements Funnel<OFSwitchConfigFailedErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFSwitchConfigFailedErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 10
+            sink.putShort((short) 0xa);
+            OFSwitchConfigFailedCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFSwitchConfigFailedErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFSwitchConfigFailedErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 10
+            bb.writeShort((short) 0xa);
+            OFSwitchConfigFailedCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFSwitchConfigFailedErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFSwitchConfigFailedErrorMsgVer11 other = (OFSwitchConfigFailedErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableConfigSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableConfigSerializerVer11.java
new file mode 100644
index 0000000..3f36f74
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableConfigSerializerVer11.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTableConfig;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFTableConfigSerializerVer11 {
+
+    public final static int TABLE_MISS_CONTROLLER_VAL = 0x0;
+    public final static int TABLE_MISS_CONTINUE_VAL = 0x1;
+    public final static int TABLE_MISS_DROP_VAL = 0x2;
+    public final static int TABLE_MISS_MASK_VAL = 0x3;
+
+    public static Set<OFTableConfig> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFTableConfig> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFTableConfig> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFTableConfig> ofWireValue(int val) {
+        EnumSet<OFTableConfig> set = EnumSet.noneOf(OFTableConfig.class);
+
+        if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_CONTROLLER_VAL)
+            set.add(OFTableConfig.TABLE_MISS_CONTROLLER);
+        else if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_CONTINUE_VAL)
+            set.add(OFTableConfig.TABLE_MISS_CONTINUE);
+        else if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_DROP_VAL)
+            set.add(OFTableConfig.TABLE_MISS_DROP);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFTableConfig> set) {
+        int wireValue = 0;
+
+        for(OFTableConfig e: set) {
+            switch(e) {
+                case TABLE_MISS_CONTROLLER:
+                    wireValue |= TABLE_MISS_CONTROLLER_VAL;
+                    break;
+                case TABLE_MISS_CONTINUE:
+                    wireValue |= TABLE_MISS_CONTINUE_VAL;
+                    break;
+                case TABLE_MISS_DROP:
+                    wireValue |= TABLE_MISS_DROP_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFTableConfig in version 1.1: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModFailedCodeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModFailedCodeSerializerVer11.java
new file mode 100644
index 0000000..3f5cb8f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModFailedCodeSerializerVer11.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTableModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTableModFailedCodeSerializerVer11 {
+
+    public final static short BAD_TABLE_VAL = (short) 0x0;
+    public final static short BAD_CONFIG_VAL = (short) 0x1;
+
+    public static OFTableModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFTableModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFTableModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFTableModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TABLE_VAL:
+                return OFTableModFailedCode.BAD_TABLE;
+            case BAD_CONFIG_VAL:
+                return OFTableModFailedCode.BAD_CONFIG;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFTableModFailedCode in version 1.1: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFTableModFailedCode e) {
+        switch(e) {
+            case BAD_TABLE:
+                return BAD_TABLE_VAL;
+            case BAD_CONFIG:
+                return BAD_CONFIG_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFTableModFailedCode in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModFailedErrorMsgVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModFailedErrorMsgVer11.java
new file mode 100644
index 0000000..b1a3b92
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModFailedErrorMsgVer11.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableModFailedErrorMsgVer11 implements OFTableModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableModFailedErrorMsgVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFTableModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableModFailedErrorMsgVer11(long xid, OFTableModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFTableModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableModFailedErrorMsg.Builder {
+        final OFTableModFailedErrorMsgVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFTableModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFTableModFailedErrorMsgVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setCode(OFTableModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFTableModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFTableModFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFTableModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setCode(OFTableModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFTableModFailedErrorMsgVer11(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableModFailedErrorMsg> {
+        @Override
+        public OFTableModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 8
+            short errType = bb.readShort();
+            if(errType != (short) 0x8)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.TABLE_MOD_FAILED(8), got="+errType);
+            OFTableModFailedCode code = OFTableModFailedCodeSerializerVer11.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_11);
+
+            OFTableModFailedErrorMsgVer11 tableModFailedErrorMsgVer11 = new OFTableModFailedErrorMsgVer11(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableModFailedErrorMsgVer11);
+            return tableModFailedErrorMsgVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableModFailedErrorMsgVer11Funnel FUNNEL = new OFTableModFailedErrorMsgVer11Funnel();
+    static class OFTableModFailedErrorMsgVer11Funnel implements Funnel<OFTableModFailedErrorMsgVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableModFailedErrorMsgVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 8
+            sink.putShort((short) 0x8);
+            OFTableModFailedCodeSerializerVer11.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableModFailedErrorMsgVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableModFailedErrorMsgVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 8
+            bb.writeShort((short) 0x8);
+            OFTableModFailedCodeSerializerVer11.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableModFailedErrorMsgVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableModFailedErrorMsgVer11 other = (OFTableModFailedErrorMsgVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModVer11.java
new file mode 100644
index 0000000..9d139a8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableModVer11.java
@@ -0,0 +1,374 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableModVer11 implements OFTableMod {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableModVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_CONFIG = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final TableId tableId;
+    private final long config;
+//
+    // Immutable default instance
+    final static OFTableModVer11 DEFAULT = new OFTableModVer11(
+        DEFAULT_XID, DEFAULT_TABLE_ID, DEFAULT_CONFIG
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableModVer11(long xid, TableId tableId, long config) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.config = config;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+
+
+    public OFTableMod.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableMod.Builder {
+        final OFTableModVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean configSet;
+        private long config;
+
+        BuilderWithParent(OFTableModVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableMod.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableMod build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long config = this.configSet ? this.config : parentMessage.config;
+
+                //
+                return new OFTableModVer11(
+                    xid,
+                    tableId,
+                    config
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableMod.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean configSet;
+        private long config;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableMod.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableMod build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+
+
+            return new OFTableModVer11(
+                    xid,
+                    tableId,
+                    config
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableMod> {
+        @Override
+        public OFTableMod readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.TABLE_MOD(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            long config = U32.f(bb.readInt());
+
+            OFTableModVer11 tableModVer11 = new OFTableModVer11(
+                    xid,
+                      tableId,
+                      config
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableModVer11);
+            return tableModVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableModVer11Funnel FUNNEL = new OFTableModVer11Funnel();
+    static class OFTableModVer11Funnel implements Funnel<OFTableModVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableModVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            sink.putLong(message.config);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableModVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableModVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeInt(U32.t(message.config));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableModVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableModVer11 other = (OFTableModVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( config != other.config)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (config ^ (config >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsEntryVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsEntryVer11.java
new file mode 100644
index 0000000..40c124e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsEntryVer11.java
@@ -0,0 +1,867 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsEntryVer11 implements OFTableStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsEntryVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 88;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static String DEFAULT_NAME = "";
+        private final static int DEFAULT_WILDCARDS = 0x0;
+        private final static long DEFAULT_INSTRUCTIONS = 0x0L;
+        private final static long DEFAULT_WRITE_ACTIONS = 0x0L;
+        private final static long DEFAULT_APPLY_ACTIONS = 0x0L;
+        private final static long DEFAULT_CONFIG = 0x0L;
+        private final static long DEFAULT_MAX_ENTRIES = 0x0L;
+        private final static long DEFAULT_ACTIVE_COUNT = 0x0L;
+        private final static U64 DEFAULT_LOOKUP_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_MATCHED_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final TableId tableId;
+    private final String name;
+    private final int wildcards;
+    private final OFMatchBmap match;
+    private final long instructions;
+    private final long writeActions;
+    private final long applyActions;
+    private final long config;
+    private final long maxEntries;
+    private final long activeCount;
+    private final U64 lookupCount;
+    private final U64 matchedCount;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsEntryVer11(TableId tableId, String name, int wildcards, OFMatchBmap match, long instructions, long writeActions, long applyActions, long config, long maxEntries, long activeCount, U64 lookupCount, U64 matchedCount) {
+        this.tableId = tableId;
+        this.name = name;
+        this.wildcards = wildcards;
+        this.match = match;
+        this.instructions = instructions;
+        this.writeActions = writeActions;
+        this.applyActions = applyActions;
+        this.config = config;
+        this.maxEntries = maxEntries;
+        this.activeCount = activeCount;
+        this.lookupCount = lookupCount;
+        this.matchedCount = matchedCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFMatchBmap getMatch() {
+        return match;
+    }
+
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public long getWriteActions() {
+        return writeActions;
+    }
+
+    @Override
+    public long getApplyActions() {
+        return applyActions;
+    }
+
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.1");
+    }
+
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.1");
+    }
+
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.1");
+    }
+
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.1");
+    }
+
+    @Override
+    public long getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+    public OFTableStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsEntry.Builder {
+        final OFTableStatsEntryVer11 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean matchSet;
+        private OFMatchBmap match;
+        private boolean instructionsSet;
+        private long instructions;
+        private boolean writeActionsSet;
+        private long writeActions;
+        private boolean applyActionsSet;
+        private long applyActions;
+        private boolean configSet;
+        private long config;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+        private boolean activeCountSet;
+        private long activeCount;
+        private boolean lookupCountSet;
+        private U64 lookupCount;
+        private boolean matchedCountSet;
+        private U64 matchedCount;
+
+        BuilderWithParent(OFTableStatsEntryVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public OFMatchBmap getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatch(OFMatchBmap match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public long getWriteActions() {
+        return writeActions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteActions(long writeActions) {
+        this.writeActions = writeActions;
+        this.writeActionsSet = true;
+        return this;
+    }
+    @Override
+    public long getApplyActions() {
+        return applyActions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplyActions(long applyActions) {
+        this.applyActions = applyActions;
+        this.applyActionsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.1");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteSetfields(U64 writeSetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.1");
+    }
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.1");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplySetfields(U64 applySetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applySetfields not supported in version 1.1");
+    }
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.1");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataMatch(U64 metadataMatch) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.1");
+    }
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.1");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataWrite(U64 metadataWrite) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.1");
+    }
+    @Override
+    public long getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setInstructions(long instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setActiveCount(long activeCount) {
+        this.activeCount = activeCount;
+        this.activeCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setLookupCount(U64 lookupCount) {
+        this.lookupCount = lookupCount;
+        this.lookupCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatchedCount(U64 matchedCount) {
+        this.matchedCount = matchedCount;
+        this.matchedCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+
+
+        @Override
+        public OFTableStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                int wildcards = this.wildcardsSet ? this.wildcards : parentMessage.wildcards;
+                OFMatchBmap match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                long instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                long writeActions = this.writeActionsSet ? this.writeActions : parentMessage.writeActions;
+                long applyActions = this.applyActionsSet ? this.applyActions : parentMessage.applyActions;
+                long config = this.configSet ? this.config : parentMessage.config;
+                long maxEntries = this.maxEntriesSet ? this.maxEntries : parentMessage.maxEntries;
+                long activeCount = this.activeCountSet ? this.activeCount : parentMessage.activeCount;
+                U64 lookupCount = this.lookupCountSet ? this.lookupCount : parentMessage.lookupCount;
+                if(lookupCount == null)
+                    throw new NullPointerException("Property lookupCount must not be null");
+                U64 matchedCount = this.matchedCountSet ? this.matchedCount : parentMessage.matchedCount;
+                if(matchedCount == null)
+                    throw new NullPointerException("Property matchedCount must not be null");
+
+                //
+                return new OFTableStatsEntryVer11(
+                    tableId,
+                    name,
+                    wildcards,
+                    match,
+                    instructions,
+                    writeActions,
+                    applyActions,
+                    config,
+                    maxEntries,
+                    activeCount,
+                    lookupCount,
+                    matchedCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean matchSet;
+        private OFMatchBmap match;
+        private boolean instructionsSet;
+        private long instructions;
+        private boolean writeActionsSet;
+        private long writeActions;
+        private boolean applyActionsSet;
+        private long applyActions;
+        private boolean configSet;
+        private long config;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+        private boolean activeCountSet;
+        private long activeCount;
+        private boolean lookupCountSet;
+        private U64 lookupCount;
+        private boolean matchedCountSet;
+        private U64 matchedCount;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public OFMatchBmap getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatch(OFMatchBmap match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public long getWriteActions() {
+        return writeActions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteActions(long writeActions) {
+        this.writeActions = writeActions;
+        this.writeActionsSet = true;
+        return this;
+    }
+    @Override
+    public long getApplyActions() {
+        return applyActions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplyActions(long applyActions) {
+        this.applyActions = applyActions;
+        this.applyActionsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.1");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteSetfields(U64 writeSetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.1");
+    }
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.1");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplySetfields(U64 applySetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applySetfields not supported in version 1.1");
+    }
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.1");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataMatch(U64 metadataMatch) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.1");
+    }
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.1");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataWrite(U64 metadataWrite) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.1");
+    }
+    @Override
+    public long getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setInstructions(long instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setActiveCount(long activeCount) {
+        this.activeCount = activeCount;
+        this.activeCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setLookupCount(U64 lookupCount) {
+        this.lookupCount = lookupCount;
+        this.lookupCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatchedCount(U64 matchedCount) {
+        this.matchedCount = matchedCount;
+        this.matchedCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+//
+        @Override
+        public OFTableStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            int wildcards = this.wildcardsSet ? this.wildcards : DEFAULT_WILDCARDS;
+            if(!this.matchSet)
+                throw new IllegalStateException("Property match doesn't have default value -- must be set");
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            long instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            long writeActions = this.writeActionsSet ? this.writeActions : DEFAULT_WRITE_ACTIONS;
+            long applyActions = this.applyActionsSet ? this.applyActions : DEFAULT_APPLY_ACTIONS;
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+            long maxEntries = this.maxEntriesSet ? this.maxEntries : DEFAULT_MAX_ENTRIES;
+            long activeCount = this.activeCountSet ? this.activeCount : DEFAULT_ACTIVE_COUNT;
+            U64 lookupCount = this.lookupCountSet ? this.lookupCount : DEFAULT_LOOKUP_COUNT;
+            if(lookupCount == null)
+                throw new NullPointerException("Property lookupCount must not be null");
+            U64 matchedCount = this.matchedCountSet ? this.matchedCount : DEFAULT_MATCHED_COUNT;
+            if(matchedCount == null)
+                throw new NullPointerException("Property matchedCount must not be null");
+
+
+            return new OFTableStatsEntryVer11(
+                    tableId,
+                    name,
+                    wildcards,
+                    match,
+                    instructions,
+                    writeActions,
+                    applyActions,
+                    config,
+                    maxEntries,
+                    activeCount,
+                    lookupCount,
+                    matchedCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsEntry> {
+        @Override
+        public OFTableStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            TableId tableId = TableId.readByte(bb);
+            // pad: 7 bytes
+            bb.skipBytes(7);
+            String name = ChannelUtils.readFixedLengthString(bb, 32);
+            int wildcards = bb.readInt();
+            OFMatchBmap match = ChannelUtilsVer11.readOFMatchBmap(bb);
+            long instructions = U32.f(bb.readInt());
+            long writeActions = U32.f(bb.readInt());
+            long applyActions = U32.f(bb.readInt());
+            long config = U32.f(bb.readInt());
+            long maxEntries = U32.f(bb.readInt());
+            long activeCount = U32.f(bb.readInt());
+            U64 lookupCount = U64.ofRaw(bb.readLong());
+            U64 matchedCount = U64.ofRaw(bb.readLong());
+
+            OFTableStatsEntryVer11 tableStatsEntryVer11 = new OFTableStatsEntryVer11(
+                    tableId,
+                      name,
+                      wildcards,
+                      match,
+                      instructions,
+                      writeActions,
+                      applyActions,
+                      config,
+                      maxEntries,
+                      activeCount,
+                      lookupCount,
+                      matchedCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsEntryVer11);
+            return tableStatsEntryVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsEntryVer11Funnel FUNNEL = new OFTableStatsEntryVer11Funnel();
+    static class OFTableStatsEntryVer11Funnel implements Funnel<OFTableStatsEntryVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsEntryVer11 message, PrimitiveSink sink) {
+            message.tableId.putTo(sink);
+            // skip pad (7 bytes)
+            sink.putUnencodedChars(message.name);
+            sink.putInt(message.wildcards);
+            message.match.putTo(sink);
+            sink.putLong(message.instructions);
+            sink.putLong(message.writeActions);
+            sink.putLong(message.applyActions);
+            sink.putLong(message.config);
+            sink.putLong(message.maxEntries);
+            sink.putLong(message.activeCount);
+            message.lookupCount.putTo(sink);
+            message.matchedCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsEntryVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsEntryVer11 message) {
+            message.tableId.writeByte(bb);
+            // pad: 7 bytes
+            bb.writeZero(7);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 32);
+            bb.writeInt(message.wildcards);
+            ChannelUtilsVer11.writeOFMatchBmap(bb, message.match);
+            bb.writeInt(U32.t(message.instructions));
+            bb.writeInt(U32.t(message.writeActions));
+            bb.writeInt(U32.t(message.applyActions));
+            bb.writeInt(U32.t(message.config));
+            bb.writeInt(U32.t(message.maxEntries));
+            bb.writeInt(U32.t(message.activeCount));
+            bb.writeLong(message.lookupCount.getValue());
+            bb.writeLong(message.matchedCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsEntryVer11(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("wildcards=").append(wildcards);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(", ");
+        b.append("writeActions=").append(writeActions);
+        b.append(", ");
+        b.append("applyActions=").append(applyActions);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("maxEntries=").append(maxEntries);
+        b.append(", ");
+        b.append("activeCount=").append(activeCount);
+        b.append(", ");
+        b.append("lookupCount=").append(lookupCount);
+        b.append(", ");
+        b.append("matchedCount=").append(matchedCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsEntryVer11 other = (OFTableStatsEntryVer11) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if( wildcards != other.wildcards)
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if( instructions != other.instructions)
+            return false;
+        if( writeActions != other.writeActions)
+            return false;
+        if( applyActions != other.applyActions)
+            return false;
+        if( config != other.config)
+            return false;
+        if( maxEntries != other.maxEntries)
+            return false;
+        if( activeCount != other.activeCount)
+            return false;
+        if (lookupCount == null) {
+            if (other.lookupCount != null)
+                return false;
+        } else if (!lookupCount.equals(other.lookupCount))
+            return false;
+        if (matchedCount == null) {
+            if (other.matchedCount != null)
+                return false;
+        } else if (!matchedCount.equals(other.matchedCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + wildcards;
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime *  (int) (instructions ^ (instructions >>> 32));
+        result = prime *  (int) (writeActions ^ (writeActions >>> 32));
+        result = prime *  (int) (applyActions ^ (applyActions >>> 32));
+        result = prime *  (int) (config ^ (config >>> 32));
+        result = prime *  (int) (maxEntries ^ (maxEntries >>> 32));
+        result = prime *  (int) (activeCount ^ (activeCount >>> 32));
+        result = prime * result + ((lookupCount == null) ? 0 : lookupCount.hashCode());
+        result = prime * result + ((matchedCount == null) ? 0 : matchedCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsReplyVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsReplyVer11.java
new file mode 100644
index 0000000..6eea25b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsReplyVer11.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsReplyVer11 implements OFTableStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsReplyVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFTableStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFTableStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFTableStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFTableStatsReplyVer11 DEFAULT = new OFTableStatsReplyVer11(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsReplyVer11(long xid, Set<OFStatsReplyFlags> flags, List<OFTableStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFTableStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsReply.Builder {
+        final OFTableStatsReplyVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableStatsEntry> entries;
+
+        BuilderWithParent(OFTableStatsReplyVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setEntries(List<OFTableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFTableStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFTableStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setEntries(List<OFTableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFTableStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFTableStatsReplyVer11(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsReply> {
+        @Override
+        public OFTableStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 3
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x3)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFTableStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFTableStatsEntryVer11.READER);
+
+            OFTableStatsReplyVer11 tableStatsReplyVer11 = new OFTableStatsReplyVer11(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsReplyVer11);
+            return tableStatsReplyVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsReplyVer11Funnel FUNNEL = new OFTableStatsReplyVer11Funnel();
+    static class OFTableStatsReplyVer11Funnel implements Funnel<OFTableStatsReplyVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsReplyVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 3
+            sink.putShort((short) 0x3);
+            OFStatsReplyFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsReplyVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsReplyVer11 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 3
+            bb.writeShort((short) 0x3);
+            OFStatsReplyFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsReplyVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsReplyVer11 other = (OFTableStatsReplyVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsRequestVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsRequestVer11.java
new file mode 100644
index 0000000..d20b395
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTableStatsRequestVer11.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsRequestVer11 implements OFTableStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsRequestVer11.class);
+    // version: 1.1
+    final static byte WIRE_VERSION = 2;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFTableStatsRequestVer11 DEFAULT = new OFTableStatsRequestVer11(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsRequestVer11(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFTableStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsRequest.Builder {
+        final OFTableStatsRequestVer11 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFTableStatsRequestVer11 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFTableStatsRequestVer11(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_11;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFTableStatsRequestVer11(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsRequest> {
+        @Override
+        public OFTableStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 2
+            byte version = bb.readByte();
+            if(version != (byte) 0x2)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 3
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x3)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer11.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFTableStatsRequestVer11 tableStatsRequestVer11 = new OFTableStatsRequestVer11(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsRequestVer11);
+            return tableStatsRequestVer11;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsRequestVer11Funnel FUNNEL = new OFTableStatsRequestVer11Funnel();
+    static class OFTableStatsRequestVer11Funnel implements Funnel<OFTableStatsRequestVer11> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsRequestVer11 message, PrimitiveSink sink) {
+            // fixed value property version = 2
+            sink.putByte((byte) 0x2);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 3
+            sink.putShort((short) 0x3);
+            OFStatsRequestFlagsSerializerVer11.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsRequestVer11> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsRequestVer11 message) {
+            // fixed value property version = 2
+            bb.writeByte((byte) 0x2);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 3
+            bb.writeShort((short) 0x3);
+            OFStatsRequestFlagsSerializerVer11.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsRequestVer11(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsRequestVer11 other = (OFTableStatsRequestVer11) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTypeSerializerVer11.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTypeSerializerVer11.java
new file mode 100644
index 0000000..db967b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver11/OFTypeSerializerVer11.java
@@ -0,0 +1,184 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver11;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTypeSerializerVer11 {
+
+    public final static byte HELLO_VAL = (byte) 0x0;
+    public final static byte ERROR_VAL = (byte) 0x1;
+    public final static byte ECHO_REQUEST_VAL = (byte) 0x2;
+    public final static byte ECHO_REPLY_VAL = (byte) 0x3;
+    public final static byte EXPERIMENTER_VAL = (byte) 0x4;
+    public final static byte FEATURES_REQUEST_VAL = (byte) 0x5;
+    public final static byte FEATURES_REPLY_VAL = (byte) 0x6;
+    public final static byte GET_CONFIG_REQUEST_VAL = (byte) 0x7;
+    public final static byte GET_CONFIG_REPLY_VAL = (byte) 0x8;
+    public final static byte SET_CONFIG_VAL = (byte) 0x9;
+    public final static byte PACKET_IN_VAL = (byte) 0xa;
+    public final static byte FLOW_REMOVED_VAL = (byte) 0xb;
+    public final static byte PORT_STATUS_VAL = (byte) 0xc;
+    public final static byte PACKET_OUT_VAL = (byte) 0xd;
+    public final static byte FLOW_MOD_VAL = (byte) 0xe;
+    public final static byte GROUP_MOD_VAL = (byte) 0xf;
+    public final static byte PORT_MOD_VAL = (byte) 0x10;
+    public final static byte TABLE_MOD_VAL = (byte) 0x11;
+    public final static byte STATS_REQUEST_VAL = (byte) 0x12;
+    public final static byte STATS_REPLY_VAL = (byte) 0x13;
+    public final static byte BARRIER_REQUEST_VAL = (byte) 0x14;
+    public final static byte BARRIER_REPLY_VAL = (byte) 0x15;
+    public final static byte QUEUE_GET_CONFIG_REQUEST_VAL = (byte) 0x16;
+    public final static byte QUEUE_GET_CONFIG_REPLY_VAL = (byte) 0x17;
+
+    public static OFType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFType e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFType e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFType ofWireValue(byte val) {
+        switch(val) {
+            case HELLO_VAL:
+                return OFType.HELLO;
+            case ERROR_VAL:
+                return OFType.ERROR;
+            case ECHO_REQUEST_VAL:
+                return OFType.ECHO_REQUEST;
+            case ECHO_REPLY_VAL:
+                return OFType.ECHO_REPLY;
+            case EXPERIMENTER_VAL:
+                return OFType.EXPERIMENTER;
+            case FEATURES_REQUEST_VAL:
+                return OFType.FEATURES_REQUEST;
+            case FEATURES_REPLY_VAL:
+                return OFType.FEATURES_REPLY;
+            case GET_CONFIG_REQUEST_VAL:
+                return OFType.GET_CONFIG_REQUEST;
+            case GET_CONFIG_REPLY_VAL:
+                return OFType.GET_CONFIG_REPLY;
+            case SET_CONFIG_VAL:
+                return OFType.SET_CONFIG;
+            case PACKET_IN_VAL:
+                return OFType.PACKET_IN;
+            case FLOW_REMOVED_VAL:
+                return OFType.FLOW_REMOVED;
+            case PORT_STATUS_VAL:
+                return OFType.PORT_STATUS;
+            case PACKET_OUT_VAL:
+                return OFType.PACKET_OUT;
+            case FLOW_MOD_VAL:
+                return OFType.FLOW_MOD;
+            case GROUP_MOD_VAL:
+                return OFType.GROUP_MOD;
+            case PORT_MOD_VAL:
+                return OFType.PORT_MOD;
+            case TABLE_MOD_VAL:
+                return OFType.TABLE_MOD;
+            case STATS_REQUEST_VAL:
+                return OFType.STATS_REQUEST;
+            case STATS_REPLY_VAL:
+                return OFType.STATS_REPLY;
+            case BARRIER_REQUEST_VAL:
+                return OFType.BARRIER_REQUEST;
+            case BARRIER_REPLY_VAL:
+                return OFType.BARRIER_REPLY;
+            case QUEUE_GET_CONFIG_REQUEST_VAL:
+                return OFType.QUEUE_GET_CONFIG_REQUEST;
+            case QUEUE_GET_CONFIG_REPLY_VAL:
+                return OFType.QUEUE_GET_CONFIG_REPLY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFType in version 1.1: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFType e) {
+        switch(e) {
+            case HELLO:
+                return HELLO_VAL;
+            case ERROR:
+                return ERROR_VAL;
+            case ECHO_REQUEST:
+                return ECHO_REQUEST_VAL;
+            case ECHO_REPLY:
+                return ECHO_REPLY_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            case FEATURES_REQUEST:
+                return FEATURES_REQUEST_VAL;
+            case FEATURES_REPLY:
+                return FEATURES_REPLY_VAL;
+            case GET_CONFIG_REQUEST:
+                return GET_CONFIG_REQUEST_VAL;
+            case GET_CONFIG_REPLY:
+                return GET_CONFIG_REPLY_VAL;
+            case SET_CONFIG:
+                return SET_CONFIG_VAL;
+            case PACKET_IN:
+                return PACKET_IN_VAL;
+            case FLOW_REMOVED:
+                return FLOW_REMOVED_VAL;
+            case PORT_STATUS:
+                return PORT_STATUS_VAL;
+            case PACKET_OUT:
+                return PACKET_OUT_VAL;
+            case FLOW_MOD:
+                return FLOW_MOD_VAL;
+            case GROUP_MOD:
+                return GROUP_MOD_VAL;
+            case PORT_MOD:
+                return PORT_MOD_VAL;
+            case TABLE_MOD:
+                return TABLE_MOD_VAL;
+            case STATS_REQUEST:
+                return STATS_REQUEST_VAL;
+            case STATS_REPLY:
+                return STATS_REPLY_VAL;
+            case BARRIER_REQUEST:
+                return BARRIER_REQUEST_VAL;
+            case BARRIER_REPLY:
+                return BARRIER_REPLY_VAL;
+            case QUEUE_GET_CONFIG_REQUEST:
+                return QUEUE_GET_CONFIG_REQUEST_VAL;
+            case QUEUE_GET_CONFIG_REPLY:
+                return QUEUE_GET_CONFIG_REPLY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFType in version 1.1: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnChecksumVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnChecksumVer12.java
new file mode 100644
index 0000000..0fb7c4a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnChecksumVer12.java
@@ -0,0 +1,313 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnChecksumVer12 implements OFActionBsnChecksum {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnChecksumVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 28;
+
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+
+    // OF message fields
+    private final U128 checksum;
+//
+    // Immutable default instance
+    final static OFActionBsnChecksumVer12 DEFAULT = new OFActionBsnChecksumVer12(
+        DEFAULT_CHECKSUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnChecksumVer12(U128 checksum) {
+        this.checksum = checksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionBsnChecksum.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnChecksum.Builder {
+        final OFActionBsnChecksumVer12 parentMessage;
+
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+        BuilderWithParent(OFActionBsnChecksumVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFActionBsnChecksum.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionBsnChecksum build() {
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+
+                //
+                return new OFActionBsnChecksumVer12(
+                    checksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnChecksum.Builder {
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFActionBsnChecksum.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionBsnChecksum build() {
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+
+
+            return new OFActionBsnChecksumVer12(
+                    checksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnChecksum> {
+        @Override
+        public OFActionBsnChecksum readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 28)
+                throw new OFParseError("Wrong length: Expected=28(28), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            U128 checksum = U128.read16Bytes(bb);
+
+            OFActionBsnChecksumVer12 actionBsnChecksumVer12 = new OFActionBsnChecksumVer12(
+                    checksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnChecksumVer12);
+            return actionBsnChecksumVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnChecksumVer12Funnel FUNNEL = new OFActionBsnChecksumVer12Funnel();
+    static class OFActionBsnChecksumVer12Funnel implements Funnel<OFActionBsnChecksumVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnChecksumVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 28
+            sink.putShort((short) 0x1c);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            message.checksum.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnChecksumVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnChecksumVer12 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 28
+            bb.writeShort((short) 0x1c);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            message.checksum.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnChecksumVer12(");
+        b.append("checksum=").append(checksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnChecksumVer12 other = (OFActionBsnChecksumVer12) obj;
+
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnMirrorVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnMirrorVer12.java
new file mode 100644
index 0000000..6f3fe5e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnMirrorVer12.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnMirrorVer12 implements OFActionBsnMirror {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnMirrorVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static OFPort DEFAULT_DEST_PORT = OFPort.ANY;
+        private final static long DEFAULT_VLAN_TAG = 0x0L;
+        private final static short DEFAULT_COPY_STAGE = (short) 0x0;
+
+    // OF message fields
+    private final OFPort destPort;
+    private final long vlanTag;
+    private final short copyStage;
+//
+    // Immutable default instance
+    final static OFActionBsnMirrorVer12 DEFAULT = new OFActionBsnMirrorVer12(
+        DEFAULT_DEST_PORT, DEFAULT_VLAN_TAG, DEFAULT_COPY_STAGE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnMirrorVer12(OFPort destPort, long vlanTag, short copyStage) {
+        this.destPort = destPort;
+        this.vlanTag = vlanTag;
+        this.copyStage = copyStage;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionBsnMirror.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnMirror.Builder {
+        final OFActionBsnMirrorVer12 parentMessage;
+
+        // OF message fields
+        private boolean destPortSet;
+        private OFPort destPort;
+        private boolean vlanTagSet;
+        private long vlanTag;
+        private boolean copyStageSet;
+        private short copyStage;
+
+        BuilderWithParent(OFActionBsnMirrorVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setDestPort(OFPort destPort) {
+        this.destPort = destPort;
+        this.destPortSet = true;
+        return this;
+    }
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setVlanTag(long vlanTag) {
+        this.vlanTag = vlanTag;
+        this.vlanTagSet = true;
+        return this;
+    }
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setCopyStage(short copyStage) {
+        this.copyStage = copyStage;
+        this.copyStageSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionBsnMirror build() {
+                OFPort destPort = this.destPortSet ? this.destPort : parentMessage.destPort;
+                if(destPort == null)
+                    throw new NullPointerException("Property destPort must not be null");
+                long vlanTag = this.vlanTagSet ? this.vlanTag : parentMessage.vlanTag;
+                short copyStage = this.copyStageSet ? this.copyStage : parentMessage.copyStage;
+
+                //
+                return new OFActionBsnMirrorVer12(
+                    destPort,
+                    vlanTag,
+                    copyStage
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnMirror.Builder {
+        // OF message fields
+        private boolean destPortSet;
+        private OFPort destPort;
+        private boolean vlanTagSet;
+        private long vlanTag;
+        private boolean copyStageSet;
+        private short copyStage;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setDestPort(OFPort destPort) {
+        this.destPort = destPort;
+        this.destPortSet = true;
+        return this;
+    }
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setVlanTag(long vlanTag) {
+        this.vlanTag = vlanTag;
+        this.vlanTagSet = true;
+        return this;
+    }
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setCopyStage(short copyStage) {
+        this.copyStage = copyStage;
+        this.copyStageSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionBsnMirror build() {
+            OFPort destPort = this.destPortSet ? this.destPort : DEFAULT_DEST_PORT;
+            if(destPort == null)
+                throw new NullPointerException("Property destPort must not be null");
+            long vlanTag = this.vlanTagSet ? this.vlanTag : DEFAULT_VLAN_TAG;
+            short copyStage = this.copyStageSet ? this.copyStage : DEFAULT_COPY_STAGE;
+
+
+            return new OFActionBsnMirrorVer12(
+                    destPort,
+                    vlanTag,
+                    copyStage
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnMirror> {
+        @Override
+        public OFActionBsnMirror readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+            OFPort destPort = OFPort.read4Bytes(bb);
+            long vlanTag = U32.f(bb.readInt());
+            short copyStage = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionBsnMirrorVer12 actionBsnMirrorVer12 = new OFActionBsnMirrorVer12(
+                    destPort,
+                      vlanTag,
+                      copyStage
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnMirrorVer12);
+            return actionBsnMirrorVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnMirrorVer12Funnel FUNNEL = new OFActionBsnMirrorVer12Funnel();
+    static class OFActionBsnMirrorVer12Funnel implements Funnel<OFActionBsnMirrorVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnMirrorVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+            message.destPort.putTo(sink);
+            sink.putLong(message.vlanTag);
+            sink.putShort(message.copyStage);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnMirrorVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnMirrorVer12 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+            message.destPort.write4Bytes(bb);
+            bb.writeInt(U32.t(message.vlanTag));
+            bb.writeByte(U8.t(message.copyStage));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnMirrorVer12(");
+        b.append("destPort=").append(destPort);
+        b.append(", ");
+        b.append("vlanTag=").append(vlanTag);
+        b.append(", ");
+        b.append("copyStage=").append(copyStage);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnMirrorVer12 other = (OFActionBsnMirrorVer12) obj;
+
+        if (destPort == null) {
+            if (other.destPort != null)
+                return false;
+        } else if (!destPort.equals(other.destPort))
+            return false;
+        if( vlanTag != other.vlanTag)
+            return false;
+        if( copyStage != other.copyStage)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((destPort == null) ? 0 : destPort.hashCode());
+        result = prime *  (int) (vlanTag ^ (vlanTag >>> 32));
+        result = prime * result + copyStage;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnSetTunnelDstVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnSetTunnelDstVer12.java
new file mode 100644
index 0000000..eb2abd6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnSetTunnelDstVer12.java
@@ -0,0 +1,306 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnSetTunnelDstVer12 implements OFActionBsnSetTunnelDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnSetTunnelDstVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_DST = 0x0L;
+
+    // OF message fields
+    private final long dst;
+//
+    // Immutable default instance
+    final static OFActionBsnSetTunnelDstVer12 DEFAULT = new OFActionBsnSetTunnelDstVer12(
+        DEFAULT_DST
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnSetTunnelDstVer12(long dst) {
+        this.dst = dst;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionBsnSetTunnelDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnSetTunnelDst.Builder {
+        final OFActionBsnSetTunnelDstVer12 parentMessage;
+
+        // OF message fields
+        private boolean dstSet;
+        private long dst;
+
+        BuilderWithParent(OFActionBsnSetTunnelDstVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFActionBsnSetTunnelDst.Builder setDst(long dst) {
+        this.dst = dst;
+        this.dstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionBsnSetTunnelDst build() {
+                long dst = this.dstSet ? this.dst : parentMessage.dst;
+
+                //
+                return new OFActionBsnSetTunnelDstVer12(
+                    dst
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnSetTunnelDst.Builder {
+        // OF message fields
+        private boolean dstSet;
+        private long dst;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFActionBsnSetTunnelDst.Builder setDst(long dst) {
+        this.dst = dst;
+        this.dstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionBsnSetTunnelDst build() {
+            long dst = this.dstSet ? this.dst : DEFAULT_DST;
+
+
+            return new OFActionBsnSetTunnelDstVer12(
+                    dst
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnSetTunnelDst> {
+        @Override
+        public OFActionBsnSetTunnelDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+            long dst = U32.f(bb.readInt());
+
+            OFActionBsnSetTunnelDstVer12 actionBsnSetTunnelDstVer12 = new OFActionBsnSetTunnelDstVer12(
+                    dst
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnSetTunnelDstVer12);
+            return actionBsnSetTunnelDstVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnSetTunnelDstVer12Funnel FUNNEL = new OFActionBsnSetTunnelDstVer12Funnel();
+    static class OFActionBsnSetTunnelDstVer12Funnel implements Funnel<OFActionBsnSetTunnelDstVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnSetTunnelDstVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+            sink.putLong(message.dst);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnSetTunnelDstVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnSetTunnelDstVer12 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+            bb.writeInt(U32.t(message.dst));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnSetTunnelDstVer12(");
+        b.append("dst=").append(dst);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnSetTunnelDstVer12 other = (OFActionBsnSetTunnelDstVer12) obj;
+
+        if( dst != other.dst)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (dst ^ (dst >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnVer12.java
new file mode 100644
index 0000000..8e9ee7a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionBsnVer12.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionBsnVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFActionBsnVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionBsn> {
+        @Override
+        public OFActionBsn readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFActionBsnChecksumVer12
+                   return OFActionBsnChecksumVer12.READER.readFrom(bb);
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFActionBsnMirrorVer12
+                   return OFActionBsnMirrorVer12.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFActionBsnSetTunnelDstVer12
+                   return OFActionBsnSetTunnelDstVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionBsnVer12: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionCopyTtlInVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionCopyTtlInVer12.java
new file mode 100644
index 0000000..990c7ec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionCopyTtlInVer12.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionCopyTtlInVer12 implements OFActionCopyTtlIn {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionCopyTtlInVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionCopyTtlInVer12 DEFAULT = new OFActionCopyTtlInVer12(
+
+    );
+
+    final static OFActionCopyTtlInVer12 INSTANCE = new OFActionCopyTtlInVer12();
+    // private empty constructor - use shared instance!
+    private OFActionCopyTtlInVer12() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.COPY_TTL_IN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionCopyTtlIn.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionCopyTtlInVer12 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionCopyTtlIn> {
+        @Override
+        public OFActionCopyTtlIn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 12
+            short type = bb.readShort();
+            if(type != (short) 0xc)
+                throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_IN(12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionCopyTtlInVer12Funnel FUNNEL = new OFActionCopyTtlInVer12Funnel();
+    static class OFActionCopyTtlInVer12Funnel implements Funnel<OFActionCopyTtlInVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionCopyTtlInVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 12
+            sink.putShort((short) 0xc);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionCopyTtlInVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionCopyTtlInVer12 message) {
+            // fixed value property type = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionCopyTtlInVer12(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionCopyTtlOutVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionCopyTtlOutVer12.java
new file mode 100644
index 0000000..b3714aa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionCopyTtlOutVer12.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionCopyTtlOutVer12 implements OFActionCopyTtlOut {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionCopyTtlOutVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionCopyTtlOutVer12 DEFAULT = new OFActionCopyTtlOutVer12(
+
+    );
+
+    final static OFActionCopyTtlOutVer12 INSTANCE = new OFActionCopyTtlOutVer12();
+    // private empty constructor - use shared instance!
+    private OFActionCopyTtlOutVer12() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.COPY_TTL_OUT;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionCopyTtlOut.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionCopyTtlOutVer12 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionCopyTtlOut> {
+        @Override
+        public OFActionCopyTtlOut readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 11
+            short type = bb.readShort();
+            if(type != (short) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_OUT(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionCopyTtlOutVer12Funnel FUNNEL = new OFActionCopyTtlOutVer12Funnel();
+    static class OFActionCopyTtlOutVer12Funnel implements Funnel<OFActionCopyTtlOutVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionCopyTtlOutVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 11
+            sink.putShort((short) 0xb);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionCopyTtlOutVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionCopyTtlOutVer12 message) {
+            // fixed value property type = 11
+            bb.writeShort((short) 0xb);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionCopyTtlOutVer12(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionDecMplsTtlVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionDecMplsTtlVer12.java
new file mode 100644
index 0000000..016b15b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionDecMplsTtlVer12.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionDecMplsTtlVer12 implements OFActionDecMplsTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionDecMplsTtlVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionDecMplsTtlVer12 DEFAULT = new OFActionDecMplsTtlVer12(
+
+    );
+
+    final static OFActionDecMplsTtlVer12 INSTANCE = new OFActionDecMplsTtlVer12();
+    // private empty constructor - use shared instance!
+    private OFActionDecMplsTtlVer12() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.DEC_MPLS_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionDecMplsTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionDecMplsTtlVer12 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionDecMplsTtl> {
+        @Override
+        public OFActionDecMplsTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 16
+            short type = bb.readShort();
+            if(type != (short) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFActionType.DEC_MPLS_TTL(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionDecMplsTtlVer12Funnel FUNNEL = new OFActionDecMplsTtlVer12Funnel();
+    static class OFActionDecMplsTtlVer12Funnel implements Funnel<OFActionDecMplsTtlVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionDecMplsTtlVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 16
+            sink.putShort((short) 0x10);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionDecMplsTtlVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionDecMplsTtlVer12 message) {
+            // fixed value property type = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionDecMplsTtlVer12(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionDecNwTtlVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionDecNwTtlVer12.java
new file mode 100644
index 0000000..657c8ac
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionDecNwTtlVer12.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionDecNwTtlVer12 implements OFActionDecNwTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionDecNwTtlVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionDecNwTtlVer12 DEFAULT = new OFActionDecNwTtlVer12(
+
+    );
+
+    final static OFActionDecNwTtlVer12 INSTANCE = new OFActionDecNwTtlVer12();
+    // private empty constructor - use shared instance!
+    private OFActionDecNwTtlVer12() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.DEC_NW_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionDecNwTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionDecNwTtlVer12 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionDecNwTtl> {
+        @Override
+        public OFActionDecNwTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 24
+            short type = bb.readShort();
+            if(type != (short) 0x18)
+                throw new OFParseError("Wrong type: Expected=OFActionType.DEC_NW_TTL(24), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionDecNwTtlVer12Funnel FUNNEL = new OFActionDecNwTtlVer12Funnel();
+    static class OFActionDecNwTtlVer12Funnel implements Funnel<OFActionDecNwTtlVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionDecNwTtlVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 24
+            sink.putShort((short) 0x18);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionDecNwTtlVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionDecNwTtlVer12 message) {
+            // fixed value property type = 24
+            bb.writeShort((short) 0x18);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionDecNwTtlVer12(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionExperimenterVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionExperimenterVer12.java
new file mode 100644
index 0000000..45594ca
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionExperimenterVer12.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionExperimenterVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionExperimenterVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionExperimenter> {
+        @Override
+        public OFActionExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFActionBsnVer12
+                   return OFActionBsnVer12.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFActionNiciraVer12
+                   return OFActionNiciraVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFActionExperimenterVer12: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionGroupVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionGroupVer12.java
new file mode 100644
index 0000000..832e27c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionGroupVer12.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionGroupVer12 implements OFActionGroup {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionGroupVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+
+    // OF message fields
+    private final OFGroup group;
+//
+    // Immutable default instance
+    final static OFActionGroupVer12 DEFAULT = new OFActionGroupVer12(
+        DEFAULT_GROUP_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionGroupVer12(OFGroup group) {
+        this.group = group;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionGroup.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionGroup.Builder {
+        final OFActionGroupVer12 parentMessage;
+
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+
+        BuilderWithParent(OFActionGroupVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFActionGroup.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionGroup build() {
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+
+                //
+                return new OFActionGroupVer12(
+                    group
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionGroup.Builder {
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFActionGroup.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionGroup build() {
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+
+
+            return new OFActionGroupVer12(
+                    group
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionGroup> {
+        @Override
+        public OFActionGroup readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 22
+            short type = bb.readShort();
+            if(type != (short) 0x16)
+                throw new OFParseError("Wrong type: Expected=OFActionType.GROUP(22), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFGroup group = OFGroup.read4Bytes(bb);
+
+            OFActionGroupVer12 actionGroupVer12 = new OFActionGroupVer12(
+                    group
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionGroupVer12);
+            return actionGroupVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionGroupVer12Funnel FUNNEL = new OFActionGroupVer12Funnel();
+    static class OFActionGroupVer12Funnel implements Funnel<OFActionGroupVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionGroupVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 22
+            sink.putShort((short) 0x16);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.group.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionGroupVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionGroupVer12 message) {
+            // fixed value property type = 22
+            bb.writeShort((short) 0x16);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.group.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionGroupVer12(");
+        b.append("group=").append(group);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionGroupVer12 other = (OFActionGroupVer12) obj;
+
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionIdsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionIdsVer12.java
new file mode 100644
index 0000000..8b519b6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionIdsVer12.java
@@ -0,0 +1,123 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+
+public class OFActionIdsVer12 implements OFActionIds {
+    public final static OFActionIdsVer12 INSTANCE = new OFActionIdsVer12();
+
+
+
+
+    public OFActionIdBsnChecksum bsnChecksum() {
+        throw new UnsupportedOperationException("OFActionIdBsnChecksum not supported in version 1.2");
+    }
+
+    public OFActionIdBsnMirror bsnMirror() {
+        throw new UnsupportedOperationException("OFActionIdBsnMirror not supported in version 1.2");
+    }
+
+    public OFActionIdBsnSetTunnelDst bsnSetTunnelDst() {
+        throw new UnsupportedOperationException("OFActionIdBsnSetTunnelDst not supported in version 1.2");
+    }
+
+    public OFActionIdCopyTtlIn copyTtlIn() {
+        throw new UnsupportedOperationException("OFActionIdCopyTtlIn not supported in version 1.2");
+    }
+
+    public OFActionIdCopyTtlOut copyTtlOut() {
+        throw new UnsupportedOperationException("OFActionIdCopyTtlOut not supported in version 1.2");
+    }
+
+    public OFActionIdDecMplsTtl decMplsTtl() {
+        throw new UnsupportedOperationException("OFActionIdDecMplsTtl not supported in version 1.2");
+    }
+
+    public OFActionIdDecNwTtl decNwTtl() {
+        throw new UnsupportedOperationException("OFActionIdDecNwTtl not supported in version 1.2");
+    }
+
+    public OFActionIdGroup group() {
+        throw new UnsupportedOperationException("OFActionIdGroup not supported in version 1.2");
+    }
+
+    public OFActionIdNiciraDecTtl niciraDecTtl() {
+        throw new UnsupportedOperationException("OFActionIdNiciraDecTtl not supported in version 1.2");
+    }
+
+    public OFActionIdOutput output() {
+        throw new UnsupportedOperationException("OFActionIdOutput not supported in version 1.2");
+    }
+
+    public OFActionIdPopMpls popMpls() {
+        throw new UnsupportedOperationException("OFActionIdPopMpls not supported in version 1.2");
+    }
+
+    public OFActionIdPopPbb popPbb() {
+        throw new UnsupportedOperationException("OFActionIdPopPbb not supported in version 1.2");
+    }
+
+    public OFActionIdPopVlan popVlan() {
+        throw new UnsupportedOperationException("OFActionIdPopVlan not supported in version 1.2");
+    }
+
+    public OFActionIdPushMpls pushMpls() {
+        throw new UnsupportedOperationException("OFActionIdPushMpls not supported in version 1.2");
+    }
+
+    public OFActionIdPushPbb pushPbb() {
+        throw new UnsupportedOperationException("OFActionIdPushPbb not supported in version 1.2");
+    }
+
+    public OFActionIdPushVlan pushVlan() {
+        throw new UnsupportedOperationException("OFActionIdPushVlan not supported in version 1.2");
+    }
+
+    public OFActionIdSetField setField() {
+        throw new UnsupportedOperationException("OFActionIdSetField not supported in version 1.2");
+    }
+
+    public OFActionIdSetMplsTtl setMplsTtl() {
+        throw new UnsupportedOperationException("OFActionIdSetMplsTtl not supported in version 1.2");
+    }
+
+    public OFActionIdSetNwTtl setNwTtl() {
+        throw new UnsupportedOperationException("OFActionIdSetNwTtl not supported in version 1.2");
+    }
+
+    public OFActionIdSetQueue setQueue() {
+        throw new UnsupportedOperationException("OFActionIdSetQueue not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFActionId> getReader() {
+        throw new UnsupportedOperationException("Reader<OFActionId> not supported in version 1.2");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionNiciraDecTtlVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionNiciraDecTtlVer12.java
new file mode 100644
index 0000000..68bbedb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionNiciraDecTtlVer12.java
@@ -0,0 +1,192 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionNiciraDecTtlVer12 implements OFActionNiciraDecTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionNiciraDecTtlVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionNiciraDecTtlVer12 DEFAULT = new OFActionNiciraDecTtlVer12(
+
+    );
+
+    final static OFActionNiciraDecTtlVer12 INSTANCE = new OFActionNiciraDecTtlVer12();
+    // private empty constructor - use shared instance!
+    private OFActionNiciraDecTtlVer12() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public int getSubtype() {
+        return 0x12;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionNiciraDecTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionNiciraDecTtlVer12 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionNiciraDecTtl> {
+        @Override
+        public OFActionNiciraDecTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            // fixed value property subtype == 0x12
+            short subtype = bb.readShort();
+            if(subtype != (short) 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12(0x12), got="+subtype);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionNiciraDecTtlVer12Funnel FUNNEL = new OFActionNiciraDecTtlVer12Funnel();
+    static class OFActionNiciraDecTtlVer12Funnel implements Funnel<OFActionNiciraDecTtlVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionNiciraDecTtlVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x2320L
+            sink.putInt(0x2320);
+            // fixed value property subtype = 0x12
+            sink.putShort((short) 0x12);
+            // skip pad (2 bytes)
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionNiciraDecTtlVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionNiciraDecTtlVer12 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x2320L
+            bb.writeInt(0x2320);
+            // fixed value property subtype = 0x12
+            bb.writeShort((short) 0x12);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionNiciraDecTtlVer12(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionNiciraVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionNiciraVer12.java
new file mode 100644
index 0000000..691a276
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionNiciraVer12.java
@@ -0,0 +1,64 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionNiciraVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFActionNiciraVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionNicira> {
+        @Override
+        public OFActionNicira readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            short subtype = bb.readShort();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case (short) 0x12:
+                   // discriminator value 0x12=0x12 for class OFActionNiciraDecTtlVer12
+                   return OFActionNiciraDecTtlVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionNiciraVer12: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionOutputVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionOutputVer12.java
new file mode 100644
index 0000000..2afbae6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionOutputVer12.java
@@ -0,0 +1,319 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionOutputVer12 implements OFActionOutput {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionOutputVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static int DEFAULT_MAX_LEN = 0x0;
+
+    // OF message fields
+    private final OFPort port;
+    private final int maxLen;
+//
+    // Immutable default instance
+    final static OFActionOutputVer12 DEFAULT = new OFActionOutputVer12(
+        DEFAULT_PORT, DEFAULT_MAX_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionOutputVer12(OFPort port, int maxLen) {
+        this.port = port;
+        this.maxLen = maxLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionOutput.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionOutput.Builder {
+        final OFActionOutputVer12 parentMessage;
+
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean maxLenSet;
+        private int maxLen;
+
+        BuilderWithParent(OFActionOutputVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionOutput.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFActionOutput.Builder setMaxLen(int maxLen) {
+        this.maxLen = maxLen;
+        this.maxLenSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionOutput build() {
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                int maxLen = this.maxLenSet ? this.maxLen : parentMessage.maxLen;
+
+                //
+                return new OFActionOutputVer12(
+                    port,
+                    maxLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionOutput.Builder {
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean maxLenSet;
+        private int maxLen;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionOutput.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFActionOutput.Builder setMaxLen(int maxLen) {
+        this.maxLen = maxLen;
+        this.maxLenSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionOutput build() {
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            int maxLen = this.maxLenSet ? this.maxLen : DEFAULT_MAX_LEN;
+
+
+            return new OFActionOutputVer12(
+                    port,
+                    maxLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionOutput> {
+        @Override
+        public OFActionOutput readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFActionType.OUTPUT(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFPort port = OFPort.read4Bytes(bb);
+            int maxLen = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFActionOutputVer12 actionOutputVer12 = new OFActionOutputVer12(
+                    port,
+                      maxLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionOutputVer12);
+            return actionOutputVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionOutputVer12Funnel FUNNEL = new OFActionOutputVer12Funnel();
+    static class OFActionOutputVer12Funnel implements Funnel<OFActionOutputVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionOutputVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            message.port.putTo(sink);
+            sink.putInt(message.maxLen);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionOutputVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionOutputVer12 message) {
+            // fixed value property type = 0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            message.port.write4Bytes(bb);
+            bb.writeShort(U16.t(message.maxLen));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionOutputVer12(");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("maxLen=").append(maxLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionOutputVer12 other = (OFActionOutputVer12) obj;
+
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if( maxLen != other.maxLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + maxLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPopMplsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPopMplsVer12.java
new file mode 100644
index 0000000..5e17aab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPopMplsVer12.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPopMplsVer12 implements OFActionPopMpls {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPopMplsVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPopMplsVer12 DEFAULT = new OFActionPopMplsVer12(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPopMplsVer12(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionPopMpls.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPopMpls.Builder {
+        final OFActionPopMplsVer12 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPopMplsVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPopMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionPopMpls build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPopMplsVer12(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPopMpls.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPopMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionPopMpls build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPopMplsVer12(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPopMpls> {
+        @Override
+        public OFActionPopMpls readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 20
+            short type = bb.readShort();
+            if(type != (short) 0x14)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_MPLS(20), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPopMplsVer12 actionPopMplsVer12 = new OFActionPopMplsVer12(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPopMplsVer12);
+            return actionPopMplsVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPopMplsVer12Funnel FUNNEL = new OFActionPopMplsVer12Funnel();
+    static class OFActionPopMplsVer12Funnel implements Funnel<OFActionPopMplsVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPopMplsVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 20
+            sink.putShort((short) 0x14);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPopMplsVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPopMplsVer12 message) {
+            // fixed value property type = 20
+            bb.writeShort((short) 0x14);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPopMplsVer12(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPopMplsVer12 other = (OFActionPopMplsVer12) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPopVlanVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPopVlanVer12.java
new file mode 100644
index 0000000..c636c56
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPopVlanVer12.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPopVlanVer12 implements OFActionPopVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPopVlanVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionPopVlanVer12 DEFAULT = new OFActionPopVlanVer12(
+
+    );
+
+    final static OFActionPopVlanVer12 INSTANCE = new OFActionPopVlanVer12();
+    // private empty constructor - use shared instance!
+    private OFActionPopVlanVer12() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_VLAN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionPopVlan.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionPopVlanVer12 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPopVlan> {
+        @Override
+        public OFActionPopVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 18
+            short type = bb.readShort();
+            if(type != (short) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_VLAN(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPopVlanVer12Funnel FUNNEL = new OFActionPopVlanVer12Funnel();
+    static class OFActionPopVlanVer12Funnel implements Funnel<OFActionPopVlanVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPopVlanVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 18
+            sink.putShort((short) 0x12);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPopVlanVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPopVlanVer12 message) {
+            // fixed value property type = 18
+            bb.writeShort((short) 0x12);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPopVlanVer12(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPushMplsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPushMplsVer12.java
new file mode 100644
index 0000000..6bc156d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPushMplsVer12.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPushMplsVer12 implements OFActionPushMpls {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPushMplsVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPushMplsVer12 DEFAULT = new OFActionPushMplsVer12(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPushMplsVer12(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionPushMpls.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPushMpls.Builder {
+        final OFActionPushMplsVer12 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPushMplsVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionPushMpls build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPushMplsVer12(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPushMpls.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionPushMpls build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPushMplsVer12(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPushMpls> {
+        @Override
+        public OFActionPushMpls readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 19
+            short type = bb.readShort();
+            if(type != (short) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_MPLS(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPushMplsVer12 actionPushMplsVer12 = new OFActionPushMplsVer12(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPushMplsVer12);
+            return actionPushMplsVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPushMplsVer12Funnel FUNNEL = new OFActionPushMplsVer12Funnel();
+    static class OFActionPushMplsVer12Funnel implements Funnel<OFActionPushMplsVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPushMplsVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 19
+            sink.putShort((short) 0x13);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPushMplsVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPushMplsVer12 message) {
+            // fixed value property type = 19
+            bb.writeShort((short) 0x13);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPushMplsVer12(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPushMplsVer12 other = (OFActionPushMplsVer12) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPushVlanVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPushVlanVer12.java
new file mode 100644
index 0000000..26cf4d6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionPushVlanVer12.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPushVlanVer12 implements OFActionPushVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPushVlanVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPushVlanVer12 DEFAULT = new OFActionPushVlanVer12(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPushVlanVer12(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionPushVlan.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPushVlan.Builder {
+        final OFActionPushVlanVer12 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPushVlanVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushVlan.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionPushVlan build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPushVlanVer12(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPushVlan.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushVlan.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionPushVlan build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPushVlanVer12(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPushVlan> {
+        @Override
+        public OFActionPushVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 17
+            short type = bb.readShort();
+            if(type != (short) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_VLAN(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPushVlanVer12 actionPushVlanVer12 = new OFActionPushVlanVer12(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPushVlanVer12);
+            return actionPushVlanVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPushVlanVer12Funnel FUNNEL = new OFActionPushVlanVer12Funnel();
+    static class OFActionPushVlanVer12Funnel implements Funnel<OFActionPushVlanVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPushVlanVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 17
+            sink.putShort((short) 0x11);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPushVlanVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPushVlanVer12 message) {
+            // fixed value property type = 17
+            bb.writeShort((short) 0x11);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPushVlanVer12(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPushVlanVer12 other = (OFActionPushVlanVer12) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetFieldVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetFieldVer12.java
new file mode 100644
index 0000000..40f6945
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetFieldVer12.java
@@ -0,0 +1,273 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetFieldVer12 implements OFActionSetField {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetFieldVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    // OF message fields
+    private final OFOxm<?> field;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetFieldVer12(OFOxm<?> field) {
+        this.field = field;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_FIELD;
+    }
+
+    @Override
+    public OFOxm<?> getField() {
+        return field;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionSetField.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetField.Builder {
+        final OFActionSetFieldVer12 parentMessage;
+
+        // OF message fields
+        private boolean fieldSet;
+        private OFOxm<?> field;
+
+        BuilderWithParent(OFActionSetFieldVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_FIELD;
+    }
+
+    @Override
+    public OFOxm<?> getField() {
+        return field;
+    }
+
+    @Override
+    public OFActionSetField.Builder setField(OFOxm<?> field) {
+        this.field = field;
+        this.fieldSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionSetField build() {
+                OFOxm<?> field = this.fieldSet ? this.field : parentMessage.field;
+                if(field == null)
+                    throw new NullPointerException("Property field must not be null");
+
+                //
+                return new OFActionSetFieldVer12(
+                    field
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetField.Builder {
+        // OF message fields
+        private boolean fieldSet;
+        private OFOxm<?> field;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_FIELD;
+    }
+
+    @Override
+    public OFOxm<?> getField() {
+        return field;
+    }
+
+    @Override
+    public OFActionSetField.Builder setField(OFOxm<?> field) {
+        this.field = field;
+        this.fieldSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionSetField build() {
+            if(!this.fieldSet)
+                throw new IllegalStateException("Property field doesn't have default value -- must be set");
+            if(field == null)
+                throw new NullPointerException("Property field must not be null");
+
+
+            return new OFActionSetFieldVer12(
+                    field
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetField> {
+        @Override
+        public OFActionSetField readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 25
+            short type = bb.readShort();
+            if(type != (short) 0x19)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_FIELD(25), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFOxm<?> field = OFOxmVer12.READER.readFrom(bb);
+            // align message to 8 bytes (length contains aligned value)
+            bb.skipBytes(length - (bb.readerIndex() - start));
+
+            OFActionSetFieldVer12 actionSetFieldVer12 = new OFActionSetFieldVer12(
+                    field
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetFieldVer12);
+            return actionSetFieldVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetFieldVer12Funnel FUNNEL = new OFActionSetFieldVer12Funnel();
+    static class OFActionSetFieldVer12Funnel implements Funnel<OFActionSetFieldVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetFieldVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 25
+            sink.putShort((short) 0x19);
+            // FIXME: skip funnel of length
+            message.field.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetFieldVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetFieldVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 25
+            bb.writeShort((short) 0x19);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.field.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            int alignedLength = ((length + 7)/8 * 8);
+            bb.setShort(lengthIndex, alignedLength);
+            // align message to 8 bytes
+            bb.writeZero(alignedLength - length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetFieldVer12(");
+        b.append("field=").append(field);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetFieldVer12 other = (OFActionSetFieldVer12) obj;
+
+        if (field == null) {
+            if (other.field != null)
+                return false;
+        } else if (!field.equals(other.field))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((field == null) ? 0 : field.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetMplsTtlVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetMplsTtlVer12.java
new file mode 100644
index 0000000..bc4ea34
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetMplsTtlVer12.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetMplsTtlVer12 implements OFActionSetMplsTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetMplsTtlVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_MPLS_TTL = (short) 0x0;
+
+    // OF message fields
+    private final short mplsTtl;
+//
+    // Immutable default instance
+    final static OFActionSetMplsTtlVer12 DEFAULT = new OFActionSetMplsTtlVer12(
+        DEFAULT_MPLS_TTL
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetMplsTtlVer12(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionSetMplsTtl.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetMplsTtl.Builder {
+        final OFActionSetMplsTtlVer12 parentMessage;
+
+        // OF message fields
+        private boolean mplsTtlSet;
+        private short mplsTtl;
+
+        BuilderWithParent(OFActionSetMplsTtlVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFActionSetMplsTtl.Builder setMplsTtl(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+        this.mplsTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionSetMplsTtl build() {
+                short mplsTtl = this.mplsTtlSet ? this.mplsTtl : parentMessage.mplsTtl;
+
+                //
+                return new OFActionSetMplsTtlVer12(
+                    mplsTtl
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetMplsTtl.Builder {
+        // OF message fields
+        private boolean mplsTtlSet;
+        private short mplsTtl;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFActionSetMplsTtl.Builder setMplsTtl(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+        this.mplsTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionSetMplsTtl build() {
+            short mplsTtl = this.mplsTtlSet ? this.mplsTtl : DEFAULT_MPLS_TTL;
+
+
+            return new OFActionSetMplsTtlVer12(
+                    mplsTtl
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetMplsTtl> {
+        @Override
+        public OFActionSetMplsTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 15
+            short type = bb.readShort();
+            if(type != (short) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_MPLS_TTL(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short mplsTtl = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetMplsTtlVer12 actionSetMplsTtlVer12 = new OFActionSetMplsTtlVer12(
+                    mplsTtl
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetMplsTtlVer12);
+            return actionSetMplsTtlVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetMplsTtlVer12Funnel FUNNEL = new OFActionSetMplsTtlVer12Funnel();
+    static class OFActionSetMplsTtlVer12Funnel implements Funnel<OFActionSetMplsTtlVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetMplsTtlVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 15
+            sink.putShort((short) 0xf);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.mplsTtl);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetMplsTtlVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetMplsTtlVer12 message) {
+            // fixed value property type = 15
+            bb.writeShort((short) 0xf);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.mplsTtl));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetMplsTtlVer12(");
+        b.append("mplsTtl=").append(mplsTtl);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetMplsTtlVer12 other = (OFActionSetMplsTtlVer12) obj;
+
+        if( mplsTtl != other.mplsTtl)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + mplsTtl;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetNwTtlVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetNwTtlVer12.java
new file mode 100644
index 0000000..b769d7d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetNwTtlVer12.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwTtlVer12 implements OFActionSetNwTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwTtlVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_NW_TTL = (short) 0x0;
+
+    // OF message fields
+    private final short nwTtl;
+//
+    // Immutable default instance
+    final static OFActionSetNwTtlVer12 DEFAULT = new OFActionSetNwTtlVer12(
+        DEFAULT_NW_TTL
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwTtlVer12(short nwTtl) {
+        this.nwTtl = nwTtl;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionSetNwTtl.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwTtl.Builder {
+        final OFActionSetNwTtlVer12 parentMessage;
+
+        // OF message fields
+        private boolean nwTtlSet;
+        private short nwTtl;
+
+        BuilderWithParent(OFActionSetNwTtlVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFActionSetNwTtl.Builder setNwTtl(short nwTtl) {
+        this.nwTtl = nwTtl;
+        this.nwTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionSetNwTtl build() {
+                short nwTtl = this.nwTtlSet ? this.nwTtl : parentMessage.nwTtl;
+
+                //
+                return new OFActionSetNwTtlVer12(
+                    nwTtl
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwTtl.Builder {
+        // OF message fields
+        private boolean nwTtlSet;
+        private short nwTtl;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFActionSetNwTtl.Builder setNwTtl(short nwTtl) {
+        this.nwTtl = nwTtl;
+        this.nwTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionSetNwTtl build() {
+            short nwTtl = this.nwTtlSet ? this.nwTtl : DEFAULT_NW_TTL;
+
+
+            return new OFActionSetNwTtlVer12(
+                    nwTtl
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwTtl> {
+        @Override
+        public OFActionSetNwTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 23
+            short type = bb.readShort();
+            if(type != (short) 0x17)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_TTL(23), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short nwTtl = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetNwTtlVer12 actionSetNwTtlVer12 = new OFActionSetNwTtlVer12(
+                    nwTtl
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwTtlVer12);
+            return actionSetNwTtlVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwTtlVer12Funnel FUNNEL = new OFActionSetNwTtlVer12Funnel();
+    static class OFActionSetNwTtlVer12Funnel implements Funnel<OFActionSetNwTtlVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwTtlVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 23
+            sink.putShort((short) 0x17);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.nwTtl);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwTtlVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwTtlVer12 message) {
+            // fixed value property type = 23
+            bb.writeShort((short) 0x17);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.nwTtl));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwTtlVer12(");
+        b.append("nwTtl=").append(nwTtl);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwTtlVer12 other = (OFActionSetNwTtlVer12) obj;
+
+        if( nwTtl != other.nwTtl)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + nwTtl;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetQueueVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetQueueVer12.java
new file mode 100644
index 0000000..5664fed
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionSetQueueVer12.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetQueueVer12 implements OFActionSetQueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetQueueVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+
+    // OF message fields
+    private final long queueId;
+//
+    // Immutable default instance
+    final static OFActionSetQueueVer12 DEFAULT = new OFActionSetQueueVer12(
+        DEFAULT_QUEUE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetQueueVer12(long queueId) {
+        this.queueId = queueId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFActionSetQueue.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetQueue.Builder {
+        final OFActionSetQueueVer12 parentMessage;
+
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+
+        BuilderWithParent(OFActionSetQueueVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFActionSetQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFActionSetQueue build() {
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+
+                //
+                return new OFActionSetQueueVer12(
+                    queueId
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetQueue.Builder {
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFActionSetQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFActionSetQueue build() {
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+
+
+            return new OFActionSetQueueVer12(
+                    queueId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetQueue> {
+        @Override
+        public OFActionSetQueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 21
+            short type = bb.readShort();
+            if(type != (short) 0x15)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_QUEUE(21), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long queueId = U32.f(bb.readInt());
+
+            OFActionSetQueueVer12 actionSetQueueVer12 = new OFActionSetQueueVer12(
+                    queueId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetQueueVer12);
+            return actionSetQueueVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetQueueVer12Funnel FUNNEL = new OFActionSetQueueVer12Funnel();
+    static class OFActionSetQueueVer12Funnel implements Funnel<OFActionSetQueueVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetQueueVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 21
+            sink.putShort((short) 0x15);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.queueId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetQueueVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetQueueVer12 message) {
+            // fixed value property type = 21
+            bb.writeShort((short) 0x15);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.queueId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetQueueVer12(");
+        b.append("queueId=").append(queueId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetQueueVer12 other = (OFActionSetQueueVer12) obj;
+
+        if( queueId != other.queueId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionTypeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionTypeSerializerVer12.java
new file mode 100644
index 0000000..308138e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionTypeSerializerVer12.java
@@ -0,0 +1,139 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFActionType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFActionTypeSerializerVer12 {
+
+    public final static short OUTPUT_VAL = (short) 0x0;
+    public final static short COPY_TTL_OUT_VAL = (short) 0xb;
+    public final static short COPY_TTL_IN_VAL = (short) 0xc;
+    public final static short SET_MPLS_TTL_VAL = (short) 0xf;
+    public final static short DEC_MPLS_TTL_VAL = (short) 0x10;
+    public final static short PUSH_VLAN_VAL = (short) 0x11;
+    public final static short POP_VLAN_VAL = (short) 0x12;
+    public final static short PUSH_MPLS_VAL = (short) 0x13;
+    public final static short POP_MPLS_VAL = (short) 0x14;
+    public final static short SET_QUEUE_VAL = (short) 0x15;
+    public final static short GROUP_VAL = (short) 0x16;
+    public final static short SET_NW_TTL_VAL = (short) 0x17;
+    public final static short DEC_NW_TTL_VAL = (short) 0x18;
+    public final static short SET_FIELD_VAL = (short) 0x19;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFActionType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFActionType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFActionType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFActionType ofWireValue(short val) {
+        switch(val) {
+            case OUTPUT_VAL:
+                return OFActionType.OUTPUT;
+            case COPY_TTL_OUT_VAL:
+                return OFActionType.COPY_TTL_OUT;
+            case COPY_TTL_IN_VAL:
+                return OFActionType.COPY_TTL_IN;
+            case SET_MPLS_TTL_VAL:
+                return OFActionType.SET_MPLS_TTL;
+            case DEC_MPLS_TTL_VAL:
+                return OFActionType.DEC_MPLS_TTL;
+            case PUSH_VLAN_VAL:
+                return OFActionType.PUSH_VLAN;
+            case POP_VLAN_VAL:
+                return OFActionType.POP_VLAN;
+            case PUSH_MPLS_VAL:
+                return OFActionType.PUSH_MPLS;
+            case POP_MPLS_VAL:
+                return OFActionType.POP_MPLS;
+            case SET_QUEUE_VAL:
+                return OFActionType.SET_QUEUE;
+            case GROUP_VAL:
+                return OFActionType.GROUP;
+            case SET_NW_TTL_VAL:
+                return OFActionType.SET_NW_TTL;
+            case DEC_NW_TTL_VAL:
+                return OFActionType.DEC_NW_TTL;
+            case SET_FIELD_VAL:
+                return OFActionType.SET_FIELD;
+            case EXPERIMENTER_VAL:
+                return OFActionType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFActionType in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFActionType e) {
+        switch(e) {
+            case OUTPUT:
+                return OUTPUT_VAL;
+            case COPY_TTL_OUT:
+                return COPY_TTL_OUT_VAL;
+            case COPY_TTL_IN:
+                return COPY_TTL_IN_VAL;
+            case SET_MPLS_TTL:
+                return SET_MPLS_TTL_VAL;
+            case DEC_MPLS_TTL:
+                return DEC_MPLS_TTL_VAL;
+            case PUSH_VLAN:
+                return PUSH_VLAN_VAL;
+            case POP_VLAN:
+                return POP_VLAN_VAL;
+            case PUSH_MPLS:
+                return PUSH_MPLS_VAL;
+            case POP_MPLS:
+                return POP_MPLS_VAL;
+            case SET_QUEUE:
+                return SET_QUEUE_VAL;
+            case GROUP:
+                return GROUP_VAL;
+            case SET_NW_TTL:
+                return SET_NW_TTL_VAL;
+            case DEC_NW_TTL:
+                return DEC_NW_TTL_VAL;
+            case SET_FIELD:
+                return SET_FIELD_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFActionType in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionVer12.java
new file mode 100644
index 0000000..0fea76e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionVer12.java
@@ -0,0 +1,96 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFAction> {
+        @Override
+        public OFAction readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0xffff:
+                   // discriminator value OFActionType.EXPERIMENTER=65535 for class OFActionExperimenterVer12
+                   return OFActionExperimenterVer12.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFActionType.OUTPUT=0 for class OFActionOutputVer12
+                   return OFActionOutputVer12.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value OFActionType.COPY_TTL_IN=12 for class OFActionCopyTtlInVer12
+                   return OFActionCopyTtlInVer12.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFActionType.COPY_TTL_OUT=11 for class OFActionCopyTtlOutVer12
+                   return OFActionCopyTtlOutVer12.READER.readFrom(bb);
+               case (short) 0x10:
+                   // discriminator value OFActionType.DEC_MPLS_TTL=16 for class OFActionDecMplsTtlVer12
+                   return OFActionDecMplsTtlVer12.READER.readFrom(bb);
+               case (short) 0x18:
+                   // discriminator value OFActionType.DEC_NW_TTL=24 for class OFActionDecNwTtlVer12
+                   return OFActionDecNwTtlVer12.READER.readFrom(bb);
+               case (short) 0x16:
+                   // discriminator value OFActionType.GROUP=22 for class OFActionGroupVer12
+                   return OFActionGroupVer12.READER.readFrom(bb);
+               case (short) 0x14:
+                   // discriminator value OFActionType.POP_MPLS=20 for class OFActionPopMplsVer12
+                   return OFActionPopMplsVer12.READER.readFrom(bb);
+               case (short) 0x12:
+                   // discriminator value OFActionType.POP_VLAN=18 for class OFActionPopVlanVer12
+                   return OFActionPopVlanVer12.READER.readFrom(bb);
+               case (short) 0x13:
+                   // discriminator value OFActionType.PUSH_MPLS=19 for class OFActionPushMplsVer12
+                   return OFActionPushMplsVer12.READER.readFrom(bb);
+               case (short) 0x11:
+                   // discriminator value OFActionType.PUSH_VLAN=17 for class OFActionPushVlanVer12
+                   return OFActionPushVlanVer12.READER.readFrom(bb);
+               case (short) 0xf:
+                   // discriminator value OFActionType.SET_MPLS_TTL=15 for class OFActionSetMplsTtlVer12
+                   return OFActionSetMplsTtlVer12.READER.readFrom(bb);
+               case (short) 0x17:
+                   // discriminator value OFActionType.SET_NW_TTL=23 for class OFActionSetNwTtlVer12
+                   return OFActionSetNwTtlVer12.READER.readFrom(bb);
+               case (short) 0x15:
+                   // discriminator value OFActionType.SET_QUEUE=21 for class OFActionSetQueueVer12
+                   return OFActionSetQueueVer12.READER.readFrom(bb);
+               case (short) 0x19:
+                   // discriminator value OFActionType.SET_FIELD=25 for class OFActionSetFieldVer12
+                   return OFActionSetFieldVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFActionVer12: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionsVer12.java
new file mode 100644
index 0000000..7fb9fb3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFActionsVer12.java
@@ -0,0 +1,277 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+
+public class OFActionsVer12 implements OFActions {
+    public final static OFActionsVer12 INSTANCE = new OFActionsVer12();
+
+
+
+
+    public OFActionBsnChecksum.Builder buildBsnChecksum() {
+        return new OFActionBsnChecksumVer12.Builder();
+    }
+    public OFActionBsnChecksum bsnChecksum(U128 checksum) {
+        return new OFActionBsnChecksumVer12(
+                checksum
+                    );
+    }
+
+    public OFActionBsnMirror.Builder buildBsnMirror() {
+        return new OFActionBsnMirrorVer12.Builder();
+    }
+
+    public OFActionBsnSetTunnelDst.Builder buildBsnSetTunnelDst() {
+        return new OFActionBsnSetTunnelDstVer12.Builder();
+    }
+    public OFActionBsnSetTunnelDst bsnSetTunnelDst(long dst) {
+        return new OFActionBsnSetTunnelDstVer12(
+                dst
+                    );
+    }
+
+    public OFActionEnqueue.Builder buildEnqueue() {
+        throw new UnsupportedOperationException("OFActionEnqueue not supported in version 1.2");
+    }
+    public OFActionEnqueue enqueue(OFPort port, long queueId) {
+        throw new UnsupportedOperationException("OFActionEnqueue not supported in version 1.2");
+    }
+
+    public OFActionNiciraDecTtl niciraDecTtl() {
+        return OFActionNiciraDecTtlVer12.INSTANCE;
+    }
+
+    public OFActionOutput.Builder buildOutput() {
+        return new OFActionOutputVer12.Builder();
+    }
+    public OFActionOutput output(OFPort port, int maxLen) {
+        return new OFActionOutputVer12(
+                port,
+                      maxLen
+                    );
+    }
+
+    public OFActionSetDlDst.Builder buildSetDlDst() {
+        throw new UnsupportedOperationException("OFActionSetDlDst not supported in version 1.2");
+    }
+    public OFActionSetDlDst setDlDst(MacAddress dlAddr) {
+        throw new UnsupportedOperationException("OFActionSetDlDst not supported in version 1.2");
+    }
+
+    public OFActionSetDlSrc.Builder buildSetDlSrc() {
+        throw new UnsupportedOperationException("OFActionSetDlSrc not supported in version 1.2");
+    }
+    public OFActionSetDlSrc setDlSrc(MacAddress dlAddr) {
+        throw new UnsupportedOperationException("OFActionSetDlSrc not supported in version 1.2");
+    }
+
+    public OFActionSetNwDst.Builder buildSetNwDst() {
+        throw new UnsupportedOperationException("OFActionSetNwDst not supported in version 1.2");
+    }
+    public OFActionSetNwDst setNwDst(IPv4Address nwAddr) {
+        throw new UnsupportedOperationException("OFActionSetNwDst not supported in version 1.2");
+    }
+
+    public OFActionSetNwSrc.Builder buildSetNwSrc() {
+        throw new UnsupportedOperationException("OFActionSetNwSrc not supported in version 1.2");
+    }
+    public OFActionSetNwSrc setNwSrc(IPv4Address nwAddr) {
+        throw new UnsupportedOperationException("OFActionSetNwSrc not supported in version 1.2");
+    }
+
+    public OFActionSetNwTos.Builder buildSetNwTos() {
+        throw new UnsupportedOperationException("OFActionSetNwTos not supported in version 1.2");
+    }
+    public OFActionSetNwTos setNwTos(short nwTos) {
+        throw new UnsupportedOperationException("OFActionSetNwTos not supported in version 1.2");
+    }
+
+    public OFActionSetTpDst.Builder buildSetTpDst() {
+        throw new UnsupportedOperationException("OFActionSetTpDst not supported in version 1.2");
+    }
+    public OFActionSetTpDst setTpDst(TransportPort tpPort) {
+        throw new UnsupportedOperationException("OFActionSetTpDst not supported in version 1.2");
+    }
+
+    public OFActionSetTpSrc.Builder buildSetTpSrc() {
+        throw new UnsupportedOperationException("OFActionSetTpSrc not supported in version 1.2");
+    }
+    public OFActionSetTpSrc setTpSrc(TransportPort tpPort) {
+        throw new UnsupportedOperationException("OFActionSetTpSrc not supported in version 1.2");
+    }
+
+    public OFActionSetVlanPcp.Builder buildSetVlanPcp() {
+        throw new UnsupportedOperationException("OFActionSetVlanPcp not supported in version 1.2");
+    }
+    public OFActionSetVlanPcp setVlanPcp(VlanPcp vlanPcp) {
+        throw new UnsupportedOperationException("OFActionSetVlanPcp not supported in version 1.2");
+    }
+
+    public OFActionSetVlanVid.Builder buildSetVlanVid() {
+        throw new UnsupportedOperationException("OFActionSetVlanVid not supported in version 1.2");
+    }
+    public OFActionSetVlanVid setVlanVid(VlanVid vlanVid) {
+        throw new UnsupportedOperationException("OFActionSetVlanVid not supported in version 1.2");
+    }
+
+    public OFActionStripVlan stripVlan() {
+        throw new UnsupportedOperationException("OFActionStripVlan not supported in version 1.2");
+    }
+
+    public OFActionCopyTtlIn copyTtlIn() {
+        return OFActionCopyTtlInVer12.INSTANCE;
+    }
+
+    public OFActionCopyTtlOut copyTtlOut() {
+        return OFActionCopyTtlOutVer12.INSTANCE;
+    }
+
+    public OFActionDecMplsTtl decMplsTtl() {
+        return OFActionDecMplsTtlVer12.INSTANCE;
+    }
+
+    public OFActionDecNwTtl decNwTtl() {
+        return OFActionDecNwTtlVer12.INSTANCE;
+    }
+
+    public OFActionGroup.Builder buildGroup() {
+        return new OFActionGroupVer12.Builder();
+    }
+    public OFActionGroup group(OFGroup group) {
+        return new OFActionGroupVer12(
+                group
+                    );
+    }
+
+    public OFActionPopMpls.Builder buildPopMpls() {
+        return new OFActionPopMplsVer12.Builder();
+    }
+    public OFActionPopMpls popMpls(EthType ethertype) {
+        return new OFActionPopMplsVer12(
+                ethertype
+                    );
+    }
+
+    public OFActionPopVlan popVlan() {
+        return OFActionPopVlanVer12.INSTANCE;
+    }
+
+    public OFActionPushMpls.Builder buildPushMpls() {
+        return new OFActionPushMplsVer12.Builder();
+    }
+    public OFActionPushMpls pushMpls(EthType ethertype) {
+        return new OFActionPushMplsVer12(
+                ethertype
+                    );
+    }
+
+    public OFActionPushVlan.Builder buildPushVlan() {
+        return new OFActionPushVlanVer12.Builder();
+    }
+    public OFActionPushVlan pushVlan(EthType ethertype) {
+        return new OFActionPushVlanVer12(
+                ethertype
+                    );
+    }
+
+    public OFActionSetMplsLabel.Builder buildSetMplsLabel() {
+        throw new UnsupportedOperationException("OFActionSetMplsLabel not supported in version 1.2");
+    }
+    public OFActionSetMplsLabel setMplsLabel(long mplsLabel) {
+        throw new UnsupportedOperationException("OFActionSetMplsLabel not supported in version 1.2");
+    }
+
+    public OFActionSetMplsTc.Builder buildSetMplsTc() {
+        throw new UnsupportedOperationException("OFActionSetMplsTc not supported in version 1.2");
+    }
+    public OFActionSetMplsTc setMplsTc(short mplsTc) {
+        throw new UnsupportedOperationException("OFActionSetMplsTc not supported in version 1.2");
+    }
+
+    public OFActionSetMplsTtl.Builder buildSetMplsTtl() {
+        return new OFActionSetMplsTtlVer12.Builder();
+    }
+    public OFActionSetMplsTtl setMplsTtl(short mplsTtl) {
+        return new OFActionSetMplsTtlVer12(
+                mplsTtl
+                    );
+    }
+
+    public OFActionSetNwEcn.Builder buildSetNwEcn() {
+        throw new UnsupportedOperationException("OFActionSetNwEcn not supported in version 1.2");
+    }
+    public OFActionSetNwEcn setNwEcn(IpEcn nwEcn) {
+        throw new UnsupportedOperationException("OFActionSetNwEcn not supported in version 1.2");
+    }
+
+    public OFActionSetNwTtl.Builder buildSetNwTtl() {
+        return new OFActionSetNwTtlVer12.Builder();
+    }
+    public OFActionSetNwTtl setNwTtl(short nwTtl) {
+        return new OFActionSetNwTtlVer12(
+                nwTtl
+                    );
+    }
+
+    public OFActionSetQueue.Builder buildSetQueue() {
+        return new OFActionSetQueueVer12.Builder();
+    }
+    public OFActionSetQueue setQueue(long queueId) {
+        return new OFActionSetQueueVer12(
+                queueId
+                    );
+    }
+
+    public OFActionSetField.Builder buildSetField() {
+        return new OFActionSetFieldVer12.Builder();
+    }
+    public OFActionSetField setField(OFOxm<?> field) {
+        return new OFActionSetFieldVer12(
+                field
+                    );
+    }
+
+    public OFActionPopPbb popPbb() {
+        throw new UnsupportedOperationException("OFActionPopPbb not supported in version 1.2");
+    }
+
+    public OFActionPushPbb.Builder buildPushPbb() {
+        throw new UnsupportedOperationException("OFActionPushPbb not supported in version 1.2");
+    }
+    public OFActionPushPbb pushPbb(EthType ethertype) {
+        throw new UnsupportedOperationException("OFActionPushPbb not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFAction> getReader() {
+        return OFActionVer12.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFAggregateStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFAggregateStatsReplyVer12.java
new file mode 100644
index 0000000..dfe896b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFAggregateStatsReplyVer12.java
@@ -0,0 +1,511 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAggregateStatsReplyVer12 implements OFAggregateStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 40;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static long DEFAULT_FLOW_COUNT = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final long flowCount;
+//
+    // Immutable default instance
+    final static OFAggregateStatsReplyVer12 DEFAULT = new OFAggregateStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_FLOW_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAggregateStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, U64 packetCount, U64 byteCount, long flowCount) {
+        this.xid = xid;
+        this.flags = flags;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.flowCount = flowCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+
+
+    public OFAggregateStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAggregateStatsReply.Builder {
+        final OFAggregateStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean flowCountSet;
+        private long flowCount;
+
+        BuilderWithParent(OFAggregateStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAggregateStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                long flowCount = this.flowCountSet ? this.flowCount : parentMessage.flowCount;
+
+                //
+                return new OFAggregateStatsReplyVer12(
+                    xid,
+                    flags,
+                    packetCount,
+                    byteCount,
+                    flowCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFAggregateStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean flowCountSet;
+        private long flowCount;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAggregateStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            long flowCount = this.flowCountSet ? this.flowCount : DEFAULT_FLOW_COUNT;
+
+
+            return new OFAggregateStatsReplyVer12(
+                    xid,
+                    flags,
+                    packetCount,
+                    byteCount,
+                    flowCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAggregateStatsReply> {
+        @Override
+        public OFAggregateStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 40)
+                throw new OFParseError("Wrong length: Expected=40(40), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 2
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x2)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.AGGREGATE(2), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            long flowCount = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFAggregateStatsReplyVer12 aggregateStatsReplyVer12 = new OFAggregateStatsReplyVer12(
+                    xid,
+                      flags,
+                      packetCount,
+                      byteCount,
+                      flowCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", aggregateStatsReplyVer12);
+            return aggregateStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAggregateStatsReplyVer12Funnel FUNNEL = new OFAggregateStatsReplyVer12Funnel();
+    static class OFAggregateStatsReplyVer12Funnel implements Funnel<OFAggregateStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAggregateStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 40
+            sink.putShort((short) 0x28);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 2
+            sink.putShort((short) 0x2);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            sink.putLong(message.flowCount);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAggregateStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFAggregateStatsReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 40
+            bb.writeShort((short) 0x28);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 2
+            bb.writeShort((short) 0x2);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            bb.writeInt(U32.t(message.flowCount));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAggregateStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("flowCount=").append(flowCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAggregateStatsReplyVer12 other = (OFAggregateStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if( flowCount != other.flowCount)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime *  (int) (flowCount ^ (flowCount >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFAggregateStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFAggregateStatsRequestVer12.java
new file mode 100644
index 0000000..5276111
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFAggregateStatsRequestVer12.java
@@ -0,0 +1,690 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAggregateStatsRequestVer12 implements OFAggregateStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final TableId tableId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFAggregateStatsRequestVer12 DEFAULT = new OFAggregateStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TABLE_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAggregateStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags, TableId tableId, OFPort outPort, OFGroup outGroup, U64 cookie, U64 cookieMask, Match match) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFAggregateStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAggregateStatsRequest.Builder {
+        final OFAggregateStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFAggregateStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAggregateStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFAggregateStatsRequestVer12(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFAggregateStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAggregateStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFAggregateStatsRequestVer12(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAggregateStatsRequest> {
+        @Override
+        public OFAggregateStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 2
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x2)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.AGGREGATE(2), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+
+            OFAggregateStatsRequestVer12 aggregateStatsRequestVer12 = new OFAggregateStatsRequestVer12(
+                    xid,
+                      flags,
+                      tableId,
+                      outPort,
+                      outGroup,
+                      cookie,
+                      cookieMask,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", aggregateStatsRequestVer12);
+            return aggregateStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAggregateStatsRequestVer12Funnel FUNNEL = new OFAggregateStatsRequestVer12Funnel();
+    static class OFAggregateStatsRequestVer12Funnel implements Funnel<OFAggregateStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAggregateStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 2
+            sink.putShort((short) 0x2);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            // skip pad (4 bytes)
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAggregateStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFAggregateStatsRequestVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 2
+            bb.writeShort((short) 0x2);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.match.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAggregateStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAggregateStatsRequestVer12 other = (OFAggregateStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadActionCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadActionCodeSerializerVer12.java
new file mode 100644
index 0000000..29a63f1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadActionCodeSerializerVer12.java
@@ -0,0 +1,144 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadActionCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadActionCodeSerializerVer12 {
+
+    public final static short BAD_TYPE_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x2;
+    public final static short BAD_EXPERIMENTER_TYPE_VAL = (short) 0x3;
+    public final static short BAD_OUT_PORT_VAL = (short) 0x4;
+    public final static short BAD_ARGUMENT_VAL = (short) 0x5;
+    public final static short EPERM_VAL = (short) 0x6;
+    public final static short TOO_MANY_VAL = (short) 0x7;
+    public final static short BAD_QUEUE_VAL = (short) 0x8;
+    public final static short BAD_OUT_GROUP_VAL = (short) 0x9;
+    public final static short MATCH_INCONSISTENT_VAL = (short) 0xa;
+    public final static short UNSUPPORTED_ORDER_VAL = (short) 0xb;
+    public final static short BAD_TAG_VAL = (short) 0xc;
+    public final static short BAD_SET_TYPE_VAL = (short) 0xd;
+    public final static short BAD_SET_LEN_VAL = (short) 0xe;
+    public final static short BAD_SET_ARGUMENT_VAL = (short) 0xf;
+
+    public static OFBadActionCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadActionCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadActionCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadActionCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TYPE_VAL:
+                return OFBadActionCode.BAD_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadActionCode.BAD_LEN;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadActionCode.BAD_EXPERIMENTER;
+            case BAD_EXPERIMENTER_TYPE_VAL:
+                return OFBadActionCode.BAD_EXPERIMENTER_TYPE;
+            case BAD_OUT_PORT_VAL:
+                return OFBadActionCode.BAD_OUT_PORT;
+            case BAD_ARGUMENT_VAL:
+                return OFBadActionCode.BAD_ARGUMENT;
+            case EPERM_VAL:
+                return OFBadActionCode.EPERM;
+            case TOO_MANY_VAL:
+                return OFBadActionCode.TOO_MANY;
+            case BAD_QUEUE_VAL:
+                return OFBadActionCode.BAD_QUEUE;
+            case BAD_OUT_GROUP_VAL:
+                return OFBadActionCode.BAD_OUT_GROUP;
+            case MATCH_INCONSISTENT_VAL:
+                return OFBadActionCode.MATCH_INCONSISTENT;
+            case UNSUPPORTED_ORDER_VAL:
+                return OFBadActionCode.UNSUPPORTED_ORDER;
+            case BAD_TAG_VAL:
+                return OFBadActionCode.BAD_TAG;
+            case BAD_SET_TYPE_VAL:
+                return OFBadActionCode.BAD_SET_TYPE;
+            case BAD_SET_LEN_VAL:
+                return OFBadActionCode.BAD_SET_LEN;
+            case BAD_SET_ARGUMENT_VAL:
+                return OFBadActionCode.BAD_SET_ARGUMENT;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadActionCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadActionCode e) {
+        switch(e) {
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_EXPERIMENTER_TYPE:
+                return BAD_EXPERIMENTER_TYPE_VAL;
+            case BAD_OUT_PORT:
+                return BAD_OUT_PORT_VAL;
+            case BAD_ARGUMENT:
+                return BAD_ARGUMENT_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case TOO_MANY:
+                return TOO_MANY_VAL;
+            case BAD_QUEUE:
+                return BAD_QUEUE_VAL;
+            case BAD_OUT_GROUP:
+                return BAD_OUT_GROUP_VAL;
+            case MATCH_INCONSISTENT:
+                return MATCH_INCONSISTENT_VAL;
+            case UNSUPPORTED_ORDER:
+                return UNSUPPORTED_ORDER_VAL;
+            case BAD_TAG:
+                return BAD_TAG_VAL;
+            case BAD_SET_TYPE:
+                return BAD_SET_TYPE_VAL;
+            case BAD_SET_LEN:
+                return BAD_SET_LEN_VAL;
+            case BAD_SET_ARGUMENT:
+                return BAD_SET_ARGUMENT_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadActionCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadActionErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadActionErrorMsgVer12.java
new file mode 100644
index 0000000..2f5bf1a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadActionErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadActionErrorMsgVer12 implements OFBadActionErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadActionErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadActionCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadActionErrorMsgVer12(long xid, OFBadActionCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadActionErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadActionErrorMsg.Builder {
+        final OFBadActionErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadActionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadActionErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setCode(OFBadActionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadActionErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadActionCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadActionErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadActionErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadActionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setCode(OFBadActionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadActionErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadActionErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadActionErrorMsg> {
+        @Override
+        public OFBadActionErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 2
+            short errType = bb.readShort();
+            if(errType != (short) 0x2)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_ACTION(2), got="+errType);
+            OFBadActionCode code = OFBadActionCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFBadActionErrorMsgVer12 badActionErrorMsgVer12 = new OFBadActionErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badActionErrorMsgVer12);
+            return badActionErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadActionErrorMsgVer12Funnel FUNNEL = new OFBadActionErrorMsgVer12Funnel();
+    static class OFBadActionErrorMsgVer12Funnel implements Funnel<OFBadActionErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadActionErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 2
+            sink.putShort((short) 0x2);
+            OFBadActionCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadActionErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadActionErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 2
+            bb.writeShort((short) 0x2);
+            OFBadActionCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadActionErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadActionErrorMsgVer12 other = (OFBadActionErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadInstructionCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadInstructionCodeSerializerVer12.java
new file mode 100644
index 0000000..fd30343
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadInstructionCodeSerializerVer12.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadInstructionCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadInstructionCodeSerializerVer12 {
+
+    public final static short UNKNOWN_INST_VAL = (short) 0x0;
+    public final static short UNSUP_INST_VAL = (short) 0x1;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x2;
+    public final static short UNSUP_METADATA_VAL = (short) 0x3;
+    public final static short UNSUP_METADATA_MASK_VAL = (short) 0x4;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x5;
+    public final static short BAD_EXPERIMENTER_TYPE_VAL = (short) 0x6;
+    public final static short BAD_LEN_VAL = (short) 0x7;
+    public final static short EPERM_VAL = (short) 0x8;
+
+    public static OFBadInstructionCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadInstructionCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadInstructionCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadInstructionCode ofWireValue(short val) {
+        switch(val) {
+            case UNKNOWN_INST_VAL:
+                return OFBadInstructionCode.UNKNOWN_INST;
+            case UNSUP_INST_VAL:
+                return OFBadInstructionCode.UNSUP_INST;
+            case BAD_TABLE_ID_VAL:
+                return OFBadInstructionCode.BAD_TABLE_ID;
+            case UNSUP_METADATA_VAL:
+                return OFBadInstructionCode.UNSUP_METADATA;
+            case UNSUP_METADATA_MASK_VAL:
+                return OFBadInstructionCode.UNSUP_METADATA_MASK;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadInstructionCode.BAD_EXPERIMENTER;
+            case BAD_EXPERIMENTER_TYPE_VAL:
+                return OFBadInstructionCode.BAD_EXPERIMENTER_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadInstructionCode.BAD_LEN;
+            case EPERM_VAL:
+                return OFBadInstructionCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadInstructionCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadInstructionCode e) {
+        switch(e) {
+            case UNKNOWN_INST:
+                return UNKNOWN_INST_VAL;
+            case UNSUP_INST:
+                return UNSUP_INST_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            case UNSUP_METADATA:
+                return UNSUP_METADATA_VAL;
+            case UNSUP_METADATA_MASK:
+                return UNSUP_METADATA_MASK_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_EXPERIMENTER_TYPE:
+                return BAD_EXPERIMENTER_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadInstructionCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadInstructionErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadInstructionErrorMsgVer12.java
new file mode 100644
index 0000000..35006d9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadInstructionErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadInstructionErrorMsgVer12 implements OFBadInstructionErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadInstructionErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadInstructionCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadInstructionErrorMsgVer12(long xid, OFBadInstructionCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadInstructionErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadInstructionErrorMsg.Builder {
+        final OFBadInstructionErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadInstructionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadInstructionErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setCode(OFBadInstructionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadInstructionErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadInstructionCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadInstructionErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadInstructionErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadInstructionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setCode(OFBadInstructionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadInstructionErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadInstructionErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadInstructionErrorMsg> {
+        @Override
+        public OFBadInstructionErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 3
+            short errType = bb.readShort();
+            if(errType != (short) 0x3)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_INSTRUCTION(3), got="+errType);
+            OFBadInstructionCode code = OFBadInstructionCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFBadInstructionErrorMsgVer12 badInstructionErrorMsgVer12 = new OFBadInstructionErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badInstructionErrorMsgVer12);
+            return badInstructionErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadInstructionErrorMsgVer12Funnel FUNNEL = new OFBadInstructionErrorMsgVer12Funnel();
+    static class OFBadInstructionErrorMsgVer12Funnel implements Funnel<OFBadInstructionErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadInstructionErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 3
+            sink.putShort((short) 0x3);
+            OFBadInstructionCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadInstructionErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadInstructionErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 3
+            bb.writeShort((short) 0x3);
+            OFBadInstructionCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadInstructionErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadInstructionErrorMsgVer12 other = (OFBadInstructionErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadMatchCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadMatchCodeSerializerVer12.java
new file mode 100644
index 0000000..fa6cd63
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadMatchCodeSerializerVer12.java
@@ -0,0 +1,124 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadMatchCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadMatchCodeSerializerVer12 {
+
+    public final static short BAD_TYPE_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short BAD_TAG_VAL = (short) 0x2;
+    public final static short BAD_DL_ADDR_MASK_VAL = (short) 0x3;
+    public final static short BAD_NW_ADDR_MASK_VAL = (short) 0x4;
+    public final static short BAD_WILDCARDS_VAL = (short) 0x5;
+    public final static short BAD_FIELD_VAL = (short) 0x6;
+    public final static short BAD_VALUE_VAL = (short) 0x7;
+    public final static short BAD_MASK_VAL = (short) 0x8;
+    public final static short BAD_PREREQ_VAL = (short) 0x9;
+    public final static short DUP_FIELD_VAL = (short) 0xa;
+    public final static short EPERM_VAL = (short) 0xb;
+
+    public static OFBadMatchCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadMatchCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadMatchCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadMatchCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TYPE_VAL:
+                return OFBadMatchCode.BAD_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadMatchCode.BAD_LEN;
+            case BAD_TAG_VAL:
+                return OFBadMatchCode.BAD_TAG;
+            case BAD_DL_ADDR_MASK_VAL:
+                return OFBadMatchCode.BAD_DL_ADDR_MASK;
+            case BAD_NW_ADDR_MASK_VAL:
+                return OFBadMatchCode.BAD_NW_ADDR_MASK;
+            case BAD_WILDCARDS_VAL:
+                return OFBadMatchCode.BAD_WILDCARDS;
+            case BAD_FIELD_VAL:
+                return OFBadMatchCode.BAD_FIELD;
+            case BAD_VALUE_VAL:
+                return OFBadMatchCode.BAD_VALUE;
+            case BAD_MASK_VAL:
+                return OFBadMatchCode.BAD_MASK;
+            case BAD_PREREQ_VAL:
+                return OFBadMatchCode.BAD_PREREQ;
+            case DUP_FIELD_VAL:
+                return OFBadMatchCode.DUP_FIELD;
+            case EPERM_VAL:
+                return OFBadMatchCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadMatchCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadMatchCode e) {
+        switch(e) {
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BAD_TAG:
+                return BAD_TAG_VAL;
+            case BAD_DL_ADDR_MASK:
+                return BAD_DL_ADDR_MASK_VAL;
+            case BAD_NW_ADDR_MASK:
+                return BAD_NW_ADDR_MASK_VAL;
+            case BAD_WILDCARDS:
+                return BAD_WILDCARDS_VAL;
+            case BAD_FIELD:
+                return BAD_FIELD_VAL;
+            case BAD_VALUE:
+                return BAD_VALUE_VAL;
+            case BAD_MASK:
+                return BAD_MASK_VAL;
+            case BAD_PREREQ:
+                return BAD_PREREQ_VAL;
+            case DUP_FIELD:
+                return DUP_FIELD_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadMatchCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadMatchErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadMatchErrorMsgVer12.java
new file mode 100644
index 0000000..1e80089
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadMatchErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadMatchErrorMsgVer12 implements OFBadMatchErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadMatchErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadMatchCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadMatchErrorMsgVer12(long xid, OFBadMatchCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadMatchErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadMatchErrorMsg.Builder {
+        final OFBadMatchErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadMatchCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadMatchErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setCode(OFBadMatchCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadMatchErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadMatchCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadMatchErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadMatchErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadMatchCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setCode(OFBadMatchCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadMatchErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadMatchErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadMatchErrorMsg> {
+        @Override
+        public OFBadMatchErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 4
+            short errType = bb.readShort();
+            if(errType != (short) 0x4)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_MATCH(4), got="+errType);
+            OFBadMatchCode code = OFBadMatchCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFBadMatchErrorMsgVer12 badMatchErrorMsgVer12 = new OFBadMatchErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badMatchErrorMsgVer12);
+            return badMatchErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadMatchErrorMsgVer12Funnel FUNNEL = new OFBadMatchErrorMsgVer12Funnel();
+    static class OFBadMatchErrorMsgVer12Funnel implements Funnel<OFBadMatchErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadMatchErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 4
+            sink.putShort((short) 0x4);
+            OFBadMatchCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadMatchErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadMatchErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 4
+            bb.writeShort((short) 0x4);
+            OFBadMatchCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadMatchErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadMatchErrorMsgVer12 other = (OFBadMatchErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadRequestCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadRequestCodeSerializerVer12.java
new file mode 100644
index 0000000..c7d8546
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadRequestCodeSerializerVer12.java
@@ -0,0 +1,129 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadRequestCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadRequestCodeSerializerVer12 {
+
+    public final static short BAD_VERSION_VAL = (short) 0x0;
+    public final static short BAD_TYPE_VAL = (short) 0x1;
+    public final static short BAD_STAT_VAL = (short) 0x2;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x3;
+    public final static short BAD_EXPERIMENTER_TYPE_VAL = (short) 0x4;
+    public final static short EPERM_VAL = (short) 0x5;
+    public final static short BAD_LEN_VAL = (short) 0x6;
+    public final static short BUFFER_EMPTY_VAL = (short) 0x7;
+    public final static short BUFFER_UNKNOWN_VAL = (short) 0x8;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x9;
+    public final static short IS_SLAVE_VAL = (short) 0xa;
+    public final static short BAD_PORT_VAL = (short) 0xb;
+    public final static short BAD_PACKET_VAL = (short) 0xc;
+
+    public static OFBadRequestCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadRequestCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadRequestCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadRequestCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_VERSION_VAL:
+                return OFBadRequestCode.BAD_VERSION;
+            case BAD_TYPE_VAL:
+                return OFBadRequestCode.BAD_TYPE;
+            case BAD_STAT_VAL:
+                return OFBadRequestCode.BAD_STAT;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadRequestCode.BAD_EXPERIMENTER;
+            case BAD_EXPERIMENTER_TYPE_VAL:
+                return OFBadRequestCode.BAD_EXPERIMENTER_TYPE;
+            case EPERM_VAL:
+                return OFBadRequestCode.EPERM;
+            case BAD_LEN_VAL:
+                return OFBadRequestCode.BAD_LEN;
+            case BUFFER_EMPTY_VAL:
+                return OFBadRequestCode.BUFFER_EMPTY;
+            case BUFFER_UNKNOWN_VAL:
+                return OFBadRequestCode.BUFFER_UNKNOWN;
+            case BAD_TABLE_ID_VAL:
+                return OFBadRequestCode.BAD_TABLE_ID;
+            case IS_SLAVE_VAL:
+                return OFBadRequestCode.IS_SLAVE;
+            case BAD_PORT_VAL:
+                return OFBadRequestCode.BAD_PORT;
+            case BAD_PACKET_VAL:
+                return OFBadRequestCode.BAD_PACKET;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadRequestCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadRequestCode e) {
+        switch(e) {
+            case BAD_VERSION:
+                return BAD_VERSION_VAL;
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_STAT:
+                return BAD_STAT_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_EXPERIMENTER_TYPE:
+                return BAD_EXPERIMENTER_TYPE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BUFFER_EMPTY:
+                return BUFFER_EMPTY_VAL;
+            case BUFFER_UNKNOWN:
+                return BUFFER_UNKNOWN_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            case IS_SLAVE:
+                return IS_SLAVE_VAL;
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_PACKET:
+                return BAD_PACKET_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadRequestCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadRequestErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadRequestErrorMsgVer12.java
new file mode 100644
index 0000000..15af33f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBadRequestErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadRequestErrorMsgVer12 implements OFBadRequestErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadRequestErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadRequestCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadRequestErrorMsgVer12(long xid, OFBadRequestCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadRequestErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadRequestErrorMsg.Builder {
+        final OFBadRequestErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadRequestCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadRequestErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setCode(OFBadRequestCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadRequestErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadRequestCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadRequestErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadRequestErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadRequestCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setCode(OFBadRequestCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadRequestErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadRequestErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadRequestErrorMsg> {
+        @Override
+        public OFBadRequestErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 1
+            short errType = bb.readShort();
+            if(errType != (short) 0x1)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_REQUEST(1), got="+errType);
+            OFBadRequestCode code = OFBadRequestCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFBadRequestErrorMsgVer12 badRequestErrorMsgVer12 = new OFBadRequestErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badRequestErrorMsgVer12);
+            return badRequestErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadRequestErrorMsgVer12Funnel FUNNEL = new OFBadRequestErrorMsgVer12Funnel();
+    static class OFBadRequestErrorMsgVer12Funnel implements Funnel<OFBadRequestErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadRequestErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 1
+            sink.putShort((short) 0x1);
+            OFBadRequestCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadRequestErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadRequestErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 1
+            bb.writeShort((short) 0x1);
+            OFBadRequestCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadRequestErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadRequestErrorMsgVer12 other = (OFBadRequestErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBarrierReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBarrierReplyVer12.java
new file mode 100644
index 0000000..4bd1c3d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBarrierReplyVer12.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBarrierReplyVer12 implements OFBarrierReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBarrierReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBarrierReplyVer12 DEFAULT = new OFBarrierReplyVer12(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBarrierReplyVer12(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFBarrierReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBarrierReply.Builder {
+        final OFBarrierReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBarrierReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBarrierReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBarrierReplyVer12(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBarrierReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBarrierReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBarrierReplyVer12(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBarrierReply> {
+        @Override
+        public OFBarrierReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 21
+            byte type = bb.readByte();
+            if(type != (byte) 0x15)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REPLY(21), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFBarrierReplyVer12 barrierReplyVer12 = new OFBarrierReplyVer12(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", barrierReplyVer12);
+            return barrierReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBarrierReplyVer12Funnel FUNNEL = new OFBarrierReplyVer12Funnel();
+    static class OFBarrierReplyVer12Funnel implements Funnel<OFBarrierReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBarrierReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 21
+            sink.putByte((byte) 0x15);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBarrierReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBarrierReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 21
+            bb.writeByte((byte) 0x15);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBarrierReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBarrierReplyVer12 other = (OFBarrierReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBarrierRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBarrierRequestVer12.java
new file mode 100644
index 0000000..dff4d85
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBarrierRequestVer12.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBarrierRequestVer12 implements OFBarrierRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBarrierRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBarrierRequestVer12 DEFAULT = new OFBarrierRequestVer12(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBarrierRequestVer12(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFBarrierRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBarrierRequest.Builder {
+        final OFBarrierRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBarrierRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBarrierRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBarrierRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBarrierRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBarrierRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBarrierRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBarrierRequest> {
+        @Override
+        public OFBarrierRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 20
+            byte type = bb.readByte();
+            if(type != (byte) 0x14)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REQUEST(20), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFBarrierRequestVer12 barrierRequestVer12 = new OFBarrierRequestVer12(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", barrierRequestVer12);
+            return barrierRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBarrierRequestVer12Funnel FUNNEL = new OFBarrierRequestVer12Funnel();
+    static class OFBarrierRequestVer12Funnel implements Funnel<OFBarrierRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBarrierRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 20
+            sink.putByte((byte) 0x14);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBarrierRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBarrierRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 20
+            bb.writeByte((byte) 0x14);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBarrierRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBarrierRequestVer12 other = (OFBarrierRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwClearDataReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwClearDataReplyVer12.java
new file mode 100644
index 0000000..653a7c1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwClearDataReplyVer12.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwClearDataReplyVer12 implements OFBsnBwClearDataReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwClearDataReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnBwClearDataReplyVer12 DEFAULT = new OFBsnBwClearDataReplyVer12(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwClearDataReplyVer12(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnBwClearDataReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwClearDataReply.Builder {
+        final OFBsnBwClearDataReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnBwClearDataReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwClearDataReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnBwClearDataReplyVer12(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwClearDataReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwClearDataReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnBwClearDataReplyVer12(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwClearDataReply> {
+        @Override
+        public OFBsnBwClearDataReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x16L
+            int subtype = bb.readInt();
+            if(subtype != 0x16)
+                throw new OFParseError("Wrong subtype: Expected=0x16L(0x16L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnBwClearDataReplyVer12 bsnBwClearDataReplyVer12 = new OFBsnBwClearDataReplyVer12(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwClearDataReplyVer12);
+            return bsnBwClearDataReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwClearDataReplyVer12Funnel FUNNEL = new OFBsnBwClearDataReplyVer12Funnel();
+    static class OFBsnBwClearDataReplyVer12Funnel implements Funnel<OFBsnBwClearDataReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwClearDataReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x16L
+            sink.putInt(0x16);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwClearDataReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwClearDataReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x16L
+            bb.writeInt(0x16);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwClearDataReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwClearDataReplyVer12 other = (OFBsnBwClearDataReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwClearDataRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwClearDataRequestVer12.java
new file mode 100644
index 0000000..359da1d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwClearDataRequestVer12.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwClearDataRequestVer12 implements OFBsnBwClearDataRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwClearDataRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnBwClearDataRequestVer12 DEFAULT = new OFBsnBwClearDataRequestVer12(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwClearDataRequestVer12(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+
+
+    public OFBsnBwClearDataRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwClearDataRequest.Builder {
+        final OFBsnBwClearDataRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnBwClearDataRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+
+
+        @Override
+        public OFBsnBwClearDataRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnBwClearDataRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwClearDataRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+//
+        @Override
+        public OFBsnBwClearDataRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnBwClearDataRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwClearDataRequest> {
+        @Override
+        public OFBsnBwClearDataRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x15L
+            int subtype = bb.readInt();
+            if(subtype != 0x15)
+                throw new OFParseError("Wrong subtype: Expected=0x15L(0x15L), got="+subtype);
+
+            OFBsnBwClearDataRequestVer12 bsnBwClearDataRequestVer12 = new OFBsnBwClearDataRequestVer12(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwClearDataRequestVer12);
+            return bsnBwClearDataRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwClearDataRequestVer12Funnel FUNNEL = new OFBsnBwClearDataRequestVer12Funnel();
+    static class OFBsnBwClearDataRequestVer12Funnel implements Funnel<OFBsnBwClearDataRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwClearDataRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x15L
+            sink.putInt(0x15);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwClearDataRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwClearDataRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x15L
+            bb.writeInt(0x15);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwClearDataRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwClearDataRequestVer12 other = (OFBsnBwClearDataRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableGetReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableGetReplyVer12.java
new file mode 100644
index 0000000..6074526
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableGetReplyVer12.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableGetReplyVer12 implements OFBsnBwEnableGetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableGetReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLED = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enabled;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableGetReplyVer12 DEFAULT = new OFBsnBwEnableGetReplyVer12(
+        DEFAULT_XID, DEFAULT_ENABLED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableGetReplyVer12(long xid, long enabled) {
+        this.xid = xid;
+        this.enabled = enabled;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+
+
+    public OFBsnBwEnableGetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableGetReply.Builder {
+        final OFBsnBwEnableGetReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+        BuilderWithParent(OFBsnBwEnableGetReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableGetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+
+                //
+                return new OFBsnBwEnableGetReplyVer12(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableGetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableGetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+
+
+            return new OFBsnBwEnableGetReplyVer12(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableGetReply> {
+        @Override
+        public OFBsnBwEnableGetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x14L
+            int subtype = bb.readInt();
+            if(subtype != 0x14)
+                throw new OFParseError("Wrong subtype: Expected=0x14L(0x14L), got="+subtype);
+            long enabled = U32.f(bb.readInt());
+
+            OFBsnBwEnableGetReplyVer12 bsnBwEnableGetReplyVer12 = new OFBsnBwEnableGetReplyVer12(
+                    xid,
+                      enabled
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableGetReplyVer12);
+            return bsnBwEnableGetReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableGetReplyVer12Funnel FUNNEL = new OFBsnBwEnableGetReplyVer12Funnel();
+    static class OFBsnBwEnableGetReplyVer12Funnel implements Funnel<OFBsnBwEnableGetReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableGetReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x14L
+            sink.putInt(0x14);
+            sink.putLong(message.enabled);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableGetReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableGetReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x14L
+            bb.writeInt(0x14);
+            bb.writeInt(U32.t(message.enabled));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableGetReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableGetReplyVer12 other = (OFBsnBwEnableGetReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enabled ^ (enabled >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableGetRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableGetRequestVer12.java
new file mode 100644
index 0000000..46e8356
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableGetRequestVer12.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableGetRequestVer12 implements OFBsnBwEnableGetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableGetRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableGetRequestVer12 DEFAULT = new OFBsnBwEnableGetRequestVer12(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableGetRequestVer12(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+
+
+    public OFBsnBwEnableGetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableGetRequest.Builder {
+        final OFBsnBwEnableGetRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnBwEnableGetRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+
+
+        @Override
+        public OFBsnBwEnableGetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnBwEnableGetRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableGetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+//
+        @Override
+        public OFBsnBwEnableGetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnBwEnableGetRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableGetRequest> {
+        @Override
+        public OFBsnBwEnableGetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x13L
+            int subtype = bb.readInt();
+            if(subtype != 0x13)
+                throw new OFParseError("Wrong subtype: Expected=0x13L(0x13L), got="+subtype);
+
+            OFBsnBwEnableGetRequestVer12 bsnBwEnableGetRequestVer12 = new OFBsnBwEnableGetRequestVer12(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableGetRequestVer12);
+            return bsnBwEnableGetRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableGetRequestVer12Funnel FUNNEL = new OFBsnBwEnableGetRequestVer12Funnel();
+    static class OFBsnBwEnableGetRequestVer12Funnel implements Funnel<OFBsnBwEnableGetRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableGetRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x13L
+            sink.putInt(0x13);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableGetRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableGetRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x13L
+            bb.writeInt(0x13);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableGetRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableGetRequestVer12 other = (OFBsnBwEnableGetRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableSetReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableSetReplyVer12.java
new file mode 100644
index 0000000..4651dc3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableSetReplyVer12.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableSetReplyVer12 implements OFBsnBwEnableSetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableSetReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableSetReplyVer12 DEFAULT = new OFBsnBwEnableSetReplyVer12(
+        DEFAULT_XID, DEFAULT_ENABLE, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableSetReplyVer12(long xid, long enable, long status) {
+        this.xid = xid;
+        this.enable = enable;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnBwEnableSetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableSetReply.Builder {
+        final OFBsnBwEnableSetReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnBwEnableSetReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableSetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnBwEnableSetReplyVer12(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableSetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableSetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnBwEnableSetReplyVer12(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableSetReply> {
+        @Override
+        public OFBsnBwEnableSetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x17L
+            int subtype = bb.readInt();
+            if(subtype != 0x17)
+                throw new OFParseError("Wrong subtype: Expected=0x17L(0x17L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+            long status = U32.f(bb.readInt());
+
+            OFBsnBwEnableSetReplyVer12 bsnBwEnableSetReplyVer12 = new OFBsnBwEnableSetReplyVer12(
+                    xid,
+                      enable,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableSetReplyVer12);
+            return bsnBwEnableSetReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableSetReplyVer12Funnel FUNNEL = new OFBsnBwEnableSetReplyVer12Funnel();
+    static class OFBsnBwEnableSetReplyVer12Funnel implements Funnel<OFBsnBwEnableSetReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableSetReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x17L
+            sink.putInt(0x17);
+            sink.putLong(message.enable);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableSetReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableSetReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x17L
+            bb.writeInt(0x17);
+            bb.writeInt(U32.t(message.enable));
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableSetReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableSetReplyVer12 other = (OFBsnBwEnableSetReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableSetRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableSetRequestVer12.java
new file mode 100644
index 0000000..11d2d1b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnBwEnableSetRequestVer12.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableSetRequestVer12 implements OFBsnBwEnableSetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableSetRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableSetRequestVer12 DEFAULT = new OFBsnBwEnableSetRequestVer12(
+        DEFAULT_XID, DEFAULT_ENABLE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableSetRequestVer12(long xid, long enable) {
+        this.xid = xid;
+        this.enable = enable;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+
+
+    public OFBsnBwEnableSetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableSetRequest.Builder {
+        final OFBsnBwEnableSetRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+        BuilderWithParent(OFBsnBwEnableSetRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableSetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+
+                //
+                return new OFBsnBwEnableSetRequestVer12(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableSetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableSetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+
+
+            return new OFBsnBwEnableSetRequestVer12(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableSetRequest> {
+        @Override
+        public OFBsnBwEnableSetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x12L
+            int subtype = bb.readInt();
+            if(subtype != 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12L(0x12L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+
+            OFBsnBwEnableSetRequestVer12 bsnBwEnableSetRequestVer12 = new OFBsnBwEnableSetRequestVer12(
+                    xid,
+                      enable
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableSetRequestVer12);
+            return bsnBwEnableSetRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableSetRequestVer12Funnel FUNNEL = new OFBsnBwEnableSetRequestVer12Funnel();
+    static class OFBsnBwEnableSetRequestVer12Funnel implements Funnel<OFBsnBwEnableSetRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableSetRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x12L
+            sink.putInt(0x12);
+            sink.putLong(message.enable);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableSetRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableSetRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x12L
+            bb.writeInt(0x12);
+            bb.writeInt(U32.t(message.enable));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableSetRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableSetRequestVer12 other = (OFBsnBwEnableSetRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetInterfacesReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetInterfacesReplyVer12.java
new file mode 100644
index 0000000..b3802e3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetInterfacesReplyVer12.java
@@ -0,0 +1,375 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetInterfacesReplyVer12 implements OFBsnGetInterfacesReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetInterfacesReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static List<OFBsnInterface> DEFAULT_INTERFACES = ImmutableList.<OFBsnInterface>of();
+
+    // OF message fields
+    private final long xid;
+    private final List<OFBsnInterface> interfaces;
+//
+    // Immutable default instance
+    final static OFBsnGetInterfacesReplyVer12 DEFAULT = new OFBsnGetInterfacesReplyVer12(
+        DEFAULT_XID, DEFAULT_INTERFACES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetInterfacesReplyVer12(long xid, List<OFBsnInterface> interfaces) {
+        this.xid = xid;
+        this.interfaces = interfaces;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+
+
+    public OFBsnGetInterfacesReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetInterfacesReply.Builder {
+        final OFBsnGetInterfacesReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean interfacesSet;
+        private List<OFBsnInterface> interfaces;
+
+        BuilderWithParent(OFBsnGetInterfacesReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setInterfaces(List<OFBsnInterface> interfaces) {
+        this.interfaces = interfaces;
+        this.interfacesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetInterfacesReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                List<OFBsnInterface> interfaces = this.interfacesSet ? this.interfaces : parentMessage.interfaces;
+                if(interfaces == null)
+                    throw new NullPointerException("Property interfaces must not be null");
+
+                //
+                return new OFBsnGetInterfacesReplyVer12(
+                    xid,
+                    interfaces
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetInterfacesReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean interfacesSet;
+        private List<OFBsnInterface> interfaces;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setInterfaces(List<OFBsnInterface> interfaces) {
+        this.interfaces = interfaces;
+        this.interfacesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetInterfacesReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            List<OFBsnInterface> interfaces = this.interfacesSet ? this.interfaces : DEFAULT_INTERFACES;
+            if(interfaces == null)
+                throw new NullPointerException("Property interfaces must not be null");
+
+
+            return new OFBsnGetInterfacesReplyVer12(
+                    xid,
+                    interfaces
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetInterfacesReply> {
+        @Override
+        public OFBsnGetInterfacesReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xaL
+            int subtype = bb.readInt();
+            if(subtype != 0xa)
+                throw new OFParseError("Wrong subtype: Expected=0xaL(0xaL), got="+subtype);
+            List<OFBsnInterface> interfaces = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnInterfaceVer12.READER);
+
+            OFBsnGetInterfacesReplyVer12 bsnGetInterfacesReplyVer12 = new OFBsnGetInterfacesReplyVer12(
+                    xid,
+                      interfaces
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetInterfacesReplyVer12);
+            return bsnGetInterfacesReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetInterfacesReplyVer12Funnel FUNNEL = new OFBsnGetInterfacesReplyVer12Funnel();
+    static class OFBsnGetInterfacesReplyVer12Funnel implements Funnel<OFBsnGetInterfacesReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetInterfacesReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            sink.putInt(0xa);
+            FunnelUtils.putList(message.interfaces, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetInterfacesReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetInterfacesReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            bb.writeInt(0xa);
+            ChannelUtils.writeList(bb, message.interfaces);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetInterfacesReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("interfaces=").append(interfaces);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetInterfacesReplyVer12 other = (OFBsnGetInterfacesReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (interfaces == null) {
+            if (other.interfaces != null)
+                return false;
+        } else if (!interfaces.equals(other.interfaces))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetInterfacesRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetInterfacesRequestVer12.java
new file mode 100644
index 0000000..3be91d0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetInterfacesRequestVer12.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetInterfacesRequestVer12 implements OFBsnGetInterfacesRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetInterfacesRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnGetInterfacesRequestVer12 DEFAULT = new OFBsnGetInterfacesRequestVer12(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetInterfacesRequestVer12(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+
+
+    public OFBsnGetInterfacesRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetInterfacesRequest.Builder {
+        final OFBsnGetInterfacesRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnGetInterfacesRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+
+
+        @Override
+        public OFBsnGetInterfacesRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnGetInterfacesRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetInterfacesRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+//
+        @Override
+        public OFBsnGetInterfacesRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnGetInterfacesRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetInterfacesRequest> {
+        @Override
+        public OFBsnGetInterfacesRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x9L
+            int subtype = bb.readInt();
+            if(subtype != 0x9)
+                throw new OFParseError("Wrong subtype: Expected=0x9L(0x9L), got="+subtype);
+
+            OFBsnGetInterfacesRequestVer12 bsnGetInterfacesRequestVer12 = new OFBsnGetInterfacesRequestVer12(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetInterfacesRequestVer12);
+            return bsnGetInterfacesRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetInterfacesRequestVer12Funnel FUNNEL = new OFBsnGetInterfacesRequestVer12Funnel();
+    static class OFBsnGetInterfacesRequestVer12Funnel implements Funnel<OFBsnGetInterfacesRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetInterfacesRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            sink.putInt(0x9);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetInterfacesRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetInterfacesRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            bb.writeInt(0x9);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetInterfacesRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetInterfacesRequestVer12 other = (OFBsnGetInterfacesRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetMirroringReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetMirroringReplyVer12.java
new file mode 100644
index 0000000..b39d38a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetMirroringReplyVer12.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetMirroringReplyVer12 implements OFBsnGetMirroringReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetMirroringReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnGetMirroringReplyVer12 DEFAULT = new OFBsnGetMirroringReplyVer12(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetMirroringReplyVer12(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnGetMirroringReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetMirroringReply.Builder {
+        final OFBsnGetMirroringReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnGetMirroringReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetMirroringReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnGetMirroringReplyVer12(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetMirroringReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetMirroringReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnGetMirroringReplyVer12(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetMirroringReply> {
+        @Override
+        public OFBsnGetMirroringReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x5L
+            int subtype = bb.readInt();
+            if(subtype != 0x5)
+                throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnGetMirroringReplyVer12 bsnGetMirroringReplyVer12 = new OFBsnGetMirroringReplyVer12(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetMirroringReplyVer12);
+            return bsnGetMirroringReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetMirroringReplyVer12Funnel FUNNEL = new OFBsnGetMirroringReplyVer12Funnel();
+    static class OFBsnGetMirroringReplyVer12Funnel implements Funnel<OFBsnGetMirroringReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetMirroringReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            sink.putInt(0x5);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetMirroringReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetMirroringReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            bb.writeInt(0x5);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetMirroringReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetMirroringReplyVer12 other = (OFBsnGetMirroringReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetMirroringRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetMirroringRequestVer12.java
new file mode 100644
index 0000000..579cbc3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnGetMirroringRequestVer12.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetMirroringRequestVer12 implements OFBsnGetMirroringRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetMirroringRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnGetMirroringRequestVer12 DEFAULT = new OFBsnGetMirroringRequestVer12(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetMirroringRequestVer12(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnGetMirroringRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetMirroringRequest.Builder {
+        final OFBsnGetMirroringRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnGetMirroringRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetMirroringRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnGetMirroringRequestVer12(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetMirroringRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetMirroringRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnGetMirroringRequestVer12(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetMirroringRequest> {
+        @Override
+        public OFBsnGetMirroringRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnGetMirroringRequestVer12 bsnGetMirroringRequestVer12 = new OFBsnGetMirroringRequestVer12(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetMirroringRequestVer12);
+            return bsnGetMirroringRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetMirroringRequestVer12Funnel FUNNEL = new OFBsnGetMirroringRequestVer12Funnel();
+    static class OFBsnGetMirroringRequestVer12Funnel implements Funnel<OFBsnGetMirroringRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetMirroringRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetMirroringRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetMirroringRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetMirroringRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetMirroringRequestVer12 other = (OFBsnGetMirroringRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnHeaderVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnHeaderVer12.java
new file mode 100644
index 0000000..12e3540
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnHeaderVer12.java
@@ -0,0 +1,133 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFBsnHeaderVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFBsnHeaderVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnHeader> {
+        @Override
+        public OFBsnHeader readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x16:
+                   // discriminator value 0x16L=0x16L for class OFBsnBwClearDataReplyVer12
+                   return OFBsnBwClearDataReplyVer12.READER.readFrom(bb);
+               case 0x15:
+                   // discriminator value 0x15L=0x15L for class OFBsnBwClearDataRequestVer12
+                   return OFBsnBwClearDataRequestVer12.READER.readFrom(bb);
+               case 0x14:
+                   // discriminator value 0x14L=0x14L for class OFBsnBwEnableGetReplyVer12
+                   return OFBsnBwEnableGetReplyVer12.READER.readFrom(bb);
+               case 0x13:
+                   // discriminator value 0x13L=0x13L for class OFBsnBwEnableGetRequestVer12
+                   return OFBsnBwEnableGetRequestVer12.READER.readFrom(bb);
+               case 0x17:
+                   // discriminator value 0x17L=0x17L for class OFBsnBwEnableSetReplyVer12
+                   return OFBsnBwEnableSetReplyVer12.READER.readFrom(bb);
+               case 0x12:
+                   // discriminator value 0x12L=0x12L for class OFBsnBwEnableSetRequestVer12
+                   return OFBsnBwEnableSetRequestVer12.READER.readFrom(bb);
+               case 0xa:
+                   // discriminator value 0xaL=0xaL for class OFBsnGetInterfacesReplyVer12
+                   return OFBsnGetInterfacesReplyVer12.READER.readFrom(bb);
+               case 0x9:
+                   // discriminator value 0x9L=0x9L for class OFBsnGetInterfacesRequestVer12
+                   return OFBsnGetInterfacesRequestVer12.READER.readFrom(bb);
+               case 0x5:
+                   // discriminator value 0x5L=0x5L for class OFBsnGetMirroringReplyVer12
+                   return OFBsnGetMirroringReplyVer12.READER.readFrom(bb);
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFBsnGetMirroringRequestVer12
+                   return OFBsnGetMirroringRequestVer12.READER.readFrom(bb);
+               case 0x22:
+                   // discriminator value 0x22L=0x22L for class OFBsnPduRxReplyVer12
+                   return OFBsnPduRxReplyVer12.READER.readFrom(bb);
+               case 0x21:
+                   // discriminator value 0x21L=0x21L for class OFBsnPduRxRequestVer12
+                   return OFBsnPduRxRequestVer12.READER.readFrom(bb);
+               case 0x23:
+                   // discriminator value 0x23L=0x23L for class OFBsnPduRxTimeoutVer12
+                   return OFBsnPduRxTimeoutVer12.READER.readFrom(bb);
+               case 0x20:
+                   // discriminator value 0x20L=0x20L for class OFBsnPduTxReplyVer12
+                   return OFBsnPduTxReplyVer12.READER.readFrom(bb);
+               case 0x1f:
+                   // discriminator value 0x1fL=0x1fL for class OFBsnPduTxRequestVer12
+                   return OFBsnPduTxRequestVer12.READER.readFrom(bb);
+               case 0x3:
+                   // discriminator value 0x3L=0x3L for class OFBsnSetMirroringVer12
+                   return OFBsnSetMirroringVer12.READER.readFrom(bb);
+               case 0x19:
+                   // discriminator value 0x19L=0x19L for class OFBsnSetPktinSuppressionReplyVer12
+                   return OFBsnSetPktinSuppressionReplyVer12.READER.readFrom(bb);
+               case 0xb:
+                   // discriminator value 0xbL=0xbL for class OFBsnSetPktinSuppressionRequestVer12
+                   return OFBsnSetPktinSuppressionRequestVer12.READER.readFrom(bb);
+               case 0x10:
+                   // discriminator value 0x10L=0x10L for class OFBsnVirtualPortCreateReplyVer12
+                   return OFBsnVirtualPortCreateReplyVer12.READER.readFrom(bb);
+               case 0xf:
+                   // discriminator value 0xfL=0xfL for class OFBsnVirtualPortCreateRequestVer12
+                   return OFBsnVirtualPortCreateRequestVer12.READER.readFrom(bb);
+               case 0x1a:
+                   // discriminator value 0x1aL=0x1aL for class OFBsnVirtualPortRemoveReplyVer12
+                   return OFBsnVirtualPortRemoveReplyVer12.READER.readFrom(bb);
+               case 0x11:
+                   // discriminator value 0x11L=0x11L for class OFBsnVirtualPortRemoveRequestVer12
+                   return OFBsnVirtualPortRemoveRequestVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnHeaderVer12: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnInterfaceVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnInterfaceVer12.java
new file mode 100644
index 0000000..154f9fa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnInterfaceVer12.java
@@ -0,0 +1,396 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnInterfaceVer12 implements OFBsnInterface {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnInterfaceVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 32;
+
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static String DEFAULT_NAME = "";
+        private final static IPv4Address DEFAULT_IPV4_ADDR = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_IPV4_NETMASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final MacAddress hwAddr;
+    private final String name;
+    private final IPv4Address ipv4Addr;
+    private final IPv4Address ipv4Netmask;
+//
+    // Immutable default instance
+    final static OFBsnInterfaceVer12 DEFAULT = new OFBsnInterfaceVer12(
+        DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_IPV4_ADDR, DEFAULT_IPV4_NETMASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnInterfaceVer12(MacAddress hwAddr, String name, IPv4Address ipv4Addr, IPv4Address ipv4Netmask) {
+        this.hwAddr = hwAddr;
+        this.name = name;
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4Netmask = ipv4Netmask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFBsnInterface.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnInterface.Builder {
+        final OFBsnInterfaceVer12 parentMessage;
+
+        // OF message fields
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+        private boolean ipv4NetmaskSet;
+        private IPv4Address ipv4Netmask;
+
+        BuilderWithParent(OFBsnInterfaceVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) {
+        this.ipv4Netmask = ipv4Netmask;
+        this.ipv4NetmaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFBsnInterface build() {
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : parentMessage.ipv4Addr;
+                if(ipv4Addr == null)
+                    throw new NullPointerException("Property ipv4Addr must not be null");
+                IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : parentMessage.ipv4Netmask;
+                if(ipv4Netmask == null)
+                    throw new NullPointerException("Property ipv4Netmask must not be null");
+
+                //
+                return new OFBsnInterfaceVer12(
+                    hwAddr,
+                    name,
+                    ipv4Addr,
+                    ipv4Netmask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnInterface.Builder {
+        // OF message fields
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+        private boolean ipv4NetmaskSet;
+        private IPv4Address ipv4Netmask;
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) {
+        this.ipv4Netmask = ipv4Netmask;
+        this.ipv4NetmaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFBsnInterface build() {
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : DEFAULT_IPV4_ADDR;
+            if(ipv4Addr == null)
+                throw new NullPointerException("Property ipv4Addr must not be null");
+            IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : DEFAULT_IPV4_NETMASK;
+            if(ipv4Netmask == null)
+                throw new NullPointerException("Property ipv4Netmask must not be null");
+
+
+            return new OFBsnInterfaceVer12(
+                    hwAddr,
+                    name,
+                    ipv4Addr,
+                    ipv4Netmask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnInterface> {
+        @Override
+        public OFBsnInterface readFrom(ChannelBuffer bb) throws OFParseError {
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            String name = ChannelUtils.readFixedLengthString(bb, 16);
+            IPv4Address ipv4Addr = IPv4Address.read4Bytes(bb);
+            IPv4Address ipv4Netmask = IPv4Address.read4Bytes(bb);
+
+            OFBsnInterfaceVer12 bsnInterfaceVer12 = new OFBsnInterfaceVer12(
+                    hwAddr,
+                      name,
+                      ipv4Addr,
+                      ipv4Netmask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnInterfaceVer12);
+            return bsnInterfaceVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnInterfaceVer12Funnel FUNNEL = new OFBsnInterfaceVer12Funnel();
+    static class OFBsnInterfaceVer12Funnel implements Funnel<OFBsnInterfaceVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnInterfaceVer12 message, PrimitiveSink sink) {
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putUnencodedChars(message.name);
+            message.ipv4Addr.putTo(sink);
+            message.ipv4Netmask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnInterfaceVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnInterfaceVer12 message) {
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 16);
+            message.ipv4Addr.write4Bytes(bb);
+            message.ipv4Netmask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnInterfaceVer12(");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("ipv4Addr=").append(ipv4Addr);
+        b.append(", ");
+        b.append("ipv4Netmask=").append(ipv4Netmask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnInterfaceVer12 other = (OFBsnInterfaceVer12) obj;
+
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (ipv4Addr == null) {
+            if (other.ipv4Addr != null)
+                return false;
+        } else if (!ipv4Addr.equals(other.ipv4Addr))
+            return false;
+        if (ipv4Netmask == null) {
+            if (other.ipv4Netmask != null)
+                return false;
+        } else if (!ipv4Netmask.equals(other.ipv4Netmask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((ipv4Addr == null) ? 0 : ipv4Addr.hashCode());
+        result = prime * result + ((ipv4Netmask == null) ? 0 : ipv4Netmask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxReplyVer12.java
new file mode 100644
index 0000000..cf2a2d7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxReplyVer12.java
@@ -0,0 +1,462 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduRxReplyVer12 implements OFBsnPduRxReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 25;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduRxReplyVer12 DEFAULT = new OFBsnPduRxReplyVer12(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxReplyVer12(long xid, long status, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduRxReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxReply.Builder {
+        final OFBsnPduRxReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduRxReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduRxReplyVer12(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduRxReplyVer12(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxReply> {
+        @Override
+        public OFBsnPduRxReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 25)
+                throw new OFParseError("Wrong length: Expected=25(25), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x22L
+            int subtype = bb.readInt();
+            if(subtype != 0x22)
+                throw new OFParseError("Wrong subtype: Expected=0x22L(0x22L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduRxReplyVer12 bsnPduRxReplyVer12 = new OFBsnPduRxReplyVer12(
+                    xid,
+                      status,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxReplyVer12);
+            return bsnPduRxReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxReplyVer12Funnel FUNNEL = new OFBsnPduRxReplyVer12Funnel();
+    static class OFBsnPduRxReplyVer12Funnel implements Funnel<OFBsnPduRxReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 25
+            sink.putShort((short) 0x19);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x22L
+            sink.putInt(0x22);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 25
+            bb.writeShort((short) 0x19);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x22L
+            bb.writeInt(0x22);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxReplyVer12 other = (OFBsnPduRxReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxRequestVer12.java
new file mode 100644
index 0000000..7088067
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxRequestVer12.java
@@ -0,0 +1,524 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnPduRxRequestVer12 implements OFBsnPduRxRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_TIMEOUT_MS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long timeoutMs;
+    private final OFPort portNo;
+    private final short slotNum;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnPduRxRequestVer12 DEFAULT = new OFBsnPduRxRequestVer12(
+        DEFAULT_XID, DEFAULT_TIMEOUT_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxRequestVer12(long xid, long timeoutMs, OFPort portNo, short slotNum, byte[] data) {
+        this.xid = xid;
+        this.timeoutMs = timeoutMs;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnPduRxRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxRequest.Builder {
+        final OFBsnPduRxRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeoutMsSet;
+        private long timeoutMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnPduRxRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setTimeoutMs(long timeoutMs) {
+        this.timeoutMs = timeoutMs;
+        this.timeoutMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long timeoutMs = this.timeoutMsSet ? this.timeoutMs : parentMessage.timeoutMs;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnPduRxRequestVer12(
+                    xid,
+                    timeoutMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeoutMsSet;
+        private long timeoutMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setTimeoutMs(long timeoutMs) {
+        this.timeoutMs = timeoutMs;
+        this.timeoutMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long timeoutMs = this.timeoutMsSet ? this.timeoutMs : DEFAULT_TIMEOUT_MS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnPduRxRequestVer12(
+                    xid,
+                    timeoutMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxRequest> {
+        @Override
+        public OFBsnPduRxRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x21L
+            int subtype = bb.readInt();
+            if(subtype != 0x21)
+                throw new OFParseError("Wrong subtype: Expected=0x21L(0x21L), got="+subtype);
+            long timeoutMs = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnPduRxRequestVer12 bsnPduRxRequestVer12 = new OFBsnPduRxRequestVer12(
+                    xid,
+                      timeoutMs,
+                      portNo,
+                      slotNum,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxRequestVer12);
+            return bsnPduRxRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxRequestVer12Funnel FUNNEL = new OFBsnPduRxRequestVer12Funnel();
+    static class OFBsnPduRxRequestVer12Funnel implements Funnel<OFBsnPduRxRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x21L
+            sink.putInt(0x21);
+            sink.putLong(message.timeoutMs);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+            // skip pad (3 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxRequestVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x21L
+            bb.writeInt(0x21);
+            bb.writeInt(U32.t(message.timeoutMs));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("timeoutMs=").append(timeoutMs);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxRequestVer12 other = (OFBsnPduRxRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( timeoutMs != other.timeoutMs)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (timeoutMs ^ (timeoutMs >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxTimeoutVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxTimeoutVer12.java
new file mode 100644
index 0000000..4146c38
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduRxTimeoutVer12.java
@@ -0,0 +1,415 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduRxTimeoutVer12 implements OFBsnPduRxTimeout {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxTimeoutVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 21;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduRxTimeoutVer12 DEFAULT = new OFBsnPduRxTimeoutVer12(
+        DEFAULT_XID, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxTimeoutVer12(long xid, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduRxTimeout.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxTimeout.Builder {
+        final OFBsnPduRxTimeoutVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduRxTimeoutVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxTimeout build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduRxTimeoutVer12(
+                    xid,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxTimeout.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxTimeout build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduRxTimeoutVer12(
+                    xid,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxTimeout> {
+        @Override
+        public OFBsnPduRxTimeout readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 21)
+                throw new OFParseError("Wrong length: Expected=21(21), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x23L
+            int subtype = bb.readInt();
+            if(subtype != 0x23)
+                throw new OFParseError("Wrong subtype: Expected=0x23L(0x23L), got="+subtype);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduRxTimeoutVer12 bsnPduRxTimeoutVer12 = new OFBsnPduRxTimeoutVer12(
+                    xid,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxTimeoutVer12);
+            return bsnPduRxTimeoutVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxTimeoutVer12Funnel FUNNEL = new OFBsnPduRxTimeoutVer12Funnel();
+    static class OFBsnPduRxTimeoutVer12Funnel implements Funnel<OFBsnPduRxTimeoutVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxTimeoutVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 21
+            sink.putShort((short) 0x15);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x23L
+            sink.putInt(0x23);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxTimeoutVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxTimeoutVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 21
+            bb.writeShort((short) 0x15);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x23L
+            bb.writeInt(0x23);
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxTimeoutVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxTimeoutVer12 other = (OFBsnPduRxTimeoutVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduSlotNumTSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduSlotNumTSerializerVer12.java
new file mode 100644
index 0000000..211adf1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduSlotNumTSerializerVer12.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnPduSlotNumT;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnPduSlotNumTSerializerVer12 {
+
+    public final static byte PDU_SLOT_NUM_ANY_VAL = (byte) 0xff;
+
+    public static OFBsnPduSlotNumT readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnPduSlotNumT e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnPduSlotNumT e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnPduSlotNumT ofWireValue(byte val) {
+        switch(val) {
+            case PDU_SLOT_NUM_ANY_VAL:
+                return OFBsnPduSlotNumT.PDU_SLOT_NUM_ANY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnPduSlotNumT in version 1.2: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnPduSlotNumT e) {
+        switch(e) {
+            case PDU_SLOT_NUM_ANY:
+                return PDU_SLOT_NUM_ANY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnPduSlotNumT in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduTxReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduTxReplyVer12.java
new file mode 100644
index 0000000..cf97f9f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduTxReplyVer12.java
@@ -0,0 +1,462 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduTxReplyVer12 implements OFBsnPduTxReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 25;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduTxReplyVer12 DEFAULT = new OFBsnPduTxReplyVer12(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduTxReplyVer12(long xid, long status, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduTxReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduTxReply.Builder {
+        final OFBsnPduTxReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduTxReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduTxReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduTxReplyVer12(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduTxReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduTxReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduTxReplyVer12(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduTxReply> {
+        @Override
+        public OFBsnPduTxReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 25)
+                throw new OFParseError("Wrong length: Expected=25(25), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x20L
+            int subtype = bb.readInt();
+            if(subtype != 0x20)
+                throw new OFParseError("Wrong subtype: Expected=0x20L(0x20L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduTxReplyVer12 bsnPduTxReplyVer12 = new OFBsnPduTxReplyVer12(
+                    xid,
+                      status,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduTxReplyVer12);
+            return bsnPduTxReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduTxReplyVer12Funnel FUNNEL = new OFBsnPduTxReplyVer12Funnel();
+    static class OFBsnPduTxReplyVer12Funnel implements Funnel<OFBsnPduTxReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduTxReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 25
+            sink.putShort((short) 0x19);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x20L
+            sink.putInt(0x20);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduTxReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduTxReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 25
+            bb.writeShort((short) 0x19);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x20L
+            bb.writeInt(0x20);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduTxReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduTxReplyVer12 other = (OFBsnPduTxReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduTxRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduTxRequestVer12.java
new file mode 100644
index 0000000..fd36a02
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnPduTxRequestVer12.java
@@ -0,0 +1,524 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnPduTxRequestVer12 implements OFBsnPduTxRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_TX_INTERVAL_MS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long txIntervalMs;
+    private final OFPort portNo;
+    private final short slotNum;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnPduTxRequestVer12 DEFAULT = new OFBsnPduTxRequestVer12(
+        DEFAULT_XID, DEFAULT_TX_INTERVAL_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduTxRequestVer12(long xid, long txIntervalMs, OFPort portNo, short slotNum, byte[] data) {
+        this.xid = xid;
+        this.txIntervalMs = txIntervalMs;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnPduTxRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduTxRequest.Builder {
+        final OFBsnPduTxRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean txIntervalMsSet;
+        private long txIntervalMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnPduTxRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) {
+        this.txIntervalMs = txIntervalMs;
+        this.txIntervalMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduTxRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : parentMessage.txIntervalMs;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnPduTxRequestVer12(
+                    xid,
+                    txIntervalMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduTxRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean txIntervalMsSet;
+        private long txIntervalMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) {
+        this.txIntervalMs = txIntervalMs;
+        this.txIntervalMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduTxRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : DEFAULT_TX_INTERVAL_MS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnPduTxRequestVer12(
+                    xid,
+                    txIntervalMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduTxRequest> {
+        @Override
+        public OFBsnPduTxRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1fL
+            int subtype = bb.readInt();
+            if(subtype != 0x1f)
+                throw new OFParseError("Wrong subtype: Expected=0x1fL(0x1fL), got="+subtype);
+            long txIntervalMs = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnPduTxRequestVer12 bsnPduTxRequestVer12 = new OFBsnPduTxRequestVer12(
+                    xid,
+                      txIntervalMs,
+                      portNo,
+                      slotNum,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduTxRequestVer12);
+            return bsnPduTxRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduTxRequestVer12Funnel FUNNEL = new OFBsnPduTxRequestVer12Funnel();
+    static class OFBsnPduTxRequestVer12Funnel implements Funnel<OFBsnPduTxRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduTxRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1fL
+            sink.putInt(0x1f);
+            sink.putLong(message.txIntervalMs);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+            // skip pad (3 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduTxRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduTxRequestVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1fL
+            bb.writeInt(0x1f);
+            bb.writeInt(U32.t(message.txIntervalMs));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduTxRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("txIntervalMs=").append(txIntervalMs);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduTxRequestVer12 other = (OFBsnPduTxRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( txIntervalMs != other.txIntervalMs)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (txIntervalMs ^ (txIntervalMs >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetMirroringVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetMirroringVer12.java
new file mode 100644
index 0000000..12183ec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetMirroringVer12.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetMirroringVer12 implements OFBsnSetMirroring {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetMirroringVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnSetMirroringVer12 DEFAULT = new OFBsnSetMirroringVer12(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetMirroringVer12(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnSetMirroring.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetMirroring.Builder {
+        final OFBsnSetMirroringVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnSetMirroringVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetMirroring build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnSetMirroringVer12(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetMirroring.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetMirroring build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnSetMirroringVer12(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetMirroring> {
+        @Override
+        public OFBsnSetMirroring readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3L
+            int subtype = bb.readInt();
+            if(subtype != 0x3)
+                throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnSetMirroringVer12 bsnSetMirroringVer12 = new OFBsnSetMirroringVer12(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetMirroringVer12);
+            return bsnSetMirroringVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetMirroringVer12Funnel FUNNEL = new OFBsnSetMirroringVer12Funnel();
+    static class OFBsnSetMirroringVer12Funnel implements Funnel<OFBsnSetMirroringVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetMirroringVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            sink.putInt(0x3);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetMirroringVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetMirroringVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            bb.writeInt(0x3);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetMirroringVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetMirroringVer12 other = (OFBsnSetMirroringVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetPktinSuppressionReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetPktinSuppressionReplyVer12.java
new file mode 100644
index 0000000..140301f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetPktinSuppressionReplyVer12.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetPktinSuppressionReplyVer12 implements OFBsnSetPktinSuppressionReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetPktinSuppressionReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnSetPktinSuppressionReplyVer12 DEFAULT = new OFBsnSetPktinSuppressionReplyVer12(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetPktinSuppressionReplyVer12(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnSetPktinSuppressionReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetPktinSuppressionReply.Builder {
+        final OFBsnSetPktinSuppressionReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnSetPktinSuppressionReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetPktinSuppressionReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnSetPktinSuppressionReplyVer12(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetPktinSuppressionReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetPktinSuppressionReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnSetPktinSuppressionReplyVer12(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetPktinSuppressionReply> {
+        @Override
+        public OFBsnSetPktinSuppressionReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x19L
+            int subtype = bb.readInt();
+            if(subtype != 0x19)
+                throw new OFParseError("Wrong subtype: Expected=0x19L(0x19L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnSetPktinSuppressionReplyVer12 bsnSetPktinSuppressionReplyVer12 = new OFBsnSetPktinSuppressionReplyVer12(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetPktinSuppressionReplyVer12);
+            return bsnSetPktinSuppressionReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetPktinSuppressionReplyVer12Funnel FUNNEL = new OFBsnSetPktinSuppressionReplyVer12Funnel();
+    static class OFBsnSetPktinSuppressionReplyVer12Funnel implements Funnel<OFBsnSetPktinSuppressionReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetPktinSuppressionReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x19L
+            sink.putInt(0x19);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetPktinSuppressionReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetPktinSuppressionReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x19L
+            bb.writeInt(0x19);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetPktinSuppressionReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetPktinSuppressionReplyVer12 other = (OFBsnSetPktinSuppressionReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetPktinSuppressionRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetPktinSuppressionRequestVer12.java
new file mode 100644
index 0000000..6a00d69
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnSetPktinSuppressionRequestVer12.java
@@ -0,0 +1,561 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetPktinSuppressionRequestVer12 implements OFBsnSetPktinSuppressionRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetPktinSuppressionRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static boolean DEFAULT_ENABLED = false;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final boolean enabled;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final U64 cookie;
+//
+    // Immutable default instance
+    final static OFBsnSetPktinSuppressionRequestVer12 DEFAULT = new OFBsnSetPktinSuppressionRequestVer12(
+        DEFAULT_XID, DEFAULT_ENABLED, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_COOKIE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetPktinSuppressionRequestVer12(long xid, boolean enabled, int idleTimeout, int hardTimeout, int priority, U64 cookie) {
+        this.xid = xid;
+        this.enabled = enabled;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.cookie = cookie;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+
+
+    public OFBsnSetPktinSuppressionRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetPktinSuppressionRequest.Builder {
+        final OFBsnSetPktinSuppressionRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private boolean enabled;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean cookieSet;
+        private U64 cookie;
+
+        BuilderWithParent(OFBsnSetPktinSuppressionRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setEnabled(boolean enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetPktinSuppressionRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                boolean enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+
+                //
+                return new OFBsnSetPktinSuppressionRequestVer12(
+                    xid,
+                    enabled,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    cookie
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetPktinSuppressionRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private boolean enabled;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean cookieSet;
+        private U64 cookie;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setEnabled(boolean enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetPktinSuppressionRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            boolean enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+
+
+            return new OFBsnSetPktinSuppressionRequestVer12(
+                    xid,
+                    enabled,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    cookie
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetPktinSuppressionRequest> {
+        @Override
+        public OFBsnSetPktinSuppressionRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xbL
+            int subtype = bb.readInt();
+            if(subtype != 0xb)
+                throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got="+subtype);
+            boolean enabled = (bb.readByte() != 0);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            U64 cookie = U64.ofRaw(bb.readLong());
+
+            OFBsnSetPktinSuppressionRequestVer12 bsnSetPktinSuppressionRequestVer12 = new OFBsnSetPktinSuppressionRequestVer12(
+                    xid,
+                      enabled,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      cookie
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetPktinSuppressionRequestVer12);
+            return bsnSetPktinSuppressionRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetPktinSuppressionRequestVer12Funnel FUNNEL = new OFBsnSetPktinSuppressionRequestVer12Funnel();
+    static class OFBsnSetPktinSuppressionRequestVer12Funnel implements Funnel<OFBsnSetPktinSuppressionRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetPktinSuppressionRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            sink.putInt(0xb);
+            sink.putBoolean(message.enabled);
+            // skip pad (1 bytes)
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.cookie.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetPktinSuppressionRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetPktinSuppressionRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            bb.writeInt(0xb);
+            bb.writeByte(message.enabled ? 1 : 0);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeLong(message.cookie.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetPktinSuppressionRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetPktinSuppressionRequestVer12 other = (OFBsnSetPktinSuppressionRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + (enabled ? 1231 : 1237);
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnStatsReplyVer12.java
new file mode 100644
index 0000000..10c32b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnStatsReplyVer12.java
@@ -0,0 +1,73 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnStatsReplyVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFBsnStatsReplyVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnStatsReply> {
+        @Override
+        public OFBsnStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnStatsReplyVer12: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnStatsRequestVer12.java
new file mode 100644
index 0000000..07e00aa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnStatsRequestVer12.java
@@ -0,0 +1,73 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnStatsRequestVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFBsnStatsRequestVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnStatsRequest<?>> {
+        @Override
+        public OFBsnStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnStatsRequestVer12: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnTcpFlagSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnTcpFlagSerializerVer12.java
new file mode 100644
index 0000000..71d22aa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnTcpFlagSerializerVer12.java
@@ -0,0 +1,126 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnTcpFlag;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFBsnTcpFlagSerializerVer12 {
+
+    public final static short BSN_TCP_FLAG_FIN_VAL = (short) 0x1;
+    public final static short BSN_TCP_FLAG_SYN_VAL = (short) 0x2;
+    public final static short BSN_TCP_FLAG_RST_VAL = (short) 0x4;
+    public final static short BSN_TCP_FLAG_PSH_VAL = (short) 0x8;
+    public final static short BSN_TCP_FLAG_ACK_VAL = (short) 0x10;
+    public final static short BSN_TCP_FLAG_URG_VAL = (short) 0x20;
+    public final static short BSN_TCP_FLAG_ECE_VAL = (short) 0x40;
+    public final static short BSN_TCP_FLAG_CWR_VAL = (short) 0x80;
+    public final static short BSN_TCP_FLAG_NS_VAL = (short) 0x100;
+
+    public static Set<OFBsnTcpFlag> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFBsnTcpFlag> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFBsnTcpFlag> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFBsnTcpFlag> ofWireValue(short val) {
+        EnumSet<OFBsnTcpFlag> set = EnumSet.noneOf(OFBsnTcpFlag.class);
+
+        if((val & BSN_TCP_FLAG_FIN_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_FIN);
+        if((val & BSN_TCP_FLAG_SYN_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_SYN);
+        if((val & BSN_TCP_FLAG_RST_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_RST);
+        if((val & BSN_TCP_FLAG_PSH_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_PSH);
+        if((val & BSN_TCP_FLAG_ACK_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_ACK);
+        if((val & BSN_TCP_FLAG_URG_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_URG);
+        if((val & BSN_TCP_FLAG_ECE_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_ECE);
+        if((val & BSN_TCP_FLAG_CWR_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_CWR);
+        if((val & BSN_TCP_FLAG_NS_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_NS);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFBsnTcpFlag> set) {
+        short wireValue = 0;
+
+        for(OFBsnTcpFlag e: set) {
+            switch(e) {
+                case BSN_TCP_FLAG_FIN:
+                    wireValue |= BSN_TCP_FLAG_FIN_VAL;
+                    break;
+                case BSN_TCP_FLAG_SYN:
+                    wireValue |= BSN_TCP_FLAG_SYN_VAL;
+                    break;
+                case BSN_TCP_FLAG_RST:
+                    wireValue |= BSN_TCP_FLAG_RST_VAL;
+                    break;
+                case BSN_TCP_FLAG_PSH:
+                    wireValue |= BSN_TCP_FLAG_PSH_VAL;
+                    break;
+                case BSN_TCP_FLAG_ACK:
+                    wireValue |= BSN_TCP_FLAG_ACK_VAL;
+                    break;
+                case BSN_TCP_FLAG_URG:
+                    wireValue |= BSN_TCP_FLAG_URG_VAL;
+                    break;
+                case BSN_TCP_FLAG_ECE:
+                    wireValue |= BSN_TCP_FLAG_ECE_VAL;
+                    break;
+                case BSN_TCP_FLAG_CWR:
+                    wireValue |= BSN_TCP_FLAG_CWR_VAL;
+                    break;
+                case BSN_TCP_FLAG_NS:
+                    wireValue |= BSN_TCP_FLAG_NS_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFBsnTcpFlag in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnTlvsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnTlvsVer12.java
new file mode 100644
index 0000000..71e175d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnTlvsVer12.java
@@ -0,0 +1,200 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFBsnTlvsVer12 implements OFBsnTlvs {
+    public final static OFBsnTlvsVer12 INSTANCE = new OFBsnTlvsVer12();
+
+
+
+
+    public OFBsnTlvBroadcastQueryTimeout.Builder buildBroadcastQueryTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvBroadcastQueryTimeout not supported in version 1.2");
+    }
+    public OFBsnTlvBroadcastQueryTimeout broadcastQueryTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvBroadcastQueryTimeout not supported in version 1.2");
+    }
+
+    public OFBsnTlvCircuitId.Builder buildCircuitId() {
+        throw new UnsupportedOperationException("OFBsnTlvCircuitId not supported in version 1.2");
+    }
+    public OFBsnTlvCircuitId circuitId(byte[] value) {
+        throw new UnsupportedOperationException("OFBsnTlvCircuitId not supported in version 1.2");
+    }
+
+    public OFBsnTlvCrcEnabled.Builder buildCrcEnabled() {
+        throw new UnsupportedOperationException("OFBsnTlvCrcEnabled not supported in version 1.2");
+    }
+    public OFBsnTlvCrcEnabled crcEnabled(short value) {
+        throw new UnsupportedOperationException("OFBsnTlvCrcEnabled not supported in version 1.2");
+    }
+
+    public OFBsnTlvIdleNotification idleNotification() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleNotification not supported in version 1.2");
+    }
+
+    public OFBsnTlvIdleTime.Builder buildIdleTime() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTime not supported in version 1.2");
+    }
+    public OFBsnTlvIdleTime idleTime(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTime not supported in version 1.2");
+    }
+
+    public OFBsnTlvIdleTimeout.Builder buildIdleTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTimeout not supported in version 1.2");
+    }
+    public OFBsnTlvIdleTimeout idleTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvIdleTimeout not supported in version 1.2");
+    }
+
+    public OFBsnTlvIpv4.Builder buildIpv4() {
+        throw new UnsupportedOperationException("OFBsnTlvIpv4 not supported in version 1.2");
+    }
+    public OFBsnTlvIpv4 ipv4(IPv4Address value) {
+        throw new UnsupportedOperationException("OFBsnTlvIpv4 not supported in version 1.2");
+    }
+
+    public OFBsnTlvMac.Builder buildMac() {
+        throw new UnsupportedOperationException("OFBsnTlvMac not supported in version 1.2");
+    }
+    public OFBsnTlvMac mac(MacAddress value) {
+        throw new UnsupportedOperationException("OFBsnTlvMac not supported in version 1.2");
+    }
+
+    public OFBsnTlvMissPackets.Builder buildMissPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvMissPackets not supported in version 1.2");
+    }
+    public OFBsnTlvMissPackets missPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvMissPackets not supported in version 1.2");
+    }
+
+    public OFBsnTlvPort.Builder buildPort() {
+        throw new UnsupportedOperationException("OFBsnTlvPort not supported in version 1.2");
+    }
+    public OFBsnTlvPort port(OFPort value) {
+        throw new UnsupportedOperationException("OFBsnTlvPort not supported in version 1.2");
+    }
+
+    public OFBsnTlvQueueId.Builder buildQueueId() {
+        throw new UnsupportedOperationException("OFBsnTlvQueueId not supported in version 1.2");
+    }
+    public OFBsnTlvQueueId queueId(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvQueueId not supported in version 1.2");
+    }
+
+    public OFBsnTlvQueueWeight.Builder buildQueueWeight() {
+        throw new UnsupportedOperationException("OFBsnTlvQueueWeight not supported in version 1.2");
+    }
+    public OFBsnTlvQueueWeight queueWeight(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvQueueWeight not supported in version 1.2");
+    }
+
+    public OFBsnTlvReplyPackets.Builder buildReplyPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvReplyPackets not supported in version 1.2");
+    }
+    public OFBsnTlvReplyPackets replyPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvReplyPackets not supported in version 1.2");
+    }
+
+    public OFBsnTlvRequestPackets.Builder buildRequestPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvRequestPackets not supported in version 1.2");
+    }
+    public OFBsnTlvRequestPackets requestPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvRequestPackets not supported in version 1.2");
+    }
+
+    public OFBsnTlvRxPackets.Builder buildRxPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvRxPackets not supported in version 1.2");
+    }
+    public OFBsnTlvRxPackets rxPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvRxPackets not supported in version 1.2");
+    }
+
+    public OFBsnTlvTxPackets.Builder buildTxPackets() {
+        throw new UnsupportedOperationException("OFBsnTlvTxPackets not supported in version 1.2");
+    }
+    public OFBsnTlvTxPackets txPackets(U64 value) {
+        throw new UnsupportedOperationException("OFBsnTlvTxPackets not supported in version 1.2");
+    }
+
+    public OFBsnTlvUdfAnchor.Builder buildUdfAnchor() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfAnchor not supported in version 1.2");
+    }
+    public OFBsnTlvUdfAnchor udfAnchor(OFBsnUdfAnchor value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfAnchor not supported in version 1.2");
+    }
+
+    public OFBsnTlvUdfId.Builder buildUdfId() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfId not supported in version 1.2");
+    }
+    public OFBsnTlvUdfId udfId(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfId not supported in version 1.2");
+    }
+
+    public OFBsnTlvUdfLength.Builder buildUdfLength() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfLength not supported in version 1.2");
+    }
+    public OFBsnTlvUdfLength udfLength(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfLength not supported in version 1.2");
+    }
+
+    public OFBsnTlvUdfOffset.Builder buildUdfOffset() {
+        throw new UnsupportedOperationException("OFBsnTlvUdfOffset not supported in version 1.2");
+    }
+    public OFBsnTlvUdfOffset udfOffset(int value) {
+        throw new UnsupportedOperationException("OFBsnTlvUdfOffset not supported in version 1.2");
+    }
+
+    public OFBsnTlvUnicastQueryTimeout.Builder buildUnicastQueryTimeout() {
+        throw new UnsupportedOperationException("OFBsnTlvUnicastQueryTimeout not supported in version 1.2");
+    }
+    public OFBsnTlvUnicastQueryTimeout unicastQueryTimeout(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvUnicastQueryTimeout not supported in version 1.2");
+    }
+
+    public OFBsnTlvVlanVid.Builder buildVlanVid() {
+        throw new UnsupportedOperationException("OFBsnTlvVlanVid not supported in version 1.2");
+    }
+    public OFBsnTlvVlanVid vlanVid(VlanVid value) {
+        throw new UnsupportedOperationException("OFBsnTlvVlanVid not supported in version 1.2");
+    }
+
+    public OFBsnTlvVrf.Builder buildVrf() {
+        throw new UnsupportedOperationException("OFBsnTlvVrf not supported in version 1.2");
+    }
+    public OFBsnTlvVrf vrf(long value) {
+        throw new UnsupportedOperationException("OFBsnTlvVrf not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFBsnTlv> getReader() {
+        throw new UnsupportedOperationException("Reader<OFBsnTlv> not supported in version 1.2");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortCreateReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortCreateReplyVer12.java
new file mode 100644
index 0000000..38ed1df
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortCreateReplyVer12.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortCreateReplyVer12 implements OFBsnVirtualPortCreateReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortCreateReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static long DEFAULT_VPORT_NO = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final long vportNo;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortCreateReplyVer12 DEFAULT = new OFBsnVirtualPortCreateReplyVer12(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_VPORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortCreateReplyVer12(long xid, long status, long vportNo) {
+        this.xid = xid;
+        this.status = status;
+        this.vportNo = vportNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+
+
+    public OFBsnVirtualPortCreateReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortCreateReply.Builder {
+        final OFBsnVirtualPortCreateReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean vportNoSet;
+        private long vportNo;
+
+        BuilderWithParent(OFBsnVirtualPortCreateReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortCreateReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                long vportNo = this.vportNoSet ? this.vportNo : parentMessage.vportNo;
+
+                //
+                return new OFBsnVirtualPortCreateReplyVer12(
+                    xid,
+                    status,
+                    vportNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortCreateReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean vportNoSet;
+        private long vportNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortCreateReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            long vportNo = this.vportNoSet ? this.vportNo : DEFAULT_VPORT_NO;
+
+
+            return new OFBsnVirtualPortCreateReplyVer12(
+                    xid,
+                    status,
+                    vportNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortCreateReply> {
+        @Override
+        public OFBsnVirtualPortCreateReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x10L
+            int subtype = bb.readInt();
+            if(subtype != 0x10)
+                throw new OFParseError("Wrong subtype: Expected=0x10L(0x10L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            long vportNo = U32.f(bb.readInt());
+
+            OFBsnVirtualPortCreateReplyVer12 bsnVirtualPortCreateReplyVer12 = new OFBsnVirtualPortCreateReplyVer12(
+                    xid,
+                      status,
+                      vportNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortCreateReplyVer12);
+            return bsnVirtualPortCreateReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortCreateReplyVer12Funnel FUNNEL = new OFBsnVirtualPortCreateReplyVer12Funnel();
+    static class OFBsnVirtualPortCreateReplyVer12Funnel implements Funnel<OFBsnVirtualPortCreateReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortCreateReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x10L
+            sink.putInt(0x10);
+            sink.putLong(message.status);
+            sink.putLong(message.vportNo);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortCreateReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortCreateReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x10L
+            bb.writeInt(0x10);
+            bb.writeInt(U32.t(message.status));
+            bb.writeInt(U32.t(message.vportNo));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortCreateReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("vportNo=").append(vportNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortCreateReplyVer12 other = (OFBsnVirtualPortCreateReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if( vportNo != other.vportNo)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime *  (int) (vportNo ^ (vportNo >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortCreateRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortCreateRequestVer12.java
new file mode 100644
index 0000000..4c9aad6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortCreateRequestVer12.java
@@ -0,0 +1,369 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortCreateRequestVer12 implements OFBsnVirtualPortCreateRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortCreateRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFBsnVport vport;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortCreateRequestVer12(long xid, OFBsnVport vport) {
+        this.xid = xid;
+        this.vport = vport;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+
+
+    public OFBsnVirtualPortCreateRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortCreateRequest.Builder {
+        final OFBsnVirtualPortCreateRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportSet;
+        private OFBsnVport vport;
+
+        BuilderWithParent(OFBsnVirtualPortCreateRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setVport(OFBsnVport vport) {
+        this.vport = vport;
+        this.vportSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortCreateRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBsnVport vport = this.vportSet ? this.vport : parentMessage.vport;
+                if(vport == null)
+                    throw new NullPointerException("Property vport must not be null");
+
+                //
+                return new OFBsnVirtualPortCreateRequestVer12(
+                    xid,
+                    vport
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortCreateRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportSet;
+        private OFBsnVport vport;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setVport(OFBsnVport vport) {
+        this.vport = vport;
+        this.vportSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortCreateRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.vportSet)
+                throw new IllegalStateException("Property vport doesn't have default value -- must be set");
+            if(vport == null)
+                throw new NullPointerException("Property vport must not be null");
+
+
+            return new OFBsnVirtualPortCreateRequestVer12(
+                    xid,
+                    vport
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortCreateRequest> {
+        @Override
+        public OFBsnVirtualPortCreateRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xfL
+            int subtype = bb.readInt();
+            if(subtype != 0xf)
+                throw new OFParseError("Wrong subtype: Expected=0xfL(0xfL), got="+subtype);
+            OFBsnVport vport = OFBsnVportVer12.READER.readFrom(bb);
+
+            OFBsnVirtualPortCreateRequestVer12 bsnVirtualPortCreateRequestVer12 = new OFBsnVirtualPortCreateRequestVer12(
+                    xid,
+                      vport
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortCreateRequestVer12);
+            return bsnVirtualPortCreateRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortCreateRequestVer12Funnel FUNNEL = new OFBsnVirtualPortCreateRequestVer12Funnel();
+    static class OFBsnVirtualPortCreateRequestVer12Funnel implements Funnel<OFBsnVirtualPortCreateRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortCreateRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            sink.putInt(0xf);
+            message.vport.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortCreateRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortCreateRequestVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            bb.writeInt(0xf);
+            message.vport.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortCreateRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vport=").append(vport);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortCreateRequestVer12 other = (OFBsnVirtualPortCreateRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (vport == null) {
+            if (other.vport != null)
+                return false;
+        } else if (!vport.equals(other.vport))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((vport == null) ? 0 : vport.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortRemoveReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortRemoveReplyVer12.java
new file mode 100644
index 0000000..3cef891
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortRemoveReplyVer12.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortRemoveReplyVer12 implements OFBsnVirtualPortRemoveReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortRemoveReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortRemoveReplyVer12 DEFAULT = new OFBsnVirtualPortRemoveReplyVer12(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortRemoveReplyVer12(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnVirtualPortRemoveReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortRemoveReply.Builder {
+        final OFBsnVirtualPortRemoveReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnVirtualPortRemoveReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortRemoveReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnVirtualPortRemoveReplyVer12(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortRemoveReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortRemoveReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnVirtualPortRemoveReplyVer12(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortRemoveReply> {
+        @Override
+        public OFBsnVirtualPortRemoveReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1aL
+            int subtype = bb.readInt();
+            if(subtype != 0x1a)
+                throw new OFParseError("Wrong subtype: Expected=0x1aL(0x1aL), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnVirtualPortRemoveReplyVer12 bsnVirtualPortRemoveReplyVer12 = new OFBsnVirtualPortRemoveReplyVer12(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortRemoveReplyVer12);
+            return bsnVirtualPortRemoveReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortRemoveReplyVer12Funnel FUNNEL = new OFBsnVirtualPortRemoveReplyVer12Funnel();
+    static class OFBsnVirtualPortRemoveReplyVer12Funnel implements Funnel<OFBsnVirtualPortRemoveReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortRemoveReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1aL
+            sink.putInt(0x1a);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortRemoveReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortRemoveReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1aL
+            bb.writeInt(0x1a);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortRemoveReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortRemoveReplyVer12 other = (OFBsnVirtualPortRemoveReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortRemoveRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortRemoveRequestVer12.java
new file mode 100644
index 0000000..8ffc9f9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVirtualPortRemoveRequestVer12.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortRemoveRequestVer12 implements OFBsnVirtualPortRemoveRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortRemoveRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_VPORT_NO = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long vportNo;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortRemoveRequestVer12 DEFAULT = new OFBsnVirtualPortRemoveRequestVer12(
+        DEFAULT_XID, DEFAULT_VPORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortRemoveRequestVer12(long xid, long vportNo) {
+        this.xid = xid;
+        this.vportNo = vportNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+
+
+    public OFBsnVirtualPortRemoveRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortRemoveRequest.Builder {
+        final OFBsnVirtualPortRemoveRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportNoSet;
+        private long vportNo;
+
+        BuilderWithParent(OFBsnVirtualPortRemoveRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortRemoveRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long vportNo = this.vportNoSet ? this.vportNo : parentMessage.vportNo;
+
+                //
+                return new OFBsnVirtualPortRemoveRequestVer12(
+                    xid,
+                    vportNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortRemoveRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportNoSet;
+        private long vportNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortRemoveRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long vportNo = this.vportNoSet ? this.vportNo : DEFAULT_VPORT_NO;
+
+
+            return new OFBsnVirtualPortRemoveRequestVer12(
+                    xid,
+                    vportNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortRemoveRequest> {
+        @Override
+        public OFBsnVirtualPortRemoveRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x11L
+            int subtype = bb.readInt();
+            if(subtype != 0x11)
+                throw new OFParseError("Wrong subtype: Expected=0x11L(0x11L), got="+subtype);
+            long vportNo = U32.f(bb.readInt());
+
+            OFBsnVirtualPortRemoveRequestVer12 bsnVirtualPortRemoveRequestVer12 = new OFBsnVirtualPortRemoveRequestVer12(
+                    xid,
+                      vportNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortRemoveRequestVer12);
+            return bsnVirtualPortRemoveRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortRemoveRequestVer12Funnel FUNNEL = new OFBsnVirtualPortRemoveRequestVer12Funnel();
+    static class OFBsnVirtualPortRemoveRequestVer12Funnel implements Funnel<OFBsnVirtualPortRemoveRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortRemoveRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x11L
+            sink.putInt(0x11);
+            sink.putLong(message.vportNo);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortRemoveRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortRemoveRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x11L
+            bb.writeInt(0x11);
+            bb.writeInt(U32.t(message.vportNo));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortRemoveRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vportNo=").append(vportNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortRemoveRequestVer12 other = (OFBsnVirtualPortRemoveRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( vportNo != other.vportNo)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (vportNo ^ (vportNo >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportL2GreFlagsSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportL2GreFlagsSerializerVer12.java
new file mode 100644
index 0000000..d3f83a6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportL2GreFlagsSerializerVer12.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportL2GreFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFBsnVportL2GreFlagsSerializerVer12 {
+
+    public final static int BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL = 0x1;
+    public final static int BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL = 0x2;
+    public final static int BSN_VPORT_L2GRE_DSCP_COPY_VAL = 0x4;
+    public final static int BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL = 0x8;
+    public final static int BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL = 0x10;
+
+    public static Set<OFBsnVportL2GreFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFBsnVportL2GreFlags> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFBsnVportL2GreFlags> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFBsnVportL2GreFlags> ofWireValue(int val) {
+        EnumSet<OFBsnVportL2GreFlags> set = EnumSet.noneOf(OFBsnVportL2GreFlags.class);
+
+        if((val & BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID);
+        if((val & BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN);
+        if((val & BSN_VPORT_L2GRE_DSCP_COPY_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_COPY);
+        if((val & BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID);
+        if((val & BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFBsnVportL2GreFlags> set) {
+        int wireValue = 0;
+
+        for(OFBsnVportL2GreFlags e: set) {
+            switch(e) {
+                case BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_DSCP_ASSIGN:
+                    wireValue |= BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_DSCP_COPY:
+                    wireValue |= BSN_VPORT_L2GRE_DSCP_COPY_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_LOOPBACK_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFBsnVportL2GreFlags in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportL2GreVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportL2GreVer12.java
new file mode 100644
index 0000000..dd3b4cc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportL2GreVer12.java
@@ -0,0 +1,839 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVportL2GreVer12 implements OFBsnVportL2Gre {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVportL2GreVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 64;
+
+        private final static Set<OFBsnVportL2GreFlags> DEFAULT_FLAGS = ImmutableSet.<OFBsnVportL2GreFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static OFPort DEFAULT_LOOPBACK_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_LOCAL_MAC = MacAddress.NONE;
+        private final static MacAddress DEFAULT_NH_MAC = MacAddress.NONE;
+        private final static IPv4Address DEFAULT_SRC_IP = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_DST_IP = IPv4Address.NONE;
+        private final static short DEFAULT_DSCP = (short) 0x0;
+        private final static short DEFAULT_TTL = (short) 0x0;
+        private final static long DEFAULT_VPN = 0x0L;
+        private final static long DEFAULT_RATE_LIMIT = 0x0L;
+        private final static String DEFAULT_IF_NAME = "";
+
+    // OF message fields
+    private final Set<OFBsnVportL2GreFlags> flags;
+    private final OFPort portNo;
+    private final OFPort loopbackPortNo;
+    private final MacAddress localMac;
+    private final MacAddress nhMac;
+    private final IPv4Address srcIp;
+    private final IPv4Address dstIp;
+    private final short dscp;
+    private final short ttl;
+    private final long vpn;
+    private final long rateLimit;
+    private final String ifName;
+//
+    // Immutable default instance
+    final static OFBsnVportL2GreVer12 DEFAULT = new OFBsnVportL2GreVer12(
+        DEFAULT_FLAGS, DEFAULT_PORT_NO, DEFAULT_LOOPBACK_PORT_NO, DEFAULT_LOCAL_MAC, DEFAULT_NH_MAC, DEFAULT_SRC_IP, DEFAULT_DST_IP, DEFAULT_DSCP, DEFAULT_TTL, DEFAULT_VPN, DEFAULT_RATE_LIMIT, DEFAULT_IF_NAME
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVportL2GreVer12(Set<OFBsnVportL2GreFlags> flags, OFPort portNo, OFPort loopbackPortNo, MacAddress localMac, MacAddress nhMac, IPv4Address srcIp, IPv4Address dstIp, short dscp, short ttl, long vpn, long rateLimit, String ifName) {
+        this.flags = flags;
+        this.portNo = portNo;
+        this.loopbackPortNo = loopbackPortNo;
+        this.localMac = localMac;
+        this.nhMac = nhMac;
+        this.srcIp = srcIp;
+        this.dstIp = dstIp;
+        this.dscp = dscp;
+        this.ttl = ttl;
+        this.vpn = vpn;
+        this.rateLimit = rateLimit;
+        this.ifName = ifName;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFBsnVportL2Gre.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVportL2Gre.Builder {
+        final OFBsnVportL2GreVer12 parentMessage;
+
+        // OF message fields
+        private boolean flagsSet;
+        private Set<OFBsnVportL2GreFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean loopbackPortNoSet;
+        private OFPort loopbackPortNo;
+        private boolean localMacSet;
+        private MacAddress localMac;
+        private boolean nhMacSet;
+        private MacAddress nhMac;
+        private boolean srcIpSet;
+        private IPv4Address srcIp;
+        private boolean dstIpSet;
+        private IPv4Address dstIp;
+        private boolean dscpSet;
+        private short dscp;
+        private boolean ttlSet;
+        private short ttl;
+        private boolean vpnSet;
+        private long vpn;
+        private boolean rateLimitSet;
+        private long rateLimit;
+        private boolean ifNameSet;
+        private String ifName;
+
+        BuilderWithParent(OFBsnVportL2GreVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setFlags(Set<OFBsnVportL2GreFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLoopbackPortNo(OFPort loopbackPortNo) {
+        this.loopbackPortNo = loopbackPortNo;
+        this.loopbackPortNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLocalMac(MacAddress localMac) {
+        this.localMac = localMac;
+        this.localMacSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setNhMac(MacAddress nhMac) {
+        this.nhMac = nhMac;
+        this.nhMacSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setSrcIp(IPv4Address srcIp) {
+        this.srcIp = srcIp;
+        this.srcIpSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDstIp(IPv4Address dstIp) {
+        this.dstIp = dstIp;
+        this.dstIpSet = true;
+        return this;
+    }
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDscp(short dscp) {
+        this.dscp = dscp;
+        this.dscpSet = true;
+        return this;
+    }
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setTtl(short ttl) {
+        this.ttl = ttl;
+        this.ttlSet = true;
+        return this;
+    }
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setVpn(long vpn) {
+        this.vpn = vpn;
+        this.vpnSet = true;
+        return this;
+    }
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setRateLimit(long rateLimit) {
+        this.rateLimit = rateLimit;
+        this.rateLimitSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFBsnVportL2Gre build() {
+                Set<OFBsnVportL2GreFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                OFPort loopbackPortNo = this.loopbackPortNoSet ? this.loopbackPortNo : parentMessage.loopbackPortNo;
+                if(loopbackPortNo == null)
+                    throw new NullPointerException("Property loopbackPortNo must not be null");
+                MacAddress localMac = this.localMacSet ? this.localMac : parentMessage.localMac;
+                if(localMac == null)
+                    throw new NullPointerException("Property localMac must not be null");
+                MacAddress nhMac = this.nhMacSet ? this.nhMac : parentMessage.nhMac;
+                if(nhMac == null)
+                    throw new NullPointerException("Property nhMac must not be null");
+                IPv4Address srcIp = this.srcIpSet ? this.srcIp : parentMessage.srcIp;
+                if(srcIp == null)
+                    throw new NullPointerException("Property srcIp must not be null");
+                IPv4Address dstIp = this.dstIpSet ? this.dstIp : parentMessage.dstIp;
+                if(dstIp == null)
+                    throw new NullPointerException("Property dstIp must not be null");
+                short dscp = this.dscpSet ? this.dscp : parentMessage.dscp;
+                short ttl = this.ttlSet ? this.ttl : parentMessage.ttl;
+                long vpn = this.vpnSet ? this.vpn : parentMessage.vpn;
+                long rateLimit = this.rateLimitSet ? this.rateLimit : parentMessage.rateLimit;
+                String ifName = this.ifNameSet ? this.ifName : parentMessage.ifName;
+                if(ifName == null)
+                    throw new NullPointerException("Property ifName must not be null");
+
+                //
+                return new OFBsnVportL2GreVer12(
+                    flags,
+                    portNo,
+                    loopbackPortNo,
+                    localMac,
+                    nhMac,
+                    srcIp,
+                    dstIp,
+                    dscp,
+                    ttl,
+                    vpn,
+                    rateLimit,
+                    ifName
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVportL2Gre.Builder {
+        // OF message fields
+        private boolean flagsSet;
+        private Set<OFBsnVportL2GreFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean loopbackPortNoSet;
+        private OFPort loopbackPortNo;
+        private boolean localMacSet;
+        private MacAddress localMac;
+        private boolean nhMacSet;
+        private MacAddress nhMac;
+        private boolean srcIpSet;
+        private IPv4Address srcIp;
+        private boolean dstIpSet;
+        private IPv4Address dstIp;
+        private boolean dscpSet;
+        private short dscp;
+        private boolean ttlSet;
+        private short ttl;
+        private boolean vpnSet;
+        private long vpn;
+        private boolean rateLimitSet;
+        private long rateLimit;
+        private boolean ifNameSet;
+        private String ifName;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setFlags(Set<OFBsnVportL2GreFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLoopbackPortNo(OFPort loopbackPortNo) {
+        this.loopbackPortNo = loopbackPortNo;
+        this.loopbackPortNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLocalMac(MacAddress localMac) {
+        this.localMac = localMac;
+        this.localMacSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setNhMac(MacAddress nhMac) {
+        this.nhMac = nhMac;
+        this.nhMacSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setSrcIp(IPv4Address srcIp) {
+        this.srcIp = srcIp;
+        this.srcIpSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDstIp(IPv4Address dstIp) {
+        this.dstIp = dstIp;
+        this.dstIpSet = true;
+        return this;
+    }
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDscp(short dscp) {
+        this.dscp = dscp;
+        this.dscpSet = true;
+        return this;
+    }
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setTtl(short ttl) {
+        this.ttl = ttl;
+        this.ttlSet = true;
+        return this;
+    }
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setVpn(long vpn) {
+        this.vpn = vpn;
+        this.vpnSet = true;
+        return this;
+    }
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setRateLimit(long rateLimit) {
+        this.rateLimit = rateLimit;
+        this.rateLimitSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFBsnVportL2Gre build() {
+            Set<OFBsnVportL2GreFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            OFPort loopbackPortNo = this.loopbackPortNoSet ? this.loopbackPortNo : DEFAULT_LOOPBACK_PORT_NO;
+            if(loopbackPortNo == null)
+                throw new NullPointerException("Property loopbackPortNo must not be null");
+            MacAddress localMac = this.localMacSet ? this.localMac : DEFAULT_LOCAL_MAC;
+            if(localMac == null)
+                throw new NullPointerException("Property localMac must not be null");
+            MacAddress nhMac = this.nhMacSet ? this.nhMac : DEFAULT_NH_MAC;
+            if(nhMac == null)
+                throw new NullPointerException("Property nhMac must not be null");
+            IPv4Address srcIp = this.srcIpSet ? this.srcIp : DEFAULT_SRC_IP;
+            if(srcIp == null)
+                throw new NullPointerException("Property srcIp must not be null");
+            IPv4Address dstIp = this.dstIpSet ? this.dstIp : DEFAULT_DST_IP;
+            if(dstIp == null)
+                throw new NullPointerException("Property dstIp must not be null");
+            short dscp = this.dscpSet ? this.dscp : DEFAULT_DSCP;
+            short ttl = this.ttlSet ? this.ttl : DEFAULT_TTL;
+            long vpn = this.vpnSet ? this.vpn : DEFAULT_VPN;
+            long rateLimit = this.rateLimitSet ? this.rateLimit : DEFAULT_RATE_LIMIT;
+            String ifName = this.ifNameSet ? this.ifName : DEFAULT_IF_NAME;
+            if(ifName == null)
+                throw new NullPointerException("Property ifName must not be null");
+
+
+            return new OFBsnVportL2GreVer12(
+                    flags,
+                    portNo,
+                    loopbackPortNo,
+                    localMac,
+                    nhMac,
+                    srcIp,
+                    dstIp,
+                    dscp,
+                    ttl,
+                    vpn,
+                    rateLimit,
+                    ifName
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVportL2Gre> {
+        @Override
+        public OFBsnVportL2Gre readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 64)
+                throw new OFParseError("Wrong length: Expected=64(64), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            Set<OFBsnVportL2GreFlags> flags = OFBsnVportL2GreFlagsSerializerVer12.readFrom(bb);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            OFPort loopbackPortNo = OFPort.read4Bytes(bb);
+            MacAddress localMac = MacAddress.read6Bytes(bb);
+            MacAddress nhMac = MacAddress.read6Bytes(bb);
+            IPv4Address srcIp = IPv4Address.read4Bytes(bb);
+            IPv4Address dstIp = IPv4Address.read4Bytes(bb);
+            short dscp = U8.f(bb.readByte());
+            short ttl = U8.f(bb.readByte());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long vpn = U32.f(bb.readInt());
+            long rateLimit = U32.f(bb.readInt());
+            String ifName = ChannelUtils.readFixedLengthString(bb, 16);
+
+            OFBsnVportL2GreVer12 bsnVportL2GreVer12 = new OFBsnVportL2GreVer12(
+                    flags,
+                      portNo,
+                      loopbackPortNo,
+                      localMac,
+                      nhMac,
+                      srcIp,
+                      dstIp,
+                      dscp,
+                      ttl,
+                      vpn,
+                      rateLimit,
+                      ifName
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVportL2GreVer12);
+            return bsnVportL2GreVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVportL2GreVer12Funnel FUNNEL = new OFBsnVportL2GreVer12Funnel();
+    static class OFBsnVportL2GreVer12Funnel implements Funnel<OFBsnVportL2GreVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVportL2GreVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 64
+            sink.putShort((short) 0x40);
+            OFBsnVportL2GreFlagsSerializerVer12.putTo(message.flags, sink);
+            message.portNo.putTo(sink);
+            message.loopbackPortNo.putTo(sink);
+            message.localMac.putTo(sink);
+            message.nhMac.putTo(sink);
+            message.srcIp.putTo(sink);
+            message.dstIp.putTo(sink);
+            sink.putShort(message.dscp);
+            sink.putShort(message.ttl);
+            // skip pad (2 bytes)
+            sink.putLong(message.vpn);
+            sink.putLong(message.rateLimit);
+            sink.putUnencodedChars(message.ifName);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVportL2GreVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVportL2GreVer12 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 64
+            bb.writeShort((short) 0x40);
+            OFBsnVportL2GreFlagsSerializerVer12.writeTo(bb, message.flags);
+            message.portNo.write4Bytes(bb);
+            message.loopbackPortNo.write4Bytes(bb);
+            message.localMac.write6Bytes(bb);
+            message.nhMac.write6Bytes(bb);
+            message.srcIp.write4Bytes(bb);
+            message.dstIp.write4Bytes(bb);
+            bb.writeByte(U8.t(message.dscp));
+            bb.writeByte(U8.t(message.ttl));
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.vpn));
+            bb.writeInt(U32.t(message.rateLimit));
+            ChannelUtils.writeFixedLengthString(bb, message.ifName, 16);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVportL2GreVer12(");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("loopbackPortNo=").append(loopbackPortNo);
+        b.append(", ");
+        b.append("localMac=").append(localMac);
+        b.append(", ");
+        b.append("nhMac=").append(nhMac);
+        b.append(", ");
+        b.append("srcIp=").append(srcIp);
+        b.append(", ");
+        b.append("dstIp=").append(dstIp);
+        b.append(", ");
+        b.append("dscp=").append(dscp);
+        b.append(", ");
+        b.append("ttl=").append(ttl);
+        b.append(", ");
+        b.append("vpn=").append(vpn);
+        b.append(", ");
+        b.append("rateLimit=").append(rateLimit);
+        b.append(", ");
+        b.append("ifName=").append(ifName);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVportL2GreVer12 other = (OFBsnVportL2GreVer12) obj;
+
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (loopbackPortNo == null) {
+            if (other.loopbackPortNo != null)
+                return false;
+        } else if (!loopbackPortNo.equals(other.loopbackPortNo))
+            return false;
+        if (localMac == null) {
+            if (other.localMac != null)
+                return false;
+        } else if (!localMac.equals(other.localMac))
+            return false;
+        if (nhMac == null) {
+            if (other.nhMac != null)
+                return false;
+        } else if (!nhMac.equals(other.nhMac))
+            return false;
+        if (srcIp == null) {
+            if (other.srcIp != null)
+                return false;
+        } else if (!srcIp.equals(other.srcIp))
+            return false;
+        if (dstIp == null) {
+            if (other.dstIp != null)
+                return false;
+        } else if (!dstIp.equals(other.dstIp))
+            return false;
+        if( dscp != other.dscp)
+            return false;
+        if( ttl != other.ttl)
+            return false;
+        if( vpn != other.vpn)
+            return false;
+        if( rateLimit != other.rateLimit)
+            return false;
+        if (ifName == null) {
+            if (other.ifName != null)
+                return false;
+        } else if (!ifName.equals(other.ifName))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((loopbackPortNo == null) ? 0 : loopbackPortNo.hashCode());
+        result = prime * result + ((localMac == null) ? 0 : localMac.hashCode());
+        result = prime * result + ((nhMac == null) ? 0 : nhMac.hashCode());
+        result = prime * result + ((srcIp == null) ? 0 : srcIp.hashCode());
+        result = prime * result + ((dstIp == null) ? 0 : dstIp.hashCode());
+        result = prime * result + dscp;
+        result = prime * result + ttl;
+        result = prime *  (int) (vpn ^ (vpn >>> 32));
+        result = prime *  (int) (rateLimit ^ (rateLimit >>> 32));
+        result = prime * result + ((ifName == null) ? 0 : ifName.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportQInQUntaggedSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportQInQUntaggedSerializerVer12.java
new file mode 100644
index 0000000..4b47458
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportQInQUntaggedSerializerVer12.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportQInQUntagged;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVportQInQUntaggedSerializerVer12 {
+
+    public final static short BSN_VPORT_Q_IN_Q_UNTAGGED_VAL = (short) 0xffff;
+
+    public static OFBsnVportQInQUntagged readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVportQInQUntagged e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnVportQInQUntagged e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVportQInQUntagged ofWireValue(short val) {
+        switch(val) {
+            case BSN_VPORT_Q_IN_Q_UNTAGGED_VAL:
+                return OFBsnVportQInQUntagged.BSN_VPORT_Q_IN_Q_UNTAGGED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVportQInQUntagged in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVportQInQUntagged e) {
+        switch(e) {
+            case BSN_VPORT_Q_IN_Q_UNTAGGED:
+                return BSN_VPORT_Q_IN_Q_UNTAGGED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVportQInQUntagged in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportQInQVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportQInQVer12.java
new file mode 100644
index 0000000..666c5fb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportQInQVer12.java
@@ -0,0 +1,502 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVportQInQVer12 implements OFBsnVportQInQ {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVportQInQVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_PORT_NO = 0x0L;
+        private final static int DEFAULT_INGRESS_TPID = 0x0;
+        private final static int DEFAULT_INGRESS_VLAN_ID = 0x0;
+        private final static int DEFAULT_EGRESS_TPID = 0x0;
+        private final static int DEFAULT_EGRESS_VLAN_ID = 0x0;
+        private final static String DEFAULT_IF_NAME = "";
+
+    // OF message fields
+    private final long portNo;
+    private final int ingressTpid;
+    private final int ingressVlanId;
+    private final int egressTpid;
+    private final int egressVlanId;
+    private final String ifName;
+//
+    // Immutable default instance
+    final static OFBsnVportQInQVer12 DEFAULT = new OFBsnVportQInQVer12(
+        DEFAULT_PORT_NO, DEFAULT_INGRESS_TPID, DEFAULT_INGRESS_VLAN_ID, DEFAULT_EGRESS_TPID, DEFAULT_EGRESS_VLAN_ID, DEFAULT_IF_NAME
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVportQInQVer12(long portNo, int ingressTpid, int ingressVlanId, int egressTpid, int egressVlanId, String ifName) {
+        this.portNo = portNo;
+        this.ingressTpid = ingressTpid;
+        this.ingressVlanId = ingressVlanId;
+        this.egressTpid = egressTpid;
+        this.egressVlanId = egressVlanId;
+        this.ifName = ifName;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFBsnVportQInQ.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVportQInQ.Builder {
+        final OFBsnVportQInQVer12 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private long portNo;
+        private boolean ingressTpidSet;
+        private int ingressTpid;
+        private boolean ingressVlanIdSet;
+        private int ingressVlanId;
+        private boolean egressTpidSet;
+        private int egressTpid;
+        private boolean egressVlanIdSet;
+        private int egressVlanId;
+        private boolean ifNameSet;
+        private String ifName;
+
+        BuilderWithParent(OFBsnVportQInQVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setPortNo(long portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressTpid(int ingressTpid) {
+        this.ingressTpid = ingressTpid;
+        this.ingressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressVlanId(int ingressVlanId) {
+        this.ingressVlanId = ingressVlanId;
+        this.ingressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressTpid(int egressTpid) {
+        this.egressTpid = egressTpid;
+        this.egressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressVlanId(int egressVlanId) {
+        this.egressVlanId = egressVlanId;
+        this.egressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFBsnVportQInQ build() {
+                long portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                int ingressTpid = this.ingressTpidSet ? this.ingressTpid : parentMessage.ingressTpid;
+                int ingressVlanId = this.ingressVlanIdSet ? this.ingressVlanId : parentMessage.ingressVlanId;
+                int egressTpid = this.egressTpidSet ? this.egressTpid : parentMessage.egressTpid;
+                int egressVlanId = this.egressVlanIdSet ? this.egressVlanId : parentMessage.egressVlanId;
+                String ifName = this.ifNameSet ? this.ifName : parentMessage.ifName;
+                if(ifName == null)
+                    throw new NullPointerException("Property ifName must not be null");
+
+                //
+                return new OFBsnVportQInQVer12(
+                    portNo,
+                    ingressTpid,
+                    ingressVlanId,
+                    egressTpid,
+                    egressVlanId,
+                    ifName
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVportQInQ.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private long portNo;
+        private boolean ingressTpidSet;
+        private int ingressTpid;
+        private boolean ingressVlanIdSet;
+        private int ingressVlanId;
+        private boolean egressTpidSet;
+        private int egressTpid;
+        private boolean egressVlanIdSet;
+        private int egressVlanId;
+        private boolean ifNameSet;
+        private String ifName;
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setPortNo(long portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressTpid(int ingressTpid) {
+        this.ingressTpid = ingressTpid;
+        this.ingressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressVlanId(int ingressVlanId) {
+        this.ingressVlanId = ingressVlanId;
+        this.ingressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressTpid(int egressTpid) {
+        this.egressTpid = egressTpid;
+        this.egressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressVlanId(int egressVlanId) {
+        this.egressVlanId = egressVlanId;
+        this.egressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFBsnVportQInQ build() {
+            long portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            int ingressTpid = this.ingressTpidSet ? this.ingressTpid : DEFAULT_INGRESS_TPID;
+            int ingressVlanId = this.ingressVlanIdSet ? this.ingressVlanId : DEFAULT_INGRESS_VLAN_ID;
+            int egressTpid = this.egressTpidSet ? this.egressTpid : DEFAULT_EGRESS_TPID;
+            int egressVlanId = this.egressVlanIdSet ? this.egressVlanId : DEFAULT_EGRESS_VLAN_ID;
+            String ifName = this.ifNameSet ? this.ifName : DEFAULT_IF_NAME;
+            if(ifName == null)
+                throw new NullPointerException("Property ifName must not be null");
+
+
+            return new OFBsnVportQInQVer12(
+                    portNo,
+                    ingressTpid,
+                    ingressVlanId,
+                    egressTpid,
+                    egressVlanId,
+                    ifName
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVportQInQ> {
+        @Override
+        public OFBsnVportQInQ readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=0x0(0x0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long portNo = U32.f(bb.readInt());
+            int ingressTpid = U16.f(bb.readShort());
+            int ingressVlanId = U16.f(bb.readShort());
+            int egressTpid = U16.f(bb.readShort());
+            int egressVlanId = U16.f(bb.readShort());
+            String ifName = ChannelUtils.readFixedLengthString(bb, 16);
+
+            OFBsnVportQInQVer12 bsnVportQInQVer12 = new OFBsnVportQInQVer12(
+                    portNo,
+                      ingressTpid,
+                      ingressVlanId,
+                      egressTpid,
+                      egressVlanId,
+                      ifName
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVportQInQVer12);
+            return bsnVportQInQVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVportQInQVer12Funnel FUNNEL = new OFBsnVportQInQVer12Funnel();
+    static class OFBsnVportQInQVer12Funnel implements Funnel<OFBsnVportQInQVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVportQInQVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 0x0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.portNo);
+            sink.putInt(message.ingressTpid);
+            sink.putInt(message.ingressVlanId);
+            sink.putInt(message.egressTpid);
+            sink.putInt(message.egressVlanId);
+            sink.putUnencodedChars(message.ifName);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVportQInQVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVportQInQVer12 message) {
+            // fixed value property type = 0x0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.portNo));
+            bb.writeShort(U16.t(message.ingressTpid));
+            bb.writeShort(U16.t(message.ingressVlanId));
+            bb.writeShort(U16.t(message.egressTpid));
+            bb.writeShort(U16.t(message.egressVlanId));
+            ChannelUtils.writeFixedLengthString(bb, message.ifName, 16);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVportQInQVer12(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("ingressTpid=").append(ingressTpid);
+        b.append(", ");
+        b.append("ingressVlanId=").append(ingressVlanId);
+        b.append(", ");
+        b.append("egressTpid=").append(egressTpid);
+        b.append(", ");
+        b.append("egressVlanId=").append(egressVlanId);
+        b.append(", ");
+        b.append("ifName=").append(ifName);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVportQInQVer12 other = (OFBsnVportQInQVer12) obj;
+
+        if( portNo != other.portNo)
+            return false;
+        if( ingressTpid != other.ingressTpid)
+            return false;
+        if( ingressVlanId != other.ingressVlanId)
+            return false;
+        if( egressTpid != other.egressTpid)
+            return false;
+        if( egressVlanId != other.egressVlanId)
+            return false;
+        if (ifName == null) {
+            if (other.ifName != null)
+                return false;
+        } else if (!ifName.equals(other.ifName))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (portNo ^ (portNo >>> 32));
+        result = prime * result + ingressTpid;
+        result = prime * result + ingressVlanId;
+        result = prime * result + egressTpid;
+        result = prime * result + egressVlanId;
+        result = prime * result + ((ifName == null) ? 0 : ifName.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportStatusSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportStatusSerializerVer12.java
new file mode 100644
index 0000000..e30e8f2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportStatusSerializerVer12.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportStatus;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVportStatusSerializerVer12 {
+
+    public final static short BSN_VPORT_STATUS_OK_VAL = (short) 0x0;
+    public final static short BSN_VPORT_STATUS_FAILED_VAL = (short) 0x1;
+
+    public static OFBsnVportStatus readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(U8.f(bb.readByte()));
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVportStatus e) {
+        bb.writeByte(U8.t(toWireValue(e)));
+    }
+
+    public static void putTo(OFBsnVportStatus e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVportStatus ofWireValue(short val) {
+        switch(val) {
+            case BSN_VPORT_STATUS_OK_VAL:
+                return OFBsnVportStatus.BSN_VPORT_STATUS_OK;
+            case BSN_VPORT_STATUS_FAILED_VAL:
+                return OFBsnVportStatus.BSN_VPORT_STATUS_FAILED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVportStatus in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVportStatus e) {
+        switch(e) {
+            case BSN_VPORT_STATUS_OK:
+                return BSN_VPORT_STATUS_OK_VAL;
+            case BSN_VPORT_STATUS_FAILED:
+                return BSN_VPORT_STATUS_FAILED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVportStatus in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportVer12.java
new file mode 100644
index 0000000..8ec1bce8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBsnVportVer12.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnVportVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFBsnVportVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnVport> {
+        @Override
+        public OFBsnVport readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFBsnVportL2GreVer12
+                   return OFBsnVportL2GreVer12.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value 0x0=0x0 for class OFBsnVportQInQVer12
+                   return OFBsnVportQInQVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFBsnVportVer12: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBucketCounterVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBucketCounterVer12.java
new file mode 100644
index 0000000..3a3cfdc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBucketCounterVer12.java
@@ -0,0 +1,283 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBucketCounterVer12 implements OFBucketCounter {
+    private static final Logger logger = LoggerFactory.getLogger(OFBucketCounterVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final U64 packetCount;
+    private final U64 byteCount;
+//
+    // Immutable default instance
+    final static OFBucketCounterVer12 DEFAULT = new OFBucketCounterVer12(
+        DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBucketCounterVer12(U64 packetCount, U64 byteCount) {
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFBucketCounter.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBucketCounter.Builder {
+        final OFBucketCounterVer12 parentMessage;
+
+        // OF message fields
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+
+        BuilderWithParent(OFBucketCounterVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFBucketCounter build() {
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+
+                //
+                return new OFBucketCounterVer12(
+                    packetCount,
+                    byteCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFBucketCounter.Builder {
+        // OF message fields
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFBucketCounter build() {
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+
+
+            return new OFBucketCounterVer12(
+                    packetCount,
+                    byteCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBucketCounter> {
+        @Override
+        public OFBucketCounter readFrom(ChannelBuffer bb) throws OFParseError {
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+
+            OFBucketCounterVer12 bucketCounterVer12 = new OFBucketCounterVer12(
+                    packetCount,
+                      byteCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bucketCounterVer12);
+            return bucketCounterVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBucketCounterVer12Funnel FUNNEL = new OFBucketCounterVer12Funnel();
+    static class OFBucketCounterVer12Funnel implements Funnel<OFBucketCounterVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBucketCounterVer12 message, PrimitiveSink sink) {
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBucketCounterVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBucketCounterVer12 message) {
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBucketCounterVer12(");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBucketCounterVer12 other = (OFBucketCounterVer12) obj;
+
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBucketVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBucketVer12.java
new file mode 100644
index 0000000..a2eb477
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFBucketVer12.java
@@ -0,0 +1,411 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBucketVer12 implements OFBucket {
+    private static final Logger logger = LoggerFactory.getLogger(OFBucketVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static int DEFAULT_WEIGHT = 0x0;
+        private final static OFPort DEFAULT_WATCH_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_WATCH_GROUP = OFGroup.ALL;
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final int weight;
+    private final OFPort watchPort;
+    private final OFGroup watchGroup;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFBucketVer12 DEFAULT = new OFBucketVer12(
+        DEFAULT_WEIGHT, DEFAULT_WATCH_PORT, DEFAULT_WATCH_GROUP, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBucketVer12(int weight, OFPort watchPort, OFGroup watchGroup, List<OFAction> actions) {
+        this.weight = weight;
+        this.watchPort = watchPort;
+        this.watchGroup = watchGroup;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFBucket.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBucket.Builder {
+        final OFBucketVer12 parentMessage;
+
+        // OF message fields
+        private boolean weightSet;
+        private int weight;
+        private boolean watchPortSet;
+        private OFPort watchPort;
+        private boolean watchGroupSet;
+        private OFGroup watchGroup;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFBucketVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFBucket.Builder setWeight(int weight) {
+        this.weight = weight;
+        this.weightSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchPort(OFPort watchPort) {
+        this.watchPort = watchPort;
+        this.watchPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchGroup(OFGroup watchGroup) {
+        this.watchGroup = watchGroup;
+        this.watchGroupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFBucket.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFBucket build() {
+                int weight = this.weightSet ? this.weight : parentMessage.weight;
+                OFPort watchPort = this.watchPortSet ? this.watchPort : parentMessage.watchPort;
+                if(watchPort == null)
+                    throw new NullPointerException("Property watchPort must not be null");
+                OFGroup watchGroup = this.watchGroupSet ? this.watchGroup : parentMessage.watchGroup;
+                if(watchGroup == null)
+                    throw new NullPointerException("Property watchGroup must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFBucketVer12(
+                    weight,
+                    watchPort,
+                    watchGroup,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFBucket.Builder {
+        // OF message fields
+        private boolean weightSet;
+        private int weight;
+        private boolean watchPortSet;
+        private OFPort watchPort;
+        private boolean watchGroupSet;
+        private OFGroup watchGroup;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFBucket.Builder setWeight(int weight) {
+        this.weight = weight;
+        this.weightSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchPort(OFPort watchPort) {
+        this.watchPort = watchPort;
+        this.watchPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchGroup(OFGroup watchGroup) {
+        this.watchGroup = watchGroup;
+        this.watchGroupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFBucket.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFBucket build() {
+            int weight = this.weightSet ? this.weight : DEFAULT_WEIGHT;
+            OFPort watchPort = this.watchPortSet ? this.watchPort : DEFAULT_WATCH_PORT;
+            if(watchPort == null)
+                throw new NullPointerException("Property watchPort must not be null");
+            OFGroup watchGroup = this.watchGroupSet ? this.watchGroup : DEFAULT_WATCH_GROUP;
+            if(watchGroup == null)
+                throw new NullPointerException("Property watchGroup must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFBucketVer12(
+                    weight,
+                    watchPort,
+                    watchGroup,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBucket> {
+        @Override
+        public OFBucket readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int weight = U16.f(bb.readShort());
+            OFPort watchPort = OFPort.read4Bytes(bb);
+            OFGroup watchGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer12.READER);
+
+            OFBucketVer12 bucketVer12 = new OFBucketVer12(
+                    weight,
+                      watchPort,
+                      watchGroup,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bucketVer12);
+            return bucketVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBucketVer12Funnel FUNNEL = new OFBucketVer12Funnel();
+    static class OFBucketVer12Funnel implements Funnel<OFBucketVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBucketVer12 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            sink.putInt(message.weight);
+            message.watchPort.putTo(sink);
+            message.watchGroup.putTo(sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBucketVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFBucketVer12 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeShort(U16.t(message.weight));
+            message.watchPort.write4Bytes(bb);
+            message.watchGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBucketVer12(");
+        b.append("weight=").append(weight);
+        b.append(", ");
+        b.append("watchPort=").append(watchPort);
+        b.append(", ");
+        b.append("watchGroup=").append(watchGroup);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBucketVer12 other = (OFBucketVer12) obj;
+
+        if( weight != other.weight)
+            return false;
+        if (watchPort == null) {
+            if (other.watchPort != null)
+                return false;
+        } else if (!watchPort.equals(other.watchPort))
+            return false;
+        if (watchGroup == null) {
+            if (other.watchGroup != null)
+                return false;
+        } else if (!watchGroup.equals(other.watchGroup))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + weight;
+        result = prime * result + ((watchPort == null) ? 0 : watchPort.hashCode());
+        result = prime * result + ((watchGroup == null) ? 0 : watchGroup.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFCapabilitiesSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFCapabilitiesSerializerVer12.java
new file mode 100644
index 0000000..a182ea7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFCapabilitiesSerializerVer12.java
@@ -0,0 +1,114 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFCapabilities;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFCapabilitiesSerializerVer12 {
+
+    public final static int FLOW_STATS_VAL = 0x1;
+    public final static int TABLE_STATS_VAL = 0x2;
+    public final static int PORT_STATS_VAL = 0x4;
+    public final static int IP_REASM_VAL = 0x20;
+    public final static int QUEUE_STATS_VAL = 0x40;
+    public final static int GROUP_STATS_VAL = 0x8;
+    public final static int PORT_BLOCKED_VAL = 0x100;
+
+    public static Set<OFCapabilities> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFCapabilities> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFCapabilities> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFCapabilities> ofWireValue(int val) {
+        EnumSet<OFCapabilities> set = EnumSet.noneOf(OFCapabilities.class);
+
+        if((val & FLOW_STATS_VAL) != 0)
+            set.add(OFCapabilities.FLOW_STATS);
+        if((val & TABLE_STATS_VAL) != 0)
+            set.add(OFCapabilities.TABLE_STATS);
+        if((val & PORT_STATS_VAL) != 0)
+            set.add(OFCapabilities.PORT_STATS);
+        if((val & IP_REASM_VAL) != 0)
+            set.add(OFCapabilities.IP_REASM);
+        if((val & QUEUE_STATS_VAL) != 0)
+            set.add(OFCapabilities.QUEUE_STATS);
+        if((val & GROUP_STATS_VAL) != 0)
+            set.add(OFCapabilities.GROUP_STATS);
+        if((val & PORT_BLOCKED_VAL) != 0)
+            set.add(OFCapabilities.PORT_BLOCKED);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFCapabilities> set) {
+        int wireValue = 0;
+
+        for(OFCapabilities e: set) {
+            switch(e) {
+                case FLOW_STATS:
+                    wireValue |= FLOW_STATS_VAL;
+                    break;
+                case TABLE_STATS:
+                    wireValue |= TABLE_STATS_VAL;
+                    break;
+                case PORT_STATS:
+                    wireValue |= PORT_STATS_VAL;
+                    break;
+                case IP_REASM:
+                    wireValue |= IP_REASM_VAL;
+                    break;
+                case QUEUE_STATS:
+                    wireValue |= QUEUE_STATS_VAL;
+                    break;
+                case GROUP_STATS:
+                    wireValue |= GROUP_STATS_VAL;
+                    break;
+                case PORT_BLOCKED:
+                    wireValue |= PORT_BLOCKED_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFCapabilities in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFConfigFlagsSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFConfigFlagsSerializerVer12.java
new file mode 100644
index 0000000..60b10cf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFConfigFlagsSerializerVer12.java
@@ -0,0 +1,97 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFConfigFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFConfigFlagsSerializerVer12 {
+
+    public final static short FRAG_NORMAL_VAL = (short) 0x0;
+    public final static short FRAG_DROP_VAL = (short) 0x1;
+    public final static short FRAG_REASM_VAL = (short) 0x2;
+    public final static short FRAG_MASK_VAL = (short) 0x3;
+    public final static short INVALID_TTL_TO_CONTROLLER_VAL = (short) 0x4;
+
+    public static Set<OFConfigFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFConfigFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFConfigFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFConfigFlags> ofWireValue(short val) {
+        EnumSet<OFConfigFlags> set = EnumSet.noneOf(OFConfigFlags.class);
+
+        if((val & FRAG_MASK_VAL) == FRAG_NORMAL_VAL)
+            set.add(OFConfigFlags.FRAG_NORMAL);
+        else if((val & FRAG_MASK_VAL) == FRAG_DROP_VAL)
+            set.add(OFConfigFlags.FRAG_DROP);
+        else if((val & FRAG_MASK_VAL) == FRAG_REASM_VAL)
+            set.add(OFConfigFlags.FRAG_REASM);
+        if((val & INVALID_TTL_TO_CONTROLLER_VAL) != 0)
+            set.add(OFConfigFlags.INVALID_TTL_TO_CONTROLLER);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFConfigFlags> set) {
+        short wireValue = 0;
+
+        for(OFConfigFlags e: set) {
+            switch(e) {
+                case FRAG_NORMAL:
+                    wireValue |= FRAG_NORMAL_VAL;
+                    break;
+                case FRAG_DROP:
+                    wireValue |= FRAG_DROP_VAL;
+                    break;
+                case FRAG_REASM:
+                    wireValue |= FRAG_REASM_VAL;
+                    break;
+                case INVALID_TTL_TO_CONTROLLER:
+                    wireValue |= INVALID_TTL_TO_CONTROLLER_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFConfigFlags in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFControllerMaxLenSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFControllerMaxLenSerializerVer12.java
new file mode 100644
index 0000000..9e8bebf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFControllerMaxLenSerializerVer12.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFControllerMaxLen;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFControllerMaxLenSerializerVer12 {
+
+    public final static short MAX_VAL = (short) 0xffe5;
+    public final static short NO_BUFFER_VAL = (short) 0xffff;
+
+    public static OFControllerMaxLen readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFControllerMaxLen e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFControllerMaxLen e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFControllerMaxLen ofWireValue(short val) {
+        switch(val) {
+            case MAX_VAL:
+                return OFControllerMaxLen.MAX;
+            case NO_BUFFER_VAL:
+                return OFControllerMaxLen.NO_BUFFER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFControllerMaxLen in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFControllerMaxLen e) {
+        switch(e) {
+            case MAX:
+                return MAX_VAL;
+            case NO_BUFFER:
+                return NO_BUFFER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFControllerMaxLen in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFControllerRoleSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFControllerRoleSerializerVer12.java
new file mode 100644
index 0000000..b005f2c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFControllerRoleSerializerVer12.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFControllerRole;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFControllerRoleSerializerVer12 {
+
+    public final static int ROLE_NOCHANGE_VAL = 0x0;
+    public final static int ROLE_EQUAL_VAL = 0x1;
+    public final static int ROLE_MASTER_VAL = 0x2;
+    public final static int ROLE_SLAVE_VAL = 0x3;
+
+    public static OFControllerRole readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFControllerRole e) {
+        bb.writeInt(toWireValue(e));
+    }
+
+    public static void putTo(OFControllerRole e, PrimitiveSink sink) {
+        sink.putInt(toWireValue(e));
+    }
+
+    public static OFControllerRole ofWireValue(int val) {
+        switch(val) {
+            case ROLE_NOCHANGE_VAL:
+                return OFControllerRole.ROLE_NOCHANGE;
+            case ROLE_EQUAL_VAL:
+                return OFControllerRole.ROLE_EQUAL;
+            case ROLE_MASTER_VAL:
+                return OFControllerRole.ROLE_MASTER;
+            case ROLE_SLAVE_VAL:
+                return OFControllerRole.ROLE_SLAVE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFControllerRole in version 1.2: " + val);
+        }
+    }
+
+
+    public static int toWireValue(OFControllerRole e) {
+        switch(e) {
+            case ROLE_NOCHANGE:
+                return ROLE_NOCHANGE_VAL;
+            case ROLE_EQUAL:
+                return ROLE_EQUAL_VAL;
+            case ROLE_MASTER:
+                return ROLE_MASTER_VAL;
+            case ROLE_SLAVE:
+                return ROLE_SLAVE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFControllerRole in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFDescStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFDescStatsReplyVer12.java
new file mode 100644
index 0000000..1d544e7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFDescStatsReplyVer12.java
@@ -0,0 +1,621 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFDescStatsReplyVer12 implements OFDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFDescStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 1072;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static String DEFAULT_MFR_DESC = "";
+        private final static String DEFAULT_HW_DESC = "";
+        private final static String DEFAULT_SW_DESC = "";
+        private final static String DEFAULT_SERIAL_NUM = "";
+        private final static String DEFAULT_DP_DESC = "";
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final String mfrDesc;
+    private final String hwDesc;
+    private final String swDesc;
+    private final String serialNum;
+    private final String dpDesc;
+//
+    // Immutable default instance
+    final static OFDescStatsReplyVer12 DEFAULT = new OFDescStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MFR_DESC, DEFAULT_HW_DESC, DEFAULT_SW_DESC, DEFAULT_SERIAL_NUM, DEFAULT_DP_DESC
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFDescStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, String mfrDesc, String hwDesc, String swDesc, String serialNum, String dpDesc) {
+        this.xid = xid;
+        this.flags = flags;
+        this.mfrDesc = mfrDesc;
+        this.hwDesc = hwDesc;
+        this.swDesc = swDesc;
+        this.serialNum = serialNum;
+        this.dpDesc = dpDesc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+
+
+    public OFDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFDescStatsReply.Builder {
+        final OFDescStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean mfrDescSet;
+        private String mfrDesc;
+        private boolean hwDescSet;
+        private String hwDesc;
+        private boolean swDescSet;
+        private String swDesc;
+        private boolean serialNumSet;
+        private String serialNum;
+        private boolean dpDescSet;
+        private String dpDesc;
+
+        BuilderWithParent(OFDescStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
+        this.mfrDesc = mfrDesc;
+        this.mfrDescSet = true;
+        return this;
+    }
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
+        this.hwDesc = hwDesc;
+        this.hwDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSwDesc(String swDesc) {
+        this.swDesc = swDesc;
+        this.swDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSerialNum(String serialNum) {
+        this.serialNum = serialNum;
+        this.serialNumSet = true;
+        return this;
+    }
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
+        this.dpDesc = dpDesc;
+        this.dpDescSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                String mfrDesc = this.mfrDescSet ? this.mfrDesc : parentMessage.mfrDesc;
+                if(mfrDesc == null)
+                    throw new NullPointerException("Property mfrDesc must not be null");
+                String hwDesc = this.hwDescSet ? this.hwDesc : parentMessage.hwDesc;
+                if(hwDesc == null)
+                    throw new NullPointerException("Property hwDesc must not be null");
+                String swDesc = this.swDescSet ? this.swDesc : parentMessage.swDesc;
+                if(swDesc == null)
+                    throw new NullPointerException("Property swDesc must not be null");
+                String serialNum = this.serialNumSet ? this.serialNum : parentMessage.serialNum;
+                if(serialNum == null)
+                    throw new NullPointerException("Property serialNum must not be null");
+                String dpDesc = this.dpDescSet ? this.dpDesc : parentMessage.dpDesc;
+                if(dpDesc == null)
+                    throw new NullPointerException("Property dpDesc must not be null");
+
+                //
+                return new OFDescStatsReplyVer12(
+                    xid,
+                    flags,
+                    mfrDesc,
+                    hwDesc,
+                    swDesc,
+                    serialNum,
+                    dpDesc
+                );
+        }
+
+    }
+
+    static class Builder implements OFDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean mfrDescSet;
+        private String mfrDesc;
+        private boolean hwDescSet;
+        private String hwDesc;
+        private boolean swDescSet;
+        private String swDesc;
+        private boolean serialNumSet;
+        private String serialNum;
+        private boolean dpDescSet;
+        private String dpDesc;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
+        this.mfrDesc = mfrDesc;
+        this.mfrDescSet = true;
+        return this;
+    }
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
+        this.hwDesc = hwDesc;
+        this.hwDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSwDesc(String swDesc) {
+        this.swDesc = swDesc;
+        this.swDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSerialNum(String serialNum) {
+        this.serialNum = serialNum;
+        this.serialNumSet = true;
+        return this;
+    }
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
+        this.dpDesc = dpDesc;
+        this.dpDescSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            String mfrDesc = this.mfrDescSet ? this.mfrDesc : DEFAULT_MFR_DESC;
+            if(mfrDesc == null)
+                throw new NullPointerException("Property mfrDesc must not be null");
+            String hwDesc = this.hwDescSet ? this.hwDesc : DEFAULT_HW_DESC;
+            if(hwDesc == null)
+                throw new NullPointerException("Property hwDesc must not be null");
+            String swDesc = this.swDescSet ? this.swDesc : DEFAULT_SW_DESC;
+            if(swDesc == null)
+                throw new NullPointerException("Property swDesc must not be null");
+            String serialNum = this.serialNumSet ? this.serialNum : DEFAULT_SERIAL_NUM;
+            if(serialNum == null)
+                throw new NullPointerException("Property serialNum must not be null");
+            String dpDesc = this.dpDescSet ? this.dpDesc : DEFAULT_DP_DESC;
+            if(dpDesc == null)
+                throw new NullPointerException("Property dpDesc must not be null");
+
+
+            return new OFDescStatsReplyVer12(
+                    xid,
+                    flags,
+                    mfrDesc,
+                    hwDesc,
+                    swDesc,
+                    serialNum,
+                    dpDesc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFDescStatsReply> {
+        @Override
+        public OFDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 1072)
+                throw new OFParseError("Wrong length: Expected=1072(1072), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 0
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x0)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            String mfrDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String hwDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String swDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String serialNum = ChannelUtils.readFixedLengthString(bb, 32);
+            String dpDesc = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFDescStatsReplyVer12 descStatsReplyVer12 = new OFDescStatsReplyVer12(
+                    xid,
+                      flags,
+                      mfrDesc,
+                      hwDesc,
+                      swDesc,
+                      serialNum,
+                      dpDesc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", descStatsReplyVer12);
+            return descStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFDescStatsReplyVer12Funnel FUNNEL = new OFDescStatsReplyVer12Funnel();
+    static class OFDescStatsReplyVer12Funnel implements Funnel<OFDescStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFDescStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 1072
+            sink.putShort((short) 0x430);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 0
+            sink.putShort((short) 0x0);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            sink.putUnencodedChars(message.mfrDesc);
+            sink.putUnencodedChars(message.hwDesc);
+            sink.putUnencodedChars(message.swDesc);
+            sink.putUnencodedChars(message.serialNum);
+            sink.putUnencodedChars(message.dpDesc);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFDescStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFDescStatsReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 1072
+            bb.writeShort((short) 0x430);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 0
+            bb.writeShort((short) 0x0);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeFixedLengthString(bb, message.mfrDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.hwDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.swDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.serialNum, 32);
+            ChannelUtils.writeFixedLengthString(bb, message.dpDesc, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFDescStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("mfrDesc=").append(mfrDesc);
+        b.append(", ");
+        b.append("hwDesc=").append(hwDesc);
+        b.append(", ");
+        b.append("swDesc=").append(swDesc);
+        b.append(", ");
+        b.append("serialNum=").append(serialNum);
+        b.append(", ");
+        b.append("dpDesc=").append(dpDesc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFDescStatsReplyVer12 other = (OFDescStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (mfrDesc == null) {
+            if (other.mfrDesc != null)
+                return false;
+        } else if (!mfrDesc.equals(other.mfrDesc))
+            return false;
+        if (hwDesc == null) {
+            if (other.hwDesc != null)
+                return false;
+        } else if (!hwDesc.equals(other.hwDesc))
+            return false;
+        if (swDesc == null) {
+            if (other.swDesc != null)
+                return false;
+        } else if (!swDesc.equals(other.swDesc))
+            return false;
+        if (serialNum == null) {
+            if (other.serialNum != null)
+                return false;
+        } else if (!serialNum.equals(other.serialNum))
+            return false;
+        if (dpDesc == null) {
+            if (other.dpDesc != null)
+                return false;
+        } else if (!dpDesc.equals(other.dpDesc))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((mfrDesc == null) ? 0 : mfrDesc.hashCode());
+        result = prime * result + ((hwDesc == null) ? 0 : hwDesc.hashCode());
+        result = prime * result + ((swDesc == null) ? 0 : swDesc.hashCode());
+        result = prime * result + ((serialNum == null) ? 0 : serialNum.hashCode());
+        result = prime * result + ((dpDesc == null) ? 0 : dpDesc.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFDescStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFDescStatsRequestVer12.java
new file mode 100644
index 0000000..4c6962d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFDescStatsRequestVer12.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFDescStatsRequestVer12 implements OFDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFDescStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFDescStatsRequestVer12 DEFAULT = new OFDescStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFDescStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFDescStatsRequest.Builder {
+        final OFDescStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFDescStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFDescStatsRequestVer12(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFDescStatsRequestVer12(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFDescStatsRequest> {
+        @Override
+        public OFDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 0
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x0)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFDescStatsRequestVer12 descStatsRequestVer12 = new OFDescStatsRequestVer12(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", descStatsRequestVer12);
+            return descStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFDescStatsRequestVer12Funnel FUNNEL = new OFDescStatsRequestVer12Funnel();
+    static class OFDescStatsRequestVer12Funnel implements Funnel<OFDescStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFDescStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 0
+            sink.putShort((short) 0x0);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFDescStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFDescStatsRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 0
+            bb.writeShort((short) 0x0);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFDescStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFDescStatsRequestVer12 other = (OFDescStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFEchoReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFEchoReplyVer12.java
new file mode 100644
index 0000000..a0fa479
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFEchoReplyVer12.java
@@ -0,0 +1,325 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFEchoReplyVer12 implements OFEchoReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFEchoReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFEchoReplyVer12 DEFAULT = new OFEchoReplyVer12(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFEchoReplyVer12(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFEchoReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFEchoReply.Builder {
+        final OFEchoReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFEchoReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoReply.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFEchoReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFEchoReplyVer12(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFEchoReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoReply.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFEchoReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFEchoReplyVer12(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFEchoReply> {
+        @Override
+        public OFEchoReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 3
+            byte type = bb.readByte();
+            if(type != (byte) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFType.ECHO_REPLY(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFEchoReplyVer12 echoReplyVer12 = new OFEchoReplyVer12(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", echoReplyVer12);
+            return echoReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFEchoReplyVer12Funnel FUNNEL = new OFEchoReplyVer12Funnel();
+    static class OFEchoReplyVer12Funnel implements Funnel<OFEchoReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFEchoReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 3
+            sink.putByte((byte) 0x3);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFEchoReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFEchoReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 3
+            bb.writeByte((byte) 0x3);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFEchoReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFEchoReplyVer12 other = (OFEchoReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFEchoRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFEchoRequestVer12.java
new file mode 100644
index 0000000..c882bba
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFEchoRequestVer12.java
@@ -0,0 +1,325 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFEchoRequestVer12 implements OFEchoRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFEchoRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFEchoRequestVer12 DEFAULT = new OFEchoRequestVer12(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFEchoRequestVer12(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFEchoRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFEchoRequest.Builder {
+        final OFEchoRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFEchoRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFEchoRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFEchoRequestVer12(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFEchoRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFEchoRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFEchoRequestVer12(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFEchoRequest> {
+        @Override
+        public OFEchoRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 2
+            byte type = bb.readByte();
+            if(type != (byte) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFType.ECHO_REQUEST(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFEchoRequestVer12 echoRequestVer12 = new OFEchoRequestVer12(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", echoRequestVer12);
+            return echoRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFEchoRequestVer12Funnel FUNNEL = new OFEchoRequestVer12Funnel();
+    static class OFEchoRequestVer12Funnel implements Funnel<OFEchoRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFEchoRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 2
+            sink.putByte((byte) 0x2);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFEchoRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFEchoRequestVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 2
+            bb.writeByte((byte) 0x2);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFEchoRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFEchoRequestVer12 other = (OFEchoRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorMsgVer12.java
new file mode 100644
index 0000000..fa97c02
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorMsgVer12.java
@@ -0,0 +1,101 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFErrorMsgVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 10;
+
+
+    public final static OFErrorMsgVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFErrorMsg> {
+        @Override
+        public OFErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short errType = bb.readShort();
+            bb.readerIndex(start);
+            switch(errType) {
+               case (short) 0x2:
+                   // discriminator value OFErrorType.BAD_ACTION=2 for class OFBadActionErrorMsgVer12
+                   return OFBadActionErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFErrorType.BAD_REQUEST=1 for class OFBadRequestErrorMsgVer12
+                   return OFBadRequestErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFErrorType.FLOW_MOD_FAILED=5 for class OFFlowModFailedErrorMsgVer12
+                   return OFFlowModFailedErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFErrorType.HELLO_FAILED=0 for class OFHelloFailedErrorMsgVer12
+                   return OFHelloFailedErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFErrorType.PORT_MOD_FAILED=7 for class OFPortModFailedErrorMsgVer12
+                   return OFPortModFailedErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x9:
+                   // discriminator value OFErrorType.QUEUE_OP_FAILED=9 for class OFQueueOpFailedErrorMsgVer12
+                   return OFQueueOpFailedErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFErrorType.BAD_INSTRUCTION=3 for class OFBadInstructionErrorMsgVer12
+                   return OFBadInstructionErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFErrorType.BAD_MATCH=4 for class OFBadMatchErrorMsgVer12
+                   return OFBadMatchErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFErrorType.GROUP_MOD_FAILED=6 for class OFGroupModFailedErrorMsgVer12
+                   return OFGroupModFailedErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0xa:
+                   // discriminator value OFErrorType.SWITCH_CONFIG_FAILED=10 for class OFSwitchConfigFailedErrorMsgVer12
+                   return OFSwitchConfigFailedErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFErrorType.TABLE_MOD_FAILED=8 for class OFTableModFailedErrorMsgVer12
+                   return OFTableModFailedErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFErrorType.EXPERIMENTER=65535 for class OFExperimenterErrorMsgVer12
+                   return OFExperimenterErrorMsgVer12.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFErrorType.ROLE_REQUEST_FAILED=11 for class OFRoleRequestFailedErrorMsgVer12
+                   return OFRoleRequestFailedErrorMsgVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator errType of class OFErrorMsgVer12: " + errType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorMsgsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorMsgsVer12.java
new file mode 100644
index 0000000..7901e4e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorMsgsVer12.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFErrorMsgsVer12 implements OFErrorMsgs {
+    public final static OFErrorMsgsVer12 INSTANCE = new OFErrorMsgsVer12();
+
+    private final XidGenerator xidGenerator = XidGenerators.global();
+
+
+
+    public OFBadActionErrorMsg.Builder buildBadActionErrorMsg() {
+        return new OFBadActionErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBadRequestErrorMsg.Builder buildBadRequestErrorMsg() {
+        return new OFBadRequestErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModFailedErrorMsg.Builder buildFlowModFailedErrorMsg() {
+        return new OFFlowModFailedErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFHelloFailedErrorMsg.Builder buildHelloFailedErrorMsg() {
+        return new OFHelloFailedErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFPortModFailedErrorMsg.Builder buildPortModFailedErrorMsg() {
+        return new OFPortModFailedErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFQueueOpFailedErrorMsg.Builder buildQueueOpFailedErrorMsg() {
+        return new OFQueueOpFailedErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBadInstructionErrorMsg.Builder buildBadInstructionErrorMsg() {
+        return new OFBadInstructionErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBadMatchErrorMsg.Builder buildBadMatchErrorMsg() {
+        return new OFBadMatchErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGroupModFailedErrorMsg.Builder buildGroupModFailedErrorMsg() {
+        return new OFGroupModFailedErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFSwitchConfigFailedErrorMsg.Builder buildSwitchConfigFailedErrorMsg() {
+        return new OFSwitchConfigFailedErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFTableModFailedErrorMsg.Builder buildTableModFailedErrorMsg() {
+        return new OFTableModFailedErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFExperimenterErrorMsg.Builder buildExperimenterErrorMsg() {
+        return new OFExperimenterErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFRoleRequestFailedErrorMsg.Builder buildRoleRequestFailedErrorMsg() {
+        return new OFRoleRequestFailedErrorMsgVer12.Builder().setXid(nextXid());
+    }
+
+    public OFMeterModFailedErrorMsg.Builder buildMeterModFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFMeterModFailedErrorMsg not supported in version 1.2");
+    }
+
+    public OFTableFeaturesFailedErrorMsg.Builder buildTableFeaturesFailedErrorMsg() {
+        throw new UnsupportedOperationException("OFTableFeaturesFailedErrorMsg not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFErrorMsg> getReader() {
+        return OFErrorMsgVer12.READER;
+    }
+
+    public long nextXid() {
+        return xidGenerator.nextXid();
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorTypeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorTypeSerializerVer12.java
new file mode 100644
index 0000000..a7e30c1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFErrorTypeSerializerVer12.java
@@ -0,0 +1,129 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFErrorType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFErrorTypeSerializerVer12 {
+
+    public final static short HELLO_FAILED_VAL = (short) 0x0;
+    public final static short BAD_REQUEST_VAL = (short) 0x1;
+    public final static short BAD_ACTION_VAL = (short) 0x2;
+    public final static short BAD_INSTRUCTION_VAL = (short) 0x3;
+    public final static short BAD_MATCH_VAL = (short) 0x4;
+    public final static short FLOW_MOD_FAILED_VAL = (short) 0x5;
+    public final static short GROUP_MOD_FAILED_VAL = (short) 0x6;
+    public final static short PORT_MOD_FAILED_VAL = (short) 0x7;
+    public final static short TABLE_MOD_FAILED_VAL = (short) 0x8;
+    public final static short QUEUE_OP_FAILED_VAL = (short) 0x9;
+    public final static short SWITCH_CONFIG_FAILED_VAL = (short) 0xa;
+    public final static short ROLE_REQUEST_FAILED_VAL = (short) 0xb;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFErrorType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFErrorType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFErrorType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFErrorType ofWireValue(short val) {
+        switch(val) {
+            case HELLO_FAILED_VAL:
+                return OFErrorType.HELLO_FAILED;
+            case BAD_REQUEST_VAL:
+                return OFErrorType.BAD_REQUEST;
+            case BAD_ACTION_VAL:
+                return OFErrorType.BAD_ACTION;
+            case BAD_INSTRUCTION_VAL:
+                return OFErrorType.BAD_INSTRUCTION;
+            case BAD_MATCH_VAL:
+                return OFErrorType.BAD_MATCH;
+            case FLOW_MOD_FAILED_VAL:
+                return OFErrorType.FLOW_MOD_FAILED;
+            case GROUP_MOD_FAILED_VAL:
+                return OFErrorType.GROUP_MOD_FAILED;
+            case PORT_MOD_FAILED_VAL:
+                return OFErrorType.PORT_MOD_FAILED;
+            case TABLE_MOD_FAILED_VAL:
+                return OFErrorType.TABLE_MOD_FAILED;
+            case QUEUE_OP_FAILED_VAL:
+                return OFErrorType.QUEUE_OP_FAILED;
+            case SWITCH_CONFIG_FAILED_VAL:
+                return OFErrorType.SWITCH_CONFIG_FAILED;
+            case ROLE_REQUEST_FAILED_VAL:
+                return OFErrorType.ROLE_REQUEST_FAILED;
+            case EXPERIMENTER_VAL:
+                return OFErrorType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFErrorType in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFErrorType e) {
+        switch(e) {
+            case HELLO_FAILED:
+                return HELLO_FAILED_VAL;
+            case BAD_REQUEST:
+                return BAD_REQUEST_VAL;
+            case BAD_ACTION:
+                return BAD_ACTION_VAL;
+            case BAD_INSTRUCTION:
+                return BAD_INSTRUCTION_VAL;
+            case BAD_MATCH:
+                return BAD_MATCH_VAL;
+            case FLOW_MOD_FAILED:
+                return FLOW_MOD_FAILED_VAL;
+            case GROUP_MOD_FAILED:
+                return GROUP_MOD_FAILED_VAL;
+            case PORT_MOD_FAILED:
+                return PORT_MOD_FAILED_VAL;
+            case TABLE_MOD_FAILED:
+                return TABLE_MOD_FAILED_VAL;
+            case QUEUE_OP_FAILED:
+                return QUEUE_OP_FAILED_VAL;
+            case SWITCH_CONFIG_FAILED:
+                return SWITCH_CONFIG_FAILED_VAL;
+            case ROLE_REQUEST_FAILED:
+                return ROLE_REQUEST_FAILED_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFErrorType in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterErrorMsgVer12.java
new file mode 100644
index 0000000..7770507
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterErrorMsgVer12.java
@@ -0,0 +1,444 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFExperimenterErrorMsgVer12 implements OFExperimenterErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFExperimenterErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static int DEFAULT_SUBTYPE = 0x0;
+        private final static long DEFAULT_EXPERIMENTER = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final int subtype;
+    private final long experimenter;
+    private final OFErrorCauseData data;
+//
+    // Immutable default instance
+    final static OFExperimenterErrorMsgVer12 DEFAULT = new OFExperimenterErrorMsgVer12(
+        DEFAULT_XID, DEFAULT_SUBTYPE, DEFAULT_EXPERIMENTER, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFExperimenterErrorMsgVer12(long xid, int subtype, long experimenter, OFErrorCauseData data) {
+        this.xid = xid;
+        this.subtype = subtype;
+        this.experimenter = experimenter;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.EXPERIMENTER;
+    }
+
+    @Override
+    public int getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFExperimenterErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFExperimenterErrorMsg.Builder {
+        final OFExperimenterErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean subtypeSet;
+        private int subtype;
+        private boolean experimenterSet;
+        private long experimenter;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFExperimenterErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.EXPERIMENTER;
+    }
+
+    @Override
+    public int getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setSubtype(int subtype) {
+        this.subtype = subtype;
+        this.subtypeSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFExperimenterErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                int subtype = this.subtypeSet ? this.subtype : parentMessage.subtype;
+                long experimenter = this.experimenterSet ? this.experimenter : parentMessage.experimenter;
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFExperimenterErrorMsgVer12(
+                    xid,
+                    subtype,
+                    experimenter,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFExperimenterErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean subtypeSet;
+        private int subtype;
+        private boolean experimenterSet;
+        private long experimenter;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.EXPERIMENTER;
+    }
+
+    @Override
+    public int getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setSubtype(int subtype) {
+        this.subtype = subtype;
+        this.subtypeSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFExperimenterErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            int subtype = this.subtypeSet ? this.subtype : DEFAULT_SUBTYPE;
+            long experimenter = this.experimenterSet ? this.experimenter : DEFAULT_EXPERIMENTER;
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFExperimenterErrorMsgVer12(
+                    xid,
+                    subtype,
+                    experimenter,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFExperimenterErrorMsg> {
+        @Override
+        public OFExperimenterErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 65535
+            short errType = bb.readShort();
+            if(errType != (short) 0xffff)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.EXPERIMENTER(65535), got="+errType);
+            int subtype = U16.f(bb.readShort());
+            long experimenter = U32.f(bb.readInt());
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFExperimenterErrorMsgVer12 experimenterErrorMsgVer12 = new OFExperimenterErrorMsgVer12(
+                    xid,
+                      subtype,
+                      experimenter,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", experimenterErrorMsgVer12);
+            return experimenterErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFExperimenterErrorMsgVer12Funnel FUNNEL = new OFExperimenterErrorMsgVer12Funnel();
+    static class OFExperimenterErrorMsgVer12Funnel implements Funnel<OFExperimenterErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFExperimenterErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 65535
+            sink.putShort((short) 0xffff);
+            sink.putInt(message.subtype);
+            sink.putLong(message.experimenter);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFExperimenterErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFExperimenterErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 65535
+            bb.writeShort((short) 0xffff);
+            bb.writeShort(U16.t(message.subtype));
+            bb.writeInt(U32.t(message.experimenter));
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFExperimenterErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("subtype=").append(subtype);
+        b.append(", ");
+        b.append("experimenter=").append(experimenter);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFExperimenterErrorMsgVer12 other = (OFExperimenterErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( subtype != other.subtype)
+            return false;
+        if( experimenter != other.experimenter)
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + subtype;
+        result = prime *  (int) (experimenter ^ (experimenter >>> 32));
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterStatsReplyVer12.java
new file mode 100644
index 0000000..77c9cf8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterStatsReplyVer12.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterStatsReplyVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFExperimenterStatsReplyVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenterStatsReply> {
+        @Override
+        public OFExperimenterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsReplyVer12
+                   return OFBsnStatsReplyVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterStatsReplyVer12: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterStatsRequestVer12.java
new file mode 100644
index 0000000..59d1491
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterStatsRequestVer12.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterStatsRequestVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFExperimenterStatsRequestVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenterStatsRequest<?>> {
+        @Override
+        public OFExperimenterStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsRequestVer12
+                   return OFBsnStatsRequestVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterStatsRequestVer12: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterVer12.java
new file mode 100644
index 0000000..182865a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFExperimenterVer12.java
@@ -0,0 +1,68 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFExperimenterVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenter> {
+        @Override
+        public OFExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnHeaderVer12
+                   return OFBsnHeaderVer12.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFNiciraHeaderVer12
+                   return OFNiciraHeaderVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterVer12: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFactoryVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFactoryVer12.java
new file mode 100644
index 0000000..6e05c61
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFactoryVer12.java
@@ -0,0 +1,1237 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.projectfloodlight.openflow.protocol.OFOxmList;
+
+
+public class OFFactoryVer12 implements OFFactory {
+    public final static OFFactoryVer12 INSTANCE = new OFFactoryVer12();
+
+    private final XidGenerator xidGenerator = XidGenerators.global();
+
+    public OFActions actions() {
+        return OFActionsVer12.INSTANCE;
+    }
+    public OFInstructions instructions() {
+        return OFInstructionsVer12.INSTANCE;
+    }
+    public OFMeterBands meterBands() {
+        return OFMeterBandsVer12.INSTANCE;
+    }
+    public OFOxms oxms() {
+        return OFOxmsVer12.INSTANCE;
+    }
+    public OFQueueProps queueProps() {
+        return OFQueuePropsVer12.INSTANCE;
+    }
+    public OFErrorMsgs errorMsgs() {
+        return OFErrorMsgsVer12.INSTANCE;
+    }
+    public OFActionIds actionIds() {
+        return OFActionIdsVer12.INSTANCE;
+    }
+    public OFInstructionIds instructionIds() {
+        return OFInstructionIdsVer12.INSTANCE;
+    }
+    public OFBsnTlvs bsnTlvs() {
+        return OFBsnTlvsVer12.INSTANCE;
+    }
+
+
+    public OFAggregateStatsReply.Builder buildAggregateStatsReply() {
+        return new OFAggregateStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFAggregateStatsRequest.Builder buildAggregateStatsRequest() {
+        return new OFAggregateStatsRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBarrierReply.Builder buildBarrierReply() {
+        return new OFBarrierReplyVer12.Builder().setXid(nextXid());
+    }
+    public OFBarrierReply barrierReply() {
+        return new OFBarrierReplyVer12(
+                nextXid()
+                    );
+    }
+
+    public OFBarrierRequest.Builder buildBarrierRequest() {
+        return new OFBarrierRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFBarrierRequest barrierRequest() {
+        return new OFBarrierRequestVer12(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwClearDataReply.Builder buildBsnBwClearDataReply() {
+        return new OFBsnBwClearDataReplyVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnBwClearDataReply bsnBwClearDataReply(long status) {
+        return new OFBsnBwClearDataReplyVer12(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnBwClearDataRequest.Builder buildBsnBwClearDataRequest() {
+        return new OFBsnBwClearDataRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnBwClearDataRequest bsnBwClearDataRequest() {
+        return new OFBsnBwClearDataRequestVer12(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwEnableGetReply.Builder buildBsnBwEnableGetReply() {
+        return new OFBsnBwEnableGetReplyVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableGetReply bsnBwEnableGetReply(long enabled) {
+        return new OFBsnBwEnableGetReplyVer12(
+                nextXid(),
+                      enabled
+                    );
+    }
+
+    public OFBsnBwEnableGetRequest.Builder buildBsnBwEnableGetRequest() {
+        return new OFBsnBwEnableGetRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableGetRequest bsnBwEnableGetRequest() {
+        return new OFBsnBwEnableGetRequestVer12(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwEnableSetReply.Builder buildBsnBwEnableSetReply() {
+        return new OFBsnBwEnableSetReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBsnBwEnableSetRequest.Builder buildBsnBwEnableSetRequest() {
+        return new OFBsnBwEnableSetRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableSetRequest bsnBwEnableSetRequest(long enable) {
+        return new OFBsnBwEnableSetRequestVer12(
+                nextXid(),
+                      enable
+                    );
+    }
+
+    public OFBsnGetInterfacesReply.Builder buildBsnGetInterfacesReply() {
+        return new OFBsnGetInterfacesReplyVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnGetInterfacesReply bsnGetInterfacesReply(List<OFBsnInterface> interfaces) {
+        return new OFBsnGetInterfacesReplyVer12(
+                nextXid(),
+                      interfaces
+                    );
+    }
+
+    public OFBsnGetInterfacesRequest.Builder buildBsnGetInterfacesRequest() {
+        return new OFBsnGetInterfacesRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnGetInterfacesRequest bsnGetInterfacesRequest() {
+        return new OFBsnGetInterfacesRequestVer12(
+                nextXid()
+                    );
+    }
+
+    public OFBsnGetIpMaskReply.Builder buildBsnGetIpMaskReply() {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskReply not supported in version 1.2");
+    }
+
+    public OFBsnGetIpMaskRequest.Builder buildBsnGetIpMaskRequest() {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskRequest not supported in version 1.2");
+    }
+    public OFBsnGetIpMaskRequest bsnGetIpMaskRequest(short index) {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskRequest not supported in version 1.2");
+    }
+
+    public OFBsnGetL2TableReply.Builder buildBsnGetL2TableReply() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableReply not supported in version 1.2");
+    }
+
+    public OFBsnGetL2TableRequest.Builder buildBsnGetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableRequest not supported in version 1.2");
+    }
+    public OFBsnGetL2TableRequest bsnGetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableRequest not supported in version 1.2");
+    }
+
+    public OFBsnGetMirroringReply.Builder buildBsnGetMirroringReply() {
+        return new OFBsnGetMirroringReplyVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnGetMirroringReply bsnGetMirroringReply(short reportMirrorPorts) {
+        return new OFBsnGetMirroringReplyVer12(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnGetMirroringRequest.Builder buildBsnGetMirroringRequest() {
+        return new OFBsnGetMirroringRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnGetMirroringRequest bsnGetMirroringRequest(short reportMirrorPorts) {
+        return new OFBsnGetMirroringRequestVer12(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnHybridGetReply.Builder buildBsnHybridGetReply() {
+        throw new UnsupportedOperationException("OFBsnHybridGetReply not supported in version 1.2");
+    }
+
+    public OFBsnHybridGetRequest.Builder buildBsnHybridGetRequest() {
+        throw new UnsupportedOperationException("OFBsnHybridGetRequest not supported in version 1.2");
+    }
+    public OFBsnHybridGetRequest bsnHybridGetRequest() {
+        throw new UnsupportedOperationException("OFBsnHybridGetRequest not supported in version 1.2");
+    }
+
+    public OFBsnInterface.Builder buildBsnInterface() {
+        return new OFBsnInterfaceVer12.Builder();
+    }
+
+    public OFBsnPduRxReply.Builder buildBsnPduRxReply() {
+        return new OFBsnPduRxReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduRxRequest.Builder buildBsnPduRxRequest() {
+        return new OFBsnPduRxRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduRxTimeout.Builder buildBsnPduRxTimeout() {
+        return new OFBsnPduRxTimeoutVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduTxReply.Builder buildBsnPduTxReply() {
+        return new OFBsnPduTxReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduTxRequest.Builder buildBsnPduTxRequest() {
+        return new OFBsnPduTxRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetIpMask.Builder buildBsnSetIpMask() {
+        throw new UnsupportedOperationException("OFBsnSetIpMask not supported in version 1.2");
+    }
+
+    public OFBsnSetL2TableReply.Builder buildBsnSetL2TableReply() {
+        throw new UnsupportedOperationException("OFBsnSetL2TableReply not supported in version 1.2");
+    }
+
+    public OFBsnSetL2TableRequest.Builder buildBsnSetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnSetL2TableRequest not supported in version 1.2");
+    }
+
+    public OFBsnSetMirroring.Builder buildBsnSetMirroring() {
+        return new OFBsnSetMirroringVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnSetMirroring bsnSetMirroring(short reportMirrorPorts) {
+        return new OFBsnSetMirroringVer12(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnSetPktinSuppressionReply.Builder buildBsnSetPktinSuppressionReply() {
+        return new OFBsnSetPktinSuppressionReplyVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnSetPktinSuppressionReply bsnSetPktinSuppressionReply(long status) {
+        return new OFBsnSetPktinSuppressionReplyVer12(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnSetPktinSuppressionRequest.Builder buildBsnSetPktinSuppressionRequest() {
+        return new OFBsnSetPktinSuppressionRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBsnShellCommand.Builder buildBsnShellCommand() {
+        throw new UnsupportedOperationException("OFBsnShellCommand not supported in version 1.2");
+    }
+
+    public OFBsnShellOutput.Builder buildBsnShellOutput() {
+        throw new UnsupportedOperationException("OFBsnShellOutput not supported in version 1.2");
+    }
+    public OFBsnShellOutput bsnShellOutput(byte[] data) {
+        throw new UnsupportedOperationException("OFBsnShellOutput not supported in version 1.2");
+    }
+
+    public OFBsnShellStatus.Builder buildBsnShellStatus() {
+        throw new UnsupportedOperationException("OFBsnShellStatus not supported in version 1.2");
+    }
+    public OFBsnShellStatus bsnShellStatus(long status) {
+        throw new UnsupportedOperationException("OFBsnShellStatus not supported in version 1.2");
+    }
+
+    public OFBsnVirtualPortCreateReply.Builder buildBsnVirtualPortCreateReply() {
+        return new OFBsnVirtualPortCreateReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFBsnVirtualPortCreateRequest.Builder buildBsnVirtualPortCreateRequest() {
+        return new OFBsnVirtualPortCreateRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest(OFBsnVport vport) {
+        return new OFBsnVirtualPortCreateRequestVer12(
+                nextXid(),
+                      vport
+                    );
+    }
+
+    public OFBsnVirtualPortRemoveReply.Builder buildBsnVirtualPortRemoveReply() {
+        return new OFBsnVirtualPortRemoveReplyVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortRemoveReply bsnVirtualPortRemoveReply(long status) {
+        return new OFBsnVirtualPortRemoveReplyVer12(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnVirtualPortRemoveRequest.Builder buildBsnVirtualPortRemoveRequest() {
+        return new OFBsnVirtualPortRemoveRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortRemoveRequest bsnVirtualPortRemoveRequest(long vportNo) {
+        return new OFBsnVirtualPortRemoveRequestVer12(
+                nextXid(),
+                      vportNo
+                    );
+    }
+
+    public OFBsnVportL2Gre.Builder buildBsnVportL2Gre() {
+        return new OFBsnVportL2GreVer12.Builder();
+    }
+
+    public OFBsnVportQInQ.Builder buildBsnVportQInQ() {
+        return new OFBsnVportQInQVer12.Builder();
+    }
+
+    public OFDescStatsReply.Builder buildDescStatsReply() {
+        return new OFDescStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFDescStatsRequest.Builder buildDescStatsRequest() {
+        return new OFDescStatsRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFDescStatsRequest descStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFDescStatsRequestVer12(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFEchoReply.Builder buildEchoReply() {
+        return new OFEchoReplyVer12.Builder().setXid(nextXid());
+    }
+    public OFEchoReply echoReply(byte[] data) {
+        return new OFEchoReplyVer12(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFEchoRequest.Builder buildEchoRequest() {
+        return new OFEchoRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFEchoRequest echoRequest(byte[] data) {
+        return new OFEchoRequestVer12(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFFeaturesReply.Builder buildFeaturesReply() {
+        return new OFFeaturesReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFeaturesRequest.Builder buildFeaturesRequest() {
+        return new OFFeaturesRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFFeaturesRequest featuresRequest() {
+        return new OFFeaturesRequestVer12(
+                nextXid()
+                    );
+    }
+
+    public OFFlowAdd.Builder buildFlowAdd() {
+        return new OFFlowAddVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFlowDelete.Builder buildFlowDelete() {
+        return new OFFlowDeleteVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFlowDeleteStrict.Builder buildFlowDeleteStrict() {
+        return new OFFlowDeleteStrictVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModify.Builder buildFlowModify() {
+        return new OFFlowModifyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModifyStrict.Builder buildFlowModifyStrict() {
+        return new OFFlowModifyStrictVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFlowRemoved.Builder buildFlowRemoved() {
+        return new OFFlowRemovedVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFlowStatsEntry.Builder buildFlowStatsEntry() {
+        return new OFFlowStatsEntryVer12.Builder();
+    }
+
+    public OFFlowStatsReply.Builder buildFlowStatsReply() {
+        return new OFFlowStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFFlowStatsRequest.Builder buildFlowStatsRequest() {
+        return new OFFlowStatsRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGetConfigReply.Builder buildGetConfigReply() {
+        return new OFGetConfigReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGetConfigRequest.Builder buildGetConfigRequest() {
+        return new OFGetConfigRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFGetConfigRequest getConfigRequest() {
+        return new OFGetConfigRequestVer12(
+                nextXid()
+                    );
+    }
+
+    public OFHello.Builder buildHello() {
+        return new OFHelloVer12.Builder().setXid(nextXid());
+    }
+    public OFHello hello(List<OFHelloElem> elements) {
+        return new OFHelloVer12(
+                nextXid()
+                    );
+    }
+
+    public OFMatchV1.Builder buildMatchV1() {
+        throw new UnsupportedOperationException("OFMatchV1 not supported in version 1.2");
+    }
+
+    public OFNiciraControllerRoleReply.Builder buildNiciraControllerRoleReply() {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleReply not supported in version 1.2");
+    }
+    public OFNiciraControllerRoleReply niciraControllerRoleReply(OFNiciraControllerRole role) {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleReply not supported in version 1.2");
+    }
+
+    public OFNiciraControllerRoleRequest.Builder buildNiciraControllerRoleRequest() {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleRequest not supported in version 1.2");
+    }
+    public OFNiciraControllerRoleRequest niciraControllerRoleRequest(OFNiciraControllerRole role) {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleRequest not supported in version 1.2");
+    }
+
+    public OFPacketIn.Builder buildPacketIn() {
+        return new OFPacketInVer12.Builder().setXid(nextXid());
+    }
+
+    public OFPacketOut.Builder buildPacketOut() {
+        return new OFPacketOutVer12.Builder().setXid(nextXid());
+    }
+
+    public OFPacketQueue.Builder buildPacketQueue() {
+        return new OFPacketQueueVer12.Builder();
+    }
+
+    public OFPortDesc.Builder buildPortDesc() {
+        return new OFPortDescVer12.Builder();
+    }
+
+    public OFPortMod.Builder buildPortMod() {
+        return new OFPortModVer12.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatsEntry.Builder buildPortStatsEntry() {
+        return new OFPortStatsEntryVer12.Builder();
+    }
+
+    public OFPortStatsReply.Builder buildPortStatsReply() {
+        return new OFPortStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatsRequest.Builder buildPortStatsRequest() {
+        return new OFPortStatsRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatus.Builder buildPortStatus() {
+        return new OFPortStatusVer12.Builder().setXid(nextXid());
+    }
+
+    public OFQueueGetConfigReply.Builder buildQueueGetConfigReply() {
+        return new OFQueueGetConfigReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFQueueGetConfigRequest.Builder buildQueueGetConfigRequest() {
+        return new OFQueueGetConfigRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFQueueGetConfigRequest queueGetConfigRequest(OFPort port) {
+        return new OFQueueGetConfigRequestVer12(
+                nextXid(),
+                      port
+                    );
+    }
+
+    public OFQueueStatsEntry.Builder buildQueueStatsEntry() {
+        return new OFQueueStatsEntryVer12.Builder();
+    }
+
+    public OFQueueStatsReply.Builder buildQueueStatsReply() {
+        return new OFQueueStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFQueueStatsRequest.Builder buildQueueStatsRequest() {
+        return new OFQueueStatsRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFSetConfig.Builder buildSetConfig() {
+        return new OFSetConfigVer12.Builder().setXid(nextXid());
+    }
+
+    public OFTableMod.Builder buildTableMod() {
+        return new OFTableModVer12.Builder().setXid(nextXid());
+    }
+
+    public OFTableStatsEntry.Builder buildTableStatsEntry() {
+        return new OFTableStatsEntryVer12.Builder();
+    }
+
+    public OFTableStatsReply.Builder buildTableStatsReply() {
+        return new OFTableStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFTableStatsRequest.Builder buildTableStatsRequest() {
+        return new OFTableStatsRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFTableStatsRequest tableStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFTableStatsRequestVer12(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBucket.Builder buildBucket() {
+        return new OFBucketVer12.Builder();
+    }
+
+    public OFBucketCounter.Builder buildBucketCounter() {
+        return new OFBucketCounterVer12.Builder();
+    }
+    public OFBucketCounter bucketCounter(U64 packetCount, U64 byteCount) {
+        return new OFBucketCounterVer12(
+                packetCount,
+                      byteCount
+                    );
+    }
+
+    public OFGroupAdd.Builder buildGroupAdd() {
+        return new OFGroupAddVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDelete.Builder buildGroupDelete() {
+        return new OFGroupDeleteVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDescStatsEntry.Builder buildGroupDescStatsEntry() {
+        return new OFGroupDescStatsEntryVer12.Builder();
+    }
+
+    public OFGroupDescStatsReply.Builder buildGroupDescStatsReply() {
+        return new OFGroupDescStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDescStatsRequest.Builder buildGroupDescStatsRequest() {
+        return new OFGroupDescStatsRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFGroupDescStatsRequest groupDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFGroupDescStatsRequestVer12(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFGroupModify.Builder buildGroupModify() {
+        return new OFGroupModifyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGroupStatsEntry.Builder buildGroupStatsEntry() {
+        return new OFGroupStatsEntryVer12.Builder();
+    }
+
+    public OFGroupStatsReply.Builder buildGroupStatsReply() {
+        return new OFGroupStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGroupStatsRequest.Builder buildGroupStatsRequest() {
+        return new OFGroupStatsRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFMatchV2.Builder buildMatchV2() {
+        throw new UnsupportedOperationException("OFMatchV2 not supported in version 1.2");
+    }
+
+    public OFGroupFeaturesStatsReply.Builder buildGroupFeaturesStatsReply() {
+        return new OFGroupFeaturesStatsReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFGroupFeaturesStatsRequest.Builder buildGroupFeaturesStatsRequest() {
+        return new OFGroupFeaturesStatsRequestVer12.Builder().setXid(nextXid());
+    }
+    public OFGroupFeaturesStatsRequest groupFeaturesStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFGroupFeaturesStatsRequestVer12(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFMatchV3.Builder buildMatchV3() {
+        return new OFMatchV3Ver12.Builder();
+    }
+    public Match.Builder buildMatch() {
+        return new OFMatchV3Ver12.Builder();
+    }
+
+    final static Match MATCH_WILDCARD_ALL = OFMatchV3Ver12.DEFAULT;
+
+    public Match matchWildcardAll() {
+        return MATCH_WILDCARD_ALL;
+    }
+    public OFMatchV3 matchV3(OFOxmList oxmList) {
+        return new OFMatchV3Ver12(
+                oxmList
+                    );
+    }
+
+    public OFRoleReply.Builder buildRoleReply() {
+        return new OFRoleReplyVer12.Builder().setXid(nextXid());
+    }
+
+    public OFRoleRequest.Builder buildRoleRequest() {
+        return new OFRoleRequestVer12.Builder().setXid(nextXid());
+    }
+
+    public OFAsyncGetReply.Builder buildAsyncGetReply() {
+        throw new UnsupportedOperationException("OFAsyncGetReply not supported in version 1.2");
+    }
+
+    public OFAsyncGetRequest.Builder buildAsyncGetRequest() {
+        throw new UnsupportedOperationException("OFAsyncGetRequest not supported in version 1.2");
+    }
+
+    public OFAsyncSet.Builder buildAsyncSet() {
+        throw new UnsupportedOperationException("OFAsyncSet not supported in version 1.2");
+    }
+
+    public OFBsnArpIdle.Builder buildBsnArpIdle() {
+        throw new UnsupportedOperationException("OFBsnArpIdle not supported in version 1.2");
+    }
+
+    public OFBsnControllerConnection.Builder buildBsnControllerConnection() {
+        throw new UnsupportedOperationException("OFBsnControllerConnection not supported in version 1.2");
+    }
+
+    public OFBsnControllerConnectionsReply.Builder buildBsnControllerConnectionsReply() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsReply not supported in version 1.2");
+    }
+    public OFBsnControllerConnectionsReply bsnControllerConnectionsReply(List<OFBsnControllerConnection> connections) {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsReply not supported in version 1.2");
+    }
+
+    public OFBsnControllerConnectionsRequest.Builder buildBsnControllerConnectionsRequest() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsRequest not supported in version 1.2");
+    }
+    public OFBsnControllerConnectionsRequest bsnControllerConnectionsRequest() {
+        throw new UnsupportedOperationException("OFBsnControllerConnectionsRequest not supported in version 1.2");
+    }
+
+    public OFBsnDebugCounterDescStatsEntry.Builder buildBsnDebugCounterDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnDebugCounterDescStatsReply.Builder buildBsnDebugCounterDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnDebugCounterDescStatsRequest.Builder buildBsnDebugCounterDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsRequest not supported in version 1.2");
+    }
+    public OFBsnDebugCounterDescStatsRequest bsnDebugCounterDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterDescStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnDebugCounterStatsEntry.Builder buildBsnDebugCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsEntry not supported in version 1.2");
+    }
+    public OFBsnDebugCounterStatsEntry bsnDebugCounterStatsEntry(U64 counterId, U64 value) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnDebugCounterStatsReply.Builder buildBsnDebugCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnDebugCounterStatsRequest.Builder buildBsnDebugCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsRequest not supported in version 1.2");
+    }
+    public OFBsnDebugCounterStatsRequest bsnDebugCounterStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnDebugCounterStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnFlowChecksumBucketStatsEntry.Builder buildBsnFlowChecksumBucketStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsEntry not supported in version 1.2");
+    }
+    public OFBsnFlowChecksumBucketStatsEntry bsnFlowChecksumBucketStatsEntry(U64 checksum) {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnFlowChecksumBucketStatsReply.Builder buildBsnFlowChecksumBucketStatsReply() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnFlowChecksumBucketStatsRequest.Builder buildBsnFlowChecksumBucketStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowChecksumBucketStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnFlowIdle.Builder buildBsnFlowIdle() {
+        throw new UnsupportedOperationException("OFBsnFlowIdle not supported in version 1.2");
+    }
+
+    public OFBsnFlowIdleEnableGetReply.Builder buildBsnFlowIdleEnableGetReply() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetReply not supported in version 1.2");
+    }
+    public OFBsnFlowIdleEnableGetReply bsnFlowIdleEnableGetReply(long enabled) {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetReply not supported in version 1.2");
+    }
+
+    public OFBsnFlowIdleEnableGetRequest.Builder buildBsnFlowIdleEnableGetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetRequest not supported in version 1.2");
+    }
+    public OFBsnFlowIdleEnableGetRequest bsnFlowIdleEnableGetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableGetRequest not supported in version 1.2");
+    }
+
+    public OFBsnFlowIdleEnableSetReply.Builder buildBsnFlowIdleEnableSetReply() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetReply not supported in version 1.2");
+    }
+
+    public OFBsnFlowIdleEnableSetRequest.Builder buildBsnFlowIdleEnableSetRequest() {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetRequest not supported in version 1.2");
+    }
+    public OFBsnFlowIdleEnableSetRequest bsnFlowIdleEnableSetRequest(long enable) {
+        throw new UnsupportedOperationException("OFBsnFlowIdleEnableSetRequest not supported in version 1.2");
+    }
+
+    public OFBsnGentableBucketStatsEntry.Builder buildBsnGentableBucketStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsEntry not supported in version 1.2");
+    }
+    public OFBsnGentableBucketStatsEntry bsnGentableBucketStatsEntry(U128 checksum) {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnGentableBucketStatsReply.Builder buildBsnGentableBucketStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnGentableBucketStatsRequest.Builder buildBsnGentableBucketStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableBucketStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnGentableClearReply.Builder buildBsnGentableClearReply() {
+        throw new UnsupportedOperationException("OFBsnGentableClearReply not supported in version 1.2");
+    }
+
+    public OFBsnGentableClearRequest.Builder buildBsnGentableClearRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableClearRequest not supported in version 1.2");
+    }
+
+    public OFBsnGentableDescStatsEntry.Builder buildBsnGentableDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnGentableDescStatsReply.Builder buildBsnGentableDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnGentableDescStatsRequest.Builder buildBsnGentableDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsRequest not supported in version 1.2");
+    }
+    public OFBsnGentableDescStatsRequest bsnGentableDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnGentableDescStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnGentableEntryAdd.Builder buildBsnGentableEntryAdd() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryAdd not supported in version 1.2");
+    }
+
+    public OFBsnGentableEntryDelete.Builder buildBsnGentableEntryDelete() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDelete not supported in version 1.2");
+    }
+
+    public OFBsnGentableEntryDescStatsEntry.Builder buildBsnGentableEntryDescStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnGentableEntryDescStatsReply.Builder buildBsnGentableEntryDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnGentableEntryDescStatsRequest.Builder buildBsnGentableEntryDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryDescStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnGentableEntryStatsEntry.Builder buildBsnGentableEntryStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsEntry not supported in version 1.2");
+    }
+    public OFBsnGentableEntryStatsEntry bsnGentableEntryStatsEntry(List<OFBsnTlv> key, List<OFBsnTlv> stats) {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnGentableEntryStatsReply.Builder buildBsnGentableEntryStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnGentableEntryStatsRequest.Builder buildBsnGentableEntryStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableEntryStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnGentableSetBucketsSize.Builder buildBsnGentableSetBucketsSize() {
+        throw new UnsupportedOperationException("OFBsnGentableSetBucketsSize not supported in version 1.2");
+    }
+
+    public OFBsnGentableStatsEntry.Builder buildBsnGentableStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnGentableStatsReply.Builder buildBsnGentableStatsReply() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnGentableStatsRequest.Builder buildBsnGentableStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnGentableStatsRequest not supported in version 1.2");
+    }
+    public OFBsnGentableStatsRequest bsnGentableStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnGentableStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnGetSwitchPipelineReply.Builder buildBsnGetSwitchPipelineReply() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineReply not supported in version 1.2");
+    }
+    public OFBsnGetSwitchPipelineReply bsnGetSwitchPipelineReply(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineReply not supported in version 1.2");
+    }
+
+    public OFBsnGetSwitchPipelineRequest.Builder buildBsnGetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineRequest not supported in version 1.2");
+    }
+    public OFBsnGetSwitchPipelineRequest bsnGetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnGetSwitchPipelineRequest not supported in version 1.2");
+    }
+
+    public OFBsnImageDescStatsReply.Builder buildBsnImageDescStatsReply() {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnImageDescStatsRequest.Builder buildBsnImageDescStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsRequest not supported in version 1.2");
+    }
+    public OFBsnImageDescStatsRequest bsnImageDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnImageDescStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnLacpConvergenceNotif.Builder buildBsnLacpConvergenceNotif() {
+        throw new UnsupportedOperationException("OFBsnLacpConvergenceNotif not supported in version 1.2");
+    }
+
+    public OFBsnLacpStatsEntry.Builder buildBsnLacpStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnLacpStatsReply.Builder buildBsnLacpStatsReply() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnLacpStatsRequest.Builder buildBsnLacpStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnLacpStatsRequest not supported in version 1.2");
+    }
+    public OFBsnLacpStatsRequest bsnLacpStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnLacpStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnLog.Builder buildBsnLog() {
+        throw new UnsupportedOperationException("OFBsnLog not supported in version 1.2");
+    }
+
+    public OFBsnPortCounterStatsEntry.Builder buildBsnPortCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsEntry not supported in version 1.2");
+    }
+    public OFBsnPortCounterStatsEntry bsnPortCounterStatsEntry(OFPort portNo, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnPortCounterStatsReply.Builder buildBsnPortCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnPortCounterStatsRequest.Builder buildBsnPortCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnPortCounterStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnRoleStatus.Builder buildBsnRoleStatus() {
+        throw new UnsupportedOperationException("OFBsnRoleStatus not supported in version 1.2");
+    }
+
+    public OFBsnSetAuxCxnsReply.Builder buildBsnSetAuxCxnsReply() {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsReply not supported in version 1.2");
+    }
+
+    public OFBsnSetAuxCxnsRequest.Builder buildBsnSetAuxCxnsRequest() {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsRequest not supported in version 1.2");
+    }
+    public OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest(long numAux) {
+        throw new UnsupportedOperationException("OFBsnSetAuxCxnsRequest not supported in version 1.2");
+    }
+
+    public OFBsnSetLacpReply.Builder buildBsnSetLacpReply() {
+        throw new UnsupportedOperationException("OFBsnSetLacpReply not supported in version 1.2");
+    }
+
+    public OFBsnSetLacpRequest.Builder buildBsnSetLacpRequest() {
+        throw new UnsupportedOperationException("OFBsnSetLacpRequest not supported in version 1.2");
+    }
+
+    public OFBsnSetSwitchPipelineReply.Builder buildBsnSetSwitchPipelineReply() {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineReply not supported in version 1.2");
+    }
+    public OFBsnSetSwitchPipelineReply bsnSetSwitchPipelineReply(long status) {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineReply not supported in version 1.2");
+    }
+
+    public OFBsnSetSwitchPipelineRequest.Builder buildBsnSetSwitchPipelineRequest() {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineRequest not supported in version 1.2");
+    }
+    public OFBsnSetSwitchPipelineRequest bsnSetSwitchPipelineRequest(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnSetSwitchPipelineRequest not supported in version 1.2");
+    }
+
+    public OFBsnSwitchPipelineStatsEntry.Builder buildBsnSwitchPipelineStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsEntry not supported in version 1.2");
+    }
+    public OFBsnSwitchPipelineStatsEntry bsnSwitchPipelineStatsEntry(String pipeline) {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnSwitchPipelineStatsReply.Builder buildBsnSwitchPipelineStatsReply() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnSwitchPipelineStatsRequest.Builder buildBsnSwitchPipelineStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsRequest not supported in version 1.2");
+    }
+    public OFBsnSwitchPipelineStatsRequest bsnSwitchPipelineStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnSwitchPipelineStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnTableChecksumStatsEntry.Builder buildBsnTableChecksumStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsEntry not supported in version 1.2");
+    }
+    public OFBsnTableChecksumStatsEntry bsnTableChecksumStatsEntry(TableId tableId, U64 checksum) {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnTableChecksumStatsReply.Builder buildBsnTableChecksumStatsReply() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnTableChecksumStatsRequest.Builder buildBsnTableChecksumStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsRequest not supported in version 1.2");
+    }
+    public OFBsnTableChecksumStatsRequest bsnTableChecksumStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFBsnTableChecksumStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnTableSetBucketsSize.Builder buildBsnTableSetBucketsSize() {
+        throw new UnsupportedOperationException("OFBsnTableSetBucketsSize not supported in version 1.2");
+    }
+
+    public OFBsnTimeReply.Builder buildBsnTimeReply() {
+        throw new UnsupportedOperationException("OFBsnTimeReply not supported in version 1.2");
+    }
+    public OFBsnTimeReply bsnTimeReply(U64 timeMs) {
+        throw new UnsupportedOperationException("OFBsnTimeReply not supported in version 1.2");
+    }
+
+    public OFBsnTimeRequest.Builder buildBsnTimeRequest() {
+        throw new UnsupportedOperationException("OFBsnTimeRequest not supported in version 1.2");
+    }
+    public OFBsnTimeRequest bsnTimeRequest() {
+        throw new UnsupportedOperationException("OFBsnTimeRequest not supported in version 1.2");
+    }
+
+    public OFBsnVlanCounterStatsEntry.Builder buildBsnVlanCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsEntry not supported in version 1.2");
+    }
+    public OFBsnVlanCounterStatsEntry bsnVlanCounterStatsEntry(int vlanVid, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnVlanCounterStatsReply.Builder buildBsnVlanCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnVlanCounterStatsRequest.Builder buildBsnVlanCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnVlanCounterStatsRequest not supported in version 1.2");
+    }
+
+    public OFBsnVrfCounterStatsEntry.Builder buildBsnVrfCounterStatsEntry() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsEntry not supported in version 1.2");
+    }
+    public OFBsnVrfCounterStatsEntry bsnVrfCounterStatsEntry(long vrf, List<U64> values) {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsEntry not supported in version 1.2");
+    }
+
+    public OFBsnVrfCounterStatsReply.Builder buildBsnVrfCounterStatsReply() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsReply not supported in version 1.2");
+    }
+
+    public OFBsnVrfCounterStatsRequest.Builder buildBsnVrfCounterStatsRequest() {
+        throw new UnsupportedOperationException("OFBsnVrfCounterStatsRequest not supported in version 1.2");
+    }
+
+    public OFHelloElemVersionbitmap.Builder buildHelloElemVersionbitmap() {
+        throw new UnsupportedOperationException("OFHelloElemVersionbitmap not supported in version 1.2");
+    }
+    public OFHelloElemVersionbitmap helloElemVersionbitmap(List<U32> bitmaps) {
+        throw new UnsupportedOperationException("OFHelloElemVersionbitmap not supported in version 1.2");
+    }
+
+    public OFMeterBandStats.Builder buildMeterBandStats() {
+        throw new UnsupportedOperationException("OFMeterBandStats not supported in version 1.2");
+    }
+    public OFMeterBandStats meterBandStats(U64 packetBandCount, U64 byteBandCount) {
+        throw new UnsupportedOperationException("OFMeterBandStats not supported in version 1.2");
+    }
+
+    public OFMeterConfig.Builder buildMeterConfig() {
+        throw new UnsupportedOperationException("OFMeterConfig not supported in version 1.2");
+    }
+
+    public OFMeterConfigStatsReply.Builder buildMeterConfigStatsReply() {
+        throw new UnsupportedOperationException("OFMeterConfigStatsReply not supported in version 1.2");
+    }
+
+    public OFMeterConfigStatsRequest.Builder buildMeterConfigStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterConfigStatsRequest not supported in version 1.2");
+    }
+
+    public OFMeterFeatures.Builder buildMeterFeatures() {
+        throw new UnsupportedOperationException("OFMeterFeatures not supported in version 1.2");
+    }
+
+    public OFMeterFeaturesStatsReply.Builder buildMeterFeaturesStatsReply() {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsReply not supported in version 1.2");
+    }
+
+    public OFMeterFeaturesStatsRequest.Builder buildMeterFeaturesStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsRequest not supported in version 1.2");
+    }
+    public OFMeterFeaturesStatsRequest meterFeaturesStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFMeterFeaturesStatsRequest not supported in version 1.2");
+    }
+
+    public OFMeterMod.Builder buildMeterMod() {
+        throw new UnsupportedOperationException("OFMeterMod not supported in version 1.2");
+    }
+
+    public OFMeterStats.Builder buildMeterStats() {
+        throw new UnsupportedOperationException("OFMeterStats not supported in version 1.2");
+    }
+
+    public OFMeterStatsReply.Builder buildMeterStatsReply() {
+        throw new UnsupportedOperationException("OFMeterStatsReply not supported in version 1.2");
+    }
+
+    public OFMeterStatsRequest.Builder buildMeterStatsRequest() {
+        throw new UnsupportedOperationException("OFMeterStatsRequest not supported in version 1.2");
+    }
+
+    public OFPortDescStatsReply.Builder buildPortDescStatsReply() {
+        throw new UnsupportedOperationException("OFPortDescStatsReply not supported in version 1.2");
+    }
+
+    public OFPortDescStatsRequest.Builder buildPortDescStatsRequest() {
+        throw new UnsupportedOperationException("OFPortDescStatsRequest not supported in version 1.2");
+    }
+    public OFPortDescStatsRequest portDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        throw new UnsupportedOperationException("OFPortDescStatsRequest not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropApplyActions.Builder buildTableFeaturePropApplyActions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActions not supported in version 1.2");
+    }
+    public OFTableFeaturePropApplyActions tableFeaturePropApplyActions(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActions not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropApplyActionsMiss.Builder buildTableFeaturePropApplyActionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActionsMiss not supported in version 1.2");
+    }
+    public OFTableFeaturePropApplyActionsMiss tableFeaturePropApplyActionsMiss(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplyActionsMiss not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropApplySetfield.Builder buildTableFeaturePropApplySetfield() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfield not supported in version 1.2");
+    }
+    public OFTableFeaturePropApplySetfield tableFeaturePropApplySetfield(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfield not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropApplySetfieldMiss.Builder buildTableFeaturePropApplySetfieldMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfieldMiss not supported in version 1.2");
+    }
+    public OFTableFeaturePropApplySetfieldMiss tableFeaturePropApplySetfieldMiss(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropApplySetfieldMiss not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropExperimenter.Builder buildTableFeaturePropExperimenter() {
+        throw new UnsupportedOperationException("OFTableFeaturePropExperimenter not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropExperimenterMiss.Builder buildTableFeaturePropExperimenterMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropExperimenterMiss not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropInstructions.Builder buildTableFeaturePropInstructions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructions not supported in version 1.2");
+    }
+    public OFTableFeaturePropInstructions tableFeaturePropInstructions(List<OFInstructionId> instructionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructions not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropInstructionsMiss.Builder buildTableFeaturePropInstructionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructionsMiss not supported in version 1.2");
+    }
+    public OFTableFeaturePropInstructionsMiss tableFeaturePropInstructionsMiss(List<OFInstructionId> instructionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropInstructionsMiss not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropMatch.Builder buildTableFeaturePropMatch() {
+        throw new UnsupportedOperationException("OFTableFeaturePropMatch not supported in version 1.2");
+    }
+    public OFTableFeaturePropMatch tableFeaturePropMatch(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropMatch not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropNextTables.Builder buildTableFeaturePropNextTables() {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTables not supported in version 1.2");
+    }
+    public OFTableFeaturePropNextTables tableFeaturePropNextTables(List<U8> nextTableIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTables not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropNextTablesMiss.Builder buildTableFeaturePropNextTablesMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTablesMiss not supported in version 1.2");
+    }
+    public OFTableFeaturePropNextTablesMiss tableFeaturePropNextTablesMiss(List<U8> nextTableIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropNextTablesMiss not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropWildcards.Builder buildTableFeaturePropWildcards() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWildcards not supported in version 1.2");
+    }
+    public OFTableFeaturePropWildcards tableFeaturePropWildcards(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWildcards not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropWriteActions.Builder buildTableFeaturePropWriteActions() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActions not supported in version 1.2");
+    }
+    public OFTableFeaturePropWriteActions tableFeaturePropWriteActions(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActions not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropWriteActionsMiss.Builder buildTableFeaturePropWriteActionsMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActionsMiss not supported in version 1.2");
+    }
+    public OFTableFeaturePropWriteActionsMiss tableFeaturePropWriteActionsMiss(List<OFActionId> actionIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteActionsMiss not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropWriteSetfield.Builder buildTableFeaturePropWriteSetfield() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfield not supported in version 1.2");
+    }
+    public OFTableFeaturePropWriteSetfield tableFeaturePropWriteSetfield(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfield not supported in version 1.2");
+    }
+
+    public OFTableFeaturePropWriteSetfieldMiss.Builder buildTableFeaturePropWriteSetfieldMiss() {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfieldMiss not supported in version 1.2");
+    }
+    public OFTableFeaturePropWriteSetfieldMiss tableFeaturePropWriteSetfieldMiss(List<U32> oxmIds) {
+        throw new UnsupportedOperationException("OFTableFeaturePropWriteSetfieldMiss not supported in version 1.2");
+    }
+
+    public OFTableFeatures.Builder buildTableFeatures() {
+        throw new UnsupportedOperationException("OFTableFeatures not supported in version 1.2");
+    }
+
+    public OFTableFeaturesStatsReply.Builder buildTableFeaturesStatsReply() {
+        throw new UnsupportedOperationException("OFTableFeaturesStatsReply not supported in version 1.2");
+    }
+
+    public OFTableFeaturesStatsRequest.Builder buildTableFeaturesStatsRequest() {
+        throw new UnsupportedOperationException("OFTableFeaturesStatsRequest not supported in version 1.2");
+    }
+
+    public OFUint64.Builder buildUint64() {
+        throw new UnsupportedOperationException("OFUint64 not supported in version 1.2");
+    }
+    public OFUint64 uint64(U64 value) {
+        throw new UnsupportedOperationException("OFUint64 not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFMessage> getReader() {
+        return OFMessageVer12.READER;
+    }
+
+    public long nextXid() {
+        return xidGenerator.nextXid();
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFeaturesReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFeaturesReplyVer12.java
new file mode 100644
index 0000000..2f0b300
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFeaturesReplyVer12.java
@@ -0,0 +1,630 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFeaturesReplyVer12 implements OFFeaturesReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFFeaturesReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static DatapathId DEFAULT_DATAPATH_ID = DatapathId.NONE;
+        private final static long DEFAULT_N_BUFFERS = 0x0L;
+        private final static short DEFAULT_N_TABLES = (short) 0x0;
+        private final static Set<OFCapabilities> DEFAULT_CAPABILITIES = ImmutableSet.<OFCapabilities>of();
+        private final static long DEFAULT_RESERVED = 0x0L;
+        private final static List<OFPortDesc> DEFAULT_PORTS = ImmutableList.<OFPortDesc>of();
+
+    // OF message fields
+    private final long xid;
+    private final DatapathId datapathId;
+    private final long nBuffers;
+    private final short nTables;
+    private final Set<OFCapabilities> capabilities;
+    private final long reserved;
+    private final List<OFPortDesc> ports;
+//
+    // Immutable default instance
+    final static OFFeaturesReplyVer12 DEFAULT = new OFFeaturesReplyVer12(
+        DEFAULT_XID, DEFAULT_DATAPATH_ID, DEFAULT_N_BUFFERS, DEFAULT_N_TABLES, DEFAULT_CAPABILITIES, DEFAULT_RESERVED, DEFAULT_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFeaturesReplyVer12(long xid, DatapathId datapathId, long nBuffers, short nTables, Set<OFCapabilities> capabilities, long reserved, List<OFPortDesc> ports) {
+        this.xid = xid;
+        this.datapathId = datapathId;
+        this.nBuffers = nBuffers;
+        this.nTables = nTables;
+        this.capabilities = capabilities;
+        this.reserved = reserved;
+        this.ports = ports;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.2");
+    }
+
+
+
+    public OFFeaturesReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFeaturesReply.Builder {
+        final OFFeaturesReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean datapathIdSet;
+        private DatapathId datapathId;
+        private boolean nBuffersSet;
+        private long nBuffers;
+        private boolean nTablesSet;
+        private short nTables;
+        private boolean capabilitiesSet;
+        private Set<OFCapabilities> capabilities;
+        private boolean reservedSet;
+        private long reserved;
+        private boolean portsSet;
+        private List<OFPortDesc> ports;
+
+        BuilderWithParent(OFFeaturesReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setDatapathId(DatapathId datapathId) {
+        this.datapathId = datapathId;
+        this.datapathIdSet = true;
+        return this;
+    }
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNBuffers(long nBuffers) {
+        this.nBuffers = nBuffers;
+        this.nBuffersSet = true;
+        return this;
+    }
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNTables(short nTables) {
+        this.nTables = nTables;
+        this.nTablesSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setCapabilities(Set<OFCapabilities> capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setReserved(long reserved) {
+        this.reserved = reserved;
+        this.reservedSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setPorts(List<OFPortDesc> ports) {
+        this.ports = ports;
+        this.portsSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setActions(Set<OFActionType> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.2");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setAuxiliaryId(OFAuxId auxiliaryId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.2");
+    }
+
+
+        @Override
+        public OFFeaturesReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                DatapathId datapathId = this.datapathIdSet ? this.datapathId : parentMessage.datapathId;
+                if(datapathId == null)
+                    throw new NullPointerException("Property datapathId must not be null");
+                long nBuffers = this.nBuffersSet ? this.nBuffers : parentMessage.nBuffers;
+                short nTables = this.nTablesSet ? this.nTables : parentMessage.nTables;
+                Set<OFCapabilities> capabilities = this.capabilitiesSet ? this.capabilities : parentMessage.capabilities;
+                if(capabilities == null)
+                    throw new NullPointerException("Property capabilities must not be null");
+                long reserved = this.reservedSet ? this.reserved : parentMessage.reserved;
+                List<OFPortDesc> ports = this.portsSet ? this.ports : parentMessage.ports;
+                if(ports == null)
+                    throw new NullPointerException("Property ports must not be null");
+
+                //
+                return new OFFeaturesReplyVer12(
+                    xid,
+                    datapathId,
+                    nBuffers,
+                    nTables,
+                    capabilities,
+                    reserved,
+                    ports
+                );
+        }
+
+    }
+
+    static class Builder implements OFFeaturesReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean datapathIdSet;
+        private DatapathId datapathId;
+        private boolean nBuffersSet;
+        private long nBuffers;
+        private boolean nTablesSet;
+        private short nTables;
+        private boolean capabilitiesSet;
+        private Set<OFCapabilities> capabilities;
+        private boolean reservedSet;
+        private long reserved;
+        private boolean portsSet;
+        private List<OFPortDesc> ports;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setDatapathId(DatapathId datapathId) {
+        this.datapathId = datapathId;
+        this.datapathIdSet = true;
+        return this;
+    }
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNBuffers(long nBuffers) {
+        this.nBuffers = nBuffers;
+        this.nBuffersSet = true;
+        return this;
+    }
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNTables(short nTables) {
+        this.nTables = nTables;
+        this.nTablesSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setCapabilities(Set<OFCapabilities> capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setReserved(long reserved) {
+        this.reserved = reserved;
+        this.reservedSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ports;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setPorts(List<OFPortDesc> ports) {
+        this.ports = ports;
+        this.portsSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setActions(Set<OFActionType> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+    @Override
+    public OFAuxId getAuxiliaryId()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.2");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setAuxiliaryId(OFAuxId auxiliaryId) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property auxiliaryId not supported in version 1.2");
+    }
+//
+        @Override
+        public OFFeaturesReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            DatapathId datapathId = this.datapathIdSet ? this.datapathId : DEFAULT_DATAPATH_ID;
+            if(datapathId == null)
+                throw new NullPointerException("Property datapathId must not be null");
+            long nBuffers = this.nBuffersSet ? this.nBuffers : DEFAULT_N_BUFFERS;
+            short nTables = this.nTablesSet ? this.nTables : DEFAULT_N_TABLES;
+            Set<OFCapabilities> capabilities = this.capabilitiesSet ? this.capabilities : DEFAULT_CAPABILITIES;
+            if(capabilities == null)
+                throw new NullPointerException("Property capabilities must not be null");
+            long reserved = this.reservedSet ? this.reserved : DEFAULT_RESERVED;
+            List<OFPortDesc> ports = this.portsSet ? this.ports : DEFAULT_PORTS;
+            if(ports == null)
+                throw new NullPointerException("Property ports must not be null");
+
+
+            return new OFFeaturesReplyVer12(
+                    xid,
+                    datapathId,
+                    nBuffers,
+                    nTables,
+                    capabilities,
+                    reserved,
+                    ports
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFeaturesReply> {
+        @Override
+        public OFFeaturesReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 6
+            byte type = bb.readByte();
+            if(type != (byte) 0x6)
+                throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REPLY(6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            DatapathId datapathId = DatapathId.of(bb.readLong());
+            long nBuffers = U32.f(bb.readInt());
+            short nTables = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            Set<OFCapabilities> capabilities = OFCapabilitiesSerializerVer12.readFrom(bb);
+            long reserved = U32.f(bb.readInt());
+            List<OFPortDesc> ports = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPortDescVer12.READER);
+
+            OFFeaturesReplyVer12 featuresReplyVer12 = new OFFeaturesReplyVer12(
+                    xid,
+                      datapathId,
+                      nBuffers,
+                      nTables,
+                      capabilities,
+                      reserved,
+                      ports
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", featuresReplyVer12);
+            return featuresReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFeaturesReplyVer12Funnel FUNNEL = new OFFeaturesReplyVer12Funnel();
+    static class OFFeaturesReplyVer12Funnel implements Funnel<OFFeaturesReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFeaturesReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 6
+            sink.putByte((byte) 0x6);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.datapathId.putTo(sink);
+            sink.putLong(message.nBuffers);
+            sink.putShort(message.nTables);
+            // skip pad (3 bytes)
+            OFCapabilitiesSerializerVer12.putTo(message.capabilities, sink);
+            sink.putLong(message.reserved);
+            FunnelUtils.putList(message.ports, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFeaturesReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFeaturesReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 6
+            bb.writeByte((byte) 0x6);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.datapathId.getLong());
+            bb.writeInt(U32.t(message.nBuffers));
+            bb.writeByte(U8.t(message.nTables));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            OFCapabilitiesSerializerVer12.writeTo(bb, message.capabilities);
+            bb.writeInt(U32.t(message.reserved));
+            ChannelUtils.writeList(bb, message.ports);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFeaturesReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("datapathId=").append(datapathId);
+        b.append(", ");
+        b.append("nBuffers=").append(nBuffers);
+        b.append(", ");
+        b.append("nTables=").append(nTables);
+        b.append(", ");
+        b.append("capabilities=").append(capabilities);
+        b.append(", ");
+        b.append("reserved=").append(reserved);
+        b.append(", ");
+        b.append("ports=").append(ports);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFeaturesReplyVer12 other = (OFFeaturesReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (datapathId == null) {
+            if (other.datapathId != null)
+                return false;
+        } else if (!datapathId.equals(other.datapathId))
+            return false;
+        if( nBuffers != other.nBuffers)
+            return false;
+        if( nTables != other.nTables)
+            return false;
+        if (capabilities == null) {
+            if (other.capabilities != null)
+                return false;
+        } else if (!capabilities.equals(other.capabilities))
+            return false;
+        if( reserved != other.reserved)
+            return false;
+        if (ports == null) {
+            if (other.ports != null)
+                return false;
+        } else if (!ports.equals(other.ports))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((datapathId == null) ? 0 : datapathId.hashCode());
+        result = prime *  (int) (nBuffers ^ (nBuffers >>> 32));
+        result = prime * result + nTables;
+        result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode());
+        result = prime *  (int) (reserved ^ (reserved >>> 32));
+        result = prime * result + ((ports == null) ? 0 : ports.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFeaturesRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFeaturesRequestVer12.java
new file mode 100644
index 0000000..7c140b4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFeaturesRequestVer12.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFeaturesRequestVer12 implements OFFeaturesRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFFeaturesRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFFeaturesRequestVer12 DEFAULT = new OFFeaturesRequestVer12(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFeaturesRequestVer12(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFFeaturesRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFeaturesRequest.Builder {
+        final OFFeaturesRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFFeaturesRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFeaturesRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFFeaturesRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFFeaturesRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFeaturesRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFFeaturesRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFeaturesRequest> {
+        @Override
+        public OFFeaturesRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 5
+            byte type = bb.readByte();
+            if(type != (byte) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REQUEST(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFFeaturesRequestVer12 featuresRequestVer12 = new OFFeaturesRequestVer12(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", featuresRequestVer12);
+            return featuresRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFeaturesRequestVer12Funnel FUNNEL = new OFFeaturesRequestVer12Funnel();
+    static class OFFeaturesRequestVer12Funnel implements Funnel<OFFeaturesRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFeaturesRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 5
+            sink.putByte((byte) 0x5);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFeaturesRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFeaturesRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 5
+            bb.writeByte((byte) 0x5);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFeaturesRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFeaturesRequestVer12 other = (OFFeaturesRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowAddVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowAddVer12.java
new file mode 100644
index 0000000..7eb68fd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowAddVer12.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowAddVer12 implements OFFlowAdd {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowAddVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowAddVer12 DEFAULT = new OFFlowAddVer12(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowAddVer12(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+
+    public OFFlowAdd.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowAdd.Builder {
+        final OFFlowAddVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowAddVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+        @Override
+        public OFFlowAdd build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowAddVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowAdd.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowAdd.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+//
+        @Override
+        public OFFlowAdd build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowAddVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowAdd> {
+        @Override
+        public OFFlowAdd readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 0
+            short command = bb.readByte();
+            if(command != (short) 0x0)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.ADD(0), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer12.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer12.READER);
+
+            OFFlowAddVer12 flowAddVer12 = new OFFlowAddVer12(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowAddVer12);
+            return flowAddVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowAddVer12Funnel FUNNEL = new OFFlowAddVer12Funnel();
+    static class OFFlowAddVer12Funnel implements Funnel<OFFlowAddVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowAddVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 0
+            sink.putShort((short) 0x0);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowAddVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowAddVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 0
+            bb.writeByte((short) 0x0);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowAddVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowAddVer12 other = (OFFlowAddVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowDeleteStrictVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowDeleteStrictVer12.java
new file mode 100644
index 0000000..7ea9195
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowDeleteStrictVer12.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowDeleteStrictVer12 implements OFFlowDeleteStrict {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteStrictVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowDeleteStrictVer12 DEFAULT = new OFFlowDeleteStrictVer12(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowDeleteStrictVer12(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+
+    public OFFlowDeleteStrict.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowDeleteStrict.Builder {
+        final OFFlowDeleteStrictVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowDeleteStrictVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+        @Override
+        public OFFlowDeleteStrict build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowDeleteStrictVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowDeleteStrict.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+//
+        @Override
+        public OFFlowDeleteStrict build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowDeleteStrictVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowDeleteStrict> {
+        @Override
+        public OFFlowDeleteStrict readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 4
+            short command = bb.readByte();
+            if(command != (short) 0x4)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE_STRICT(4), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer12.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer12.READER);
+
+            OFFlowDeleteStrictVer12 flowDeleteStrictVer12 = new OFFlowDeleteStrictVer12(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowDeleteStrictVer12);
+            return flowDeleteStrictVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowDeleteStrictVer12Funnel FUNNEL = new OFFlowDeleteStrictVer12Funnel();
+    static class OFFlowDeleteStrictVer12Funnel implements Funnel<OFFlowDeleteStrictVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowDeleteStrictVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 4
+            sink.putShort((short) 0x4);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowDeleteStrictVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowDeleteStrictVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 4
+            bb.writeByte((short) 0x4);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowDeleteStrictVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowDeleteStrictVer12 other = (OFFlowDeleteStrictVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowDeleteVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowDeleteVer12.java
new file mode 100644
index 0000000..287b61d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowDeleteVer12.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowDeleteVer12 implements OFFlowDelete {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowDeleteVer12 DEFAULT = new OFFlowDeleteVer12(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowDeleteVer12(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+
+    public OFFlowDelete.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowDelete.Builder {
+        final OFFlowDeleteVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowDeleteVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+        @Override
+        public OFFlowDelete build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowDeleteVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowDelete.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowDelete.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+//
+        @Override
+        public OFFlowDelete build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowDeleteVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowDelete> {
+        @Override
+        public OFFlowDelete readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 3
+            short command = bb.readByte();
+            if(command != (short) 0x3)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE(3), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer12.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer12.READER);
+
+            OFFlowDeleteVer12 flowDeleteVer12 = new OFFlowDeleteVer12(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowDeleteVer12);
+            return flowDeleteVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowDeleteVer12Funnel FUNNEL = new OFFlowDeleteVer12Funnel();
+    static class OFFlowDeleteVer12Funnel implements Funnel<OFFlowDeleteVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowDeleteVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 3
+            sink.putShort((short) 0x3);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowDeleteVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowDeleteVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 3
+            bb.writeByte((short) 0x3);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowDeleteVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowDeleteVer12 other = (OFFlowDeleteVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModCommandSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModCommandSerializerVer12.java
new file mode 100644
index 0000000..1865226
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModCommandSerializerVer12.java
@@ -0,0 +1,89 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModCommand;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowModCommandSerializerVer12 {
+
+    public final static byte ADD_VAL = (byte) 0x0;
+    public final static byte MODIFY_VAL = (byte) 0x1;
+    public final static byte MODIFY_STRICT_VAL = (byte) 0x2;
+    public final static byte DELETE_VAL = (byte) 0x3;
+    public final static byte DELETE_STRICT_VAL = (byte) 0x4;
+
+    public static OFFlowModCommand readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowModCommand e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowModCommand e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFFlowModCommand ofWireValue(byte val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFFlowModCommand.ADD;
+            case MODIFY_VAL:
+                return OFFlowModCommand.MODIFY;
+            case MODIFY_STRICT_VAL:
+                return OFFlowModCommand.MODIFY_STRICT;
+            case DELETE_VAL:
+                return OFFlowModCommand.DELETE;
+            case DELETE_STRICT_VAL:
+                return OFFlowModCommand.DELETE_STRICT;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowModCommand in version 1.2: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFFlowModCommand e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            case MODIFY_STRICT:
+                return MODIFY_STRICT_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case DELETE_STRICT:
+                return DELETE_STRICT_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowModCommand in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFailedCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFailedCodeSerializerVer12.java
new file mode 100644
index 0000000..938c8fa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFailedCodeSerializerVer12.java
@@ -0,0 +1,104 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowModFailedCodeSerializerVer12 {
+
+    public final static short UNKNOWN_VAL = (short) 0x0;
+    public final static short TABLE_FULL_VAL = (short) 0x1;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x2;
+    public final static short OVERLAP_VAL = (short) 0x3;
+    public final static short EPERM_VAL = (short) 0x4;
+    public final static short BAD_TIMEOUT_VAL = (short) 0x5;
+    public final static short BAD_COMMAND_VAL = (short) 0x6;
+    public final static short BAD_FLAGS_VAL = (short) 0x7;
+
+    public static OFFlowModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFFlowModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case UNKNOWN_VAL:
+                return OFFlowModFailedCode.UNKNOWN;
+            case TABLE_FULL_VAL:
+                return OFFlowModFailedCode.TABLE_FULL;
+            case BAD_TABLE_ID_VAL:
+                return OFFlowModFailedCode.BAD_TABLE_ID;
+            case OVERLAP_VAL:
+                return OFFlowModFailedCode.OVERLAP;
+            case EPERM_VAL:
+                return OFFlowModFailedCode.EPERM;
+            case BAD_TIMEOUT_VAL:
+                return OFFlowModFailedCode.BAD_TIMEOUT;
+            case BAD_COMMAND_VAL:
+                return OFFlowModFailedCode.BAD_COMMAND;
+            case BAD_FLAGS_VAL:
+                return OFFlowModFailedCode.BAD_FLAGS;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowModFailedCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFFlowModFailedCode e) {
+        switch(e) {
+            case UNKNOWN:
+                return UNKNOWN_VAL;
+            case TABLE_FULL:
+                return TABLE_FULL_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            case OVERLAP:
+                return OVERLAP_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case BAD_TIMEOUT:
+                return BAD_TIMEOUT_VAL;
+            case BAD_COMMAND:
+                return BAD_COMMAND_VAL;
+            case BAD_FLAGS:
+                return BAD_FLAGS_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowModFailedCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFailedErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFailedErrorMsgVer12.java
new file mode 100644
index 0000000..eec91f1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFailedErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModFailedErrorMsgVer12 implements OFFlowModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModFailedErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFFlowModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModFailedErrorMsgVer12(long xid, OFFlowModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFFlowModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModFailedErrorMsg.Builder {
+        final OFFlowModFailedErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFFlowModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFFlowModFailedErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setCode(OFFlowModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFFlowModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFFlowModFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFFlowModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setCode(OFFlowModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFFlowModFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModFailedErrorMsg> {
+        @Override
+        public OFFlowModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 5
+            short errType = bb.readShort();
+            if(errType != (short) 0x5)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.FLOW_MOD_FAILED(5), got="+errType);
+            OFFlowModFailedCode code = OFFlowModFailedCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFFlowModFailedErrorMsgVer12 flowModFailedErrorMsgVer12 = new OFFlowModFailedErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModFailedErrorMsgVer12);
+            return flowModFailedErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModFailedErrorMsgVer12Funnel FUNNEL = new OFFlowModFailedErrorMsgVer12Funnel();
+    static class OFFlowModFailedErrorMsgVer12Funnel implements Funnel<OFFlowModFailedErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModFailedErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 5
+            sink.putShort((short) 0x5);
+            OFFlowModFailedCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModFailedErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModFailedErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 5
+            bb.writeShort((short) 0x5);
+            OFFlowModFailedCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModFailedErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModFailedErrorMsgVer12 other = (OFFlowModFailedErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFlagsSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFlagsSerializerVer12.java
new file mode 100644
index 0000000..7bc1953
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModFlagsSerializerVer12.java
@@ -0,0 +1,90 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFFlowModFlagsSerializerVer12 {
+
+    public final static short SEND_FLOW_REM_VAL = (short) 0x1;
+    public final static short CHECK_OVERLAP_VAL = (short) 0x2;
+    public final static short RESET_COUNTS_VAL = (short) 0x4;
+
+    public static Set<OFFlowModFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFFlowModFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFFlowModFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFFlowModFlags> ofWireValue(short val) {
+        EnumSet<OFFlowModFlags> set = EnumSet.noneOf(OFFlowModFlags.class);
+
+        if((val & SEND_FLOW_REM_VAL) != 0)
+            set.add(OFFlowModFlags.SEND_FLOW_REM);
+        if((val & CHECK_OVERLAP_VAL) != 0)
+            set.add(OFFlowModFlags.CHECK_OVERLAP);
+        if((val & RESET_COUNTS_VAL) != 0)
+            set.add(OFFlowModFlags.RESET_COUNTS);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFFlowModFlags> set) {
+        short wireValue = 0;
+
+        for(OFFlowModFlags e: set) {
+            switch(e) {
+                case SEND_FLOW_REM:
+                    wireValue |= SEND_FLOW_REM_VAL;
+                    break;
+                case CHECK_OVERLAP:
+                    wireValue |= CHECK_OVERLAP_VAL;
+                    break;
+                case RESET_COUNTS:
+                    wireValue |= RESET_COUNTS_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFFlowModFlags in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModVer12.java
new file mode 100644
index 0000000..86d71a7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModVer12.java
@@ -0,0 +1,80 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFFlowModVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+
+    public final static OFFlowModVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFFlowMod> {
+        @Override
+        public OFFlowMod readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            U64.ofRaw(bb.readLong());
+            U64.ofRaw(bb.readLong());
+            TableId.readByte(bb);
+            short command = bb.readByte();
+            bb.readerIndex(start);
+            switch(command) {
+               case (short) 0x0:
+                   // discriminator value OFFlowModCommand.ADD=0 for class OFFlowAddVer12
+                   return OFFlowAddVer12.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFFlowModCommand.DELETE=3 for class OFFlowDeleteVer12
+                   return OFFlowDeleteVer12.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFFlowModCommand.DELETE_STRICT=4 for class OFFlowDeleteStrictVer12
+                   return OFFlowDeleteStrictVer12.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFFlowModCommand.MODIFY=1 for class OFFlowModifyVer12
+                   return OFFlowModifyVer12.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFFlowModCommand.MODIFY_STRICT=2 for class OFFlowModifyStrictVer12
+                   return OFFlowModifyStrictVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator command of class OFFlowModVer12: " + command);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModifyStrictVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModifyStrictVer12.java
new file mode 100644
index 0000000..1040469
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModifyStrictVer12.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModifyStrictVer12 implements OFFlowModifyStrict {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModifyStrictVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowModifyStrictVer12 DEFAULT = new OFFlowModifyStrictVer12(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModifyStrictVer12(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+
+    public OFFlowModifyStrict.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModifyStrict.Builder {
+        final OFFlowModifyStrictVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowModifyStrictVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+        @Override
+        public OFFlowModifyStrict build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowModifyStrictVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModifyStrict.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+//
+        @Override
+        public OFFlowModifyStrict build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowModifyStrictVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModifyStrict> {
+        @Override
+        public OFFlowModifyStrict readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 2
+            short command = bb.readByte();
+            if(command != (short) 0x2)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.MODIFY_STRICT(2), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer12.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer12.READER);
+
+            OFFlowModifyStrictVer12 flowModifyStrictVer12 = new OFFlowModifyStrictVer12(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModifyStrictVer12);
+            return flowModifyStrictVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModifyStrictVer12Funnel FUNNEL = new OFFlowModifyStrictVer12Funnel();
+    static class OFFlowModifyStrictVer12Funnel implements Funnel<OFFlowModifyStrictVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModifyStrictVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 2
+            sink.putShort((short) 0x2);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModifyStrictVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModifyStrictVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 2
+            bb.writeByte((short) 0x2);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModifyStrictVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModifyStrictVer12 other = (OFFlowModifyStrictVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModifyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModifyVer12.java
new file mode 100644
index 0000000..05f7249
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowModifyVer12.java
@@ -0,0 +1,954 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModifyVer12 implements OFFlowModify {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModifyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowModifyVer12 DEFAULT = new OFFlowModifyVer12(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModifyVer12(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+
+    public OFFlowModify.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModify.Builder {
+        final OFFlowModifyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowModifyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModify.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModify.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModify.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModify.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowModify.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+
+        @Override
+        public OFFlowModify build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowModifyVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModify.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModify.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModify.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModify.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModify.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowModify.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+//
+        @Override
+        public OFFlowModify build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowModifyVer12(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModify> {
+        @Override
+        public OFFlowModify readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 1
+            short command = bb.readByte();
+            if(command != (short) 0x1)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.MODIFY(1), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer12.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer12.READER);
+
+            OFFlowModifyVer12 flowModifyVer12 = new OFFlowModifyVer12(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModifyVer12);
+            return flowModifyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModifyVer12Funnel FUNNEL = new OFFlowModifyVer12Funnel();
+    static class OFFlowModifyVer12Funnel implements Funnel<OFFlowModifyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModifyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 1
+            sink.putShort((short) 0x1);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModifyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModifyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 1
+            bb.writeByte((short) 0x1);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModifyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModifyVer12 other = (OFFlowModifyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowRemovedReasonSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowRemovedReasonSerializerVer12.java
new file mode 100644
index 0000000..5eefadb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowRemovedReasonSerializerVer12.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowRemovedReasonSerializerVer12 {
+
+    public final static byte IDLE_TIMEOUT_VAL = (byte) 0x0;
+    public final static byte HARD_TIMEOUT_VAL = (byte) 0x1;
+    public final static byte DELETE_VAL = (byte) 0x2;
+    public final static byte GROUP_DELETE_VAL = (byte) 0x3;
+
+    public static OFFlowRemovedReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowRemovedReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowRemovedReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFFlowRemovedReason ofWireValue(byte val) {
+        switch(val) {
+            case IDLE_TIMEOUT_VAL:
+                return OFFlowRemovedReason.IDLE_TIMEOUT;
+            case HARD_TIMEOUT_VAL:
+                return OFFlowRemovedReason.HARD_TIMEOUT;
+            case DELETE_VAL:
+                return OFFlowRemovedReason.DELETE;
+            case GROUP_DELETE_VAL:
+                return OFFlowRemovedReason.GROUP_DELETE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowRemovedReason in version 1.2: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFFlowRemovedReason e) {
+        switch(e) {
+            case IDLE_TIMEOUT:
+                return IDLE_TIMEOUT_VAL;
+            case HARD_TIMEOUT:
+                return HARD_TIMEOUT_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case GROUP_DELETE:
+                return GROUP_DELETE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowRemovedReason in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowRemovedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowRemovedVer12.java
new file mode 100644
index 0000000..da6db7e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowRemovedVer12.java
@@ -0,0 +1,825 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowRemovedVer12 implements OFFlowRemoved {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowRemovedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static short DEFAULT_REASON = (short) 0x0;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final int priority;
+    private final short reason;
+    private final TableId tableId;
+    private final long durationSec;
+    private final long durationNsec;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFFlowRemovedVer12 DEFAULT = new OFFlowRemovedVer12(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_PRIORITY, DEFAULT_REASON, DEFAULT_TABLE_ID, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowRemovedVer12(long xid, U64 cookie, int priority, short reason, TableId tableId, long durationSec, long durationNsec, int idleTimeout, int hardTimeout, U64 packetCount, U64 byteCount, Match match) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.priority = priority;
+        this.reason = reason;
+        this.tableId = tableId;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFFlowRemoved.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowRemoved.Builder {
+        final OFFlowRemovedVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean reasonSet;
+        private short reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFFlowRemovedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setReason(short reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowRemoved build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                short reason = this.reasonSet ? this.reason : parentMessage.reason;
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFFlowRemovedVer12(
+                    xid,
+                    cookie,
+                    priority,
+                    reason,
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    idleTimeout,
+                    hardTimeout,
+                    packetCount,
+                    byteCount,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowRemoved.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean reasonSet;
+        private short reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setReason(short reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowRemoved build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            short reason = this.reasonSet ? this.reason : DEFAULT_REASON;
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFFlowRemovedVer12(
+                    xid,
+                    cookie,
+                    priority,
+                    reason,
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    idleTimeout,
+                    hardTimeout,
+                    packetCount,
+                    byteCount,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowRemoved> {
+        @Override
+        public OFFlowRemoved readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 11
+            byte type = bb.readByte();
+            if(type != (byte) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_REMOVED(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            int priority = U16.f(bb.readShort());
+            short reason = U8.f(bb.readByte());
+            TableId tableId = TableId.readByte(bb);
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+
+            OFFlowRemovedVer12 flowRemovedVer12 = new OFFlowRemovedVer12(
+                    xid,
+                      cookie,
+                      priority,
+                      reason,
+                      tableId,
+                      durationSec,
+                      durationNsec,
+                      idleTimeout,
+                      hardTimeout,
+                      packetCount,
+                      byteCount,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowRemovedVer12);
+            return flowRemovedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowRemovedVer12Funnel FUNNEL = new OFFlowRemovedVer12Funnel();
+    static class OFFlowRemovedVer12Funnel implements Funnel<OFFlowRemovedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowRemovedVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 11
+            sink.putByte((byte) 0xb);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            sink.putInt(message.priority);
+            sink.putShort(message.reason);
+            message.tableId.putTo(sink);
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowRemovedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowRemovedVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 11
+            bb.writeByte((byte) 0xb);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeShort(U16.t(message.priority));
+            bb.writeByte(U8.t(message.reason));
+            message.tableId.writeByte(bb);
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            message.match.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowRemovedVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowRemovedVer12 other = (OFFlowRemovedVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( priority != other.priority)
+            return false;
+        if( reason != other.reason)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + priority;
+        result = prime * result + reason;
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsEntryVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsEntryVer12.java
new file mode 100644
index 0000000..cbd6ace
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsEntryVer12.java
@@ -0,0 +1,812 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsEntryVer12 implements OFFlowStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsEntryVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final TableId tableId;
+    private final long durationSec;
+    private final long durationNsec;
+    private final int priority;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final U64 cookie;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowStatsEntryVer12 DEFAULT = new OFFlowStatsEntryVer12(
+        DEFAULT_TABLE_ID, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_PRIORITY, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_COOKIE, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsEntryVer12(TableId tableId, long durationSec, long durationNsec, int priority, int idleTimeout, int hardTimeout, U64 cookie, U64 packetCount, U64 byteCount, Match match, List<OFInstruction> instructions) {
+        this.tableId = tableId;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.priority = priority;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.cookie = cookie;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFFlowStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsEntry.Builder {
+        final OFFlowStatsEntryVer12 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean prioritySet;
+        private int priority;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowStatsEntryVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property flags not supported in version 1.2");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFFlowStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowStatsEntryVer12(
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    priority,
+                    idleTimeout,
+                    hardTimeout,
+                    cookie,
+                    packetCount,
+                    byteCount,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean prioritySet;
+        private int priority;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.2");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property flags not supported in version 1.2");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property flags not supported in version 1.2");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFFlowStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowStatsEntryVer12(
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    priority,
+                    idleTimeout,
+                    hardTimeout,
+                    cookie,
+                    packetCount,
+                    byteCount,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsEntry> {
+        @Override
+        public OFFlowStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            int priority = U16.f(bb.readShort());
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer12.READER);
+
+            OFFlowStatsEntryVer12 flowStatsEntryVer12 = new OFFlowStatsEntryVer12(
+                    tableId,
+                      durationSec,
+                      durationNsec,
+                      priority,
+                      idleTimeout,
+                      hardTimeout,
+                      cookie,
+                      packetCount,
+                      byteCount,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsEntryVer12);
+            return flowStatsEntryVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsEntryVer12Funnel FUNNEL = new OFFlowStatsEntryVer12Funnel();
+    static class OFFlowStatsEntryVer12Funnel implements Funnel<OFFlowStatsEntryVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsEntryVer12 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            message.tableId.putTo(sink);
+            // skip pad (1 bytes)
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            sink.putInt(message.priority);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            // skip pad (6 bytes)
+            message.cookie.putTo(sink);
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsEntryVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsEntryVer12 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.tableId.writeByte(bb);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            // pad: 6 bytes
+            bb.writeZero(6);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsEntryVer12(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsEntryVer12 other = (OFFlowStatsEntryVer12) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + priority;
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsReplyVer12.java
new file mode 100644
index 0000000..d7f0226
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsReplyVer12.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsReplyVer12 implements OFFlowStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFFlowStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFFlowStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFFlowStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFFlowStatsReplyVer12 DEFAULT = new OFFlowStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, List<OFFlowStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFFlowStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsReply.Builder {
+        final OFFlowStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFFlowStatsEntry> entries;
+
+        BuilderWithParent(OFFlowStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setEntries(List<OFFlowStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFFlowStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFFlowStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFFlowStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setEntries(List<OFFlowStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFFlowStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFFlowStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsReply> {
+        @Override
+        public OFFlowStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 1
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x1)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.FLOW(1), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFFlowStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFFlowStatsEntryVer12.READER);
+
+            OFFlowStatsReplyVer12 flowStatsReplyVer12 = new OFFlowStatsReplyVer12(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsReplyVer12);
+            return flowStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsReplyVer12Funnel FUNNEL = new OFFlowStatsReplyVer12Funnel();
+    static class OFFlowStatsReplyVer12Funnel implements Funnel<OFFlowStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 1
+            sink.putShort((short) 0x1);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 1
+            bb.writeShort((short) 0x1);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsReplyVer12 other = (OFFlowStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsRequestVer12.java
new file mode 100644
index 0000000..ebed377
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFFlowStatsRequestVer12.java
@@ -0,0 +1,690 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsRequestVer12 implements OFFlowStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final TableId tableId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFFlowStatsRequestVer12 DEFAULT = new OFFlowStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TABLE_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags, TableId tableId, OFPort outPort, OFGroup outGroup, U64 cookie, U64 cookieMask, Match match) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFFlowStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsRequest.Builder {
+        final OFFlowStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFFlowStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFFlowStatsRequestVer12(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFFlowStatsRequestVer12(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsRequest> {
+        @Override
+        public OFFlowStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 1
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x1)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.FLOW(1), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+
+            OFFlowStatsRequestVer12 flowStatsRequestVer12 = new OFFlowStatsRequestVer12(
+                    xid,
+                      flags,
+                      tableId,
+                      outPort,
+                      outGroup,
+                      cookie,
+                      cookieMask,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsRequestVer12);
+            return flowStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsRequestVer12Funnel FUNNEL = new OFFlowStatsRequestVer12Funnel();
+    static class OFFlowStatsRequestVer12Funnel implements Funnel<OFFlowStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 1
+            sink.putShort((short) 0x1);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            // skip pad (4 bytes)
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsRequestVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 1
+            bb.writeShort((short) 0x1);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.match.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsRequestVer12 other = (OFFlowStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGetConfigReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGetConfigReplyVer12.java
new file mode 100644
index 0000000..8cd125a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGetConfigReplyVer12.java
@@ -0,0 +1,370 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGetConfigReplyVer12 implements OFGetConfigReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGetConfigReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFConfigFlags> DEFAULT_FLAGS = ImmutableSet.<OFConfigFlags>of();
+        private final static int DEFAULT_MISS_SEND_LEN = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFConfigFlags> flags;
+    private final int missSendLen;
+//
+    // Immutable default instance
+    final static OFGetConfigReplyVer12 DEFAULT = new OFGetConfigReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MISS_SEND_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGetConfigReplyVer12(long xid, Set<OFConfigFlags> flags, int missSendLen) {
+        this.xid = xid;
+        this.flags = flags;
+        this.missSendLen = missSendLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+
+
+    public OFGetConfigReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGetConfigReply.Builder {
+        final OFGetConfigReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+        BuilderWithParent(OFGetConfigReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGetConfigReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFConfigFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int missSendLen = this.missSendLenSet ? this.missSendLen : parentMessage.missSendLen;
+
+                //
+                return new OFGetConfigReplyVer12(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFGetConfigReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGetConfigReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFConfigFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int missSendLen = this.missSendLenSet ? this.missSendLen : DEFAULT_MISS_SEND_LEN;
+
+
+            return new OFGetConfigReplyVer12(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGetConfigReply> {
+        @Override
+        public OFGetConfigReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 8
+            byte type = bb.readByte();
+            if(type != (byte) 0x8)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REPLY(8), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Set<OFConfigFlags> flags = OFConfigFlagsSerializerVer12.readFrom(bb);
+            int missSendLen = U16.f(bb.readShort());
+
+            OFGetConfigReplyVer12 getConfigReplyVer12 = new OFGetConfigReplyVer12(
+                    xid,
+                      flags,
+                      missSendLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", getConfigReplyVer12);
+            return getConfigReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGetConfigReplyVer12Funnel FUNNEL = new OFGetConfigReplyVer12Funnel();
+    static class OFGetConfigReplyVer12Funnel implements Funnel<OFGetConfigReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGetConfigReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 8
+            sink.putByte((byte) 0x8);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            OFConfigFlagsSerializerVer12.putTo(message.flags, sink);
+            sink.putInt(message.missSendLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGetConfigReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGetConfigReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 8
+            bb.writeByte((byte) 0x8);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            OFConfigFlagsSerializerVer12.writeTo(bb, message.flags);
+            bb.writeShort(U16.t(message.missSendLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGetConfigReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("missSendLen=").append(missSendLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGetConfigReplyVer12 other = (OFGetConfigReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( missSendLen != other.missSendLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + missSendLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGetConfigRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGetConfigRequestVer12.java
new file mode 100644
index 0000000..04a6b7a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGetConfigRequestVer12.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGetConfigRequestVer12 implements OFGetConfigRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGetConfigRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFGetConfigRequestVer12 DEFAULT = new OFGetConfigRequestVer12(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGetConfigRequestVer12(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFGetConfigRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGetConfigRequest.Builder {
+        final OFGetConfigRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFGetConfigRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGetConfigRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFGetConfigRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFGetConfigRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGetConfigRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFGetConfigRequestVer12(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGetConfigRequest> {
+        @Override
+        public OFGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 7
+            byte type = bb.readByte();
+            if(type != (byte) 0x7)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REQUEST(7), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFGetConfigRequestVer12 getConfigRequestVer12 = new OFGetConfigRequestVer12(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", getConfigRequestVer12);
+            return getConfigRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGetConfigRequestVer12Funnel FUNNEL = new OFGetConfigRequestVer12Funnel();
+    static class OFGetConfigRequestVer12Funnel implements Funnel<OFGetConfigRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGetConfigRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 7
+            sink.putByte((byte) 0x7);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGetConfigRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGetConfigRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 7
+            bb.writeByte((byte) 0x7);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGetConfigRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGetConfigRequestVer12 other = (OFGetConfigRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupAddVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupAddVer12.java
new file mode 100644
index 0000000..215f761
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupAddVer12.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupAddVer12 implements OFGroupAdd {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupAddVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupAddVer12(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupAdd.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupAdd.Builder {
+        final OFGroupAddVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupAddVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupAdd build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupAddVer12(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupAdd.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupAdd build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupAddVer12(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupAdd> {
+        @Override
+        public OFGroupAdd readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 0
+            short command = bb.readShort();
+            if(command != (short) 0x0)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.ADD(0), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer12.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer12.READER);
+
+            OFGroupAddVer12 groupAddVer12 = new OFGroupAddVer12(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupAddVer12);
+            return groupAddVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupAddVer12Funnel FUNNEL = new OFGroupAddVer12Funnel();
+    static class OFGroupAddVer12Funnel implements Funnel<OFGroupAddVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupAddVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 0
+            sink.putShort((short) 0x0);
+            OFGroupTypeSerializerVer12.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupAddVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupAddVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 0
+            bb.writeShort((short) 0x0);
+            OFGroupTypeSerializerVer12.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupAddVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupAddVer12 other = (OFGroupAddVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupCapabilitiesSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupCapabilitiesSerializerVer12.java
new file mode 100644
index 0000000..6c99bc6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupCapabilitiesSerializerVer12.java
@@ -0,0 +1,96 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupCapabilities;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFGroupCapabilitiesSerializerVer12 {
+
+    public final static int SELECT_WEIGHT_VAL = 0x1;
+    public final static int SELECT_LIVENESS_VAL = 0x2;
+    public final static int CHAINING_VAL = 0x4;
+    public final static int CHAINING_CHECKS_VAL = 0x8;
+
+    public static Set<OFGroupCapabilities> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFGroupCapabilities> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFGroupCapabilities> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFGroupCapabilities> ofWireValue(int val) {
+        EnumSet<OFGroupCapabilities> set = EnumSet.noneOf(OFGroupCapabilities.class);
+
+        if((val & SELECT_WEIGHT_VAL) != 0)
+            set.add(OFGroupCapabilities.SELECT_WEIGHT);
+        if((val & SELECT_LIVENESS_VAL) != 0)
+            set.add(OFGroupCapabilities.SELECT_LIVENESS);
+        if((val & CHAINING_VAL) != 0)
+            set.add(OFGroupCapabilities.CHAINING);
+        if((val & CHAINING_CHECKS_VAL) != 0)
+            set.add(OFGroupCapabilities.CHAINING_CHECKS);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFGroupCapabilities> set) {
+        int wireValue = 0;
+
+        for(OFGroupCapabilities e: set) {
+            switch(e) {
+                case SELECT_WEIGHT:
+                    wireValue |= SELECT_WEIGHT_VAL;
+                    break;
+                case SELECT_LIVENESS:
+                    wireValue |= SELECT_LIVENESS_VAL;
+                    break;
+                case CHAINING:
+                    wireValue |= CHAINING_VAL;
+                    break;
+                case CHAINING_CHECKS:
+                    wireValue |= CHAINING_CHECKS_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFGroupCapabilities in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDeleteVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDeleteVer12.java
new file mode 100644
index 0000000..c0c5407
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDeleteVer12.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDeleteVer12 implements OFGroupDelete {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDeleteVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDeleteVer12(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupDelete.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDelete.Builder {
+        final OFGroupDeleteVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupDeleteVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDelete build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupDeleteVer12(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDelete.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDelete build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupDeleteVer12(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDelete> {
+        @Override
+        public OFGroupDelete readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 2
+            short command = bb.readShort();
+            if(command != (short) 0x2)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.DELETE(2), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer12.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer12.READER);
+
+            OFGroupDeleteVer12 groupDeleteVer12 = new OFGroupDeleteVer12(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDeleteVer12);
+            return groupDeleteVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDeleteVer12Funnel FUNNEL = new OFGroupDeleteVer12Funnel();
+    static class OFGroupDeleteVer12Funnel implements Funnel<OFGroupDeleteVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDeleteVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 2
+            sink.putShort((short) 0x2);
+            OFGroupTypeSerializerVer12.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDeleteVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDeleteVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 2
+            bb.writeShort((short) 0x2);
+            OFGroupTypeSerializerVer12.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDeleteVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDeleteVer12 other = (OFGroupDeleteVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsEntryVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsEntryVer12.java
new file mode 100644
index 0000000..c9b9c3f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsEntryVer12.java
@@ -0,0 +1,360 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsEntryVer12 implements OFGroupDescStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsEntryVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsEntryVer12(OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFGroupDescStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsEntry.Builder {
+        final OFGroupDescStatsEntryVer12 parentMessage;
+
+        // OF message fields
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupDescStatsEntryVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFGroupDescStatsEntry build() {
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupDescStatsEntryVer12(
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsEntry.Builder {
+        // OF message fields
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFGroupDescStatsEntry build() {
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupDescStatsEntryVer12(
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsEntry> {
+        @Override
+        public OFGroupDescStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFGroupType groupType = OFGroupTypeSerializerVer12.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer12.READER);
+
+            OFGroupDescStatsEntryVer12 groupDescStatsEntryVer12 = new OFGroupDescStatsEntryVer12(
+                    groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsEntryVer12);
+            return groupDescStatsEntryVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsEntryVer12Funnel FUNNEL = new OFGroupDescStatsEntryVer12Funnel();
+    static class OFGroupDescStatsEntryVer12Funnel implements Funnel<OFGroupDescStatsEntryVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsEntryVer12 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            OFGroupTypeSerializerVer12.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsEntryVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsEntryVer12 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            OFGroupTypeSerializerVer12.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsEntryVer12(");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsEntryVer12 other = (OFGroupDescStatsEntryVer12) obj;
+
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsReplyVer12.java
new file mode 100644
index 0000000..7c88c9e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsReplyVer12.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsReplyVer12 implements OFGroupDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFGroupDescStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFGroupDescStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFGroupDescStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFGroupDescStatsReplyVer12 DEFAULT = new OFGroupDescStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, List<OFGroupDescStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFGroupDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsReply.Builder {
+        final OFGroupDescStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupDescStatsEntry> entries;
+
+        BuilderWithParent(OFGroupDescStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setEntries(List<OFGroupDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFGroupDescStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFGroupDescStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupDescStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setEntries(List<OFGroupDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFGroupDescStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFGroupDescStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsReply> {
+        @Override
+        public OFGroupDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 7
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x7)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_DESC(7), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFGroupDescStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFGroupDescStatsEntryVer12.READER);
+
+            OFGroupDescStatsReplyVer12 groupDescStatsReplyVer12 = new OFGroupDescStatsReplyVer12(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsReplyVer12);
+            return groupDescStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsReplyVer12Funnel FUNNEL = new OFGroupDescStatsReplyVer12Funnel();
+    static class OFGroupDescStatsReplyVer12Funnel implements Funnel<OFGroupDescStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 7
+            sink.putShort((short) 0x7);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 7
+            bb.writeShort((short) 0x7);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsReplyVer12 other = (OFGroupDescStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsRequestVer12.java
new file mode 100644
index 0000000..9fd4a8e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupDescStatsRequestVer12.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsRequestVer12 implements OFGroupDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFGroupDescStatsRequestVer12 DEFAULT = new OFGroupDescStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFGroupDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsRequest.Builder {
+        final OFGroupDescStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFGroupDescStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFGroupDescStatsRequestVer12(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFGroupDescStatsRequestVer12(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsRequest> {
+        @Override
+        public OFGroupDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 7
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x7)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_DESC(7), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFGroupDescStatsRequestVer12 groupDescStatsRequestVer12 = new OFGroupDescStatsRequestVer12(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsRequestVer12);
+            return groupDescStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsRequestVer12Funnel FUNNEL = new OFGroupDescStatsRequestVer12Funnel();
+    static class OFGroupDescStatsRequestVer12Funnel implements Funnel<OFGroupDescStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 7
+            sink.putShort((short) 0x7);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 7
+            bb.writeShort((short) 0x7);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsRequestVer12 other = (OFGroupDescStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupFeaturesStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupFeaturesStatsReplyVer12.java
new file mode 100644
index 0000000..d11e17b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupFeaturesStatsReplyVer12.java
@@ -0,0 +1,821 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupFeaturesStatsReplyVer12 implements OFGroupFeaturesStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupFeaturesStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static long DEFAULT_TYPES = 0x0L;
+        private final static long DEFAULT_CAPABILITIES = 0x0L;
+        private final static long DEFAULT_MAX_GROUPS_ALL = 0x0L;
+        private final static long DEFAULT_MAX_GROUPS_SELECT = 0x0L;
+        private final static long DEFAULT_MAX_GROUPS_INDIRECT = 0x0L;
+        private final static long DEFAULT_MAX_GROUPS_FF = 0x0L;
+        private final static long DEFAULT_ACTIONS_ALL = 0x0L;
+        private final static long DEFAULT_ACTIONS_SELECT = 0x0L;
+        private final static long DEFAULT_ACTIONS_INDIRECT = 0x0L;
+        private final static long DEFAULT_ACTIONS_FF = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final long types;
+    private final long capabilities;
+    private final long maxGroupsAll;
+    private final long maxGroupsSelect;
+    private final long maxGroupsIndirect;
+    private final long maxGroupsFf;
+    private final long actionsAll;
+    private final long actionsSelect;
+    private final long actionsIndirect;
+    private final long actionsFf;
+//
+    // Immutable default instance
+    final static OFGroupFeaturesStatsReplyVer12 DEFAULT = new OFGroupFeaturesStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TYPES, DEFAULT_CAPABILITIES, DEFAULT_MAX_GROUPS_ALL, DEFAULT_MAX_GROUPS_SELECT, DEFAULT_MAX_GROUPS_INDIRECT, DEFAULT_MAX_GROUPS_FF, DEFAULT_ACTIONS_ALL, DEFAULT_ACTIONS_SELECT, DEFAULT_ACTIONS_INDIRECT, DEFAULT_ACTIONS_FF
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupFeaturesStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, long types, long capabilities, long maxGroupsAll, long maxGroupsSelect, long maxGroupsIndirect, long maxGroupsFf, long actionsAll, long actionsSelect, long actionsIndirect, long actionsFf) {
+        this.xid = xid;
+        this.flags = flags;
+        this.types = types;
+        this.capabilities = capabilities;
+        this.maxGroupsAll = maxGroupsAll;
+        this.maxGroupsSelect = maxGroupsSelect;
+        this.maxGroupsIndirect = maxGroupsIndirect;
+        this.maxGroupsFf = maxGroupsFf;
+        this.actionsAll = actionsAll;
+        this.actionsSelect = actionsSelect;
+        this.actionsIndirect = actionsIndirect;
+        this.actionsFf = actionsFf;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getTypes() {
+        return types;
+    }
+
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public long getMaxGroupsAll() {
+        return maxGroupsAll;
+    }
+
+    @Override
+    public long getMaxGroupsSelect() {
+        return maxGroupsSelect;
+    }
+
+    @Override
+    public long getMaxGroupsIndirect() {
+        return maxGroupsIndirect;
+    }
+
+    @Override
+    public long getMaxGroupsFf() {
+        return maxGroupsFf;
+    }
+
+    @Override
+    public long getActionsAll() {
+        return actionsAll;
+    }
+
+    @Override
+    public long getActionsSelect() {
+        return actionsSelect;
+    }
+
+    @Override
+    public long getActionsIndirect() {
+        return actionsIndirect;
+    }
+
+    @Override
+    public long getActionsFf() {
+        return actionsFf;
+    }
+
+
+
+    public OFGroupFeaturesStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupFeaturesStatsReply.Builder {
+        final OFGroupFeaturesStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean typesSet;
+        private long types;
+        private boolean capabilitiesSet;
+        private long capabilities;
+        private boolean maxGroupsAllSet;
+        private long maxGroupsAll;
+        private boolean maxGroupsSelectSet;
+        private long maxGroupsSelect;
+        private boolean maxGroupsIndirectSet;
+        private long maxGroupsIndirect;
+        private boolean maxGroupsFfSet;
+        private long maxGroupsFf;
+        private boolean actionsAllSet;
+        private long actionsAll;
+        private boolean actionsSelectSet;
+        private long actionsSelect;
+        private boolean actionsIndirectSet;
+        private long actionsIndirect;
+        private boolean actionsFfSet;
+        private long actionsFf;
+
+        BuilderWithParent(OFGroupFeaturesStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getTypes() {
+        return types;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setTypes(long types) {
+        this.types = types;
+        this.typesSet = true;
+        return this;
+    }
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setCapabilities(long capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsAll() {
+        return maxGroupsAll;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsAll(long maxGroupsAll) {
+        this.maxGroupsAll = maxGroupsAll;
+        this.maxGroupsAllSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsSelect() {
+        return maxGroupsSelect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsSelect(long maxGroupsSelect) {
+        this.maxGroupsSelect = maxGroupsSelect;
+        this.maxGroupsSelectSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsIndirect() {
+        return maxGroupsIndirect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsIndirect(long maxGroupsIndirect) {
+        this.maxGroupsIndirect = maxGroupsIndirect;
+        this.maxGroupsIndirectSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsFf() {
+        return maxGroupsFf;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsFf(long maxGroupsFf) {
+        this.maxGroupsFf = maxGroupsFf;
+        this.maxGroupsFfSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsAll() {
+        return actionsAll;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsAll(long actionsAll) {
+        this.actionsAll = actionsAll;
+        this.actionsAllSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsSelect() {
+        return actionsSelect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsSelect(long actionsSelect) {
+        this.actionsSelect = actionsSelect;
+        this.actionsSelectSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsIndirect() {
+        return actionsIndirect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsIndirect(long actionsIndirect) {
+        this.actionsIndirect = actionsIndirect;
+        this.actionsIndirectSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsFf() {
+        return actionsFf;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsFf(long actionsFf) {
+        this.actionsFf = actionsFf;
+        this.actionsFfSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupFeaturesStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                long types = this.typesSet ? this.types : parentMessage.types;
+                long capabilities = this.capabilitiesSet ? this.capabilities : parentMessage.capabilities;
+                long maxGroupsAll = this.maxGroupsAllSet ? this.maxGroupsAll : parentMessage.maxGroupsAll;
+                long maxGroupsSelect = this.maxGroupsSelectSet ? this.maxGroupsSelect : parentMessage.maxGroupsSelect;
+                long maxGroupsIndirect = this.maxGroupsIndirectSet ? this.maxGroupsIndirect : parentMessage.maxGroupsIndirect;
+                long maxGroupsFf = this.maxGroupsFfSet ? this.maxGroupsFf : parentMessage.maxGroupsFf;
+                long actionsAll = this.actionsAllSet ? this.actionsAll : parentMessage.actionsAll;
+                long actionsSelect = this.actionsSelectSet ? this.actionsSelect : parentMessage.actionsSelect;
+                long actionsIndirect = this.actionsIndirectSet ? this.actionsIndirect : parentMessage.actionsIndirect;
+                long actionsFf = this.actionsFfSet ? this.actionsFf : parentMessage.actionsFf;
+
+                //
+                return new OFGroupFeaturesStatsReplyVer12(
+                    xid,
+                    flags,
+                    types,
+                    capabilities,
+                    maxGroupsAll,
+                    maxGroupsSelect,
+                    maxGroupsIndirect,
+                    maxGroupsFf,
+                    actionsAll,
+                    actionsSelect,
+                    actionsIndirect,
+                    actionsFf
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupFeaturesStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean typesSet;
+        private long types;
+        private boolean capabilitiesSet;
+        private long capabilities;
+        private boolean maxGroupsAllSet;
+        private long maxGroupsAll;
+        private boolean maxGroupsSelectSet;
+        private long maxGroupsSelect;
+        private boolean maxGroupsIndirectSet;
+        private long maxGroupsIndirect;
+        private boolean maxGroupsFfSet;
+        private long maxGroupsFf;
+        private boolean actionsAllSet;
+        private long actionsAll;
+        private boolean actionsSelectSet;
+        private long actionsSelect;
+        private boolean actionsIndirectSet;
+        private long actionsIndirect;
+        private boolean actionsFfSet;
+        private long actionsFf;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getTypes() {
+        return types;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setTypes(long types) {
+        this.types = types;
+        this.typesSet = true;
+        return this;
+    }
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setCapabilities(long capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsAll() {
+        return maxGroupsAll;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsAll(long maxGroupsAll) {
+        this.maxGroupsAll = maxGroupsAll;
+        this.maxGroupsAllSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsSelect() {
+        return maxGroupsSelect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsSelect(long maxGroupsSelect) {
+        this.maxGroupsSelect = maxGroupsSelect;
+        this.maxGroupsSelectSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsIndirect() {
+        return maxGroupsIndirect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsIndirect(long maxGroupsIndirect) {
+        this.maxGroupsIndirect = maxGroupsIndirect;
+        this.maxGroupsIndirectSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsFf() {
+        return maxGroupsFf;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsFf(long maxGroupsFf) {
+        this.maxGroupsFf = maxGroupsFf;
+        this.maxGroupsFfSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsAll() {
+        return actionsAll;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsAll(long actionsAll) {
+        this.actionsAll = actionsAll;
+        this.actionsAllSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsSelect() {
+        return actionsSelect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsSelect(long actionsSelect) {
+        this.actionsSelect = actionsSelect;
+        this.actionsSelectSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsIndirect() {
+        return actionsIndirect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsIndirect(long actionsIndirect) {
+        this.actionsIndirect = actionsIndirect;
+        this.actionsIndirectSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsFf() {
+        return actionsFf;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsFf(long actionsFf) {
+        this.actionsFf = actionsFf;
+        this.actionsFfSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupFeaturesStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            long types = this.typesSet ? this.types : DEFAULT_TYPES;
+            long capabilities = this.capabilitiesSet ? this.capabilities : DEFAULT_CAPABILITIES;
+            long maxGroupsAll = this.maxGroupsAllSet ? this.maxGroupsAll : DEFAULT_MAX_GROUPS_ALL;
+            long maxGroupsSelect = this.maxGroupsSelectSet ? this.maxGroupsSelect : DEFAULT_MAX_GROUPS_SELECT;
+            long maxGroupsIndirect = this.maxGroupsIndirectSet ? this.maxGroupsIndirect : DEFAULT_MAX_GROUPS_INDIRECT;
+            long maxGroupsFf = this.maxGroupsFfSet ? this.maxGroupsFf : DEFAULT_MAX_GROUPS_FF;
+            long actionsAll = this.actionsAllSet ? this.actionsAll : DEFAULT_ACTIONS_ALL;
+            long actionsSelect = this.actionsSelectSet ? this.actionsSelect : DEFAULT_ACTIONS_SELECT;
+            long actionsIndirect = this.actionsIndirectSet ? this.actionsIndirect : DEFAULT_ACTIONS_INDIRECT;
+            long actionsFf = this.actionsFfSet ? this.actionsFf : DEFAULT_ACTIONS_FF;
+
+
+            return new OFGroupFeaturesStatsReplyVer12(
+                    xid,
+                    flags,
+                    types,
+                    capabilities,
+                    maxGroupsAll,
+                    maxGroupsSelect,
+                    maxGroupsIndirect,
+                    maxGroupsFf,
+                    actionsAll,
+                    actionsSelect,
+                    actionsIndirect,
+                    actionsFf
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupFeaturesStatsReply> {
+        @Override
+        public OFGroupFeaturesStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 56)
+                throw new OFParseError("Wrong length: Expected=56(56), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 8
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x8)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_FEATURES(8), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            long types = U32.f(bb.readInt());
+            long capabilities = U32.f(bb.readInt());
+            long maxGroupsAll = U32.f(bb.readInt());
+            long maxGroupsSelect = U32.f(bb.readInt());
+            long maxGroupsIndirect = U32.f(bb.readInt());
+            long maxGroupsFf = U32.f(bb.readInt());
+            long actionsAll = U32.f(bb.readInt());
+            long actionsSelect = U32.f(bb.readInt());
+            long actionsIndirect = U32.f(bb.readInt());
+            long actionsFf = U32.f(bb.readInt());
+
+            OFGroupFeaturesStatsReplyVer12 groupFeaturesStatsReplyVer12 = new OFGroupFeaturesStatsReplyVer12(
+                    xid,
+                      flags,
+                      types,
+                      capabilities,
+                      maxGroupsAll,
+                      maxGroupsSelect,
+                      maxGroupsIndirect,
+                      maxGroupsFf,
+                      actionsAll,
+                      actionsSelect,
+                      actionsIndirect,
+                      actionsFf
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupFeaturesStatsReplyVer12);
+            return groupFeaturesStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupFeaturesStatsReplyVer12Funnel FUNNEL = new OFGroupFeaturesStatsReplyVer12Funnel();
+    static class OFGroupFeaturesStatsReplyVer12Funnel implements Funnel<OFGroupFeaturesStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupFeaturesStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 56
+            sink.putShort((short) 0x38);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 8
+            sink.putShort((short) 0x8);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            sink.putLong(message.types);
+            sink.putLong(message.capabilities);
+            sink.putLong(message.maxGroupsAll);
+            sink.putLong(message.maxGroupsSelect);
+            sink.putLong(message.maxGroupsIndirect);
+            sink.putLong(message.maxGroupsFf);
+            sink.putLong(message.actionsAll);
+            sink.putLong(message.actionsSelect);
+            sink.putLong(message.actionsIndirect);
+            sink.putLong(message.actionsFf);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupFeaturesStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupFeaturesStatsReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 56
+            bb.writeShort((short) 0x38);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 8
+            bb.writeShort((short) 0x8);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeInt(U32.t(message.types));
+            bb.writeInt(U32.t(message.capabilities));
+            bb.writeInt(U32.t(message.maxGroupsAll));
+            bb.writeInt(U32.t(message.maxGroupsSelect));
+            bb.writeInt(U32.t(message.maxGroupsIndirect));
+            bb.writeInt(U32.t(message.maxGroupsFf));
+            bb.writeInt(U32.t(message.actionsAll));
+            bb.writeInt(U32.t(message.actionsSelect));
+            bb.writeInt(U32.t(message.actionsIndirect));
+            bb.writeInt(U32.t(message.actionsFf));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupFeaturesStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("types=").append(types);
+        b.append(", ");
+        b.append("capabilities=").append(capabilities);
+        b.append(", ");
+        b.append("maxGroupsAll=").append(maxGroupsAll);
+        b.append(", ");
+        b.append("maxGroupsSelect=").append(maxGroupsSelect);
+        b.append(", ");
+        b.append("maxGroupsIndirect=").append(maxGroupsIndirect);
+        b.append(", ");
+        b.append("maxGroupsFf=").append(maxGroupsFf);
+        b.append(", ");
+        b.append("actionsAll=").append(actionsAll);
+        b.append(", ");
+        b.append("actionsSelect=").append(actionsSelect);
+        b.append(", ");
+        b.append("actionsIndirect=").append(actionsIndirect);
+        b.append(", ");
+        b.append("actionsFf=").append(actionsFf);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupFeaturesStatsReplyVer12 other = (OFGroupFeaturesStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( types != other.types)
+            return false;
+        if( capabilities != other.capabilities)
+            return false;
+        if( maxGroupsAll != other.maxGroupsAll)
+            return false;
+        if( maxGroupsSelect != other.maxGroupsSelect)
+            return false;
+        if( maxGroupsIndirect != other.maxGroupsIndirect)
+            return false;
+        if( maxGroupsFf != other.maxGroupsFf)
+            return false;
+        if( actionsAll != other.actionsAll)
+            return false;
+        if( actionsSelect != other.actionsSelect)
+            return false;
+        if( actionsIndirect != other.actionsIndirect)
+            return false;
+        if( actionsFf != other.actionsFf)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime *  (int) (types ^ (types >>> 32));
+        result = prime *  (int) (capabilities ^ (capabilities >>> 32));
+        result = prime *  (int) (maxGroupsAll ^ (maxGroupsAll >>> 32));
+        result = prime *  (int) (maxGroupsSelect ^ (maxGroupsSelect >>> 32));
+        result = prime *  (int) (maxGroupsIndirect ^ (maxGroupsIndirect >>> 32));
+        result = prime *  (int) (maxGroupsFf ^ (maxGroupsFf >>> 32));
+        result = prime *  (int) (actionsAll ^ (actionsAll >>> 32));
+        result = prime *  (int) (actionsSelect ^ (actionsSelect >>> 32));
+        result = prime *  (int) (actionsIndirect ^ (actionsIndirect >>> 32));
+        result = prime *  (int) (actionsFf ^ (actionsFf >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupFeaturesStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupFeaturesStatsRequestVer12.java
new file mode 100644
index 0000000..51a872e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupFeaturesStatsRequestVer12.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupFeaturesStatsRequestVer12 implements OFGroupFeaturesStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupFeaturesStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFGroupFeaturesStatsRequestVer12 DEFAULT = new OFGroupFeaturesStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupFeaturesStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFGroupFeaturesStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupFeaturesStatsRequest.Builder {
+        final OFGroupFeaturesStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFGroupFeaturesStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupFeaturesStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFGroupFeaturesStatsRequestVer12(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupFeaturesStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupFeaturesStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFGroupFeaturesStatsRequestVer12(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupFeaturesStatsRequest> {
+        @Override
+        public OFGroupFeaturesStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 8
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x8)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_FEATURES(8), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFGroupFeaturesStatsRequestVer12 groupFeaturesStatsRequestVer12 = new OFGroupFeaturesStatsRequestVer12(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupFeaturesStatsRequestVer12);
+            return groupFeaturesStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupFeaturesStatsRequestVer12Funnel FUNNEL = new OFGroupFeaturesStatsRequestVer12Funnel();
+    static class OFGroupFeaturesStatsRequestVer12Funnel implements Funnel<OFGroupFeaturesStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupFeaturesStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 8
+            sink.putShort((short) 0x8);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupFeaturesStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupFeaturesStatsRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 8
+            bb.writeShort((short) 0x8);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupFeaturesStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupFeaturesStatsRequestVer12 other = (OFGroupFeaturesStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModCommandSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModCommandSerializerVer12.java
new file mode 100644
index 0000000..ad465e1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModCommandSerializerVer12.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupModCommand;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupModCommandSerializerVer12 {
+
+    public final static short ADD_VAL = (short) 0x0;
+    public final static short MODIFY_VAL = (short) 0x1;
+    public final static short DELETE_VAL = (short) 0x2;
+
+    public static OFGroupModCommand readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupModCommand e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupModCommand e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFGroupModCommand ofWireValue(short val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFGroupModCommand.ADD;
+            case MODIFY_VAL:
+                return OFGroupModCommand.MODIFY;
+            case DELETE_VAL:
+                return OFGroupModCommand.DELETE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupModCommand in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFGroupModCommand e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupModCommand in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModFailedCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModFailedCodeSerializerVer12.java
new file mode 100644
index 0000000..db6ddf9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModFailedCodeSerializerVer12.java
@@ -0,0 +1,139 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupModFailedCodeSerializerVer12 {
+
+    public final static short GROUP_EXISTS_VAL = (short) 0x0;
+    public final static short INVALID_GROUP_VAL = (short) 0x1;
+    public final static short WEIGHT_UNSUPPORTED_VAL = (short) 0x2;
+    public final static short OUT_OF_GROUPS_VAL = (short) 0x3;
+    public final static short OUT_OF_BUCKETS_VAL = (short) 0x4;
+    public final static short CHAINING_UNSUPPORTED_VAL = (short) 0x5;
+    public final static short WATCH_UNSUPPORTED_VAL = (short) 0x6;
+    public final static short LOOP_VAL = (short) 0x7;
+    public final static short UNKNOWN_GROUP_VAL = (short) 0x8;
+    public final static short CHAINED_GROUP_VAL = (short) 0x9;
+    public final static short BAD_TYPE_VAL = (short) 0xa;
+    public final static short BAD_COMMAND_VAL = (short) 0xb;
+    public final static short BAD_BUCKET_VAL = (short) 0xc;
+    public final static short BAD_WATCH_VAL = (short) 0xd;
+    public final static short EPERM_VAL = (short) 0xe;
+
+    public static OFGroupModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFGroupModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case GROUP_EXISTS_VAL:
+                return OFGroupModFailedCode.GROUP_EXISTS;
+            case INVALID_GROUP_VAL:
+                return OFGroupModFailedCode.INVALID_GROUP;
+            case WEIGHT_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.WEIGHT_UNSUPPORTED;
+            case OUT_OF_GROUPS_VAL:
+                return OFGroupModFailedCode.OUT_OF_GROUPS;
+            case OUT_OF_BUCKETS_VAL:
+                return OFGroupModFailedCode.OUT_OF_BUCKETS;
+            case CHAINING_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.CHAINING_UNSUPPORTED;
+            case WATCH_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.WATCH_UNSUPPORTED;
+            case LOOP_VAL:
+                return OFGroupModFailedCode.LOOP;
+            case UNKNOWN_GROUP_VAL:
+                return OFGroupModFailedCode.UNKNOWN_GROUP;
+            case CHAINED_GROUP_VAL:
+                return OFGroupModFailedCode.CHAINED_GROUP;
+            case BAD_TYPE_VAL:
+                return OFGroupModFailedCode.BAD_TYPE;
+            case BAD_COMMAND_VAL:
+                return OFGroupModFailedCode.BAD_COMMAND;
+            case BAD_BUCKET_VAL:
+                return OFGroupModFailedCode.BAD_BUCKET;
+            case BAD_WATCH_VAL:
+                return OFGroupModFailedCode.BAD_WATCH;
+            case EPERM_VAL:
+                return OFGroupModFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupModFailedCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFGroupModFailedCode e) {
+        switch(e) {
+            case GROUP_EXISTS:
+                return GROUP_EXISTS_VAL;
+            case INVALID_GROUP:
+                return INVALID_GROUP_VAL;
+            case WEIGHT_UNSUPPORTED:
+                return WEIGHT_UNSUPPORTED_VAL;
+            case OUT_OF_GROUPS:
+                return OUT_OF_GROUPS_VAL;
+            case OUT_OF_BUCKETS:
+                return OUT_OF_BUCKETS_VAL;
+            case CHAINING_UNSUPPORTED:
+                return CHAINING_UNSUPPORTED_VAL;
+            case WATCH_UNSUPPORTED:
+                return WATCH_UNSUPPORTED_VAL;
+            case LOOP:
+                return LOOP_VAL;
+            case UNKNOWN_GROUP:
+                return UNKNOWN_GROUP_VAL;
+            case CHAINED_GROUP:
+                return CHAINED_GROUP_VAL;
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_COMMAND:
+                return BAD_COMMAND_VAL;
+            case BAD_BUCKET:
+                return BAD_BUCKET_VAL;
+            case BAD_WATCH:
+                return BAD_WATCH_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupModFailedCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModFailedErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModFailedErrorMsgVer12.java
new file mode 100644
index 0000000..eb59186
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModFailedErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupModFailedErrorMsgVer12 implements OFGroupModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupModFailedErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupModFailedErrorMsgVer12(long xid, OFGroupModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFGroupModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupModFailedErrorMsg.Builder {
+        final OFGroupModFailedErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFGroupModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFGroupModFailedErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setCode(OFGroupModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFGroupModFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFGroupModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setCode(OFGroupModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFGroupModFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupModFailedErrorMsg> {
+        @Override
+        public OFGroupModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 6
+            short errType = bb.readShort();
+            if(errType != (short) 0x6)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.GROUP_MOD_FAILED(6), got="+errType);
+            OFGroupModFailedCode code = OFGroupModFailedCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFGroupModFailedErrorMsgVer12 groupModFailedErrorMsgVer12 = new OFGroupModFailedErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupModFailedErrorMsgVer12);
+            return groupModFailedErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupModFailedErrorMsgVer12Funnel FUNNEL = new OFGroupModFailedErrorMsgVer12Funnel();
+    static class OFGroupModFailedErrorMsgVer12Funnel implements Funnel<OFGroupModFailedErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupModFailedErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 6
+            sink.putShort((short) 0x6);
+            OFGroupModFailedCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupModFailedErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupModFailedErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 6
+            bb.writeShort((short) 0x6);
+            OFGroupModFailedCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupModFailedErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupModFailedErrorMsgVer12 other = (OFGroupModFailedErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModVer12.java
new file mode 100644
index 0000000..228687e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModVer12.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFGroupModVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFGroupModVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFGroupMod> {
+        @Override
+        public OFGroupMod readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short command = bb.readShort();
+            bb.readerIndex(start);
+            switch(command) {
+               case (short) 0x0:
+                   // discriminator value OFGroupModCommand.ADD=0 for class OFGroupAddVer12
+                   return OFGroupAddVer12.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFGroupModCommand.DELETE=2 for class OFGroupDeleteVer12
+                   return OFGroupDeleteVer12.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFGroupModCommand.MODIFY=1 for class OFGroupModifyVer12
+                   return OFGroupModifyVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator command of class OFGroupModVer12: " + command);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModifyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModifyVer12.java
new file mode 100644
index 0000000..ca8df7c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupModifyVer12.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupModifyVer12 implements OFGroupModify {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupModifyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupModifyVer12(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupModify.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupModify.Builder {
+        final OFGroupModifyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupModifyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupModify.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupModify build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupModifyVer12(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupModify.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupModify.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupModify build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupModifyVer12(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupModify> {
+        @Override
+        public OFGroupModify readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 1
+            short command = bb.readShort();
+            if(command != (short) 0x1)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.MODIFY(1), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer12.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer12.READER);
+
+            OFGroupModifyVer12 groupModifyVer12 = new OFGroupModifyVer12(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupModifyVer12);
+            return groupModifyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupModifyVer12Funnel FUNNEL = new OFGroupModifyVer12Funnel();
+    static class OFGroupModifyVer12Funnel implements Funnel<OFGroupModifyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupModifyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 1
+            sink.putShort((short) 0x1);
+            OFGroupTypeSerializerVer12.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupModifyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupModifyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 1
+            bb.writeShort((short) 0x1);
+            OFGroupTypeSerializerVer12.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupModifyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupModifyVer12 other = (OFGroupModifyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsEntryVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsEntryVer12.java
new file mode 100644
index 0000000..bedd579
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsEntryVer12.java
@@ -0,0 +1,516 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsEntryVer12 implements OFGroupStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsEntryVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 32;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static long DEFAULT_REF_COUNT = 0x0L;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static List<OFBucketCounter> DEFAULT_BUCKET_STATS = ImmutableList.<OFBucketCounter>of();
+
+    // OF message fields
+    private final OFGroup group;
+    private final long refCount;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final List<OFBucketCounter> bucketStats;
+//
+    // Immutable default instance
+    final static OFGroupStatsEntryVer12 DEFAULT = new OFGroupStatsEntryVer12(
+        DEFAULT_GROUP_ID, DEFAULT_REF_COUNT, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_BUCKET_STATS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsEntryVer12(OFGroup group, long refCount, U64 packetCount, U64 byteCount, List<OFBucketCounter> bucketStats) {
+        this.group = group;
+        this.refCount = refCount;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.bucketStats = bucketStats;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFGroupStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsEntry.Builder {
+        final OFGroupStatsEntryVer12 parentMessage;
+
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean refCountSet;
+        private long refCount;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean bucketStatsSet;
+        private List<OFBucketCounter> bucketStats;
+
+        BuilderWithParent(OFGroupStatsEntryVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setRefCount(long refCount) {
+        this.refCount = refCount;
+        this.refCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setBucketStats(List<OFBucketCounter> bucketStats) {
+        this.bucketStats = bucketStats;
+        this.bucketStatsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFGroupStatsEntry build() {
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                long refCount = this.refCountSet ? this.refCount : parentMessage.refCount;
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                List<OFBucketCounter> bucketStats = this.bucketStatsSet ? this.bucketStats : parentMessage.bucketStats;
+                if(bucketStats == null)
+                    throw new NullPointerException("Property bucketStats must not be null");
+
+                //
+                return new OFGroupStatsEntryVer12(
+                    group,
+                    refCount,
+                    packetCount,
+                    byteCount,
+                    bucketStats
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsEntry.Builder {
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean refCountSet;
+        private long refCount;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean bucketStatsSet;
+        private List<OFBucketCounter> bucketStats;
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setRefCount(long refCount) {
+        this.refCount = refCount;
+        this.refCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setBucketStats(List<OFBucketCounter> bucketStats) {
+        this.bucketStats = bucketStats;
+        this.bucketStatsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFGroupStatsEntry build() {
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            long refCount = this.refCountSet ? this.refCount : DEFAULT_REF_COUNT;
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            List<OFBucketCounter> bucketStats = this.bucketStatsSet ? this.bucketStats : DEFAULT_BUCKET_STATS;
+            if(bucketStats == null)
+                throw new NullPointerException("Property bucketStats must not be null");
+
+
+            return new OFGroupStatsEntryVer12(
+                    group,
+                    refCount,
+                    packetCount,
+                    byteCount,
+                    bucketStats
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsEntry> {
+        @Override
+        public OFGroupStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            long refCount = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            List<OFBucketCounter> bucketStats = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketCounterVer12.READER);
+
+            OFGroupStatsEntryVer12 groupStatsEntryVer12 = new OFGroupStatsEntryVer12(
+                    group,
+                      refCount,
+                      packetCount,
+                      byteCount,
+                      bucketStats
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsEntryVer12);
+            return groupStatsEntryVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsEntryVer12Funnel FUNNEL = new OFGroupStatsEntryVer12Funnel();
+    static class OFGroupStatsEntryVer12Funnel implements Funnel<OFGroupStatsEntryVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsEntryVer12 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            // skip pad (2 bytes)
+            message.group.putTo(sink);
+            sink.putLong(message.refCount);
+            // skip pad (4 bytes)
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            FunnelUtils.putList(message.bucketStats, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsEntryVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsEntryVer12 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.group.write4Bytes(bb);
+            bb.writeInt(U32.t(message.refCount));
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            ChannelUtils.writeList(bb, message.bucketStats);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsEntryVer12(");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("refCount=").append(refCount);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("bucketStats=").append(bucketStats);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsEntryVer12 other = (OFGroupStatsEntryVer12) obj;
+
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if( refCount != other.refCount)
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (bucketStats == null) {
+            if (other.bucketStats != null)
+                return false;
+        } else if (!bucketStats.equals(other.bucketStats))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime *  (int) (refCount ^ (refCount >>> 32));
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((bucketStats == null) ? 0 : bucketStats.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsReplyVer12.java
new file mode 100644
index 0000000..62aab09
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsReplyVer12.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsReplyVer12 implements OFGroupStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFGroupStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFGroupStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFGroupStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFGroupStatsReplyVer12 DEFAULT = new OFGroupStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, List<OFGroupStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFGroupStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsReply.Builder {
+        final OFGroupStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupStatsEntry> entries;
+
+        BuilderWithParent(OFGroupStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setEntries(List<OFGroupStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFGroupStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFGroupStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setEntries(List<OFGroupStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFGroupStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFGroupStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsReply> {
+        @Override
+        public OFGroupStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 6
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x6)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP(6), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFGroupStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFGroupStatsEntryVer12.READER);
+
+            OFGroupStatsReplyVer12 groupStatsReplyVer12 = new OFGroupStatsReplyVer12(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsReplyVer12);
+            return groupStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsReplyVer12Funnel FUNNEL = new OFGroupStatsReplyVer12Funnel();
+    static class OFGroupStatsReplyVer12Funnel implements Funnel<OFGroupStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 6
+            sink.putShort((short) 0x6);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 6
+            bb.writeShort((short) 0x6);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsReplyVer12 other = (OFGroupStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsRequestVer12.java
new file mode 100644
index 0000000..2e0d1ce
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupStatsRequestVer12.java
@@ -0,0 +1,410 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsRequestVer12 implements OFGroupStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFGroup group;
+//
+    // Immutable default instance
+    final static OFGroupStatsRequestVer12 DEFAULT = new OFGroupStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_GROUP_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags, OFGroup group) {
+        this.xid = xid;
+        this.flags = flags;
+        this.group = group;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+
+
+    public OFGroupStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsRequest.Builder {
+        final OFGroupStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean groupSet;
+        private OFGroup group;
+
+        BuilderWithParent(OFGroupStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+
+                //
+                return new OFGroupStatsRequestVer12(
+                    xid,
+                    flags,
+                    group
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean groupSet;
+        private OFGroup group;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+
+
+            return new OFGroupStatsRequestVer12(
+                    xid,
+                    flags,
+                    group
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsRequest> {
+        @Override
+        public OFGroupStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 6
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x6)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP(6), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFGroupStatsRequestVer12 groupStatsRequestVer12 = new OFGroupStatsRequestVer12(
+                    xid,
+                      flags,
+                      group
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsRequestVer12);
+            return groupStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsRequestVer12Funnel FUNNEL = new OFGroupStatsRequestVer12Funnel();
+    static class OFGroupStatsRequestVer12Funnel implements Funnel<OFGroupStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 6
+            sink.putShort((short) 0x6);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.group.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 6
+            bb.writeShort((short) 0x6);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.group.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsRequestVer12 other = (OFGroupStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupTypeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupTypeSerializerVer12.java
new file mode 100644
index 0000000..c6169f7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFGroupTypeSerializerVer12.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupTypeSerializerVer12 {
+
+    public final static byte ALL_VAL = (byte) 0x0;
+    public final static byte SELECT_VAL = (byte) 0x1;
+    public final static byte INDIRECT_VAL = (byte) 0x2;
+    public final static byte FF_VAL = (byte) 0x3;
+
+    public static OFGroupType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupType e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupType e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFGroupType ofWireValue(byte val) {
+        switch(val) {
+            case ALL_VAL:
+                return OFGroupType.ALL;
+            case SELECT_VAL:
+                return OFGroupType.SELECT;
+            case INDIRECT_VAL:
+                return OFGroupType.INDIRECT;
+            case FF_VAL:
+                return OFGroupType.FF;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupType in version 1.2: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFGroupType e) {
+        switch(e) {
+            case ALL:
+                return ALL_VAL;
+            case SELECT:
+                return SELECT_VAL;
+            case INDIRECT:
+                return INDIRECT_VAL;
+            case FF:
+                return FF_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupType in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloFailedCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloFailedCodeSerializerVer12.java
new file mode 100644
index 0000000..6c1fa0b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloFailedCodeSerializerVer12.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFHelloFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFHelloFailedCodeSerializerVer12 {
+
+    public final static short INCOMPATIBLE_VAL = (short) 0x0;
+    public final static short EPERM_VAL = (short) 0x1;
+
+    public static OFHelloFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFHelloFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFHelloFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFHelloFailedCode ofWireValue(short val) {
+        switch(val) {
+            case INCOMPATIBLE_VAL:
+                return OFHelloFailedCode.INCOMPATIBLE;
+            case EPERM_VAL:
+                return OFHelloFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFHelloFailedCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFHelloFailedCode e) {
+        switch(e) {
+            case INCOMPATIBLE:
+                return INCOMPATIBLE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFHelloFailedCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloFailedErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloFailedErrorMsgVer12.java
new file mode 100644
index 0000000..983bb90
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloFailedErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloFailedErrorMsgVer12 implements OFHelloFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloFailedErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFHelloFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloFailedErrorMsgVer12(long xid, OFHelloFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFHelloFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHelloFailedErrorMsg.Builder {
+        final OFHelloFailedErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFHelloFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFHelloFailedErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setCode(OFHelloFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFHelloFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFHelloFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFHelloFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFHelloFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFHelloFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setCode(OFHelloFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFHelloFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFHelloFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHelloFailedErrorMsg> {
+        @Override
+        public OFHelloFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 0
+            short errType = bb.readShort();
+            if(errType != (short) 0x0)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.HELLO_FAILED(0), got="+errType);
+            OFHelloFailedCode code = OFHelloFailedCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFHelloFailedErrorMsgVer12 helloFailedErrorMsgVer12 = new OFHelloFailedErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloFailedErrorMsgVer12);
+            return helloFailedErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloFailedErrorMsgVer12Funnel FUNNEL = new OFHelloFailedErrorMsgVer12Funnel();
+    static class OFHelloFailedErrorMsgVer12Funnel implements Funnel<OFHelloFailedErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloFailedErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 0
+            sink.putShort((short) 0x0);
+            OFHelloFailedCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloFailedErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloFailedErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 0
+            bb.writeShort((short) 0x0);
+            OFHelloFailedCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloFailedErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloFailedErrorMsgVer12 other = (OFHelloFailedErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloVer12.java
new file mode 100644
index 0000000..054573f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFHelloVer12.java
@@ -0,0 +1,292 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloVer12 implements OFHello {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFHelloVer12 DEFAULT = new OFHelloVer12(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloVer12(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.2");
+    }
+
+
+
+    public OFHello.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHello.Builder {
+        final OFHelloVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFHelloVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHello.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.2");
+    }
+
+    @Override
+    public OFHello.Builder setElements(List<OFHelloElem> elements) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property elements not supported in version 1.2");
+    }
+
+
+        @Override
+        public OFHello build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFHelloVer12(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFHello.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHello.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public List<OFHelloElem> getElements()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property elements not supported in version 1.2");
+    }
+
+    @Override
+    public OFHello.Builder setElements(List<OFHelloElem> elements) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property elements not supported in version 1.2");
+    }
+//
+        @Override
+        public OFHello build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFHelloVer12(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHello> {
+        @Override
+        public OFHello readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 0
+            byte type = bb.readByte();
+            if(type != (byte) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFType.HELLO(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFHelloVer12 helloVer12 = new OFHelloVer12(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloVer12);
+            return helloVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloVer12Funnel FUNNEL = new OFHelloVer12Funnel();
+    static class OFHelloVer12Funnel implements Funnel<OFHelloVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 0
+            sink.putByte((byte) 0x0);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 0
+            bb.writeByte((byte) 0x0);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloVer12(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloVer12 other = (OFHelloVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionApplyActionsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionApplyActionsVer12.java
new file mode 100644
index 0000000..0586d0c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionApplyActionsVer12.java
@@ -0,0 +1,279 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionApplyActionsVer12 implements OFInstructionApplyActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionApplyActionsVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFInstructionApplyActionsVer12 DEFAULT = new OFInstructionApplyActionsVer12(
+        DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionApplyActionsVer12(List<OFAction> actions) {
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFInstructionApplyActions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionApplyActions.Builder {
+        final OFInstructionApplyActionsVer12 parentMessage;
+
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFInstructionApplyActionsVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionApplyActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFInstructionApplyActions build() {
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFInstructionApplyActionsVer12(
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionApplyActions.Builder {
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionApplyActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFInstructionApplyActions build() {
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFInstructionApplyActionsVer12(
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionApplyActions> {
+        @Override
+        public OFInstructionApplyActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 4
+            short type = bb.readShort();
+            if(type != (short) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.APPLY_ACTIONS(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer12.READER);
+
+            OFInstructionApplyActionsVer12 instructionApplyActionsVer12 = new OFInstructionApplyActionsVer12(
+                    actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionApplyActionsVer12);
+            return instructionApplyActionsVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionApplyActionsVer12Funnel FUNNEL = new OFInstructionApplyActionsVer12Funnel();
+    static class OFInstructionApplyActionsVer12Funnel implements Funnel<OFInstructionApplyActionsVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionApplyActionsVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 4
+            sink.putShort((short) 0x4);
+            // FIXME: skip funnel of length
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionApplyActionsVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionApplyActionsVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 4
+            bb.writeShort((short) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionApplyActionsVer12(");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionApplyActionsVer12 other = (OFInstructionApplyActionsVer12) obj;
+
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionClearActionsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionClearActionsVer12.java
new file mode 100644
index 0000000..b453e01
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionClearActionsVer12.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionClearActionsVer12 implements OFInstructionClearActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionClearActionsVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionClearActionsVer12 DEFAULT = new OFInstructionClearActionsVer12(
+
+    );
+
+    final static OFInstructionClearActionsVer12 INSTANCE = new OFInstructionClearActionsVer12();
+    // private empty constructor - use shared instance!
+    private OFInstructionClearActionsVer12() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.CLEAR_ACTIONS;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionClearActions.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionClearActionsVer12 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionClearActions> {
+        @Override
+        public OFInstructionClearActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 5
+            short type = bb.readShort();
+            if(type != (short) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.CLEAR_ACTIONS(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionClearActionsVer12Funnel FUNNEL = new OFInstructionClearActionsVer12Funnel();
+    static class OFInstructionClearActionsVer12Funnel implements Funnel<OFInstructionClearActionsVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionClearActionsVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 5
+            sink.putShort((short) 0x5);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionClearActionsVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionClearActionsVer12 message) {
+            // fixed value property type = 5
+            bb.writeShort((short) 0x5);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionClearActionsVer12(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionExperimenterVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionExperimenterVer12.java
new file mode 100644
index 0000000..ac30cbb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionExperimenterVer12.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionExperimenterVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFInstructionExperimenterVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstructionExperimenter> {
+        @Override
+        public OFInstructionExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFInstructionExperimenterVer12: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionGotoTableVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionGotoTableVer12.java
new file mode 100644
index 0000000..b2f33ca
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionGotoTableVer12.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionGotoTableVer12 implements OFInstructionGotoTable {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionGotoTableVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+
+    // OF message fields
+    private final TableId tableId;
+//
+    // Immutable default instance
+    final static OFInstructionGotoTableVer12 DEFAULT = new OFInstructionGotoTableVer12(
+        DEFAULT_TABLE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionGotoTableVer12(TableId tableId) {
+        this.tableId = tableId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFInstructionGotoTable.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionGotoTable.Builder {
+        final OFInstructionGotoTableVer12 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+
+        BuilderWithParent(OFInstructionGotoTableVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFInstructionGotoTable.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFInstructionGotoTable build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+
+                //
+                return new OFInstructionGotoTableVer12(
+                    tableId
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionGotoTable.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFInstructionGotoTable.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFInstructionGotoTable build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+
+
+            return new OFInstructionGotoTableVer12(
+                    tableId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionGotoTable> {
+        @Override
+        public OFInstructionGotoTable readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.GOTO_TABLE(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFInstructionGotoTableVer12 instructionGotoTableVer12 = new OFInstructionGotoTableVer12(
+                    tableId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionGotoTableVer12);
+            return instructionGotoTableVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionGotoTableVer12Funnel FUNNEL = new OFInstructionGotoTableVer12Funnel();
+    static class OFInstructionGotoTableVer12Funnel implements Funnel<OFInstructionGotoTableVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionGotoTableVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionGotoTableVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionGotoTableVer12 message) {
+            // fixed value property type = 1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionGotoTableVer12(");
+        b.append("tableId=").append(tableId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionGotoTableVer12 other = (OFInstructionGotoTableVer12) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionIdsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionIdsVer12.java
new file mode 100644
index 0000000..a0dc720
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionIdsVer12.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFInstructionIdsVer12 implements OFInstructionIds {
+    public final static OFInstructionIdsVer12 INSTANCE = new OFInstructionIdsVer12();
+
+
+
+
+    public OFInstructionIdApplyActions applyActions() {
+        throw new UnsupportedOperationException("OFInstructionIdApplyActions not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnArpOffload bsnArpOffload() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnArpOffload not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnDeny bsnDeny() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDeny not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnDhcpOffload bsnDhcpOffload() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDhcpOffload not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableSplitHorizonCheck not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnDisableSrcMacCheck bsnDisableSrcMacCheck() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableSrcMacCheck not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnDisableVlanCounters bsnDisableVlanCounters() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableVlanCounters not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnPacketOfDeath bsnPacketOfDeath() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPacketOfDeath not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnPermit bsnPermit() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPermit not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnPrioritizePdus bsnPrioritizePdus() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPrioritizePdus not supported in version 1.2");
+    }
+
+    public OFInstructionIdBsnRequireVlanXlate bsnRequireVlanXlate() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnRequireVlanXlate not supported in version 1.2");
+    }
+
+    public OFInstructionIdClearActions clearActions() {
+        throw new UnsupportedOperationException("OFInstructionIdClearActions not supported in version 1.2");
+    }
+
+    public OFInstructionIdGotoTable gotoTable() {
+        throw new UnsupportedOperationException("OFInstructionIdGotoTable not supported in version 1.2");
+    }
+
+    public OFInstructionIdMeter meter() {
+        throw new UnsupportedOperationException("OFInstructionIdMeter not supported in version 1.2");
+    }
+
+    public OFInstructionIdWriteActions writeActions() {
+        throw new UnsupportedOperationException("OFInstructionIdWriteActions not supported in version 1.2");
+    }
+
+    public OFInstructionIdWriteMetadata writeMetadata() {
+        throw new UnsupportedOperationException("OFInstructionIdWriteMetadata not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFInstructionId> getReader() {
+        throw new UnsupportedOperationException("Reader<OFInstructionId> not supported in version 1.2");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionTypeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionTypeSerializerVer12.java
new file mode 100644
index 0000000..c9b87ba
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionTypeSerializerVer12.java
@@ -0,0 +1,108 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFInstructionType;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFInstructionTypeSerializerVer12 {
+
+    public final static short GOTO_TABLE_VAL = (short) 0x1;
+    public final static short WRITE_METADATA_VAL = (short) 0x2;
+    public final static short WRITE_ACTIONS_VAL = (short) 0x3;
+    public final static short APPLY_ACTIONS_VAL = (short) 0x4;
+    public final static short CLEAR_ACTIONS_VAL = (short) 0x5;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static Set<OFInstructionType> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFInstructionType> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFInstructionType> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFInstructionType> ofWireValue(short val) {
+        EnumSet<OFInstructionType> set = EnumSet.noneOf(OFInstructionType.class);
+
+        if((val & GOTO_TABLE_VAL) != 0)
+            set.add(OFInstructionType.GOTO_TABLE);
+        if((val & WRITE_METADATA_VAL) != 0)
+            set.add(OFInstructionType.WRITE_METADATA);
+        if((val & WRITE_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.WRITE_ACTIONS);
+        if((val & APPLY_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.APPLY_ACTIONS);
+        if((val & CLEAR_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.CLEAR_ACTIONS);
+        if((val & EXPERIMENTER_VAL) != 0)
+            set.add(OFInstructionType.EXPERIMENTER);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFInstructionType> set) {
+        short wireValue = 0;
+
+        for(OFInstructionType e: set) {
+            switch(e) {
+                case GOTO_TABLE:
+                    wireValue |= GOTO_TABLE_VAL;
+                    break;
+                case WRITE_METADATA:
+                    wireValue |= WRITE_METADATA_VAL;
+                    break;
+                case WRITE_ACTIONS:
+                    wireValue |= WRITE_ACTIONS_VAL;
+                    break;
+                case APPLY_ACTIONS:
+                    wireValue |= APPLY_ACTIONS_VAL;
+                    break;
+                case CLEAR_ACTIONS:
+                    wireValue |= CLEAR_ACTIONS_VAL;
+                    break;
+                case EXPERIMENTER:
+                    wireValue |= EXPERIMENTER_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFInstructionType in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionVer12.java
new file mode 100644
index 0000000..1c8b999
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionVer12.java
@@ -0,0 +1,68 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFInstructionVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstruction> {
+        @Override
+        public OFInstruction readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x4:
+                   // discriminator value OFInstructionType.APPLY_ACTIONS=4 for class OFInstructionApplyActionsVer12
+                   return OFInstructionApplyActionsVer12.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFInstructionType.CLEAR_ACTIONS=5 for class OFInstructionClearActionsVer12
+                   return OFInstructionClearActionsVer12.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFInstructionType.EXPERIMENTER=65535 for class OFInstructionExperimenterVer12
+                   return OFInstructionExperimenterVer12.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFInstructionType.GOTO_TABLE=1 for class OFInstructionGotoTableVer12
+                   return OFInstructionGotoTableVer12.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFInstructionType.WRITE_ACTIONS=3 for class OFInstructionWriteActionsVer12
+                   return OFInstructionWriteActionsVer12.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFInstructionType.WRITE_METADATA=2 for class OFInstructionWriteMetadataVer12
+                   return OFInstructionWriteMetadataVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFInstructionVer12: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionWriteActionsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionWriteActionsVer12.java
new file mode 100644
index 0000000..282cd5b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionWriteActionsVer12.java
@@ -0,0 +1,279 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionWriteActionsVer12 implements OFInstructionWriteActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionWriteActionsVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFInstructionWriteActionsVer12 DEFAULT = new OFInstructionWriteActionsVer12(
+        DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionWriteActionsVer12(List<OFAction> actions) {
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFInstructionWriteActions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionWriteActions.Builder {
+        final OFInstructionWriteActionsVer12 parentMessage;
+
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFInstructionWriteActionsVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionWriteActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFInstructionWriteActions build() {
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFInstructionWriteActionsVer12(
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionWriteActions.Builder {
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionWriteActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFInstructionWriteActions build() {
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFInstructionWriteActionsVer12(
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionWriteActions> {
+        @Override
+        public OFInstructionWriteActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 3
+            short type = bb.readShort();
+            if(type != (short) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_ACTIONS(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer12.READER);
+
+            OFInstructionWriteActionsVer12 instructionWriteActionsVer12 = new OFInstructionWriteActionsVer12(
+                    actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionWriteActionsVer12);
+            return instructionWriteActionsVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionWriteActionsVer12Funnel FUNNEL = new OFInstructionWriteActionsVer12Funnel();
+    static class OFInstructionWriteActionsVer12Funnel implements Funnel<OFInstructionWriteActionsVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionWriteActionsVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 3
+            sink.putShort((short) 0x3);
+            // FIXME: skip funnel of length
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionWriteActionsVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionWriteActionsVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 3
+            bb.writeShort((short) 0x3);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionWriteActionsVer12(");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionWriteActionsVer12 other = (OFInstructionWriteActionsVer12) obj;
+
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionWriteMetadataVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionWriteMetadataVer12.java
new file mode 100644
index 0000000..29e4803f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionWriteMetadataVer12.java
@@ -0,0 +1,326 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionWriteMetadataVer12 implements OFInstructionWriteMetadata {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionWriteMetadataVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static U64 DEFAULT_METADATA = U64.ZERO;
+        private final static U64 DEFAULT_METADATA_MASK = U64.ZERO;
+
+    // OF message fields
+    private final U64 metadata;
+    private final U64 metadataMask;
+//
+    // Immutable default instance
+    final static OFInstructionWriteMetadataVer12 DEFAULT = new OFInstructionWriteMetadataVer12(
+        DEFAULT_METADATA, DEFAULT_METADATA_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionWriteMetadataVer12(U64 metadata, U64 metadataMask) {
+        this.metadata = metadata;
+        this.metadataMask = metadataMask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFInstructionWriteMetadata.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionWriteMetadata.Builder {
+        final OFInstructionWriteMetadataVer12 parentMessage;
+
+        // OF message fields
+        private boolean metadataSet;
+        private U64 metadata;
+        private boolean metadataMaskSet;
+        private U64 metadataMask;
+
+        BuilderWithParent(OFInstructionWriteMetadataVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadata(U64 metadata) {
+        this.metadata = metadata;
+        this.metadataSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadataMask(U64 metadataMask) {
+        this.metadataMask = metadataMask;
+        this.metadataMaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFInstructionWriteMetadata build() {
+                U64 metadata = this.metadataSet ? this.metadata : parentMessage.metadata;
+                if(metadata == null)
+                    throw new NullPointerException("Property metadata must not be null");
+                U64 metadataMask = this.metadataMaskSet ? this.metadataMask : parentMessage.metadataMask;
+                if(metadataMask == null)
+                    throw new NullPointerException("Property metadataMask must not be null");
+
+                //
+                return new OFInstructionWriteMetadataVer12(
+                    metadata,
+                    metadataMask
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionWriteMetadata.Builder {
+        // OF message fields
+        private boolean metadataSet;
+        private U64 metadata;
+        private boolean metadataMaskSet;
+        private U64 metadataMask;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadata(U64 metadata) {
+        this.metadata = metadata;
+        this.metadataSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadataMask(U64 metadataMask) {
+        this.metadataMask = metadataMask;
+        this.metadataMaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFInstructionWriteMetadata build() {
+            U64 metadata = this.metadataSet ? this.metadata : DEFAULT_METADATA;
+            if(metadata == null)
+                throw new NullPointerException("Property metadata must not be null");
+            U64 metadataMask = this.metadataMaskSet ? this.metadataMask : DEFAULT_METADATA_MASK;
+            if(metadataMask == null)
+                throw new NullPointerException("Property metadataMask must not be null");
+
+
+            return new OFInstructionWriteMetadataVer12(
+                    metadata,
+                    metadataMask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionWriteMetadata> {
+        @Override
+        public OFInstructionWriteMetadata readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_METADATA(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 metadata = U64.ofRaw(bb.readLong());
+            U64 metadataMask = U64.ofRaw(bb.readLong());
+
+            OFInstructionWriteMetadataVer12 instructionWriteMetadataVer12 = new OFInstructionWriteMetadataVer12(
+                    metadata,
+                      metadataMask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionWriteMetadataVer12);
+            return instructionWriteMetadataVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionWriteMetadataVer12Funnel FUNNEL = new OFInstructionWriteMetadataVer12Funnel();
+    static class OFInstructionWriteMetadataVer12Funnel implements Funnel<OFInstructionWriteMetadataVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionWriteMetadataVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            // skip pad (4 bytes)
+            message.metadata.putTo(sink);
+            message.metadataMask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionWriteMetadataVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionWriteMetadataVer12 message) {
+            // fixed value property type = 2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.metadata.getValue());
+            bb.writeLong(message.metadataMask.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionWriteMetadataVer12(");
+        b.append("metadata=").append(metadata);
+        b.append(", ");
+        b.append("metadataMask=").append(metadataMask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionWriteMetadataVer12 other = (OFInstructionWriteMetadataVer12) obj;
+
+        if (metadata == null) {
+            if (other.metadata != null)
+                return false;
+        } else if (!metadata.equals(other.metadata))
+            return false;
+        if (metadataMask == null) {
+            if (other.metadataMask != null)
+                return false;
+        } else if (!metadataMask.equals(other.metadataMask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
+        result = prime * result + ((metadataMask == null) ? 0 : metadataMask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionsVer12.java
new file mode 100644
index 0000000..3e8fbd9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFInstructionsVer12.java
@@ -0,0 +1,131 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+
+
+public class OFInstructionsVer12 implements OFInstructions {
+    public final static OFInstructionsVer12 INSTANCE = new OFInstructionsVer12();
+
+
+
+
+    public OFInstructionApplyActions.Builder buildApplyActions() {
+        return new OFInstructionApplyActionsVer12.Builder();
+    }
+    public OFInstructionApplyActions applyActions(List<OFAction> actions) {
+        return new OFInstructionApplyActionsVer12(
+                actions
+                    );
+    }
+
+    public OFInstructionClearActions clearActions() {
+        return OFInstructionClearActionsVer12.INSTANCE;
+    }
+
+    public OFInstructionGotoTable.Builder buildGotoTable() {
+        return new OFInstructionGotoTableVer12.Builder();
+    }
+    public OFInstructionGotoTable gotoTable(TableId tableId) {
+        return new OFInstructionGotoTableVer12(
+                tableId
+                    );
+    }
+
+    public OFInstructionWriteActions.Builder buildWriteActions() {
+        return new OFInstructionWriteActionsVer12.Builder();
+    }
+    public OFInstructionWriteActions writeActions(List<OFAction> actions) {
+        return new OFInstructionWriteActionsVer12(
+                actions
+                    );
+    }
+
+    public OFInstructionWriteMetadata.Builder buildWriteMetadata() {
+        return new OFInstructionWriteMetadataVer12.Builder();
+    }
+    public OFInstructionWriteMetadata writeMetadata(U64 metadata, U64 metadataMask) {
+        return new OFInstructionWriteMetadataVer12(
+                metadata,
+                      metadataMask
+                    );
+    }
+
+    public OFInstructionBsnArpOffload bsnArpOffload() {
+        throw new UnsupportedOperationException("OFInstructionBsnArpOffload not supported in version 1.2");
+    }
+
+    public OFInstructionBsnDeny bsnDeny() {
+        throw new UnsupportedOperationException("OFInstructionBsnDeny not supported in version 1.2");
+    }
+
+    public OFInstructionBsnDhcpOffload bsnDhcpOffload() {
+        throw new UnsupportedOperationException("OFInstructionBsnDhcpOffload not supported in version 1.2");
+    }
+
+    public OFInstructionBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableSplitHorizonCheck not supported in version 1.2");
+    }
+
+    public OFInstructionBsnDisableSrcMacCheck bsnDisableSrcMacCheck() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableSrcMacCheck not supported in version 1.2");
+    }
+
+    public OFInstructionBsnDisableVlanCounters bsnDisableVlanCounters() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableVlanCounters not supported in version 1.2");
+    }
+
+    public OFInstructionBsnPacketOfDeath bsnPacketOfDeath() {
+        throw new UnsupportedOperationException("OFInstructionBsnPacketOfDeath not supported in version 1.2");
+    }
+
+    public OFInstructionBsnPermit bsnPermit() {
+        throw new UnsupportedOperationException("OFInstructionBsnPermit not supported in version 1.2");
+    }
+
+    public OFInstructionBsnPrioritizePdus bsnPrioritizePdus() {
+        throw new UnsupportedOperationException("OFInstructionBsnPrioritizePdus not supported in version 1.2");
+    }
+
+    public OFInstructionBsnRequireVlanXlate bsnRequireVlanXlate() {
+        throw new UnsupportedOperationException("OFInstructionBsnRequireVlanXlate not supported in version 1.2");
+    }
+
+    public OFInstructionMeter.Builder buildMeter() {
+        throw new UnsupportedOperationException("OFInstructionMeter not supported in version 1.2");
+    }
+    public OFInstructionMeter meter(long meterId) {
+        throw new UnsupportedOperationException("OFInstructionMeter not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFInstruction> getReader() {
+        return OFInstructionVer12.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMatchTypeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMatchTypeSerializerVer12.java
new file mode 100644
index 0000000..108349e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMatchTypeSerializerVer12.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFMatchType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFMatchTypeSerializerVer12 {
+
+    public final static short STANDARD_VAL = (short) 0x0;
+    public final static short OXM_VAL = (short) 0x1;
+
+    public static OFMatchType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFMatchType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFMatchType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFMatchType ofWireValue(short val) {
+        switch(val) {
+            case STANDARD_VAL:
+                return OFMatchType.STANDARD;
+            case OXM_VAL:
+                return OFMatchType.OXM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFMatchType in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFMatchType e) {
+        switch(e) {
+            case STANDARD:
+                return STANDARD_VAL;
+            case OXM:
+                return OXM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFMatchType in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMatchV3Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMatchV3Ver12.java
new file mode 100644
index 0000000..da112a2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMatchV3Ver12.java
@@ -0,0 +1,596 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMatchV3Ver12 implements OFMatchV3 {
+    private static final Logger logger = LoggerFactory.getLogger(OFMatchV3Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static OFOxmList DEFAULT_OXM_LIST = OFOxmList.EMPTY;
+
+    // OF message fields
+    private final OFOxmList oxmList;
+//
+    // Immutable default instance
+    final static OFMatchV3Ver12 DEFAULT = new OFMatchV3Ver12(
+        DEFAULT_OXM_LIST
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMatchV3Ver12(OFOxmList oxmList) {
+        this.oxmList = oxmList;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public OFOxmList getOxmList() {
+        return oxmList;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    @Override
+    public <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        if (!supports(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
+
+        OFOxm<F> oxm = this.oxmList.get(field);
+
+        if (oxm == null || !field.arePrerequisitesOK(this))
+            return null;
+
+        return oxm.getValue();
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        if (!supportsMasked(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support masked matching on field " + field.getName());
+
+        OFOxm<F> oxm = this.oxmList.get(field);
+
+        if (oxm == null || !field.arePrerequisitesOK(this))
+            return null;
+
+        if (oxm.getMask() == null)
+            return null;
+
+        // TODO: Make OfOxm extend Masked and just return the OXM?
+        return Masked.of(oxm.getValue(), oxm.getMask());
+    }
+
+    private static boolean supportsField(MatchField<?> field) {
+        switch (field.id) {
+            case IN_PORT:
+            case IN_PHY_PORT:
+            case METADATA:
+            case ETH_DST:
+            case ETH_SRC:
+            case ETH_TYPE:
+            case VLAN_VID:
+            case VLAN_PCP:
+            case IP_DSCP:
+            case IP_ECN:
+            case IP_PROTO:
+            case IPV4_SRC:
+            case IPV4_DST:
+            case TCP_SRC:
+            case TCP_DST:
+            case UDP_SRC:
+            case UDP_DST:
+            case SCTP_SRC:
+            case SCTP_DST:
+            case ICMPV4_TYPE:
+            case ICMPV4_CODE:
+            case ARP_OP:
+            case ARP_SPA:
+            case ARP_TPA:
+            case ARP_SHA:
+            case ARP_THA:
+            case IPV6_SRC:
+            case IPV6_DST:
+            case IPV6_FLABEL:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean isExact(MatchField<?> field) {
+        if (!supports(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
+
+        OFOxm<?> oxm = this.oxmList.get(field);
+
+        return oxm != null && !oxm.isMasked();
+    }
+
+    @Override
+    public boolean isFullyWildcarded(MatchField<?> field) {
+        if (!supports(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
+
+        OFOxm<?> oxm = this.oxmList.get(field);
+
+        return oxm == null;
+    }
+
+    @Override
+    public boolean isPartiallyMasked(MatchField<?> field) {
+        if (!supports(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
+
+        OFOxm<?> oxm = this.oxmList.get(field);
+
+        return oxm != null && oxm.isMasked();
+    }
+
+    @Override
+    public Iterable<MatchField<?>> getMatchFields() {
+        throw new UnsupportedOperationException();
+    }
+
+    public OFMatchV3.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMatchV3.Builder {
+        final OFMatchV3Ver12 parentMessage;
+
+        // OF message fields
+        private boolean oxmListSet;
+        private OFOxmList oxmList;
+
+        BuilderWithParent(OFMatchV3Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public OFOxmList getOxmList() {
+        return oxmList;
+    }
+
+    @Override
+    public OFMatchV3.Builder setOxmList(OFOxmList oxmList) {
+        this.oxmList = oxmList;
+        this.oxmListSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFMatchV3 build() {
+                OFOxmList oxmList = this.oxmListSet ? this.oxmList : parentMessage.oxmList;
+                if(oxmList == null)
+                    throw new NullPointerException("Property oxmList must not be null");
+
+                //
+                return new OFMatchV3Ver12(
+                    oxmList
+                );
+        }
+
+    private OFOxmList.Builder oxmListBuilder;
+
+    private synchronized void initBuilder() {
+        if (oxmListBuilder != null)
+            return;
+        oxmListBuilder = new OFOxmList.Builder();
+    }
+
+    private synchronized void updateOxmList() {
+        this.oxmList = this.oxmListBuilder.build();
+        this.oxmListSet = true;
+    }
+
+    private <F extends OFValueType<F>> OFOxm<F> getOxm(MatchField<F> field) {
+        return this.oxmListSet ? this.oxmList.get(field) : parentMessage.oxmList.get(field);
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        OFOxm<F> value = getOxm(field);
+        if (value == null)
+            return null;
+        return value.getValue();
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        OFOxm<F> value = getOxm(field);
+        if (value == null || !value.isMasked())
+            return null;
+        // TODO: If changing OXMs to extend Masked, then use it here
+        return Masked.of(value.getValue(), value.getMask());
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public synchronized boolean isExact(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value != null && !value.isMasked());
+    }
+
+    @Override
+    public synchronized boolean isFullyWildcarded(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value == null);
+    }
+
+    @Override
+    public synchronized boolean isPartiallyMasked(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value != null && value.isMasked());
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Match.Builder setExact(
+            MatchField<F> field, F value) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromValue(value, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, F value, F mask) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromValueAndMask(value, mask, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, Masked<F> valueWithMask) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromMasked(valueWithMask, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+        initBuilder();
+        this.oxmListBuilder.unset(field);
+        updateOxmList();
+        return this;
+    }
+
+    }
+
+    static class Builder implements OFMatchV3.Builder {
+        // OF message fields
+        private boolean oxmListSet;
+        private OFOxmList oxmList;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public OFOxmList getOxmList() {
+        return oxmList;
+    }
+
+    @Override
+    public OFMatchV3.Builder setOxmList(OFOxmList oxmList) {
+        this.oxmList = oxmList;
+        this.oxmListSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFMatchV3 build() {
+            OFOxmList oxmList = this.oxmListSet ? this.oxmList : DEFAULT_OXM_LIST;
+            if(oxmList == null)
+                throw new NullPointerException("Property oxmList must not be null");
+
+
+            return new OFMatchV3Ver12(
+                    oxmList
+                );
+        }
+
+    private OFOxmList.Builder oxmListBuilder;
+
+    private synchronized void initBuilder() {
+        if (oxmListBuilder != null)
+            return;
+        oxmListBuilder = new OFOxmList.Builder();
+    }
+
+    private synchronized void updateOxmList() {
+        this.oxmList = this.oxmListBuilder.build();
+        this.oxmListSet = true;
+    }
+
+    private <F extends OFValueType<F>> OFOxm<F> getOxm(MatchField<F> field) {
+        return this.oxmListSet ? this.oxmList.get(field) : null;
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        OFOxm<F> value = getOxm(field);
+        if (value == null)
+            return null;
+        return value.getValue();
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        OFOxm<F> value = getOxm(field);
+        if (value == null || !value.isMasked())
+            return null;
+        // TODO: If changing OXMs to extend Masked, then use it here
+        return Masked.of(value.getValue(), value.getMask());
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public synchronized boolean isExact(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value != null && !value.isMasked());
+    }
+
+    @Override
+    public synchronized boolean isFullyWildcarded(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value == null);
+    }
+
+    @Override
+    public synchronized boolean isPartiallyMasked(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value != null && value.isMasked());
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Match.Builder setExact(
+            MatchField<F> field, F value) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromValue(value, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, F value, F mask) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromValueAndMask(value, mask, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, Masked<F> valueWithMask) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromMasked(valueWithMask, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public synchronized <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+        initBuilder();
+        this.oxmListBuilder.unset(field);
+        updateOxmList();
+        return this;
+    }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMatchV3> {
+        @Override
+        public OFMatchV3 readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFOxmList oxmList = OFOxmList.readFrom(bb, length - (bb.readerIndex() - start), OFOxmVer12.READER);
+            // align message to 8 bytes (length does not contain alignment)
+            bb.skipBytes(((length + 7)/8 * 8 ) - length );
+
+            OFMatchV3Ver12 matchV3Ver12 = new OFMatchV3Ver12(
+                    oxmList
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", matchV3Ver12);
+            return matchV3Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMatchV3Ver12Funnel FUNNEL = new OFMatchV3Ver12Funnel();
+    static class OFMatchV3Ver12Funnel implements Funnel<OFMatchV3Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMatchV3Ver12 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // FIXME: skip funnel of length
+            message.oxmList.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMatchV3Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFMatchV3Ver12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.oxmList.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            int alignedLength = ((length + 7)/8 * 8);
+            bb.setShort(lengthIndex, length);
+            // align message to 8 bytes
+            bb.writeZero(alignedLength - length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMatchV3Ver12(");
+        b.append("oxmList=").append(oxmList);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMatchV3Ver12 other = (OFMatchV3Ver12) obj;
+
+        if (oxmList == null) {
+            if (other.oxmList != null)
+                return false;
+        } else if (!oxmList.equals(other.oxmList))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((oxmList == null) ? 0 : oxmList.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMessageVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMessageVer12.java
new file mode 100644
index 0000000..235b0c3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMessageVer12.java
@@ -0,0 +1,133 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFMessageVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFMessageVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFMessage> {
+        @Override
+        public OFMessage readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            byte type = bb.readByte();
+            bb.readerIndex(start);
+            switch(type) {
+               case (byte) 0x13:
+                   // discriminator value OFType.STATS_REPLY=19 for class OFStatsReplyVer12
+                   return OFStatsReplyVer12.READER.readFrom(bb);
+               case (byte) 0x12:
+                   // discriminator value OFType.STATS_REQUEST=18 for class OFStatsRequestVer12
+                   return OFStatsRequestVer12.READER.readFrom(bb);
+               case (byte) 0x1:
+                   // discriminator value OFType.ERROR=1 for class OFErrorMsgVer12
+                   return OFErrorMsgVer12.READER.readFrom(bb);
+               case (byte) 0x15:
+                   // discriminator value OFType.BARRIER_REPLY=21 for class OFBarrierReplyVer12
+                   return OFBarrierReplyVer12.READER.readFrom(bb);
+               case (byte) 0x14:
+                   // discriminator value OFType.BARRIER_REQUEST=20 for class OFBarrierRequestVer12
+                   return OFBarrierRequestVer12.READER.readFrom(bb);
+               case (byte) 0x4:
+                   // discriminator value OFType.EXPERIMENTER=4 for class OFExperimenterVer12
+                   return OFExperimenterVer12.READER.readFrom(bb);
+               case (byte) 0x3:
+                   // discriminator value OFType.ECHO_REPLY=3 for class OFEchoReplyVer12
+                   return OFEchoReplyVer12.READER.readFrom(bb);
+               case (byte) 0x2:
+                   // discriminator value OFType.ECHO_REQUEST=2 for class OFEchoRequestVer12
+                   return OFEchoRequestVer12.READER.readFrom(bb);
+               case (byte) 0x6:
+                   // discriminator value OFType.FEATURES_REPLY=6 for class OFFeaturesReplyVer12
+                   return OFFeaturesReplyVer12.READER.readFrom(bb);
+               case (byte) 0x5:
+                   // discriminator value OFType.FEATURES_REQUEST=5 for class OFFeaturesRequestVer12
+                   return OFFeaturesRequestVer12.READER.readFrom(bb);
+               case (byte) 0xe:
+                   // discriminator value OFType.FLOW_MOD=14 for class OFFlowModVer12
+                   return OFFlowModVer12.READER.readFrom(bb);
+               case (byte) 0xb:
+                   // discriminator value OFType.FLOW_REMOVED=11 for class OFFlowRemovedVer12
+                   return OFFlowRemovedVer12.READER.readFrom(bb);
+               case (byte) 0x8:
+                   // discriminator value OFType.GET_CONFIG_REPLY=8 for class OFGetConfigReplyVer12
+                   return OFGetConfigReplyVer12.READER.readFrom(bb);
+               case (byte) 0x7:
+                   // discriminator value OFType.GET_CONFIG_REQUEST=7 for class OFGetConfigRequestVer12
+                   return OFGetConfigRequestVer12.READER.readFrom(bb);
+               case (byte) 0x0:
+                   // discriminator value OFType.HELLO=0 for class OFHelloVer12
+                   return OFHelloVer12.READER.readFrom(bb);
+               case (byte) 0xa:
+                   // discriminator value OFType.PACKET_IN=10 for class OFPacketInVer12
+                   return OFPacketInVer12.READER.readFrom(bb);
+               case (byte) 0xd:
+                   // discriminator value OFType.PACKET_OUT=13 for class OFPacketOutVer12
+                   return OFPacketOutVer12.READER.readFrom(bb);
+               case (byte) 0x10:
+                   // discriminator value OFType.PORT_MOD=16 for class OFPortModVer12
+                   return OFPortModVer12.READER.readFrom(bb);
+               case (byte) 0xc:
+                   // discriminator value OFType.PORT_STATUS=12 for class OFPortStatusVer12
+                   return OFPortStatusVer12.READER.readFrom(bb);
+               case (byte) 0x17:
+                   // discriminator value OFType.QUEUE_GET_CONFIG_REPLY=23 for class OFQueueGetConfigReplyVer12
+                   return OFQueueGetConfigReplyVer12.READER.readFrom(bb);
+               case (byte) 0x16:
+                   // discriminator value OFType.QUEUE_GET_CONFIG_REQUEST=22 for class OFQueueGetConfigRequestVer12
+                   return OFQueueGetConfigRequestVer12.READER.readFrom(bb);
+               case (byte) 0x9:
+                   // discriminator value OFType.SET_CONFIG=9 for class OFSetConfigVer12
+                   return OFSetConfigVer12.READER.readFrom(bb);
+               case (byte) 0x11:
+                   // discriminator value OFType.TABLE_MOD=17 for class OFTableModVer12
+                   return OFTableModVer12.READER.readFrom(bb);
+               case (byte) 0xf:
+                   // discriminator value OFType.GROUP_MOD=15 for class OFGroupModVer12
+                   return OFGroupModVer12.READER.readFrom(bb);
+               case (byte) 0x19:
+                   // discriminator value OFType.ROLE_REPLY=25 for class OFRoleReplyVer12
+                   return OFRoleReplyVer12.READER.readFrom(bb);
+               case (byte) 0x18:
+                   // discriminator value OFType.ROLE_REQUEST=24 for class OFRoleRequestVer12
+                   return OFRoleRequestVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFMessageVer12: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMeterBandsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMeterBandsVer12.java
new file mode 100644
index 0000000..d657bc4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFMeterBandsVer12.java
@@ -0,0 +1,57 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFMeterBandsVer12 implements OFMeterBands {
+    public final static OFMeterBandsVer12 INSTANCE = new OFMeterBandsVer12();
+
+
+
+
+    public OFMeterBandDrop.Builder buildDrop() {
+        throw new UnsupportedOperationException("OFMeterBandDrop not supported in version 1.2");
+    }
+    public OFMeterBandDrop drop(long rate, long burstSize) {
+        throw new UnsupportedOperationException("OFMeterBandDrop not supported in version 1.2");
+    }
+
+    public OFMeterBandDscpRemark.Builder buildDscpRemark() {
+        throw new UnsupportedOperationException("OFMeterBandDscpRemark not supported in version 1.2");
+    }
+
+    public OFMeterBandExperimenter.Builder buildExperimenter() {
+        throw new UnsupportedOperationException("OFMeterBandExperimenter not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFMeterBand> getReader() {
+        throw new UnsupportedOperationException("Reader<OFMeterBand> not supported in version 1.2");
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFNiciraHeaderVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFNiciraHeaderVer12.java
new file mode 100644
index 0000000..aba183d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFNiciraHeaderVer12.java
@@ -0,0 +1,66 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFNiciraHeaderVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFNiciraHeaderVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFNiciraHeader> {
+        @Override
+        public OFNiciraHeader readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFNiciraHeaderVer12: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpOpMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpOpMaskedVer12.java
new file mode 100644
index 0000000..ce0e730
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpOpMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpOpMaskedVer12 implements OFOxmArpOpMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpOpMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static ArpOpcode DEFAULT_VALUE = ArpOpcode.NONE;
+        private final static ArpOpcode DEFAULT_VALUE_MASK = ArpOpcode.NONE;
+
+    // OF message fields
+    private final ArpOpcode value;
+    private final ArpOpcode mask;
+//
+    // Immutable default instance
+    final static OFOxmArpOpMaskedVer12 DEFAULT = new OFOxmArpOpMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpOpMaskedVer12(ArpOpcode value, ArpOpcode mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002b04L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public ArpOpcode getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ArpOpcode> getCanonical() {
+        if (ArpOpcode.NO_MASK.equals(mask)) {
+            return new OFOxmArpOpVer12(value);
+        } else if(ArpOpcode.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpOpMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpOpMasked.Builder {
+        final OFOxmArpOpMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ArpOpcode value;
+        private boolean maskSet;
+        private ArpOpcode mask;
+
+        BuilderWithParent(OFOxmArpOpMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002b04L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpOpMasked.Builder setValue(ArpOpcode value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ArpOpcode getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpOpMasked.Builder setMask(ArpOpcode mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ArpOpcode> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpOpMasked build() {
+                ArpOpcode value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ArpOpcode mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpOpMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpOpMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ArpOpcode value;
+        private boolean maskSet;
+        private ArpOpcode mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002b04L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpOpMasked.Builder setValue(ArpOpcode value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ArpOpcode getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpOpMasked.Builder setMask(ArpOpcode mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ArpOpcode> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpOpMasked build() {
+            ArpOpcode value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ArpOpcode mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpOpMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpOpMasked> {
+        @Override
+        public OFOxmArpOpMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002b04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002b04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002b04L(0x80002b04L), got="+typeLen);
+            ArpOpcode value = ArpOpcode.read2Bytes(bb);
+            ArpOpcode mask = ArpOpcode.read2Bytes(bb);
+
+            OFOxmArpOpMaskedVer12 oxmArpOpMaskedVer12 = new OFOxmArpOpMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpOpMaskedVer12);
+            return oxmArpOpMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpOpMaskedVer12Funnel FUNNEL = new OFOxmArpOpMaskedVer12Funnel();
+    static class OFOxmArpOpMaskedVer12Funnel implements Funnel<OFOxmArpOpMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpOpMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002b04L
+            sink.putInt((int) 0x80002b04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpOpMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpOpMaskedVer12 message) {
+            // fixed value property typeLen = 0x80002b04L
+            bb.writeInt((int) 0x80002b04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpOpMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpOpMaskedVer12 other = (OFOxmArpOpMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpOpVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpOpVer12.java
new file mode 100644
index 0000000..c9cfe10
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpOpVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpOpVer12 implements OFOxmArpOp {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpOpVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static ArpOpcode DEFAULT_VALUE = ArpOpcode.NONE;
+
+    // OF message fields
+    private final ArpOpcode value;
+//
+    // Immutable default instance
+    final static OFOxmArpOpVer12 DEFAULT = new OFOxmArpOpVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpOpVer12(ArpOpcode value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002a02L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ArpOpcode> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ArpOpcode getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpOp.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpOp.Builder {
+        final OFOxmArpOpVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ArpOpcode value;
+
+        BuilderWithParent(OFOxmArpOpVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002a02L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpOp.Builder setValue(ArpOpcode value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ArpOpcode> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ArpOpcode getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpOp build() {
+                ArpOpcode value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpOpVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpOp.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ArpOpcode value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002a02L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpOp.Builder setValue(ArpOpcode value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ArpOpcode> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ArpOpcode getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpOp build() {
+            ArpOpcode value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpOpVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpOp> {
+        @Override
+        public OFOxmArpOp readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002a02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002a02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002a02L(0x80002a02L), got="+typeLen);
+            ArpOpcode value = ArpOpcode.read2Bytes(bb);
+
+            OFOxmArpOpVer12 oxmArpOpVer12 = new OFOxmArpOpVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpOpVer12);
+            return oxmArpOpVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpOpVer12Funnel FUNNEL = new OFOxmArpOpVer12Funnel();
+    static class OFOxmArpOpVer12Funnel implements Funnel<OFOxmArpOpVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpOpVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002a02L
+            sink.putInt((int) 0x80002a02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpOpVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpOpVer12 message) {
+            // fixed value property typeLen = 0x80002a02L
+            bb.writeInt((int) 0x80002a02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpOpVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpOpVer12 other = (OFOxmArpOpVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpShaMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpShaMaskedVer12.java
new file mode 100644
index 0000000..985d42d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpShaMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpShaMaskedVer12 implements OFOxmArpShaMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpShaMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmArpShaMaskedVer12 DEFAULT = new OFOxmArpShaMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpShaMaskedVer12(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000310cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmArpShaVer12(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpShaMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpShaMasked.Builder {
+        final OFOxmArpShaMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmArpShaMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000310cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpShaMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpShaMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpShaMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpShaMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpShaMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000310cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpShaMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpShaMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpShaMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpShaMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpShaMasked> {
+        @Override
+        public OFOxmArpShaMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000310cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000310c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000310cL(0x8000310cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmArpShaMaskedVer12 oxmArpShaMaskedVer12 = new OFOxmArpShaMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpShaMaskedVer12);
+            return oxmArpShaMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpShaMaskedVer12Funnel FUNNEL = new OFOxmArpShaMaskedVer12Funnel();
+    static class OFOxmArpShaMaskedVer12Funnel implements Funnel<OFOxmArpShaMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpShaMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000310cL
+            sink.putInt((int) 0x8000310c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpShaMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpShaMaskedVer12 message) {
+            // fixed value property typeLen = 0x8000310cL
+            bb.writeInt((int) 0x8000310c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpShaMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpShaMaskedVer12 other = (OFOxmArpShaMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpShaVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpShaVer12.java
new file mode 100644
index 0000000..7bbd75f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpShaVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpShaVer12 implements OFOxmArpSha {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpShaVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmArpShaVer12 DEFAULT = new OFOxmArpShaVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpShaVer12(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpSha.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpSha.Builder {
+        final OFOxmArpShaVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmArpShaVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSha.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpSha build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpShaVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpSha.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSha.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpSha build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpShaVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpSha> {
+        @Override
+        public OFOxmArpSha readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003006L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003006)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003006L(0x80003006L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmArpShaVer12 oxmArpShaVer12 = new OFOxmArpShaVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpShaVer12);
+            return oxmArpShaVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpShaVer12Funnel FUNNEL = new OFOxmArpShaVer12Funnel();
+    static class OFOxmArpShaVer12Funnel implements Funnel<OFOxmArpShaVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpShaVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003006L
+            sink.putInt((int) 0x80003006);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpShaVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpShaVer12 message) {
+            // fixed value property typeLen = 0x80003006L
+            bb.writeInt((int) 0x80003006);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpShaVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpShaVer12 other = (OFOxmArpShaVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpSpaMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpSpaMaskedVer12.java
new file mode 100644
index 0000000..6fef0c3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpSpaMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpSpaMaskedVer12 implements OFOxmArpSpaMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpSpaMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_VALUE_MASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+    private final IPv4Address mask;
+//
+    // Immutable default instance
+    final static OFOxmArpSpaMaskedVer12 DEFAULT = new OFOxmArpSpaMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpSpaMaskedVer12(IPv4Address value, IPv4Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002d08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        if (IPv4Address.NO_MASK.equals(mask)) {
+            return new OFOxmArpSpaVer12(value);
+        } else if(IPv4Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpSpaMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpSpaMasked.Builder {
+        final OFOxmArpSpaMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+        BuilderWithParent(OFOxmArpSpaMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002d08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSpaMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpSpaMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpSpaMasked build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv4Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpSpaMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpSpaMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002d08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSpaMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpSpaMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpSpaMasked build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv4Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpSpaMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpSpaMasked> {
+        @Override
+        public OFOxmArpSpaMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002d08L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002d08)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002d08L(0x80002d08L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+            IPv4Address mask = IPv4Address.read4Bytes(bb);
+
+            OFOxmArpSpaMaskedVer12 oxmArpSpaMaskedVer12 = new OFOxmArpSpaMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpSpaMaskedVer12);
+            return oxmArpSpaMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpSpaMaskedVer12Funnel FUNNEL = new OFOxmArpSpaMaskedVer12Funnel();
+    static class OFOxmArpSpaMaskedVer12Funnel implements Funnel<OFOxmArpSpaMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpSpaMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002d08L
+            sink.putInt((int) 0x80002d08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpSpaMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpSpaMaskedVer12 message) {
+            // fixed value property typeLen = 0x80002d08L
+            bb.writeInt((int) 0x80002d08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpSpaMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpSpaMaskedVer12 other = (OFOxmArpSpaMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpSpaVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpSpaVer12.java
new file mode 100644
index 0000000..20eef17
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpSpaVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpSpaVer12 implements OFOxmArpSpa {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpSpaVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFOxmArpSpaVer12 DEFAULT = new OFOxmArpSpaVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpSpaVer12(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002c04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpSpa.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpSpa.Builder {
+        final OFOxmArpSpaVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFOxmArpSpaVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002c04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSpa.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpSpa build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpSpaVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpSpa.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002c04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSpa.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpSpa build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpSpaVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpSpa> {
+        @Override
+        public OFOxmArpSpa readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002c04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002c04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002c04L(0x80002c04L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFOxmArpSpaVer12 oxmArpSpaVer12 = new OFOxmArpSpaVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpSpaVer12);
+            return oxmArpSpaVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpSpaVer12Funnel FUNNEL = new OFOxmArpSpaVer12Funnel();
+    static class OFOxmArpSpaVer12Funnel implements Funnel<OFOxmArpSpaVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpSpaVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002c04L
+            sink.putInt((int) 0x80002c04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpSpaVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpSpaVer12 message) {
+            // fixed value property typeLen = 0x80002c04L
+            bb.writeInt((int) 0x80002c04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpSpaVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpSpaVer12 other = (OFOxmArpSpaVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpThaMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpThaMaskedVer12.java
new file mode 100644
index 0000000..351f716
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpThaMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpThaMaskedVer12 implements OFOxmArpThaMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpThaMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmArpThaMaskedVer12 DEFAULT = new OFOxmArpThaMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpThaMaskedVer12(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000330cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmArpThaVer12(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpThaMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpThaMasked.Builder {
+        final OFOxmArpThaMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmArpThaMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000330cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpThaMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpThaMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpThaMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpThaMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpThaMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000330cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpThaMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpThaMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpThaMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpThaMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpThaMasked> {
+        @Override
+        public OFOxmArpThaMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000330cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000330c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000330cL(0x8000330cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmArpThaMaskedVer12 oxmArpThaMaskedVer12 = new OFOxmArpThaMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpThaMaskedVer12);
+            return oxmArpThaMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpThaMaskedVer12Funnel FUNNEL = new OFOxmArpThaMaskedVer12Funnel();
+    static class OFOxmArpThaMaskedVer12Funnel implements Funnel<OFOxmArpThaMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpThaMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000330cL
+            sink.putInt((int) 0x8000330c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpThaMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpThaMaskedVer12 message) {
+            // fixed value property typeLen = 0x8000330cL
+            bb.writeInt((int) 0x8000330c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpThaMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpThaMaskedVer12 other = (OFOxmArpThaMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpThaVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpThaVer12.java
new file mode 100644
index 0000000..d11c2af
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpThaVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpThaVer12 implements OFOxmArpTha {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpThaVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmArpThaVer12 DEFAULT = new OFOxmArpThaVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpThaVer12(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpTha.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpTha.Builder {
+        final OFOxmArpThaVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmArpThaVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTha.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpTha build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpThaVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpTha.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTha.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpTha build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpThaVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpTha> {
+        @Override
+        public OFOxmArpTha readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003206L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003206)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003206L(0x80003206L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmArpThaVer12 oxmArpThaVer12 = new OFOxmArpThaVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpThaVer12);
+            return oxmArpThaVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpThaVer12Funnel FUNNEL = new OFOxmArpThaVer12Funnel();
+    static class OFOxmArpThaVer12Funnel implements Funnel<OFOxmArpThaVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpThaVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003206L
+            sink.putInt((int) 0x80003206);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpThaVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpThaVer12 message) {
+            // fixed value property typeLen = 0x80003206L
+            bb.writeInt((int) 0x80003206);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpThaVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpThaVer12 other = (OFOxmArpThaVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpTpaMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpTpaMaskedVer12.java
new file mode 100644
index 0000000..4242a14
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpTpaMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpTpaMaskedVer12 implements OFOxmArpTpaMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpTpaMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_VALUE_MASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+    private final IPv4Address mask;
+//
+    // Immutable default instance
+    final static OFOxmArpTpaMaskedVer12 DEFAULT = new OFOxmArpTpaMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpTpaMaskedVer12(IPv4Address value, IPv4Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002f08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        if (IPv4Address.NO_MASK.equals(mask)) {
+            return new OFOxmArpTpaVer12(value);
+        } else if(IPv4Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpTpaMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpTpaMasked.Builder {
+        final OFOxmArpTpaMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+        BuilderWithParent(OFOxmArpTpaMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002f08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTpaMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpTpaMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpTpaMasked build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv4Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpTpaMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpTpaMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002f08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTpaMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpTpaMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpTpaMasked build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv4Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpTpaMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpTpaMasked> {
+        @Override
+        public OFOxmArpTpaMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002f08L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002f08)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002f08L(0x80002f08L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+            IPv4Address mask = IPv4Address.read4Bytes(bb);
+
+            OFOxmArpTpaMaskedVer12 oxmArpTpaMaskedVer12 = new OFOxmArpTpaMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpTpaMaskedVer12);
+            return oxmArpTpaMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpTpaMaskedVer12Funnel FUNNEL = new OFOxmArpTpaMaskedVer12Funnel();
+    static class OFOxmArpTpaMaskedVer12Funnel implements Funnel<OFOxmArpTpaMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpTpaMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002f08L
+            sink.putInt((int) 0x80002f08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpTpaMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpTpaMaskedVer12 message) {
+            // fixed value property typeLen = 0x80002f08L
+            bb.writeInt((int) 0x80002f08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpTpaMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpTpaMaskedVer12 other = (OFOxmArpTpaMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpTpaVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpTpaVer12.java
new file mode 100644
index 0000000..99e21fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmArpTpaVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpTpaVer12 implements OFOxmArpTpa {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpTpaVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFOxmArpTpaVer12 DEFAULT = new OFOxmArpTpaVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpTpaVer12(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002e04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmArpTpa.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpTpa.Builder {
+        final OFOxmArpTpaVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFOxmArpTpaVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002e04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTpa.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmArpTpa build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpTpaVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpTpa.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002e04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTpa.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmArpTpa build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpTpaVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpTpa> {
+        @Override
+        public OFOxmArpTpa readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002e04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002e04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002e04L(0x80002e04L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFOxmArpTpaVer12 oxmArpTpaVer12 = new OFOxmArpTpaVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpTpaVer12);
+            return oxmArpTpaVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpTpaVer12Funnel FUNNEL = new OFOxmArpTpaVer12Funnel();
+    static class OFOxmArpTpaVer12Funnel implements Funnel<OFOxmArpTpaVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpTpaVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002e04L
+            sink.putInt((int) 0x80002e04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpTpaVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpTpaVer12 message) {
+            // fixed value property typeLen = 0x80002e04L
+            bb.writeInt((int) 0x80002e04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpTpaVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpTpaVer12 other = (OFOxmArpTpaVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnEgrPortGroupIdMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnEgrPortGroupIdMaskedVer12.java
new file mode 100644
index 0000000..be891226
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnEgrPortGroupIdMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnEgrPortGroupIdMaskedVer12 implements OFOxmBsnEgrPortGroupIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnEgrPortGroupIdMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnEgrPortGroupIdMaskedVer12 DEFAULT = new OFOxmBsnEgrPortGroupIdMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnEgrPortGroupIdMaskedVer12(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30f08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnEgrPortGroupIdVer12(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnEgrPortGroupIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnEgrPortGroupIdMasked.Builder {
+        final OFOxmBsnEgrPortGroupIdMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnEgrPortGroupIdMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30f08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnEgrPortGroupIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnEgrPortGroupIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnEgrPortGroupIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30f08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnEgrPortGroupIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnEgrPortGroupIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnEgrPortGroupIdMasked> {
+        @Override
+        public OFOxmBsnEgrPortGroupIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30f08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30f08)
+                throw new OFParseError("Wrong typeLen: Expected=0x30f08L(0x30f08L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnEgrPortGroupIdMaskedVer12 oxmBsnEgrPortGroupIdMaskedVer12 = new OFOxmBsnEgrPortGroupIdMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnEgrPortGroupIdMaskedVer12);
+            return oxmBsnEgrPortGroupIdMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnEgrPortGroupIdMaskedVer12Funnel FUNNEL = new OFOxmBsnEgrPortGroupIdMaskedVer12Funnel();
+    static class OFOxmBsnEgrPortGroupIdMaskedVer12Funnel implements Funnel<OFOxmBsnEgrPortGroupIdMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnEgrPortGroupIdMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30f08L
+            sink.putInt(0x30f08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnEgrPortGroupIdMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnEgrPortGroupIdMaskedVer12 message) {
+            // fixed value property typeLen = 0x30f08L
+            bb.writeInt(0x30f08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnEgrPortGroupIdMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnEgrPortGroupIdMaskedVer12 other = (OFOxmBsnEgrPortGroupIdMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnEgrPortGroupIdVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnEgrPortGroupIdVer12.java
new file mode 100644
index 0000000..16ffbfa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnEgrPortGroupIdVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnEgrPortGroupIdVer12 implements OFOxmBsnEgrPortGroupId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnEgrPortGroupIdVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnEgrPortGroupIdVer12 DEFAULT = new OFOxmBsnEgrPortGroupIdVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnEgrPortGroupIdVer12(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30e04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnEgrPortGroupId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnEgrPortGroupId.Builder {
+        final OFOxmBsnEgrPortGroupIdVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnEgrPortGroupIdVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30e04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnEgrPortGroupId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnEgrPortGroupIdVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnEgrPortGroupId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30e04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnEgrPortGroupId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnEgrPortGroupIdVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnEgrPortGroupId> {
+        @Override
+        public OFOxmBsnEgrPortGroupId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30e04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30e04)
+                throw new OFParseError("Wrong typeLen: Expected=0x30e04L(0x30e04L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnEgrPortGroupIdVer12 oxmBsnEgrPortGroupIdVer12 = new OFOxmBsnEgrPortGroupIdVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnEgrPortGroupIdVer12);
+            return oxmBsnEgrPortGroupIdVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnEgrPortGroupIdVer12Funnel FUNNEL = new OFOxmBsnEgrPortGroupIdVer12Funnel();
+    static class OFOxmBsnEgrPortGroupIdVer12Funnel implements Funnel<OFOxmBsnEgrPortGroupIdVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnEgrPortGroupIdVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30e04L
+            sink.putInt(0x30e04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnEgrPortGroupIdVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnEgrPortGroupIdVer12 message) {
+            // fixed value property typeLen = 0x30e04L
+            bb.writeInt(0x30e04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnEgrPortGroupIdVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnEgrPortGroupIdVer12 other = (OFOxmBsnEgrPortGroupIdVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnGlobalVrfAllowedMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnGlobalVrfAllowedMaskedVer12.java
new file mode 100644
index 0000000..343abc17
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnGlobalVrfAllowedMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnGlobalVrfAllowedMaskedVer12 implements OFOxmBsnGlobalVrfAllowedMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnGlobalVrfAllowedMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static OFBooleanValue DEFAULT_VALUE = OFBooleanValue.FALSE;
+        private final static OFBooleanValue DEFAULT_VALUE_MASK = OFBooleanValue.FALSE;
+
+    // OF message fields
+    private final OFBooleanValue value;
+    private final OFBooleanValue mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnGlobalVrfAllowedMaskedVer12 DEFAULT = new OFOxmBsnGlobalVrfAllowedMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnGlobalVrfAllowedMaskedVer12(OFBooleanValue value, OFBooleanValue mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30702L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBooleanValue getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFBooleanValue> getCanonical() {
+        if (OFBooleanValue.NO_MASK.equals(mask)) {
+            return new OFOxmBsnGlobalVrfAllowedVer12(value);
+        } else if(OFBooleanValue.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnGlobalVrfAllowedMasked.Builder {
+        final OFOxmBsnGlobalVrfAllowedMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBooleanValue value;
+        private boolean maskSet;
+        private OFBooleanValue mask;
+
+        BuilderWithParent(OFOxmBsnGlobalVrfAllowedMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30702L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder setValue(OFBooleanValue value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFBooleanValue getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder setMask(OFBooleanValue mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFBooleanValue> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnGlobalVrfAllowedMasked build() {
+                OFBooleanValue value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFBooleanValue mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnGlobalVrfAllowedMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnGlobalVrfAllowedMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBooleanValue value;
+        private boolean maskSet;
+        private OFBooleanValue mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30702L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder setValue(OFBooleanValue value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFBooleanValue getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder setMask(OFBooleanValue mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFBooleanValue> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnGlobalVrfAllowedMasked build() {
+            OFBooleanValue value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFBooleanValue mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnGlobalVrfAllowedMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnGlobalVrfAllowedMasked> {
+        @Override
+        public OFOxmBsnGlobalVrfAllowedMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30702L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30702)
+                throw new OFParseError("Wrong typeLen: Expected=0x30702L(0x30702L), got="+typeLen);
+            OFBooleanValue value = OFBooleanValue.of(bb.readByte() != 0);
+            OFBooleanValue mask = OFBooleanValue.of(bb.readByte() != 0);
+
+            OFOxmBsnGlobalVrfAllowedMaskedVer12 oxmBsnGlobalVrfAllowedMaskedVer12 = new OFOxmBsnGlobalVrfAllowedMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnGlobalVrfAllowedMaskedVer12);
+            return oxmBsnGlobalVrfAllowedMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnGlobalVrfAllowedMaskedVer12Funnel FUNNEL = new OFOxmBsnGlobalVrfAllowedMaskedVer12Funnel();
+    static class OFOxmBsnGlobalVrfAllowedMaskedVer12Funnel implements Funnel<OFOxmBsnGlobalVrfAllowedMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnGlobalVrfAllowedMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30702L
+            sink.putInt(0x30702);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnGlobalVrfAllowedMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnGlobalVrfAllowedMaskedVer12 message) {
+            // fixed value property typeLen = 0x30702L
+            bb.writeInt(0x30702);
+            bb.writeByte(message.value.getInt());
+            bb.writeByte(message.mask.getInt());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnGlobalVrfAllowedMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnGlobalVrfAllowedMaskedVer12 other = (OFOxmBsnGlobalVrfAllowedMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnGlobalVrfAllowedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnGlobalVrfAllowedVer12.java
new file mode 100644
index 0000000..30a404a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnGlobalVrfAllowedVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnGlobalVrfAllowedVer12 implements OFOxmBsnGlobalVrfAllowed {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnGlobalVrfAllowedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static OFBooleanValue DEFAULT_VALUE = OFBooleanValue.FALSE;
+
+    // OF message fields
+    private final OFBooleanValue value;
+//
+    // Immutable default instance
+    final static OFOxmBsnGlobalVrfAllowedVer12 DEFAULT = new OFOxmBsnGlobalVrfAllowedVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnGlobalVrfAllowedVer12(OFBooleanValue value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30601L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFBooleanValue> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFBooleanValue getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnGlobalVrfAllowed.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnGlobalVrfAllowed.Builder {
+        final OFOxmBsnGlobalVrfAllowedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBooleanValue value;
+
+        BuilderWithParent(OFOxmBsnGlobalVrfAllowedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30601L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowed.Builder setValue(OFBooleanValue value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFBooleanValue> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFBooleanValue getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnGlobalVrfAllowed build() {
+                OFBooleanValue value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnGlobalVrfAllowedVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnGlobalVrfAllowed.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBooleanValue value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30601L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowed.Builder setValue(OFBooleanValue value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFBooleanValue> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFBooleanValue getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnGlobalVrfAllowed build() {
+            OFBooleanValue value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnGlobalVrfAllowedVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnGlobalVrfAllowed> {
+        @Override
+        public OFOxmBsnGlobalVrfAllowed readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30601L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30601)
+                throw new OFParseError("Wrong typeLen: Expected=0x30601L(0x30601L), got="+typeLen);
+            OFBooleanValue value = OFBooleanValue.of(bb.readByte() != 0);
+
+            OFOxmBsnGlobalVrfAllowedVer12 oxmBsnGlobalVrfAllowedVer12 = new OFOxmBsnGlobalVrfAllowedVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnGlobalVrfAllowedVer12);
+            return oxmBsnGlobalVrfAllowedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnGlobalVrfAllowedVer12Funnel FUNNEL = new OFOxmBsnGlobalVrfAllowedVer12Funnel();
+    static class OFOxmBsnGlobalVrfAllowedVer12Funnel implements Funnel<OFOxmBsnGlobalVrfAllowedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnGlobalVrfAllowedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30601L
+            sink.putInt(0x30601);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnGlobalVrfAllowedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnGlobalVrfAllowedVer12 message) {
+            // fixed value property typeLen = 0x30601L
+            bb.writeInt(0x30601);
+            bb.writeByte(message.value.getInt());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnGlobalVrfAllowedVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnGlobalVrfAllowedVer12 other = (OFOxmBsnGlobalVrfAllowedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnInPorts128MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnInPorts128MaskedVer12.java
new file mode 100644
index 0000000..eed8381
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnInPorts128MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnInPorts128MaskedVer12 implements OFOxmBsnInPorts128Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnInPorts128MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 36;
+
+        private final static OFBitMask128 DEFAULT_VALUE = OFBitMask128.NONE;
+        private final static OFBitMask128 DEFAULT_VALUE_MASK = OFBitMask128.NONE;
+
+    // OF message fields
+    private final OFBitMask128 value;
+    private final OFBitMask128 mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnInPorts128MaskedVer12 DEFAULT = new OFOxmBsnInPorts128MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnInPorts128MaskedVer12(OFBitMask128 value, OFBitMask128 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30120L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBitMask128 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFBitMask128> getCanonical() {
+        if (OFBitMask128.NO_MASK.equals(mask)) {
+            return new OFOxmBsnInPorts128Ver12(value);
+        } else if(OFBitMask128.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnInPorts128Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnInPorts128Masked.Builder {
+        final OFOxmBsnInPorts128MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBitMask128 value;
+        private boolean maskSet;
+        private OFBitMask128 mask;
+
+        BuilderWithParent(OFOxmBsnInPorts128MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30120L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128Masked.Builder setValue(OFBitMask128 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFBitMask128 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128Masked.Builder setMask(OFBitMask128 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFBitMask128> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnInPorts128Masked build() {
+                OFBitMask128 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFBitMask128 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnInPorts128MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnInPorts128Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBitMask128 value;
+        private boolean maskSet;
+        private OFBitMask128 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30120L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128Masked.Builder setValue(OFBitMask128 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFBitMask128 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128Masked.Builder setMask(OFBitMask128 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFBitMask128> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnInPorts128Masked build() {
+            OFBitMask128 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFBitMask128 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnInPorts128MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnInPorts128Masked> {
+        @Override
+        public OFOxmBsnInPorts128Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30120L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30120)
+                throw new OFParseError("Wrong typeLen: Expected=0x30120L(0x30120L), got="+typeLen);
+            OFBitMask128 value = OFBitMask128.read16Bytes(bb);
+            OFBitMask128 mask = OFBitMask128.read16Bytes(bb);
+
+            OFOxmBsnInPorts128MaskedVer12 oxmBsnInPorts128MaskedVer12 = new OFOxmBsnInPorts128MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnInPorts128MaskedVer12);
+            return oxmBsnInPorts128MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnInPorts128MaskedVer12Funnel FUNNEL = new OFOxmBsnInPorts128MaskedVer12Funnel();
+    static class OFOxmBsnInPorts128MaskedVer12Funnel implements Funnel<OFOxmBsnInPorts128MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnInPorts128MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30120L
+            sink.putInt(0x30120);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnInPorts128MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnInPorts128MaskedVer12 message) {
+            // fixed value property typeLen = 0x30120L
+            bb.writeInt(0x30120);
+            message.value.write16Bytes(bb);
+            message.mask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnInPorts128MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnInPorts128MaskedVer12 other = (OFOxmBsnInPorts128MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnInPorts128Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnInPorts128Ver12.java
new file mode 100644
index 0000000..b6db0a1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnInPorts128Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnInPorts128Ver12 implements OFOxmBsnInPorts128 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnInPorts128Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static OFBitMask128 DEFAULT_VALUE = OFBitMask128.NONE;
+
+    // OF message fields
+    private final OFBitMask128 value;
+//
+    // Immutable default instance
+    final static OFOxmBsnInPorts128Ver12 DEFAULT = new OFOxmBsnInPorts128Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnInPorts128Ver12(OFBitMask128 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30010L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFBitMask128> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFBitMask128 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnInPorts128.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnInPorts128.Builder {
+        final OFOxmBsnInPorts128Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBitMask128 value;
+
+        BuilderWithParent(OFOxmBsnInPorts128Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30010L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128.Builder setValue(OFBitMask128 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFBitMask128> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFBitMask128 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnInPorts128 build() {
+                OFBitMask128 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnInPorts128Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnInPorts128.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBitMask128 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30010L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128.Builder setValue(OFBitMask128 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFBitMask128> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFBitMask128 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnInPorts128 build() {
+            OFBitMask128 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnInPorts128Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnInPorts128> {
+        @Override
+        public OFOxmBsnInPorts128 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30010L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30010)
+                throw new OFParseError("Wrong typeLen: Expected=0x30010L(0x30010L), got="+typeLen);
+            OFBitMask128 value = OFBitMask128.read16Bytes(bb);
+
+            OFOxmBsnInPorts128Ver12 oxmBsnInPorts128Ver12 = new OFOxmBsnInPorts128Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnInPorts128Ver12);
+            return oxmBsnInPorts128Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnInPorts128Ver12Funnel FUNNEL = new OFOxmBsnInPorts128Ver12Funnel();
+    static class OFOxmBsnInPorts128Ver12Funnel implements Funnel<OFOxmBsnInPorts128Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnInPorts128Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30010L
+            sink.putInt(0x30010);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnInPorts128Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnInPorts128Ver12 message) {
+            // fixed value property typeLen = 0x30010L
+            bb.writeInt(0x30010);
+            message.value.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnInPorts128Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnInPorts128Ver12 other = (OFOxmBsnInPorts128Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3DstClassIdMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3DstClassIdMaskedVer12.java
new file mode 100644
index 0000000..971e803
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3DstClassIdMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3DstClassIdMaskedVer12 implements OFOxmBsnL3DstClassIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3DstClassIdMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3DstClassIdMaskedVer12 DEFAULT = new OFOxmBsnL3DstClassIdMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3DstClassIdMaskedVer12(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30d08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnL3DstClassIdVer12(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnL3DstClassIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3DstClassIdMasked.Builder {
+        final OFOxmBsnL3DstClassIdMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnL3DstClassIdMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30d08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3DstClassIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnL3DstClassIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3DstClassIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30d08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3DstClassIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnL3DstClassIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3DstClassIdMasked> {
+        @Override
+        public OFOxmBsnL3DstClassIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30d08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30d08)
+                throw new OFParseError("Wrong typeLen: Expected=0x30d08L(0x30d08L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3DstClassIdMaskedVer12 oxmBsnL3DstClassIdMaskedVer12 = new OFOxmBsnL3DstClassIdMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3DstClassIdMaskedVer12);
+            return oxmBsnL3DstClassIdMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3DstClassIdMaskedVer12Funnel FUNNEL = new OFOxmBsnL3DstClassIdMaskedVer12Funnel();
+    static class OFOxmBsnL3DstClassIdMaskedVer12Funnel implements Funnel<OFOxmBsnL3DstClassIdMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3DstClassIdMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30d08L
+            sink.putInt(0x30d08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3DstClassIdMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3DstClassIdMaskedVer12 message) {
+            // fixed value property typeLen = 0x30d08L
+            bb.writeInt(0x30d08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3DstClassIdMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3DstClassIdMaskedVer12 other = (OFOxmBsnL3DstClassIdMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3DstClassIdVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3DstClassIdVer12.java
new file mode 100644
index 0000000..32f524b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3DstClassIdVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3DstClassIdVer12 implements OFOxmBsnL3DstClassId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3DstClassIdVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3DstClassIdVer12 DEFAULT = new OFOxmBsnL3DstClassIdVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3DstClassIdVer12(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30c04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnL3DstClassId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3DstClassId.Builder {
+        final OFOxmBsnL3DstClassIdVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnL3DstClassIdVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30c04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3DstClassId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnL3DstClassIdVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3DstClassId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30c04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3DstClassId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnL3DstClassIdVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3DstClassId> {
+        @Override
+        public OFOxmBsnL3DstClassId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30c04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30c04)
+                throw new OFParseError("Wrong typeLen: Expected=0x30c04L(0x30c04L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3DstClassIdVer12 oxmBsnL3DstClassIdVer12 = new OFOxmBsnL3DstClassIdVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3DstClassIdVer12);
+            return oxmBsnL3DstClassIdVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3DstClassIdVer12Funnel FUNNEL = new OFOxmBsnL3DstClassIdVer12Funnel();
+    static class OFOxmBsnL3DstClassIdVer12Funnel implements Funnel<OFOxmBsnL3DstClassIdVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3DstClassIdVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30c04L
+            sink.putInt(0x30c04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3DstClassIdVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3DstClassIdVer12 message) {
+            // fixed value property typeLen = 0x30c04L
+            bb.writeInt(0x30c04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3DstClassIdVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3DstClassIdVer12 other = (OFOxmBsnL3DstClassIdVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3InterfaceClassIdMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3InterfaceClassIdMaskedVer12.java
new file mode 100644
index 0000000..1ebb06a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3InterfaceClassIdMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3InterfaceClassIdMaskedVer12 implements OFOxmBsnL3InterfaceClassIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3InterfaceClassIdMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3InterfaceClassIdMaskedVer12 DEFAULT = new OFOxmBsnL3InterfaceClassIdMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3InterfaceClassIdMaskedVer12(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30908L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnL3InterfaceClassIdVer12(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3InterfaceClassIdMasked.Builder {
+        final OFOxmBsnL3InterfaceClassIdMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnL3InterfaceClassIdMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30908L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3InterfaceClassIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnL3InterfaceClassIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3InterfaceClassIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30908L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3InterfaceClassIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnL3InterfaceClassIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3InterfaceClassIdMasked> {
+        @Override
+        public OFOxmBsnL3InterfaceClassIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30908L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30908)
+                throw new OFParseError("Wrong typeLen: Expected=0x30908L(0x30908L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3InterfaceClassIdMaskedVer12 oxmBsnL3InterfaceClassIdMaskedVer12 = new OFOxmBsnL3InterfaceClassIdMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3InterfaceClassIdMaskedVer12);
+            return oxmBsnL3InterfaceClassIdMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3InterfaceClassIdMaskedVer12Funnel FUNNEL = new OFOxmBsnL3InterfaceClassIdMaskedVer12Funnel();
+    static class OFOxmBsnL3InterfaceClassIdMaskedVer12Funnel implements Funnel<OFOxmBsnL3InterfaceClassIdMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3InterfaceClassIdMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30908L
+            sink.putInt(0x30908);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3InterfaceClassIdMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3InterfaceClassIdMaskedVer12 message) {
+            // fixed value property typeLen = 0x30908L
+            bb.writeInt(0x30908);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3InterfaceClassIdMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3InterfaceClassIdMaskedVer12 other = (OFOxmBsnL3InterfaceClassIdMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3InterfaceClassIdVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3InterfaceClassIdVer12.java
new file mode 100644
index 0000000..f2707c6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3InterfaceClassIdVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3InterfaceClassIdVer12 implements OFOxmBsnL3InterfaceClassId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3InterfaceClassIdVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3InterfaceClassIdVer12 DEFAULT = new OFOxmBsnL3InterfaceClassIdVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3InterfaceClassIdVer12(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30804L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnL3InterfaceClassId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3InterfaceClassId.Builder {
+        final OFOxmBsnL3InterfaceClassIdVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnL3InterfaceClassIdVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30804L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3InterfaceClassId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnL3InterfaceClassIdVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3InterfaceClassId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30804L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3InterfaceClassId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnL3InterfaceClassIdVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3InterfaceClassId> {
+        @Override
+        public OFOxmBsnL3InterfaceClassId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30804L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30804)
+                throw new OFParseError("Wrong typeLen: Expected=0x30804L(0x30804L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3InterfaceClassIdVer12 oxmBsnL3InterfaceClassIdVer12 = new OFOxmBsnL3InterfaceClassIdVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3InterfaceClassIdVer12);
+            return oxmBsnL3InterfaceClassIdVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3InterfaceClassIdVer12Funnel FUNNEL = new OFOxmBsnL3InterfaceClassIdVer12Funnel();
+    static class OFOxmBsnL3InterfaceClassIdVer12Funnel implements Funnel<OFOxmBsnL3InterfaceClassIdVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3InterfaceClassIdVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30804L
+            sink.putInt(0x30804);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3InterfaceClassIdVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3InterfaceClassIdVer12 message) {
+            // fixed value property typeLen = 0x30804L
+            bb.writeInt(0x30804);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3InterfaceClassIdVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3InterfaceClassIdVer12 other = (OFOxmBsnL3InterfaceClassIdVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3SrcClassIdMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3SrcClassIdMaskedVer12.java
new file mode 100644
index 0000000..3d167ec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3SrcClassIdMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3SrcClassIdMaskedVer12 implements OFOxmBsnL3SrcClassIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3SrcClassIdMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3SrcClassIdMaskedVer12 DEFAULT = new OFOxmBsnL3SrcClassIdMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3SrcClassIdMaskedVer12(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30b08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnL3SrcClassIdVer12(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnL3SrcClassIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3SrcClassIdMasked.Builder {
+        final OFOxmBsnL3SrcClassIdMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnL3SrcClassIdMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30b08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3SrcClassIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnL3SrcClassIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3SrcClassIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30b08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3SrcClassIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnL3SrcClassIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3SrcClassIdMasked> {
+        @Override
+        public OFOxmBsnL3SrcClassIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30b08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30b08)
+                throw new OFParseError("Wrong typeLen: Expected=0x30b08L(0x30b08L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3SrcClassIdMaskedVer12 oxmBsnL3SrcClassIdMaskedVer12 = new OFOxmBsnL3SrcClassIdMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3SrcClassIdMaskedVer12);
+            return oxmBsnL3SrcClassIdMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3SrcClassIdMaskedVer12Funnel FUNNEL = new OFOxmBsnL3SrcClassIdMaskedVer12Funnel();
+    static class OFOxmBsnL3SrcClassIdMaskedVer12Funnel implements Funnel<OFOxmBsnL3SrcClassIdMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3SrcClassIdMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30b08L
+            sink.putInt(0x30b08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3SrcClassIdMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3SrcClassIdMaskedVer12 message) {
+            // fixed value property typeLen = 0x30b08L
+            bb.writeInt(0x30b08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3SrcClassIdMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3SrcClassIdMaskedVer12 other = (OFOxmBsnL3SrcClassIdMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3SrcClassIdVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3SrcClassIdVer12.java
new file mode 100644
index 0000000..ec67cd1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnL3SrcClassIdVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3SrcClassIdVer12 implements OFOxmBsnL3SrcClassId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3SrcClassIdVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3SrcClassIdVer12 DEFAULT = new OFOxmBsnL3SrcClassIdVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3SrcClassIdVer12(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30a04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnL3SrcClassId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3SrcClassId.Builder {
+        final OFOxmBsnL3SrcClassIdVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnL3SrcClassIdVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30a04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3SrcClassId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnL3SrcClassIdVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3SrcClassId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30a04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3SrcClassId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnL3SrcClassIdVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3SrcClassId> {
+        @Override
+        public OFOxmBsnL3SrcClassId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30a04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30a04)
+                throw new OFParseError("Wrong typeLen: Expected=0x30a04L(0x30a04L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3SrcClassIdVer12 oxmBsnL3SrcClassIdVer12 = new OFOxmBsnL3SrcClassIdVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3SrcClassIdVer12);
+            return oxmBsnL3SrcClassIdVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3SrcClassIdVer12Funnel FUNNEL = new OFOxmBsnL3SrcClassIdVer12Funnel();
+    static class OFOxmBsnL3SrcClassIdVer12Funnel implements Funnel<OFOxmBsnL3SrcClassIdVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3SrcClassIdVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30a04L
+            sink.putInt(0x30a04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3SrcClassIdVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3SrcClassIdVer12 message) {
+            // fixed value property typeLen = 0x30a04L
+            bb.writeInt(0x30a04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3SrcClassIdVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3SrcClassIdVer12 other = (OFOxmBsnL3SrcClassIdVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnLagIdMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnLagIdMaskedVer12.java
new file mode 100644
index 0000000..be953ad
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnLagIdMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnLagIdMaskedVer12 implements OFOxmBsnLagIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnLagIdMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static LagId DEFAULT_VALUE = LagId.NONE;
+        private final static LagId DEFAULT_VALUE_MASK = LagId.NONE;
+
+    // OF message fields
+    private final LagId value;
+    private final LagId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnLagIdMaskedVer12 DEFAULT = new OFOxmBsnLagIdMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnLagIdMaskedVer12(LagId value, LagId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30308L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public LagId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<LagId> getCanonical() {
+        if (LagId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnLagIdVer12(value);
+        } else if(LagId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnLagIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnLagIdMasked.Builder {
+        final OFOxmBsnLagIdMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private LagId value;
+        private boolean maskSet;
+        private LagId mask;
+
+        BuilderWithParent(OFOxmBsnLagIdMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30308L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnLagIdMasked.Builder setValue(LagId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public LagId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnLagIdMasked.Builder setMask(LagId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<LagId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnLagIdMasked build() {
+                LagId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                LagId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnLagIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnLagIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private LagId value;
+        private boolean maskSet;
+        private LagId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30308L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnLagIdMasked.Builder setValue(LagId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public LagId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnLagIdMasked.Builder setMask(LagId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<LagId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnLagIdMasked build() {
+            LagId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            LagId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnLagIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnLagIdMasked> {
+        @Override
+        public OFOxmBsnLagIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30308L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30308)
+                throw new OFParseError("Wrong typeLen: Expected=0x30308L(0x30308L), got="+typeLen);
+            LagId value = LagId.read4Bytes(bb);
+            LagId mask = LagId.read4Bytes(bb);
+
+            OFOxmBsnLagIdMaskedVer12 oxmBsnLagIdMaskedVer12 = new OFOxmBsnLagIdMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnLagIdMaskedVer12);
+            return oxmBsnLagIdMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnLagIdMaskedVer12Funnel FUNNEL = new OFOxmBsnLagIdMaskedVer12Funnel();
+    static class OFOxmBsnLagIdMaskedVer12Funnel implements Funnel<OFOxmBsnLagIdMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnLagIdMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30308L
+            sink.putInt(0x30308);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnLagIdMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnLagIdMaskedVer12 message) {
+            // fixed value property typeLen = 0x30308L
+            bb.writeInt(0x30308);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnLagIdMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnLagIdMaskedVer12 other = (OFOxmBsnLagIdMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnLagIdVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnLagIdVer12.java
new file mode 100644
index 0000000..fbae4ae
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnLagIdVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnLagIdVer12 implements OFOxmBsnLagId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnLagIdVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static LagId DEFAULT_VALUE = LagId.NONE;
+
+    // OF message fields
+    private final LagId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnLagIdVer12 DEFAULT = new OFOxmBsnLagIdVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnLagIdVer12(LagId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30204L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<LagId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public LagId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnLagId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnLagId.Builder {
+        final OFOxmBsnLagIdVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private LagId value;
+
+        BuilderWithParent(OFOxmBsnLagIdVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30204L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnLagId.Builder setValue(LagId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<LagId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public LagId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnLagId build() {
+                LagId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnLagIdVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnLagId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private LagId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30204L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnLagId.Builder setValue(LagId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<LagId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public LagId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnLagId build() {
+            LagId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnLagIdVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnLagId> {
+        @Override
+        public OFOxmBsnLagId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30204L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30204)
+                throw new OFParseError("Wrong typeLen: Expected=0x30204L(0x30204L), got="+typeLen);
+            LagId value = LagId.read4Bytes(bb);
+
+            OFOxmBsnLagIdVer12 oxmBsnLagIdVer12 = new OFOxmBsnLagIdVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnLagIdVer12);
+            return oxmBsnLagIdVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnLagIdVer12Funnel FUNNEL = new OFOxmBsnLagIdVer12Funnel();
+    static class OFOxmBsnLagIdVer12Funnel implements Funnel<OFOxmBsnLagIdVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnLagIdVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30204L
+            sink.putInt(0x30204);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnLagIdVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnLagIdVer12 message) {
+            // fixed value property typeLen = 0x30204L
+            bb.writeInt(0x30204);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnLagIdVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnLagIdVer12 other = (OFOxmBsnLagIdVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnTcpFlagsMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnTcpFlagsMaskedVer12.java
new file mode 100644
index 0000000..b37bddb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnTcpFlagsMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnTcpFlagsMaskedVer12 implements OFOxmBsnTcpFlagsMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnTcpFlagsMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static U16 DEFAULT_VALUE = U16.ZERO;
+        private final static U16 DEFAULT_VALUE_MASK = U16.ZERO;
+
+    // OF message fields
+    private final U16 value;
+    private final U16 mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnTcpFlagsMaskedVer12 DEFAULT = new OFOxmBsnTcpFlagsMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnTcpFlagsMaskedVer12(U16 value, U16 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x32104L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public U16 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U16> getCanonical() {
+        if (U16.NO_MASK.equals(mask)) {
+            return new OFOxmBsnTcpFlagsVer12(value);
+        } else if(U16.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnTcpFlagsMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnTcpFlagsMasked.Builder {
+        final OFOxmBsnTcpFlagsMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U16 value;
+        private boolean maskSet;
+        private U16 mask;
+
+        BuilderWithParent(OFOxmBsnTcpFlagsMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x32104L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlagsMasked.Builder setValue(U16 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U16 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlagsMasked.Builder setMask(U16 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U16> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnTcpFlagsMasked build() {
+                U16 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U16 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnTcpFlagsMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnTcpFlagsMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U16 value;
+        private boolean maskSet;
+        private U16 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x32104L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlagsMasked.Builder setValue(U16 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U16 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlagsMasked.Builder setMask(U16 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U16> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnTcpFlagsMasked build() {
+            U16 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U16 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnTcpFlagsMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnTcpFlagsMasked> {
+        @Override
+        public OFOxmBsnTcpFlagsMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x32104L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x32104)
+                throw new OFParseError("Wrong typeLen: Expected=0x32104L(0x32104L), got="+typeLen);
+            U16 value = U16.of(bb.readShort());
+            U16 mask = U16.of(bb.readShort());
+
+            OFOxmBsnTcpFlagsMaskedVer12 oxmBsnTcpFlagsMaskedVer12 = new OFOxmBsnTcpFlagsMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnTcpFlagsMaskedVer12);
+            return oxmBsnTcpFlagsMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnTcpFlagsMaskedVer12Funnel FUNNEL = new OFOxmBsnTcpFlagsMaskedVer12Funnel();
+    static class OFOxmBsnTcpFlagsMaskedVer12Funnel implements Funnel<OFOxmBsnTcpFlagsMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnTcpFlagsMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x32104L
+            sink.putInt(0x32104);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnTcpFlagsMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnTcpFlagsMaskedVer12 message) {
+            // fixed value property typeLen = 0x32104L
+            bb.writeInt(0x32104);
+            bb.writeShort(message.value.getRaw());
+            bb.writeShort(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnTcpFlagsMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnTcpFlagsMaskedVer12 other = (OFOxmBsnTcpFlagsMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnTcpFlagsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnTcpFlagsVer12.java
new file mode 100644
index 0000000..5919219
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnTcpFlagsVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnTcpFlagsVer12 implements OFOxmBsnTcpFlags {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnTcpFlagsVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static U16 DEFAULT_VALUE = U16.ZERO;
+
+    // OF message fields
+    private final U16 value;
+//
+    // Immutable default instance
+    final static OFOxmBsnTcpFlagsVer12 DEFAULT = new OFOxmBsnTcpFlagsVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnTcpFlagsVer12(U16 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x32002L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U16> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U16 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnTcpFlags.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnTcpFlags.Builder {
+        final OFOxmBsnTcpFlagsVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U16 value;
+
+        BuilderWithParent(OFOxmBsnTcpFlagsVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x32002L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlags.Builder setValue(U16 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U16> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U16 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnTcpFlags build() {
+                U16 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnTcpFlagsVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnTcpFlags.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U16 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x32002L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlags.Builder setValue(U16 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U16> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U16 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnTcpFlags build() {
+            U16 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnTcpFlagsVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnTcpFlags> {
+        @Override
+        public OFOxmBsnTcpFlags readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x32002L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x32002)
+                throw new OFParseError("Wrong typeLen: Expected=0x32002L(0x32002L), got="+typeLen);
+            U16 value = U16.of(bb.readShort());
+
+            OFOxmBsnTcpFlagsVer12 oxmBsnTcpFlagsVer12 = new OFOxmBsnTcpFlagsVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnTcpFlagsVer12);
+            return oxmBsnTcpFlagsVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnTcpFlagsVer12Funnel FUNNEL = new OFOxmBsnTcpFlagsVer12Funnel();
+    static class OFOxmBsnTcpFlagsVer12Funnel implements Funnel<OFOxmBsnTcpFlagsVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnTcpFlagsVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x32002L
+            sink.putInt(0x32002);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnTcpFlagsVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnTcpFlagsVer12 message) {
+            // fixed value property typeLen = 0x32002L
+            bb.writeInt(0x32002);
+            bb.writeShort(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnTcpFlagsVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnTcpFlagsVer12 other = (OFOxmBsnTcpFlagsVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf0MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf0MaskedVer12.java
new file mode 100644
index 0000000..ae677da
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf0MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf0MaskedVer12 implements OFOxmBsnUdf0Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf0MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf0MaskedVer12 DEFAULT = new OFOxmBsnUdf0MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf0MaskedVer12(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31108L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf0Ver12(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf0Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf0Masked.Builder {
+        final OFOxmBsnUdf0MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf0MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31108L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf0Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf0Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf0Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf0MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf0Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31108L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf0Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf0Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf0Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf0MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf0Masked> {
+        @Override
+        public OFOxmBsnUdf0Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31108L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31108)
+                throw new OFParseError("Wrong typeLen: Expected=0x31108L(0x31108L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf0MaskedVer12 oxmBsnUdf0MaskedVer12 = new OFOxmBsnUdf0MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf0MaskedVer12);
+            return oxmBsnUdf0MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf0MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf0MaskedVer12Funnel();
+    static class OFOxmBsnUdf0MaskedVer12Funnel implements Funnel<OFOxmBsnUdf0MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf0MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31108L
+            sink.putInt(0x31108);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf0MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf0MaskedVer12 message) {
+            // fixed value property typeLen = 0x31108L
+            bb.writeInt(0x31108);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf0MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf0MaskedVer12 other = (OFOxmBsnUdf0MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf0Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf0Ver12.java
new file mode 100644
index 0000000..654516a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf0Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf0Ver12 implements OFOxmBsnUdf0 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf0Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf0Ver12 DEFAULT = new OFOxmBsnUdf0Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf0Ver12(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31004L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf0.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf0.Builder {
+        final OFOxmBsnUdf0Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf0Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31004L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf0.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf0 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf0Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf0.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31004L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf0.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf0 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf0Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf0> {
+        @Override
+        public OFOxmBsnUdf0 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31004L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31004)
+                throw new OFParseError("Wrong typeLen: Expected=0x31004L(0x31004L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf0Ver12 oxmBsnUdf0Ver12 = new OFOxmBsnUdf0Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf0Ver12);
+            return oxmBsnUdf0Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf0Ver12Funnel FUNNEL = new OFOxmBsnUdf0Ver12Funnel();
+    static class OFOxmBsnUdf0Ver12Funnel implements Funnel<OFOxmBsnUdf0Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf0Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31004L
+            sink.putInt(0x31004);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf0Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf0Ver12 message) {
+            // fixed value property typeLen = 0x31004L
+            bb.writeInt(0x31004);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf0Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf0Ver12 other = (OFOxmBsnUdf0Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf1MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf1MaskedVer12.java
new file mode 100644
index 0000000..c3f2be9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf1MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf1MaskedVer12 implements OFOxmBsnUdf1Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf1MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf1MaskedVer12 DEFAULT = new OFOxmBsnUdf1MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf1MaskedVer12(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31308L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf1Ver12(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf1Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf1Masked.Builder {
+        final OFOxmBsnUdf1MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf1MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31308L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf1Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf1Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf1Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf1MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf1Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31308L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf1Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf1Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf1Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf1MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf1Masked> {
+        @Override
+        public OFOxmBsnUdf1Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31308L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31308)
+                throw new OFParseError("Wrong typeLen: Expected=0x31308L(0x31308L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf1MaskedVer12 oxmBsnUdf1MaskedVer12 = new OFOxmBsnUdf1MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf1MaskedVer12);
+            return oxmBsnUdf1MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf1MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf1MaskedVer12Funnel();
+    static class OFOxmBsnUdf1MaskedVer12Funnel implements Funnel<OFOxmBsnUdf1MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf1MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31308L
+            sink.putInt(0x31308);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf1MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf1MaskedVer12 message) {
+            // fixed value property typeLen = 0x31308L
+            bb.writeInt(0x31308);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf1MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf1MaskedVer12 other = (OFOxmBsnUdf1MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf1Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf1Ver12.java
new file mode 100644
index 0000000..2682d77
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf1Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf1Ver12 implements OFOxmBsnUdf1 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf1Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf1Ver12 DEFAULT = new OFOxmBsnUdf1Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf1Ver12(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31204L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf1.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf1.Builder {
+        final OFOxmBsnUdf1Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf1Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31204L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf1.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf1 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf1Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf1.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31204L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf1.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf1 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf1Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf1> {
+        @Override
+        public OFOxmBsnUdf1 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31204L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31204)
+                throw new OFParseError("Wrong typeLen: Expected=0x31204L(0x31204L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf1Ver12 oxmBsnUdf1Ver12 = new OFOxmBsnUdf1Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf1Ver12);
+            return oxmBsnUdf1Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf1Ver12Funnel FUNNEL = new OFOxmBsnUdf1Ver12Funnel();
+    static class OFOxmBsnUdf1Ver12Funnel implements Funnel<OFOxmBsnUdf1Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf1Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31204L
+            sink.putInt(0x31204);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf1Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf1Ver12 message) {
+            // fixed value property typeLen = 0x31204L
+            bb.writeInt(0x31204);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf1Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf1Ver12 other = (OFOxmBsnUdf1Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf2MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf2MaskedVer12.java
new file mode 100644
index 0000000..61986e3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf2MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf2MaskedVer12 implements OFOxmBsnUdf2Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf2MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf2MaskedVer12 DEFAULT = new OFOxmBsnUdf2MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf2MaskedVer12(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31508L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf2Ver12(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf2Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf2Masked.Builder {
+        final OFOxmBsnUdf2MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf2MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31508L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf2Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf2Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf2Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf2MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf2Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31508L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf2Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf2Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf2Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf2MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf2Masked> {
+        @Override
+        public OFOxmBsnUdf2Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31508L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31508)
+                throw new OFParseError("Wrong typeLen: Expected=0x31508L(0x31508L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf2MaskedVer12 oxmBsnUdf2MaskedVer12 = new OFOxmBsnUdf2MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf2MaskedVer12);
+            return oxmBsnUdf2MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf2MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf2MaskedVer12Funnel();
+    static class OFOxmBsnUdf2MaskedVer12Funnel implements Funnel<OFOxmBsnUdf2MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf2MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31508L
+            sink.putInt(0x31508);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf2MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf2MaskedVer12 message) {
+            // fixed value property typeLen = 0x31508L
+            bb.writeInt(0x31508);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf2MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf2MaskedVer12 other = (OFOxmBsnUdf2MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf2Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf2Ver12.java
new file mode 100644
index 0000000..6778f5f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf2Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf2Ver12 implements OFOxmBsnUdf2 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf2Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf2Ver12 DEFAULT = new OFOxmBsnUdf2Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf2Ver12(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31404L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf2.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf2.Builder {
+        final OFOxmBsnUdf2Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf2Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31404L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf2.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf2 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf2Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf2.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31404L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf2.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf2 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf2Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf2> {
+        @Override
+        public OFOxmBsnUdf2 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31404L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31404)
+                throw new OFParseError("Wrong typeLen: Expected=0x31404L(0x31404L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf2Ver12 oxmBsnUdf2Ver12 = new OFOxmBsnUdf2Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf2Ver12);
+            return oxmBsnUdf2Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf2Ver12Funnel FUNNEL = new OFOxmBsnUdf2Ver12Funnel();
+    static class OFOxmBsnUdf2Ver12Funnel implements Funnel<OFOxmBsnUdf2Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf2Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31404L
+            sink.putInt(0x31404);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf2Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf2Ver12 message) {
+            // fixed value property typeLen = 0x31404L
+            bb.writeInt(0x31404);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf2Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf2Ver12 other = (OFOxmBsnUdf2Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf3MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf3MaskedVer12.java
new file mode 100644
index 0000000..77f56ee
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf3MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf3MaskedVer12 implements OFOxmBsnUdf3Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf3MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf3MaskedVer12 DEFAULT = new OFOxmBsnUdf3MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf3MaskedVer12(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31708L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf3Ver12(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf3Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf3Masked.Builder {
+        final OFOxmBsnUdf3MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf3MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31708L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf3Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf3Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf3Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf3MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf3Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31708L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf3Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf3Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf3Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf3MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf3Masked> {
+        @Override
+        public OFOxmBsnUdf3Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31708L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31708)
+                throw new OFParseError("Wrong typeLen: Expected=0x31708L(0x31708L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf3MaskedVer12 oxmBsnUdf3MaskedVer12 = new OFOxmBsnUdf3MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf3MaskedVer12);
+            return oxmBsnUdf3MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf3MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf3MaskedVer12Funnel();
+    static class OFOxmBsnUdf3MaskedVer12Funnel implements Funnel<OFOxmBsnUdf3MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf3MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31708L
+            sink.putInt(0x31708);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf3MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf3MaskedVer12 message) {
+            // fixed value property typeLen = 0x31708L
+            bb.writeInt(0x31708);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf3MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf3MaskedVer12 other = (OFOxmBsnUdf3MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf3Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf3Ver12.java
new file mode 100644
index 0000000..2ace6f8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf3Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf3Ver12 implements OFOxmBsnUdf3 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf3Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf3Ver12 DEFAULT = new OFOxmBsnUdf3Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf3Ver12(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31604L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf3.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf3.Builder {
+        final OFOxmBsnUdf3Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf3Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31604L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf3.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf3 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf3Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf3.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31604L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf3.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf3 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf3Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf3> {
+        @Override
+        public OFOxmBsnUdf3 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31604L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31604)
+                throw new OFParseError("Wrong typeLen: Expected=0x31604L(0x31604L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf3Ver12 oxmBsnUdf3Ver12 = new OFOxmBsnUdf3Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf3Ver12);
+            return oxmBsnUdf3Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf3Ver12Funnel FUNNEL = new OFOxmBsnUdf3Ver12Funnel();
+    static class OFOxmBsnUdf3Ver12Funnel implements Funnel<OFOxmBsnUdf3Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf3Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31604L
+            sink.putInt(0x31604);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf3Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf3Ver12 message) {
+            // fixed value property typeLen = 0x31604L
+            bb.writeInt(0x31604);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf3Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf3Ver12 other = (OFOxmBsnUdf3Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf4MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf4MaskedVer12.java
new file mode 100644
index 0000000..88cfd47
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf4MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf4MaskedVer12 implements OFOxmBsnUdf4Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf4MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf4MaskedVer12 DEFAULT = new OFOxmBsnUdf4MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf4MaskedVer12(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31908L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf4Ver12(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf4Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf4Masked.Builder {
+        final OFOxmBsnUdf4MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf4MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31908L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf4Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf4Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf4Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf4MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf4Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31908L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf4Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf4Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf4Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf4MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf4Masked> {
+        @Override
+        public OFOxmBsnUdf4Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31908L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31908)
+                throw new OFParseError("Wrong typeLen: Expected=0x31908L(0x31908L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf4MaskedVer12 oxmBsnUdf4MaskedVer12 = new OFOxmBsnUdf4MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf4MaskedVer12);
+            return oxmBsnUdf4MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf4MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf4MaskedVer12Funnel();
+    static class OFOxmBsnUdf4MaskedVer12Funnel implements Funnel<OFOxmBsnUdf4MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf4MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31908L
+            sink.putInt(0x31908);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf4MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf4MaskedVer12 message) {
+            // fixed value property typeLen = 0x31908L
+            bb.writeInt(0x31908);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf4MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf4MaskedVer12 other = (OFOxmBsnUdf4MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf4Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf4Ver12.java
new file mode 100644
index 0000000..58980e6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf4Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf4Ver12 implements OFOxmBsnUdf4 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf4Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf4Ver12 DEFAULT = new OFOxmBsnUdf4Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf4Ver12(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31804L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf4.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf4.Builder {
+        final OFOxmBsnUdf4Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf4Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31804L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf4.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf4 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf4Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf4.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31804L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf4.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf4 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf4Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf4> {
+        @Override
+        public OFOxmBsnUdf4 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31804L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31804)
+                throw new OFParseError("Wrong typeLen: Expected=0x31804L(0x31804L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf4Ver12 oxmBsnUdf4Ver12 = new OFOxmBsnUdf4Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf4Ver12);
+            return oxmBsnUdf4Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf4Ver12Funnel FUNNEL = new OFOxmBsnUdf4Ver12Funnel();
+    static class OFOxmBsnUdf4Ver12Funnel implements Funnel<OFOxmBsnUdf4Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf4Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31804L
+            sink.putInt(0x31804);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf4Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf4Ver12 message) {
+            // fixed value property typeLen = 0x31804L
+            bb.writeInt(0x31804);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf4Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf4Ver12 other = (OFOxmBsnUdf4Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf5MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf5MaskedVer12.java
new file mode 100644
index 0000000..8f6b981
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf5MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf5MaskedVer12 implements OFOxmBsnUdf5Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf5MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf5MaskedVer12 DEFAULT = new OFOxmBsnUdf5MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf5MaskedVer12(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31b08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf5Ver12(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf5Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf5Masked.Builder {
+        final OFOxmBsnUdf5MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf5MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31b08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf5Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf5Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf5Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf5MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf5Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31b08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf5Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf5Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf5Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf5MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf5Masked> {
+        @Override
+        public OFOxmBsnUdf5Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31b08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31b08)
+                throw new OFParseError("Wrong typeLen: Expected=0x31b08L(0x31b08L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf5MaskedVer12 oxmBsnUdf5MaskedVer12 = new OFOxmBsnUdf5MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf5MaskedVer12);
+            return oxmBsnUdf5MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf5MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf5MaskedVer12Funnel();
+    static class OFOxmBsnUdf5MaskedVer12Funnel implements Funnel<OFOxmBsnUdf5MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf5MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31b08L
+            sink.putInt(0x31b08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf5MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf5MaskedVer12 message) {
+            // fixed value property typeLen = 0x31b08L
+            bb.writeInt(0x31b08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf5MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf5MaskedVer12 other = (OFOxmBsnUdf5MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf5Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf5Ver12.java
new file mode 100644
index 0000000..f6bec89
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf5Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf5Ver12 implements OFOxmBsnUdf5 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf5Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf5Ver12 DEFAULT = new OFOxmBsnUdf5Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf5Ver12(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31a04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf5.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf5.Builder {
+        final OFOxmBsnUdf5Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf5Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31a04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf5.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf5 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf5Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf5.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31a04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf5.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf5 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf5Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf5> {
+        @Override
+        public OFOxmBsnUdf5 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31a04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31a04)
+                throw new OFParseError("Wrong typeLen: Expected=0x31a04L(0x31a04L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf5Ver12 oxmBsnUdf5Ver12 = new OFOxmBsnUdf5Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf5Ver12);
+            return oxmBsnUdf5Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf5Ver12Funnel FUNNEL = new OFOxmBsnUdf5Ver12Funnel();
+    static class OFOxmBsnUdf5Ver12Funnel implements Funnel<OFOxmBsnUdf5Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf5Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31a04L
+            sink.putInt(0x31a04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf5Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf5Ver12 message) {
+            // fixed value property typeLen = 0x31a04L
+            bb.writeInt(0x31a04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf5Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf5Ver12 other = (OFOxmBsnUdf5Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf6MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf6MaskedVer12.java
new file mode 100644
index 0000000..2d9ae76
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf6MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf6MaskedVer12 implements OFOxmBsnUdf6Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf6MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf6MaskedVer12 DEFAULT = new OFOxmBsnUdf6MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf6MaskedVer12(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31d08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf6Ver12(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf6Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf6Masked.Builder {
+        final OFOxmBsnUdf6MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf6MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31d08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf6Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf6Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf6Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf6MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf6Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31d08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf6Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf6Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf6Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf6MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf6Masked> {
+        @Override
+        public OFOxmBsnUdf6Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31d08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31d08)
+                throw new OFParseError("Wrong typeLen: Expected=0x31d08L(0x31d08L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf6MaskedVer12 oxmBsnUdf6MaskedVer12 = new OFOxmBsnUdf6MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf6MaskedVer12);
+            return oxmBsnUdf6MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf6MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf6MaskedVer12Funnel();
+    static class OFOxmBsnUdf6MaskedVer12Funnel implements Funnel<OFOxmBsnUdf6MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf6MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31d08L
+            sink.putInt(0x31d08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf6MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf6MaskedVer12 message) {
+            // fixed value property typeLen = 0x31d08L
+            bb.writeInt(0x31d08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf6MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf6MaskedVer12 other = (OFOxmBsnUdf6MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf6Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf6Ver12.java
new file mode 100644
index 0000000..394bb59
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf6Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf6Ver12 implements OFOxmBsnUdf6 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf6Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf6Ver12 DEFAULT = new OFOxmBsnUdf6Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf6Ver12(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31c04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf6.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf6.Builder {
+        final OFOxmBsnUdf6Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf6Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31c04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf6.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf6 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf6Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf6.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31c04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf6.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf6 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf6Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf6> {
+        @Override
+        public OFOxmBsnUdf6 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31c04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31c04)
+                throw new OFParseError("Wrong typeLen: Expected=0x31c04L(0x31c04L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf6Ver12 oxmBsnUdf6Ver12 = new OFOxmBsnUdf6Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf6Ver12);
+            return oxmBsnUdf6Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf6Ver12Funnel FUNNEL = new OFOxmBsnUdf6Ver12Funnel();
+    static class OFOxmBsnUdf6Ver12Funnel implements Funnel<OFOxmBsnUdf6Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf6Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31c04L
+            sink.putInt(0x31c04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf6Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf6Ver12 message) {
+            // fixed value property typeLen = 0x31c04L
+            bb.writeInt(0x31c04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf6Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf6Ver12 other = (OFOxmBsnUdf6Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf7MaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf7MaskedVer12.java
new file mode 100644
index 0000000..cbecda6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf7MaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf7MaskedVer12 implements OFOxmBsnUdf7Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf7MaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf7MaskedVer12 DEFAULT = new OFOxmBsnUdf7MaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf7MaskedVer12(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31f08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf7Ver12(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf7Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf7Masked.Builder {
+        final OFOxmBsnUdf7MaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf7MaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31f08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf7Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf7Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf7Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf7MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf7Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31f08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf7Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf7Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf7Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf7MaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf7Masked> {
+        @Override
+        public OFOxmBsnUdf7Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31f08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31f08)
+                throw new OFParseError("Wrong typeLen: Expected=0x31f08L(0x31f08L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf7MaskedVer12 oxmBsnUdf7MaskedVer12 = new OFOxmBsnUdf7MaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf7MaskedVer12);
+            return oxmBsnUdf7MaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf7MaskedVer12Funnel FUNNEL = new OFOxmBsnUdf7MaskedVer12Funnel();
+    static class OFOxmBsnUdf7MaskedVer12Funnel implements Funnel<OFOxmBsnUdf7MaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf7MaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31f08L
+            sink.putInt(0x31f08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf7MaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf7MaskedVer12 message) {
+            // fixed value property typeLen = 0x31f08L
+            bb.writeInt(0x31f08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf7MaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf7MaskedVer12 other = (OFOxmBsnUdf7MaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf7Ver12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf7Ver12.java
new file mode 100644
index 0000000..2a82fcb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnUdf7Ver12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf7Ver12 implements OFOxmBsnUdf7 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf7Ver12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf7Ver12 DEFAULT = new OFOxmBsnUdf7Ver12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf7Ver12(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31e04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnUdf7.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf7.Builder {
+        final OFOxmBsnUdf7Ver12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf7Ver12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31e04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf7.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf7 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf7Ver12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf7.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31e04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf7.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf7 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf7Ver12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf7> {
+        @Override
+        public OFOxmBsnUdf7 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31e04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31e04)
+                throw new OFParseError("Wrong typeLen: Expected=0x31e04L(0x31e04L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf7Ver12 oxmBsnUdf7Ver12 = new OFOxmBsnUdf7Ver12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf7Ver12);
+            return oxmBsnUdf7Ver12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf7Ver12Funnel FUNNEL = new OFOxmBsnUdf7Ver12Funnel();
+    static class OFOxmBsnUdf7Ver12Funnel implements Funnel<OFOxmBsnUdf7Ver12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf7Ver12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31e04L
+            sink.putInt(0x31e04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf7Ver12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf7Ver12 message) {
+            // fixed value property typeLen = 0x31e04L
+            bb.writeInt(0x31e04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf7Ver12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf7Ver12 other = (OFOxmBsnUdf7Ver12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVlanXlatePortGroupIdMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVlanXlatePortGroupIdMaskedVer12.java
new file mode 100644
index 0000000..924d154
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVlanXlatePortGroupIdMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnVlanXlatePortGroupIdMaskedVer12 implements OFOxmBsnVlanXlatePortGroupIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnVlanXlatePortGroupIdMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnVlanXlatePortGroupIdMaskedVer12 DEFAULT = new OFOxmBsnVlanXlatePortGroupIdMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnVlanXlatePortGroupIdMaskedVer12(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x32308L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnVlanXlatePortGroupIdVer12(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnVlanXlatePortGroupIdMasked.Builder {
+        final OFOxmBsnVlanXlatePortGroupIdMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnVlanXlatePortGroupIdMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x32308L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnVlanXlatePortGroupIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnVlanXlatePortGroupIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnVlanXlatePortGroupIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x32308L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnVlanXlatePortGroupIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnVlanXlatePortGroupIdMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnVlanXlatePortGroupIdMasked> {
+        @Override
+        public OFOxmBsnVlanXlatePortGroupIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x32308L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x32308)
+                throw new OFParseError("Wrong typeLen: Expected=0x32308L(0x32308L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnVlanXlatePortGroupIdMaskedVer12 oxmBsnVlanXlatePortGroupIdMaskedVer12 = new OFOxmBsnVlanXlatePortGroupIdMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnVlanXlatePortGroupIdMaskedVer12);
+            return oxmBsnVlanXlatePortGroupIdMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnVlanXlatePortGroupIdMaskedVer12Funnel FUNNEL = new OFOxmBsnVlanXlatePortGroupIdMaskedVer12Funnel();
+    static class OFOxmBsnVlanXlatePortGroupIdMaskedVer12Funnel implements Funnel<OFOxmBsnVlanXlatePortGroupIdMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnVlanXlatePortGroupIdMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x32308L
+            sink.putInt(0x32308);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnVlanXlatePortGroupIdMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnVlanXlatePortGroupIdMaskedVer12 message) {
+            // fixed value property typeLen = 0x32308L
+            bb.writeInt(0x32308);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnVlanXlatePortGroupIdMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnVlanXlatePortGroupIdMaskedVer12 other = (OFOxmBsnVlanXlatePortGroupIdMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVlanXlatePortGroupIdVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVlanXlatePortGroupIdVer12.java
new file mode 100644
index 0000000..49702a7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVlanXlatePortGroupIdVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnVlanXlatePortGroupIdVer12 implements OFOxmBsnVlanXlatePortGroupId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnVlanXlatePortGroupIdVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnVlanXlatePortGroupIdVer12 DEFAULT = new OFOxmBsnVlanXlatePortGroupIdVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnVlanXlatePortGroupIdVer12(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x32204L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnVlanXlatePortGroupId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnVlanXlatePortGroupId.Builder {
+        final OFOxmBsnVlanXlatePortGroupIdVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnVlanXlatePortGroupIdVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x32204L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnVlanXlatePortGroupId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnVlanXlatePortGroupIdVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnVlanXlatePortGroupId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x32204L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnVlanXlatePortGroupId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnVlanXlatePortGroupIdVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnVlanXlatePortGroupId> {
+        @Override
+        public OFOxmBsnVlanXlatePortGroupId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x32204L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x32204)
+                throw new OFParseError("Wrong typeLen: Expected=0x32204L(0x32204L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnVlanXlatePortGroupIdVer12 oxmBsnVlanXlatePortGroupIdVer12 = new OFOxmBsnVlanXlatePortGroupIdVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnVlanXlatePortGroupIdVer12);
+            return oxmBsnVlanXlatePortGroupIdVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnVlanXlatePortGroupIdVer12Funnel FUNNEL = new OFOxmBsnVlanXlatePortGroupIdVer12Funnel();
+    static class OFOxmBsnVlanXlatePortGroupIdVer12Funnel implements Funnel<OFOxmBsnVlanXlatePortGroupIdVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnVlanXlatePortGroupIdVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x32204L
+            sink.putInt(0x32204);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnVlanXlatePortGroupIdVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnVlanXlatePortGroupIdVer12 message) {
+            // fixed value property typeLen = 0x32204L
+            bb.writeInt(0x32204);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnVlanXlatePortGroupIdVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnVlanXlatePortGroupIdVer12 other = (OFOxmBsnVlanXlatePortGroupIdVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVrfMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVrfMaskedVer12.java
new file mode 100644
index 0000000..fdb2c9d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVrfMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnVrfMaskedVer12 implements OFOxmBsnVrfMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnVrfMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static VRF DEFAULT_VALUE = VRF.ZERO;
+        private final static VRF DEFAULT_VALUE_MASK = VRF.ZERO;
+
+    // OF message fields
+    private final VRF value;
+    private final VRF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnVrfMaskedVer12 DEFAULT = new OFOxmBsnVrfMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnVrfMaskedVer12(VRF value, VRF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30508L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public VRF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<VRF> getCanonical() {
+        if (VRF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnVrfVer12(value);
+        } else if(VRF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnVrfMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnVrfMasked.Builder {
+        final OFOxmBsnVrfMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VRF value;
+        private boolean maskSet;
+        private VRF mask;
+
+        BuilderWithParent(OFOxmBsnVrfMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30508L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVrfMasked.Builder setValue(VRF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public VRF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnVrfMasked.Builder setMask(VRF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<VRF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnVrfMasked build() {
+                VRF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                VRF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnVrfMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnVrfMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VRF value;
+        private boolean maskSet;
+        private VRF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30508L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVrfMasked.Builder setValue(VRF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public VRF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnVrfMasked.Builder setMask(VRF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<VRF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnVrfMasked build() {
+            VRF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            VRF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnVrfMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnVrfMasked> {
+        @Override
+        public OFOxmBsnVrfMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30508L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30508)
+                throw new OFParseError("Wrong typeLen: Expected=0x30508L(0x30508L), got="+typeLen);
+            VRF value = VRF.read4Bytes(bb);
+            VRF mask = VRF.read4Bytes(bb);
+
+            OFOxmBsnVrfMaskedVer12 oxmBsnVrfMaskedVer12 = new OFOxmBsnVrfMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnVrfMaskedVer12);
+            return oxmBsnVrfMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnVrfMaskedVer12Funnel FUNNEL = new OFOxmBsnVrfMaskedVer12Funnel();
+    static class OFOxmBsnVrfMaskedVer12Funnel implements Funnel<OFOxmBsnVrfMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnVrfMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30508L
+            sink.putInt(0x30508);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnVrfMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnVrfMaskedVer12 message) {
+            // fixed value property typeLen = 0x30508L
+            bb.writeInt(0x30508);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnVrfMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnVrfMaskedVer12 other = (OFOxmBsnVrfMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVrfVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVrfVer12.java
new file mode 100644
index 0000000..6bd9560
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmBsnVrfVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnVrfVer12 implements OFOxmBsnVrf {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnVrfVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static VRF DEFAULT_VALUE = VRF.ZERO;
+
+    // OF message fields
+    private final VRF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnVrfVer12 DEFAULT = new OFOxmBsnVrfVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnVrfVer12(VRF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30404L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<VRF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public VRF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmBsnVrf.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnVrf.Builder {
+        final OFOxmBsnVrfVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VRF value;
+
+        BuilderWithParent(OFOxmBsnVrfVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30404L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVrf.Builder setValue(VRF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<VRF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public VRF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmBsnVrf build() {
+                VRF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnVrfVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnVrf.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VRF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30404L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVrf.Builder setValue(VRF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<VRF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public VRF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmBsnVrf build() {
+            VRF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnVrfVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnVrf> {
+        @Override
+        public OFOxmBsnVrf readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30404L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30404)
+                throw new OFParseError("Wrong typeLen: Expected=0x30404L(0x30404L), got="+typeLen);
+            VRF value = VRF.read4Bytes(bb);
+
+            OFOxmBsnVrfVer12 oxmBsnVrfVer12 = new OFOxmBsnVrfVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnVrfVer12);
+            return oxmBsnVrfVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnVrfVer12Funnel FUNNEL = new OFOxmBsnVrfVer12Funnel();
+    static class OFOxmBsnVrfVer12Funnel implements Funnel<OFOxmBsnVrfVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnVrfVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30404L
+            sink.putInt(0x30404);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnVrfVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnVrfVer12 message) {
+            // fixed value property typeLen = 0x30404L
+            bb.writeInt(0x30404);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnVrfVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnVrfVer12 other = (OFOxmBsnVrfVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmClassSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmClassSerializerVer12.java
new file mode 100644
index 0000000..5a433e5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmClassSerializerVer12.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFOxmClass;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFOxmClassSerializerVer12 {
+
+    public final static short NXM_0_VAL = (short) 0x0;
+    public final static short NXM_1_VAL = (short) 0x1;
+    public final static short OPENFLOW_BASIC_VAL = (short) 0x8000;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFOxmClass readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFOxmClass e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFOxmClass e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFOxmClass ofWireValue(short val) {
+        switch(val) {
+            case NXM_0_VAL:
+                return OFOxmClass.NXM_0;
+            case NXM_1_VAL:
+                return OFOxmClass.NXM_1;
+            case OPENFLOW_BASIC_VAL:
+                return OFOxmClass.OPENFLOW_BASIC;
+            case EXPERIMENTER_VAL:
+                return OFOxmClass.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFOxmClass in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFOxmClass e) {
+        switch(e) {
+            case NXM_0:
+                return NXM_0_VAL;
+            case NXM_1:
+                return NXM_1_VAL;
+            case OPENFLOW_BASIC:
+                return OPENFLOW_BASIC_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFOxmClass in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthDstMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthDstMaskedVer12.java
new file mode 100644
index 0000000..d659ec9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthDstMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthDstMaskedVer12 implements OFOxmEthDstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthDstMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmEthDstMaskedVer12 DEFAULT = new OFOxmEthDstMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthDstMaskedVer12(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000070cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmEthDstVer12(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmEthDstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthDstMasked.Builder {
+        final OFOxmEthDstMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmEthDstMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000070cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthDstMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthDstMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmEthDstMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmEthDstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthDstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000070cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthDstMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthDstMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmEthDstMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmEthDstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthDstMasked> {
+        @Override
+        public OFOxmEthDstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000070cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000070c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000070cL(0x8000070cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmEthDstMaskedVer12 oxmEthDstMaskedVer12 = new OFOxmEthDstMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthDstMaskedVer12);
+            return oxmEthDstMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthDstMaskedVer12Funnel FUNNEL = new OFOxmEthDstMaskedVer12Funnel();
+    static class OFOxmEthDstMaskedVer12Funnel implements Funnel<OFOxmEthDstMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthDstMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000070cL
+            sink.putInt((int) 0x8000070c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthDstMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthDstMaskedVer12 message) {
+            // fixed value property typeLen = 0x8000070cL
+            bb.writeInt((int) 0x8000070c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthDstMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthDstMaskedVer12 other = (OFOxmEthDstMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthDstVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthDstVer12.java
new file mode 100644
index 0000000..d4114cd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthDstVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthDstVer12 implements OFOxmEthDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthDstVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmEthDstVer12 DEFAULT = new OFOxmEthDstVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthDstVer12(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000606L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmEthDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthDst.Builder {
+        final OFOxmEthDstVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmEthDstVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000606L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthDst.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmEthDst build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmEthDstVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthDst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000606L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthDst.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmEthDst build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmEthDstVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthDst> {
+        @Override
+        public OFOxmEthDst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000606L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000606)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000606L(0x80000606L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmEthDstVer12 oxmEthDstVer12 = new OFOxmEthDstVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthDstVer12);
+            return oxmEthDstVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthDstVer12Funnel FUNNEL = new OFOxmEthDstVer12Funnel();
+    static class OFOxmEthDstVer12Funnel implements Funnel<OFOxmEthDstVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthDstVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000606L
+            sink.putInt((int) 0x80000606);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthDstVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthDstVer12 message) {
+            // fixed value property typeLen = 0x80000606L
+            bb.writeInt((int) 0x80000606);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthDstVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthDstVer12 other = (OFOxmEthDstVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthSrcMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthSrcMaskedVer12.java
new file mode 100644
index 0000000..5a14c17
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthSrcMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthSrcMaskedVer12 implements OFOxmEthSrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthSrcMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmEthSrcMaskedVer12 DEFAULT = new OFOxmEthSrcMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthSrcMaskedVer12(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000090cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmEthSrcVer12(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmEthSrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthSrcMasked.Builder {
+        final OFOxmEthSrcMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmEthSrcMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000090cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthSrcMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthSrcMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmEthSrcMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmEthSrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthSrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000090cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthSrcMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthSrcMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmEthSrcMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmEthSrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthSrcMasked> {
+        @Override
+        public OFOxmEthSrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000090cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000090c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000090cL(0x8000090cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmEthSrcMaskedVer12 oxmEthSrcMaskedVer12 = new OFOxmEthSrcMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthSrcMaskedVer12);
+            return oxmEthSrcMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthSrcMaskedVer12Funnel FUNNEL = new OFOxmEthSrcMaskedVer12Funnel();
+    static class OFOxmEthSrcMaskedVer12Funnel implements Funnel<OFOxmEthSrcMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthSrcMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000090cL
+            sink.putInt((int) 0x8000090c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthSrcMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthSrcMaskedVer12 message) {
+            // fixed value property typeLen = 0x8000090cL
+            bb.writeInt((int) 0x8000090c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthSrcMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthSrcMaskedVer12 other = (OFOxmEthSrcMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthSrcVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthSrcVer12.java
new file mode 100644
index 0000000..62fac6d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthSrcVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthSrcVer12 implements OFOxmEthSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthSrcVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmEthSrcVer12 DEFAULT = new OFOxmEthSrcVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthSrcVer12(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000806L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmEthSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthSrc.Builder {
+        final OFOxmEthSrcVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmEthSrcVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000806L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthSrc.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmEthSrc build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmEthSrcVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthSrc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000806L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthSrc.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmEthSrc build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmEthSrcVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthSrc> {
+        @Override
+        public OFOxmEthSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000806L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000806)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000806L(0x80000806L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmEthSrcVer12 oxmEthSrcVer12 = new OFOxmEthSrcVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthSrcVer12);
+            return oxmEthSrcVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthSrcVer12Funnel FUNNEL = new OFOxmEthSrcVer12Funnel();
+    static class OFOxmEthSrcVer12Funnel implements Funnel<OFOxmEthSrcVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthSrcVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000806L
+            sink.putInt((int) 0x80000806);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthSrcVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthSrcVer12 message) {
+            // fixed value property typeLen = 0x80000806L
+            bb.writeInt((int) 0x80000806);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthSrcVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthSrcVer12 other = (OFOxmEthSrcVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthTypeMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthTypeMaskedVer12.java
new file mode 100644
index 0000000..2fee309
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthTypeMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthTypeMaskedVer12 implements OFOxmEthTypeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthTypeMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_VALUE = EthType.NONE;
+        private final static EthType DEFAULT_VALUE_MASK = EthType.NONE;
+
+    // OF message fields
+    private final EthType value;
+    private final EthType mask;
+//
+    // Immutable default instance
+    final static OFOxmEthTypeMaskedVer12 DEFAULT = new OFOxmEthTypeMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthTypeMaskedVer12(EthType value, EthType mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000b04L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public EthType getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<EthType> getCanonical() {
+        if (EthType.NO_MASK.equals(mask)) {
+            return new OFOxmEthTypeVer12(value);
+        } else if(EthType.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmEthTypeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthTypeMasked.Builder {
+        final OFOxmEthTypeMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private EthType value;
+        private boolean maskSet;
+        private EthType mask;
+
+        BuilderWithParent(OFOxmEthTypeMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000b04L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthTypeMasked.Builder setValue(EthType value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public EthType getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthTypeMasked.Builder setMask(EthType mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<EthType> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmEthTypeMasked build() {
+                EthType value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                EthType mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmEthTypeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthTypeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private EthType value;
+        private boolean maskSet;
+        private EthType mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000b04L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthTypeMasked.Builder setValue(EthType value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public EthType getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthTypeMasked.Builder setMask(EthType mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<EthType> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmEthTypeMasked build() {
+            EthType value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            EthType mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmEthTypeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthTypeMasked> {
+        @Override
+        public OFOxmEthTypeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000b04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000b04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000b04L(0x80000b04L), got="+typeLen);
+            EthType value = EthType.read2Bytes(bb);
+            EthType mask = EthType.read2Bytes(bb);
+
+            OFOxmEthTypeMaskedVer12 oxmEthTypeMaskedVer12 = new OFOxmEthTypeMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthTypeMaskedVer12);
+            return oxmEthTypeMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthTypeMaskedVer12Funnel FUNNEL = new OFOxmEthTypeMaskedVer12Funnel();
+    static class OFOxmEthTypeMaskedVer12Funnel implements Funnel<OFOxmEthTypeMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthTypeMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000b04L
+            sink.putInt((int) 0x80000b04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthTypeMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthTypeMaskedVer12 message) {
+            // fixed value property typeLen = 0x80000b04L
+            bb.writeInt((int) 0x80000b04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthTypeMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthTypeMaskedVer12 other = (OFOxmEthTypeMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthTypeVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthTypeVer12.java
new file mode 100644
index 0000000..d8d67db
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmEthTypeVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthTypeVer12 implements OFOxmEthType {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthTypeVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static EthType DEFAULT_VALUE = EthType.NONE;
+
+    // OF message fields
+    private final EthType value;
+//
+    // Immutable default instance
+    final static OFOxmEthTypeVer12 DEFAULT = new OFOxmEthTypeVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthTypeVer12(EthType value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000a02L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<EthType> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public EthType getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmEthType.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthType.Builder {
+        final OFOxmEthTypeVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private EthType value;
+
+        BuilderWithParent(OFOxmEthTypeVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000a02L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthType.Builder setValue(EthType value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<EthType> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public EthType getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmEthType build() {
+                EthType value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmEthTypeVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthType.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private EthType value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000a02L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthType.Builder setValue(EthType value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<EthType> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public EthType getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmEthType build() {
+            EthType value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmEthTypeVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthType> {
+        @Override
+        public OFOxmEthType readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000a02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000a02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000a02L(0x80000a02L), got="+typeLen);
+            EthType value = EthType.read2Bytes(bb);
+
+            OFOxmEthTypeVer12 oxmEthTypeVer12 = new OFOxmEthTypeVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthTypeVer12);
+            return oxmEthTypeVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthTypeVer12Funnel FUNNEL = new OFOxmEthTypeVer12Funnel();
+    static class OFOxmEthTypeVer12Funnel implements Funnel<OFOxmEthTypeVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthTypeVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000a02L
+            sink.putInt((int) 0x80000a02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthTypeVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthTypeVer12 message) {
+            // fixed value property typeLen = 0x80000a02L
+            bb.writeInt((int) 0x80000a02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthTypeVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthTypeVer12 other = (OFOxmEthTypeVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4CodeMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4CodeMaskedVer12.java
new file mode 100644
index 0000000..323487d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4CodeMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv4CodeMaskedVer12 implements OFOxmIcmpv4CodeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv4CodeMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static ICMPv4Code DEFAULT_VALUE = ICMPv4Code.NONE;
+        private final static ICMPv4Code DEFAULT_VALUE_MASK = ICMPv4Code.NONE;
+
+    // OF message fields
+    private final ICMPv4Code value;
+    private final ICMPv4Code mask;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv4CodeMaskedVer12 DEFAULT = new OFOxmIcmpv4CodeMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv4CodeMaskedVer12(ICMPv4Code value, ICMPv4Code mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002902L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public ICMPv4Code getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ICMPv4Code> getCanonical() {
+        if (ICMPv4Code.NO_MASK.equals(mask)) {
+            return new OFOxmIcmpv4CodeVer12(value);
+        } else if(ICMPv4Code.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIcmpv4CodeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv4CodeMasked.Builder {
+        final OFOxmIcmpv4CodeMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Code value;
+        private boolean maskSet;
+        private ICMPv4Code mask;
+
+        BuilderWithParent(OFOxmIcmpv4CodeMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002902L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4CodeMasked.Builder setValue(ICMPv4Code value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ICMPv4Code getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv4CodeMasked.Builder setMask(ICMPv4Code mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Code> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv4CodeMasked build() {
+                ICMPv4Code value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ICMPv4Code mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIcmpv4CodeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv4CodeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Code value;
+        private boolean maskSet;
+        private ICMPv4Code mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002902L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4CodeMasked.Builder setValue(ICMPv4Code value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ICMPv4Code getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv4CodeMasked.Builder setMask(ICMPv4Code mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Code> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv4CodeMasked build() {
+            ICMPv4Code value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ICMPv4Code mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIcmpv4CodeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv4CodeMasked> {
+        @Override
+        public OFOxmIcmpv4CodeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002902L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002902)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002902L(0x80002902L), got="+typeLen);
+            ICMPv4Code value = ICMPv4Code.readByte(bb);
+            ICMPv4Code mask = ICMPv4Code.readByte(bb);
+
+            OFOxmIcmpv4CodeMaskedVer12 oxmIcmpv4CodeMaskedVer12 = new OFOxmIcmpv4CodeMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv4CodeMaskedVer12);
+            return oxmIcmpv4CodeMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv4CodeMaskedVer12Funnel FUNNEL = new OFOxmIcmpv4CodeMaskedVer12Funnel();
+    static class OFOxmIcmpv4CodeMaskedVer12Funnel implements Funnel<OFOxmIcmpv4CodeMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv4CodeMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002902L
+            sink.putInt((int) 0x80002902);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv4CodeMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv4CodeMaskedVer12 message) {
+            // fixed value property typeLen = 0x80002902L
+            bb.writeInt((int) 0x80002902);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv4CodeMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv4CodeMaskedVer12 other = (OFOxmIcmpv4CodeMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4CodeVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4CodeVer12.java
new file mode 100644
index 0000000..b8127d2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4CodeVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv4CodeVer12 implements OFOxmIcmpv4Code {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv4CodeVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static ICMPv4Code DEFAULT_VALUE = ICMPv4Code.NONE;
+
+    // OF message fields
+    private final ICMPv4Code value;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv4CodeVer12 DEFAULT = new OFOxmIcmpv4CodeVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv4CodeVer12(ICMPv4Code value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002801L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ICMPv4Code> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ICMPv4Code getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIcmpv4Code.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv4Code.Builder {
+        final OFOxmIcmpv4CodeVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Code value;
+
+        BuilderWithParent(OFOxmIcmpv4CodeVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002801L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4Code.Builder setValue(ICMPv4Code value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Code> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ICMPv4Code getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv4Code build() {
+                ICMPv4Code value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIcmpv4CodeVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv4Code.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Code value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002801L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4Code.Builder setValue(ICMPv4Code value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Code> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ICMPv4Code getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv4Code build() {
+            ICMPv4Code value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIcmpv4CodeVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv4Code> {
+        @Override
+        public OFOxmIcmpv4Code readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002801L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002801)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002801L(0x80002801L), got="+typeLen);
+            ICMPv4Code value = ICMPv4Code.readByte(bb);
+
+            OFOxmIcmpv4CodeVer12 oxmIcmpv4CodeVer12 = new OFOxmIcmpv4CodeVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv4CodeVer12);
+            return oxmIcmpv4CodeVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv4CodeVer12Funnel FUNNEL = new OFOxmIcmpv4CodeVer12Funnel();
+    static class OFOxmIcmpv4CodeVer12Funnel implements Funnel<OFOxmIcmpv4CodeVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv4CodeVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002801L
+            sink.putInt((int) 0x80002801);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv4CodeVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv4CodeVer12 message) {
+            // fixed value property typeLen = 0x80002801L
+            bb.writeInt((int) 0x80002801);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv4CodeVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv4CodeVer12 other = (OFOxmIcmpv4CodeVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4TypeMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4TypeMaskedVer12.java
new file mode 100644
index 0000000..0d16afb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4TypeMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv4TypeMaskedVer12 implements OFOxmIcmpv4TypeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv4TypeMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static ICMPv4Type DEFAULT_VALUE = ICMPv4Type.NONE;
+        private final static ICMPv4Type DEFAULT_VALUE_MASK = ICMPv4Type.NONE;
+
+    // OF message fields
+    private final ICMPv4Type value;
+    private final ICMPv4Type mask;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv4TypeMaskedVer12 DEFAULT = new OFOxmIcmpv4TypeMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv4TypeMaskedVer12(ICMPv4Type value, ICMPv4Type mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002702L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public ICMPv4Type getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ICMPv4Type> getCanonical() {
+        if (ICMPv4Type.NO_MASK.equals(mask)) {
+            return new OFOxmIcmpv4TypeVer12(value);
+        } else if(ICMPv4Type.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIcmpv4TypeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv4TypeMasked.Builder {
+        final OFOxmIcmpv4TypeMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Type value;
+        private boolean maskSet;
+        private ICMPv4Type mask;
+
+        BuilderWithParent(OFOxmIcmpv4TypeMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002702L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4TypeMasked.Builder setValue(ICMPv4Type value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ICMPv4Type getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv4TypeMasked.Builder setMask(ICMPv4Type mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Type> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv4TypeMasked build() {
+                ICMPv4Type value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ICMPv4Type mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIcmpv4TypeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv4TypeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Type value;
+        private boolean maskSet;
+        private ICMPv4Type mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002702L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4TypeMasked.Builder setValue(ICMPv4Type value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ICMPv4Type getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv4TypeMasked.Builder setMask(ICMPv4Type mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Type> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv4TypeMasked build() {
+            ICMPv4Type value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ICMPv4Type mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIcmpv4TypeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv4TypeMasked> {
+        @Override
+        public OFOxmIcmpv4TypeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002702L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002702)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002702L(0x80002702L), got="+typeLen);
+            ICMPv4Type value = ICMPv4Type.readByte(bb);
+            ICMPv4Type mask = ICMPv4Type.readByte(bb);
+
+            OFOxmIcmpv4TypeMaskedVer12 oxmIcmpv4TypeMaskedVer12 = new OFOxmIcmpv4TypeMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv4TypeMaskedVer12);
+            return oxmIcmpv4TypeMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv4TypeMaskedVer12Funnel FUNNEL = new OFOxmIcmpv4TypeMaskedVer12Funnel();
+    static class OFOxmIcmpv4TypeMaskedVer12Funnel implements Funnel<OFOxmIcmpv4TypeMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv4TypeMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002702L
+            sink.putInt((int) 0x80002702);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv4TypeMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv4TypeMaskedVer12 message) {
+            // fixed value property typeLen = 0x80002702L
+            bb.writeInt((int) 0x80002702);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv4TypeMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv4TypeMaskedVer12 other = (OFOxmIcmpv4TypeMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4TypeVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4TypeVer12.java
new file mode 100644
index 0000000..9e4b8d3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv4TypeVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv4TypeVer12 implements OFOxmIcmpv4Type {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv4TypeVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static ICMPv4Type DEFAULT_VALUE = ICMPv4Type.NONE;
+
+    // OF message fields
+    private final ICMPv4Type value;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv4TypeVer12 DEFAULT = new OFOxmIcmpv4TypeVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv4TypeVer12(ICMPv4Type value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002601L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ICMPv4Type> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ICMPv4Type getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIcmpv4Type.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv4Type.Builder {
+        final OFOxmIcmpv4TypeVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Type value;
+
+        BuilderWithParent(OFOxmIcmpv4TypeVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002601L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4Type.Builder setValue(ICMPv4Type value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Type> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ICMPv4Type getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv4Type build() {
+                ICMPv4Type value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIcmpv4TypeVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv4Type.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Type value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002601L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4Type.Builder setValue(ICMPv4Type value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Type> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public ICMPv4Type getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv4Type build() {
+            ICMPv4Type value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIcmpv4TypeVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv4Type> {
+        @Override
+        public OFOxmIcmpv4Type readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002601L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002601)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002601L(0x80002601L), got="+typeLen);
+            ICMPv4Type value = ICMPv4Type.readByte(bb);
+
+            OFOxmIcmpv4TypeVer12 oxmIcmpv4TypeVer12 = new OFOxmIcmpv4TypeVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv4TypeVer12);
+            return oxmIcmpv4TypeVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv4TypeVer12Funnel FUNNEL = new OFOxmIcmpv4TypeVer12Funnel();
+    static class OFOxmIcmpv4TypeVer12Funnel implements Funnel<OFOxmIcmpv4TypeVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv4TypeVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002601L
+            sink.putInt((int) 0x80002601);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv4TypeVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv4TypeVer12 message) {
+            // fixed value property typeLen = 0x80002601L
+            bb.writeInt((int) 0x80002601);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv4TypeVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv4TypeVer12 other = (OFOxmIcmpv4TypeVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6CodeMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6CodeMaskedVer12.java
new file mode 100644
index 0000000..a399c19
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6CodeMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv6CodeMaskedVer12 implements OFOxmIcmpv6CodeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6CodeMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+        private final static U8 DEFAULT_VALUE_MASK = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+    private final U8 mask;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv6CodeMaskedVer12 DEFAULT = new OFOxmIcmpv6CodeMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv6CodeMaskedVer12(U8 value, U8 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003d02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        if (U8.NO_MASK.equals(mask)) {
+            return new OFOxmIcmpv6CodeVer12(value);
+        } else if(U8.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIcmpv6CodeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv6CodeMasked.Builder {
+        final OFOxmIcmpv6CodeMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+        BuilderWithParent(OFOxmIcmpv6CodeMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003d02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6CodeMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv6CodeMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv6CodeMasked build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U8 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIcmpv6CodeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv6CodeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003d02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6CodeMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv6CodeMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv6CodeMasked build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U8 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIcmpv6CodeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv6CodeMasked> {
+        @Override
+        public OFOxmIcmpv6CodeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003d02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003d02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003d02L(0x80003d02L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+            U8 mask = U8.of(bb.readByte());
+
+            OFOxmIcmpv6CodeMaskedVer12 oxmIcmpv6CodeMaskedVer12 = new OFOxmIcmpv6CodeMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv6CodeMaskedVer12);
+            return oxmIcmpv6CodeMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv6CodeMaskedVer12Funnel FUNNEL = new OFOxmIcmpv6CodeMaskedVer12Funnel();
+    static class OFOxmIcmpv6CodeMaskedVer12Funnel implements Funnel<OFOxmIcmpv6CodeMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv6CodeMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003d02L
+            sink.putInt((int) 0x80003d02);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv6CodeMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv6CodeMaskedVer12 message) {
+            // fixed value property typeLen = 0x80003d02L
+            bb.writeInt((int) 0x80003d02);
+            bb.writeByte(message.value.getRaw());
+            bb.writeByte(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv6CodeMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv6CodeMaskedVer12 other = (OFOxmIcmpv6CodeMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6CodeVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6CodeVer12.java
new file mode 100644
index 0000000..ec48fca
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6CodeVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv6CodeVer12 implements OFOxmIcmpv6Code {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6CodeVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv6CodeVer12 DEFAULT = new OFOxmIcmpv6CodeVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv6CodeVer12(U8 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003c01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIcmpv6Code.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv6Code.Builder {
+        final OFOxmIcmpv6CodeVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+        BuilderWithParent(OFOxmIcmpv6CodeVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003c01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6Code.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv6Code build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIcmpv6CodeVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv6Code.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003c01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6Code.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv6Code build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIcmpv6CodeVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv6Code> {
+        @Override
+        public OFOxmIcmpv6Code readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003c01L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003c01)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003c01L(0x80003c01L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+
+            OFOxmIcmpv6CodeVer12 oxmIcmpv6CodeVer12 = new OFOxmIcmpv6CodeVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv6CodeVer12);
+            return oxmIcmpv6CodeVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv6CodeVer12Funnel FUNNEL = new OFOxmIcmpv6CodeVer12Funnel();
+    static class OFOxmIcmpv6CodeVer12Funnel implements Funnel<OFOxmIcmpv6CodeVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv6CodeVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003c01L
+            sink.putInt((int) 0x80003c01);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv6CodeVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv6CodeVer12 message) {
+            // fixed value property typeLen = 0x80003c01L
+            bb.writeInt((int) 0x80003c01);
+            bb.writeByte(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv6CodeVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv6CodeVer12 other = (OFOxmIcmpv6CodeVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6TypeMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6TypeMaskedVer12.java
new file mode 100644
index 0000000..fcdf81c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6TypeMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv6TypeMaskedVer12 implements OFOxmIcmpv6TypeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6TypeMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+        private final static U8 DEFAULT_VALUE_MASK = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+    private final U8 mask;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv6TypeMaskedVer12 DEFAULT = new OFOxmIcmpv6TypeMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv6TypeMaskedVer12(U8 value, U8 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003b02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        if (U8.NO_MASK.equals(mask)) {
+            return new OFOxmIcmpv6TypeVer12(value);
+        } else if(U8.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIcmpv6TypeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv6TypeMasked.Builder {
+        final OFOxmIcmpv6TypeMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+        BuilderWithParent(OFOxmIcmpv6TypeMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003b02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6TypeMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv6TypeMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv6TypeMasked build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U8 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIcmpv6TypeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv6TypeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003b02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6TypeMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv6TypeMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv6TypeMasked build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U8 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIcmpv6TypeMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv6TypeMasked> {
+        @Override
+        public OFOxmIcmpv6TypeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003b02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003b02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003b02L(0x80003b02L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+            U8 mask = U8.of(bb.readByte());
+
+            OFOxmIcmpv6TypeMaskedVer12 oxmIcmpv6TypeMaskedVer12 = new OFOxmIcmpv6TypeMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv6TypeMaskedVer12);
+            return oxmIcmpv6TypeMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv6TypeMaskedVer12Funnel FUNNEL = new OFOxmIcmpv6TypeMaskedVer12Funnel();
+    static class OFOxmIcmpv6TypeMaskedVer12Funnel implements Funnel<OFOxmIcmpv6TypeMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv6TypeMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003b02L
+            sink.putInt((int) 0x80003b02);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv6TypeMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv6TypeMaskedVer12 message) {
+            // fixed value property typeLen = 0x80003b02L
+            bb.writeInt((int) 0x80003b02);
+            bb.writeByte(message.value.getRaw());
+            bb.writeByte(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv6TypeMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv6TypeMaskedVer12 other = (OFOxmIcmpv6TypeMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6TypeVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6TypeVer12.java
new file mode 100644
index 0000000..801cdda
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIcmpv6TypeVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv6TypeVer12 implements OFOxmIcmpv6Type {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6TypeVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv6TypeVer12 DEFAULT = new OFOxmIcmpv6TypeVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv6TypeVer12(U8 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003a01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIcmpv6Type.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv6Type.Builder {
+        final OFOxmIcmpv6TypeVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+        BuilderWithParent(OFOxmIcmpv6TypeVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003a01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6Type.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv6Type build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIcmpv6TypeVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv6Type.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003a01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6Type.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv6Type build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIcmpv6TypeVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv6Type> {
+        @Override
+        public OFOxmIcmpv6Type readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003a01L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003a01)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003a01L(0x80003a01L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+
+            OFOxmIcmpv6TypeVer12 oxmIcmpv6TypeVer12 = new OFOxmIcmpv6TypeVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv6TypeVer12);
+            return oxmIcmpv6TypeVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv6TypeVer12Funnel FUNNEL = new OFOxmIcmpv6TypeVer12Funnel();
+    static class OFOxmIcmpv6TypeVer12Funnel implements Funnel<OFOxmIcmpv6TypeVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv6TypeVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003a01L
+            sink.putInt((int) 0x80003a01);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv6TypeVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv6TypeVer12 message) {
+            // fixed value property typeLen = 0x80003a01L
+            bb.writeInt((int) 0x80003a01);
+            bb.writeByte(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv6TypeVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv6TypeVer12 other = (OFOxmIcmpv6TypeVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortMaskedVer12.java
new file mode 100644
index 0000000..3f5f033
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmInPhyPortMaskedVer12 implements OFOxmInPhyPortMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmInPhyPortMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+        private final static OFPort DEFAULT_VALUE_MASK = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+    private final OFPort mask;
+//
+    // Immutable default instance
+    final static OFOxmInPhyPortMaskedVer12 DEFAULT = new OFOxmInPhyPortMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmInPhyPortMaskedVer12(OFPort value, OFPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000308L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFPort> getCanonical() {
+        if (OFPort.NO_MASK.equals(mask)) {
+            return new OFOxmInPhyPortVer12(value);
+        } else if(OFPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmInPhyPortMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmInPhyPortMasked.Builder {
+        final OFOxmInPhyPortMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+        private boolean maskSet;
+        private OFPort mask;
+
+        BuilderWithParent(OFOxmInPhyPortMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000308L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPhyPortMasked.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmInPhyPortMasked.Builder setMask(OFPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmInPhyPortMasked build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmInPhyPortMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmInPhyPortMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+        private boolean maskSet;
+        private OFPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000308L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPhyPortMasked.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmInPhyPortMasked.Builder setMask(OFPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmInPhyPortMasked build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmInPhyPortMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmInPhyPortMasked> {
+        @Override
+        public OFOxmInPhyPortMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000308L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000308)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000308L(0x80000308L), got="+typeLen);
+            OFPort value = OFPort.read4Bytes(bb);
+            OFPort mask = OFPort.read4Bytes(bb);
+
+            OFOxmInPhyPortMaskedVer12 oxmInPhyPortMaskedVer12 = new OFOxmInPhyPortMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmInPhyPortMaskedVer12);
+            return oxmInPhyPortMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmInPhyPortMaskedVer12Funnel FUNNEL = new OFOxmInPhyPortMaskedVer12Funnel();
+    static class OFOxmInPhyPortMaskedVer12Funnel implements Funnel<OFOxmInPhyPortMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmInPhyPortMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000308L
+            sink.putInt((int) 0x80000308);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmInPhyPortMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmInPhyPortMaskedVer12 message) {
+            // fixed value property typeLen = 0x80000308L
+            bb.writeInt((int) 0x80000308);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmInPhyPortMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmInPhyPortMaskedVer12 other = (OFOxmInPhyPortMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortVer12.java
new file mode 100644
index 0000000..88cf4d3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmInPhyPortVer12 implements OFOxmInPhyPort {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmInPhyPortVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+//
+    // Immutable default instance
+    final static OFOxmInPhyPortVer12 DEFAULT = new OFOxmInPhyPortVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmInPhyPortVer12(OFPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000204L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmInPhyPort.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmInPhyPort.Builder {
+        final OFOxmInPhyPortVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+        BuilderWithParent(OFOxmInPhyPortVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000204L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPhyPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmInPhyPort build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmInPhyPortVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmInPhyPort.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000204L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPhyPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmInPhyPort build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmInPhyPortVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmInPhyPort> {
+        @Override
+        public OFOxmInPhyPort readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000204L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000204)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000204L(0x80000204L), got="+typeLen);
+            OFPort value = OFPort.read4Bytes(bb);
+
+            OFOxmInPhyPortVer12 oxmInPhyPortVer12 = new OFOxmInPhyPortVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmInPhyPortVer12);
+            return oxmInPhyPortVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmInPhyPortVer12Funnel FUNNEL = new OFOxmInPhyPortVer12Funnel();
+    static class OFOxmInPhyPortVer12Funnel implements Funnel<OFOxmInPhyPortVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmInPhyPortVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000204L
+            sink.putInt((int) 0x80000204);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmInPhyPortVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmInPhyPortVer12 message) {
+            // fixed value property typeLen = 0x80000204L
+            bb.writeInt((int) 0x80000204);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmInPhyPortVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmInPhyPortVer12 other = (OFOxmInPhyPortVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPortMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPortMaskedVer12.java
new file mode 100644
index 0000000..1013fff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPortMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmInPortMaskedVer12 implements OFOxmInPortMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmInPortMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+        private final static OFPort DEFAULT_VALUE_MASK = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+    private final OFPort mask;
+//
+    // Immutable default instance
+    final static OFOxmInPortMaskedVer12 DEFAULT = new OFOxmInPortMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmInPortMaskedVer12(OFPort value, OFPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000108L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFPort> getCanonical() {
+        if (OFPort.NO_MASK.equals(mask)) {
+            return new OFOxmInPortVer12(value);
+        } else if(OFPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmInPortMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmInPortMasked.Builder {
+        final OFOxmInPortMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+        private boolean maskSet;
+        private OFPort mask;
+
+        BuilderWithParent(OFOxmInPortMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000108L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPortMasked.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmInPortMasked.Builder setMask(OFPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmInPortMasked build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmInPortMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmInPortMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+        private boolean maskSet;
+        private OFPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000108L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPortMasked.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmInPortMasked.Builder setMask(OFPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmInPortMasked build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmInPortMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmInPortMasked> {
+        @Override
+        public OFOxmInPortMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000108L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000108)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000108L(0x80000108L), got="+typeLen);
+            OFPort value = OFPort.read4Bytes(bb);
+            OFPort mask = OFPort.read4Bytes(bb);
+
+            OFOxmInPortMaskedVer12 oxmInPortMaskedVer12 = new OFOxmInPortMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmInPortMaskedVer12);
+            return oxmInPortMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmInPortMaskedVer12Funnel FUNNEL = new OFOxmInPortMaskedVer12Funnel();
+    static class OFOxmInPortMaskedVer12Funnel implements Funnel<OFOxmInPortMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmInPortMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000108L
+            sink.putInt((int) 0x80000108);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmInPortMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmInPortMaskedVer12 message) {
+            // fixed value property typeLen = 0x80000108L
+            bb.writeInt((int) 0x80000108);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmInPortMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmInPortMaskedVer12 other = (OFOxmInPortMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPortVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPortVer12.java
new file mode 100644
index 0000000..1a414d4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPortVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmInPortVer12 implements OFOxmInPort {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmInPortVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+//
+    // Immutable default instance
+    final static OFOxmInPortVer12 DEFAULT = new OFOxmInPortVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmInPortVer12(OFPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000004L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmInPort.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmInPort.Builder {
+        final OFOxmInPortVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+        BuilderWithParent(OFOxmInPortVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000004L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmInPort build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmInPortVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmInPort.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000004L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmInPort build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmInPortVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmInPort> {
+        @Override
+        public OFOxmInPort readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000004L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000004)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000004L(0x80000004L), got="+typeLen);
+            OFPort value = OFPort.read4Bytes(bb);
+
+            OFOxmInPortVer12 oxmInPortVer12 = new OFOxmInPortVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmInPortVer12);
+            return oxmInPortVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmInPortVer12Funnel FUNNEL = new OFOxmInPortVer12Funnel();
+    static class OFOxmInPortVer12Funnel implements Funnel<OFOxmInPortVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmInPortVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000004L
+            sink.putInt((int) 0x80000004);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmInPortVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmInPortVer12 message) {
+            // fixed value property typeLen = 0x80000004L
+            bb.writeInt((int) 0x80000004);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmInPortVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmInPortVer12 other = (OFOxmInPortVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpDscpMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpDscpMaskedVer12.java
new file mode 100644
index 0000000..d95821b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpDscpMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpDscpMaskedVer12 implements OFOxmIpDscpMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpDscpMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static IpDscp DEFAULT_VALUE = IpDscp.NONE;
+        private final static IpDscp DEFAULT_VALUE_MASK = IpDscp.NONE;
+
+    // OF message fields
+    private final IpDscp value;
+    private final IpDscp mask;
+//
+    // Immutable default instance
+    final static OFOxmIpDscpMaskedVer12 DEFAULT = new OFOxmIpDscpMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpDscpMaskedVer12(IpDscp value, IpDscp mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001102L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public IpDscp getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IpDscp> getCanonical() {
+        if (IpDscp.NO_MASK.equals(mask)) {
+            return new OFOxmIpDscpVer12(value);
+        } else if(IpDscp.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpDscpMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpDscpMasked.Builder {
+        final OFOxmIpDscpMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpDscp value;
+        private boolean maskSet;
+        private IpDscp mask;
+
+        BuilderWithParent(OFOxmIpDscpMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001102L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpDscpMasked.Builder setValue(IpDscp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpDscp getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpDscpMasked.Builder setMask(IpDscp mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpDscp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpDscpMasked build() {
+                IpDscp value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IpDscp mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpDscpMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpDscpMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpDscp value;
+        private boolean maskSet;
+        private IpDscp mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001102L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpDscpMasked.Builder setValue(IpDscp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpDscp getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpDscpMasked.Builder setMask(IpDscp mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpDscp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpDscpMasked build() {
+            IpDscp value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IpDscp mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpDscpMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpDscpMasked> {
+        @Override
+        public OFOxmIpDscpMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001102L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001102)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001102L(0x80001102L), got="+typeLen);
+            IpDscp value = IpDscp.readByte(bb);
+            IpDscp mask = IpDscp.readByte(bb);
+
+            OFOxmIpDscpMaskedVer12 oxmIpDscpMaskedVer12 = new OFOxmIpDscpMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpDscpMaskedVer12);
+            return oxmIpDscpMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpDscpMaskedVer12Funnel FUNNEL = new OFOxmIpDscpMaskedVer12Funnel();
+    static class OFOxmIpDscpMaskedVer12Funnel implements Funnel<OFOxmIpDscpMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpDscpMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001102L
+            sink.putInt((int) 0x80001102);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpDscpMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpDscpMaskedVer12 message) {
+            // fixed value property typeLen = 0x80001102L
+            bb.writeInt((int) 0x80001102);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpDscpMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpDscpMaskedVer12 other = (OFOxmIpDscpMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpDscpVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpDscpVer12.java
new file mode 100644
index 0000000..155c51b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpDscpVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpDscpVer12 implements OFOxmIpDscp {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpDscpVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static IpDscp DEFAULT_VALUE = IpDscp.NONE;
+
+    // OF message fields
+    private final IpDscp value;
+//
+    // Immutable default instance
+    final static OFOxmIpDscpVer12 DEFAULT = new OFOxmIpDscpVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpDscpVer12(IpDscp value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001001L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IpDscp> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IpDscp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpDscp.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpDscp.Builder {
+        final OFOxmIpDscpVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpDscp value;
+
+        BuilderWithParent(OFOxmIpDscpVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001001L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpDscp.Builder setValue(IpDscp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpDscp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IpDscp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpDscp build() {
+                IpDscp value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpDscpVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpDscp.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpDscp value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001001L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpDscp.Builder setValue(IpDscp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpDscp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IpDscp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpDscp build() {
+            IpDscp value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpDscpVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpDscp> {
+        @Override
+        public OFOxmIpDscp readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001001L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001001)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001001L(0x80001001L), got="+typeLen);
+            IpDscp value = IpDscp.readByte(bb);
+
+            OFOxmIpDscpVer12 oxmIpDscpVer12 = new OFOxmIpDscpVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpDscpVer12);
+            return oxmIpDscpVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpDscpVer12Funnel FUNNEL = new OFOxmIpDscpVer12Funnel();
+    static class OFOxmIpDscpVer12Funnel implements Funnel<OFOxmIpDscpVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpDscpVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001001L
+            sink.putInt((int) 0x80001001);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpDscpVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpDscpVer12 message) {
+            // fixed value property typeLen = 0x80001001L
+            bb.writeInt((int) 0x80001001);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpDscpVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpDscpVer12 other = (OFOxmIpDscpVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpEcnMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpEcnMaskedVer12.java
new file mode 100644
index 0000000..3ecef84
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpEcnMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpEcnMaskedVer12 implements OFOxmIpEcnMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpEcnMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static IpEcn DEFAULT_VALUE = IpEcn.NONE;
+        private final static IpEcn DEFAULT_VALUE_MASK = IpEcn.NONE;
+
+    // OF message fields
+    private final IpEcn value;
+    private final IpEcn mask;
+//
+    // Immutable default instance
+    final static OFOxmIpEcnMaskedVer12 DEFAULT = new OFOxmIpEcnMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpEcnMaskedVer12(IpEcn value, IpEcn mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001302L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public IpEcn getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IpEcn> getCanonical() {
+        if (IpEcn.NO_MASK.equals(mask)) {
+            return new OFOxmIpEcnVer12(value);
+        } else if(IpEcn.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpEcnMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpEcnMasked.Builder {
+        final OFOxmIpEcnMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpEcn value;
+        private boolean maskSet;
+        private IpEcn mask;
+
+        BuilderWithParent(OFOxmIpEcnMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001302L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpEcnMasked.Builder setValue(IpEcn value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpEcn getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpEcnMasked.Builder setMask(IpEcn mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpEcn> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpEcnMasked build() {
+                IpEcn value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IpEcn mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpEcnMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpEcnMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpEcn value;
+        private boolean maskSet;
+        private IpEcn mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001302L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpEcnMasked.Builder setValue(IpEcn value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpEcn getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpEcnMasked.Builder setMask(IpEcn mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpEcn> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpEcnMasked build() {
+            IpEcn value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IpEcn mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpEcnMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpEcnMasked> {
+        @Override
+        public OFOxmIpEcnMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001302L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001302)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001302L(0x80001302L), got="+typeLen);
+            IpEcn value = IpEcn.readByte(bb);
+            IpEcn mask = IpEcn.readByte(bb);
+
+            OFOxmIpEcnMaskedVer12 oxmIpEcnMaskedVer12 = new OFOxmIpEcnMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpEcnMaskedVer12);
+            return oxmIpEcnMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpEcnMaskedVer12Funnel FUNNEL = new OFOxmIpEcnMaskedVer12Funnel();
+    static class OFOxmIpEcnMaskedVer12Funnel implements Funnel<OFOxmIpEcnMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpEcnMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001302L
+            sink.putInt((int) 0x80001302);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpEcnMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpEcnMaskedVer12 message) {
+            // fixed value property typeLen = 0x80001302L
+            bb.writeInt((int) 0x80001302);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpEcnMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpEcnMaskedVer12 other = (OFOxmIpEcnMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpEcnVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpEcnVer12.java
new file mode 100644
index 0000000..cc2b7d4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpEcnVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpEcnVer12 implements OFOxmIpEcn {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpEcnVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static IpEcn DEFAULT_VALUE = IpEcn.NONE;
+
+    // OF message fields
+    private final IpEcn value;
+//
+    // Immutable default instance
+    final static OFOxmIpEcnVer12 DEFAULT = new OFOxmIpEcnVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpEcnVer12(IpEcn value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001201L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IpEcn> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IpEcn getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpEcn.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpEcn.Builder {
+        final OFOxmIpEcnVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpEcn value;
+
+        BuilderWithParent(OFOxmIpEcnVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001201L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpEcn.Builder setValue(IpEcn value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpEcn> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IpEcn getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpEcn build() {
+                IpEcn value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpEcnVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpEcn.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpEcn value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001201L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpEcn.Builder setValue(IpEcn value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpEcn> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IpEcn getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpEcn build() {
+            IpEcn value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpEcnVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpEcn> {
+        @Override
+        public OFOxmIpEcn readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001201L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001201)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001201L(0x80001201L), got="+typeLen);
+            IpEcn value = IpEcn.readByte(bb);
+
+            OFOxmIpEcnVer12 oxmIpEcnVer12 = new OFOxmIpEcnVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpEcnVer12);
+            return oxmIpEcnVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpEcnVer12Funnel FUNNEL = new OFOxmIpEcnVer12Funnel();
+    static class OFOxmIpEcnVer12Funnel implements Funnel<OFOxmIpEcnVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpEcnVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001201L
+            sink.putInt((int) 0x80001201);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpEcnVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpEcnVer12 message) {
+            // fixed value property typeLen = 0x80001201L
+            bb.writeInt((int) 0x80001201);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpEcnVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpEcnVer12 other = (OFOxmIpEcnVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpProtoMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpProtoMaskedVer12.java
new file mode 100644
index 0000000..7031176
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpProtoMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpProtoMaskedVer12 implements OFOxmIpProtoMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpProtoMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static IpProtocol DEFAULT_VALUE = IpProtocol.NONE;
+        private final static IpProtocol DEFAULT_VALUE_MASK = IpProtocol.NONE;
+
+    // OF message fields
+    private final IpProtocol value;
+    private final IpProtocol mask;
+//
+    // Immutable default instance
+    final static OFOxmIpProtoMaskedVer12 DEFAULT = new OFOxmIpProtoMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpProtoMaskedVer12(IpProtocol value, IpProtocol mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001502L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public IpProtocol getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IpProtocol> getCanonical() {
+        if (IpProtocol.NO_MASK.equals(mask)) {
+            return new OFOxmIpProtoVer12(value);
+        } else if(IpProtocol.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpProtoMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpProtoMasked.Builder {
+        final OFOxmIpProtoMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpProtocol value;
+        private boolean maskSet;
+        private IpProtocol mask;
+
+        BuilderWithParent(OFOxmIpProtoMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001502L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpProtoMasked.Builder setValue(IpProtocol value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpProtocol getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpProtoMasked.Builder setMask(IpProtocol mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpProtocol> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpProtoMasked build() {
+                IpProtocol value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IpProtocol mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpProtoMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpProtoMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpProtocol value;
+        private boolean maskSet;
+        private IpProtocol mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001502L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpProtoMasked.Builder setValue(IpProtocol value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpProtocol getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpProtoMasked.Builder setMask(IpProtocol mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpProtocol> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpProtoMasked build() {
+            IpProtocol value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IpProtocol mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpProtoMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpProtoMasked> {
+        @Override
+        public OFOxmIpProtoMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001502L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001502)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001502L(0x80001502L), got="+typeLen);
+            IpProtocol value = IpProtocol.readByte(bb);
+            IpProtocol mask = IpProtocol.readByte(bb);
+
+            OFOxmIpProtoMaskedVer12 oxmIpProtoMaskedVer12 = new OFOxmIpProtoMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpProtoMaskedVer12);
+            return oxmIpProtoMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpProtoMaskedVer12Funnel FUNNEL = new OFOxmIpProtoMaskedVer12Funnel();
+    static class OFOxmIpProtoMaskedVer12Funnel implements Funnel<OFOxmIpProtoMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpProtoMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001502L
+            sink.putInt((int) 0x80001502);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpProtoMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpProtoMaskedVer12 message) {
+            // fixed value property typeLen = 0x80001502L
+            bb.writeInt((int) 0x80001502);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpProtoMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpProtoMaskedVer12 other = (OFOxmIpProtoMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpProtoVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpProtoVer12.java
new file mode 100644
index 0000000..71fb786
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpProtoVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpProtoVer12 implements OFOxmIpProto {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpProtoVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static IpProtocol DEFAULT_VALUE = IpProtocol.NONE;
+
+    // OF message fields
+    private final IpProtocol value;
+//
+    // Immutable default instance
+    final static OFOxmIpProtoVer12 DEFAULT = new OFOxmIpProtoVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpProtoVer12(IpProtocol value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001401L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IpProtocol> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IpProtocol getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpProto.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpProto.Builder {
+        final OFOxmIpProtoVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpProtocol value;
+
+        BuilderWithParent(OFOxmIpProtoVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001401L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpProto.Builder setValue(IpProtocol value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpProtocol> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IpProtocol getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpProto build() {
+                IpProtocol value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpProtoVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpProto.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpProtocol value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001401L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpProto.Builder setValue(IpProtocol value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpProtocol> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IpProtocol getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpProto build() {
+            IpProtocol value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpProtoVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpProto> {
+        @Override
+        public OFOxmIpProto readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001401L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001401)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001401L(0x80001401L), got="+typeLen);
+            IpProtocol value = IpProtocol.readByte(bb);
+
+            OFOxmIpProtoVer12 oxmIpProtoVer12 = new OFOxmIpProtoVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpProtoVer12);
+            return oxmIpProtoVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpProtoVer12Funnel FUNNEL = new OFOxmIpProtoVer12Funnel();
+    static class OFOxmIpProtoVer12Funnel implements Funnel<OFOxmIpProtoVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpProtoVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001401L
+            sink.putInt((int) 0x80001401);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpProtoVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpProtoVer12 message) {
+            // fixed value property typeLen = 0x80001401L
+            bb.writeInt((int) 0x80001401);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpProtoVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpProtoVer12 other = (OFOxmIpProtoVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4DstMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4DstMaskedVer12.java
new file mode 100644
index 0000000..930cf58
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4DstMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv4DstMaskedVer12 implements OFOxmIpv4DstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv4DstMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_VALUE_MASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+    private final IPv4Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv4DstMaskedVer12 DEFAULT = new OFOxmIpv4DstMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv4DstMaskedVer12(IPv4Address value, IPv4Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001908L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        if (IPv4Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv4DstVer12(value);
+        } else if(IPv4Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv4DstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv4DstMasked.Builder {
+        final OFOxmIpv4DstMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+        BuilderWithParent(OFOxmIpv4DstMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001908L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4DstMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv4DstMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv4DstMasked build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv4Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv4DstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv4DstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001908L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4DstMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv4DstMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv4DstMasked build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv4Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv4DstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv4DstMasked> {
+        @Override
+        public OFOxmIpv4DstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001908L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001908)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001908L(0x80001908L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+            IPv4Address mask = IPv4Address.read4Bytes(bb);
+
+            OFOxmIpv4DstMaskedVer12 oxmIpv4DstMaskedVer12 = new OFOxmIpv4DstMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv4DstMaskedVer12);
+            return oxmIpv4DstMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv4DstMaskedVer12Funnel FUNNEL = new OFOxmIpv4DstMaskedVer12Funnel();
+    static class OFOxmIpv4DstMaskedVer12Funnel implements Funnel<OFOxmIpv4DstMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv4DstMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001908L
+            sink.putInt((int) 0x80001908);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv4DstMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv4DstMaskedVer12 message) {
+            // fixed value property typeLen = 0x80001908L
+            bb.writeInt((int) 0x80001908);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv4DstMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv4DstMaskedVer12 other = (OFOxmIpv4DstMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4DstVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4DstVer12.java
new file mode 100644
index 0000000..c1cc14e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4DstVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv4DstVer12 implements OFOxmIpv4Dst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv4DstVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv4DstVer12 DEFAULT = new OFOxmIpv4DstVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv4DstVer12(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001804L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv4Dst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv4Dst.Builder {
+        final OFOxmIpv4DstVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFOxmIpv4DstVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001804L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4Dst.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv4Dst build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv4DstVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv4Dst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001804L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4Dst.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv4Dst build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv4DstVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv4Dst> {
+        @Override
+        public OFOxmIpv4Dst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001804L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001804)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001804L(0x80001804L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFOxmIpv4DstVer12 oxmIpv4DstVer12 = new OFOxmIpv4DstVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv4DstVer12);
+            return oxmIpv4DstVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv4DstVer12Funnel FUNNEL = new OFOxmIpv4DstVer12Funnel();
+    static class OFOxmIpv4DstVer12Funnel implements Funnel<OFOxmIpv4DstVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv4DstVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001804L
+            sink.putInt((int) 0x80001804);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv4DstVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv4DstVer12 message) {
+            // fixed value property typeLen = 0x80001804L
+            bb.writeInt((int) 0x80001804);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv4DstVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv4DstVer12 other = (OFOxmIpv4DstVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4SrcMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4SrcMaskedVer12.java
new file mode 100644
index 0000000..d11854f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4SrcMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv4SrcMaskedVer12 implements OFOxmIpv4SrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv4SrcMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_VALUE_MASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+    private final IPv4Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv4SrcMaskedVer12 DEFAULT = new OFOxmIpv4SrcMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv4SrcMaskedVer12(IPv4Address value, IPv4Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001708L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        if (IPv4Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv4SrcVer12(value);
+        } else if(IPv4Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv4SrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv4SrcMasked.Builder {
+        final OFOxmIpv4SrcMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+        BuilderWithParent(OFOxmIpv4SrcMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001708L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4SrcMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv4SrcMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv4SrcMasked build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv4Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv4SrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv4SrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001708L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4SrcMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv4SrcMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv4SrcMasked build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv4Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv4SrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv4SrcMasked> {
+        @Override
+        public OFOxmIpv4SrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001708L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001708)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001708L(0x80001708L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+            IPv4Address mask = IPv4Address.read4Bytes(bb);
+
+            OFOxmIpv4SrcMaskedVer12 oxmIpv4SrcMaskedVer12 = new OFOxmIpv4SrcMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv4SrcMaskedVer12);
+            return oxmIpv4SrcMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv4SrcMaskedVer12Funnel FUNNEL = new OFOxmIpv4SrcMaskedVer12Funnel();
+    static class OFOxmIpv4SrcMaskedVer12Funnel implements Funnel<OFOxmIpv4SrcMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv4SrcMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001708L
+            sink.putInt((int) 0x80001708);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv4SrcMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv4SrcMaskedVer12 message) {
+            // fixed value property typeLen = 0x80001708L
+            bb.writeInt((int) 0x80001708);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv4SrcMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv4SrcMaskedVer12 other = (OFOxmIpv4SrcMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4SrcVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4SrcVer12.java
new file mode 100644
index 0000000..f76c994
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv4SrcVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv4SrcVer12 implements OFOxmIpv4Src {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv4SrcVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv4SrcVer12 DEFAULT = new OFOxmIpv4SrcVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv4SrcVer12(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001604L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv4Src.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv4Src.Builder {
+        final OFOxmIpv4SrcVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFOxmIpv4SrcVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001604L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4Src.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv4Src build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv4SrcVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv4Src.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001604L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4Src.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv4Src build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv4SrcVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv4Src> {
+        @Override
+        public OFOxmIpv4Src readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001604L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001604)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001604L(0x80001604L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFOxmIpv4SrcVer12 oxmIpv4SrcVer12 = new OFOxmIpv4SrcVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv4SrcVer12);
+            return oxmIpv4SrcVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv4SrcVer12Funnel FUNNEL = new OFOxmIpv4SrcVer12Funnel();
+    static class OFOxmIpv4SrcVer12Funnel implements Funnel<OFOxmIpv4SrcVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv4SrcVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001604L
+            sink.putInt((int) 0x80001604);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv4SrcVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv4SrcVer12 message) {
+            // fixed value property typeLen = 0x80001604L
+            bb.writeInt((int) 0x80001604);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv4SrcVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv4SrcVer12 other = (OFOxmIpv4SrcVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstMaskedVer12.java
new file mode 100644
index 0000000..e38e8ca
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6DstMaskedVer12 implements OFOxmIpv6DstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6DstMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 36;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+        private final static IPv6Address DEFAULT_VALUE_MASK = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+    private final IPv6Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6DstMaskedVer12 DEFAULT = new OFOxmIpv6DstMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6DstMaskedVer12(IPv6Address value, IPv6Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003720L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        if (IPv6Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6DstVer12(value);
+        } else if(IPv6Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6DstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6DstMasked.Builder {
+        final OFOxmIpv6DstMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+        BuilderWithParent(OFOxmIpv6DstMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003720L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6DstMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6DstMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6DstMasked build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv6Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6DstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6DstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003720L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6DstMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6DstMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6DstMasked build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv6Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6DstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6DstMasked> {
+        @Override
+        public OFOxmIpv6DstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003720L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003720)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003720L(0x80003720L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+            IPv6Address mask = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6DstMaskedVer12 oxmIpv6DstMaskedVer12 = new OFOxmIpv6DstMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6DstMaskedVer12);
+            return oxmIpv6DstMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6DstMaskedVer12Funnel FUNNEL = new OFOxmIpv6DstMaskedVer12Funnel();
+    static class OFOxmIpv6DstMaskedVer12Funnel implements Funnel<OFOxmIpv6DstMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6DstMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003720L
+            sink.putInt((int) 0x80003720);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6DstMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6DstMaskedVer12 message) {
+            // fixed value property typeLen = 0x80003720L
+            bb.writeInt((int) 0x80003720);
+            message.value.write16Bytes(bb);
+            message.mask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6DstMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6DstMaskedVer12 other = (OFOxmIpv6DstMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstVer12.java
new file mode 100644
index 0000000..3410e73
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6DstVer12 implements OFOxmIpv6Dst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6DstVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6DstVer12 DEFAULT = new OFOxmIpv6DstVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6DstVer12(IPv6Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003610L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6Dst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6Dst.Builder {
+        final OFOxmIpv6DstVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+        BuilderWithParent(OFOxmIpv6DstVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003610L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Dst.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6Dst build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6DstVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6Dst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003610L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Dst.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6Dst build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6DstVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6Dst> {
+        @Override
+        public OFOxmIpv6Dst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003610L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003610)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003610L(0x80003610L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6DstVer12 oxmIpv6DstVer12 = new OFOxmIpv6DstVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6DstVer12);
+            return oxmIpv6DstVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6DstVer12Funnel FUNNEL = new OFOxmIpv6DstVer12Funnel();
+    static class OFOxmIpv6DstVer12Funnel implements Funnel<OFOxmIpv6DstVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6DstVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003610L
+            sink.putInt((int) 0x80003610);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6DstVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6DstVer12 message) {
+            // fixed value property typeLen = 0x80003610L
+            bb.writeInt((int) 0x80003610);
+            message.value.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6DstVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6DstVer12 other = (OFOxmIpv6DstVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6FlabelMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6FlabelMaskedVer12.java
new file mode 100644
index 0000000..6f9237d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6FlabelMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6FlabelMaskedVer12 implements OFOxmIpv6FlabelMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6FlabelMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static IPv6FlowLabel DEFAULT_VALUE = IPv6FlowLabel.NONE;
+        private final static IPv6FlowLabel DEFAULT_VALUE_MASK = IPv6FlowLabel.NONE;
+
+    // OF message fields
+    private final IPv6FlowLabel value;
+    private final IPv6FlowLabel mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6FlabelMaskedVer12 DEFAULT = new OFOxmIpv6FlabelMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6FlabelMaskedVer12(IPv6FlowLabel value, IPv6FlowLabel mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003908L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv6FlowLabel getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv6FlowLabel> getCanonical() {
+        if (IPv6FlowLabel.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6FlabelVer12(value);
+        } else if(IPv6FlowLabel.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6FlabelMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6FlabelMasked.Builder {
+        final OFOxmIpv6FlabelMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6FlowLabel value;
+        private boolean maskSet;
+        private IPv6FlowLabel mask;
+
+        BuilderWithParent(OFOxmIpv6FlabelMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003908L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6FlabelMasked.Builder setValue(IPv6FlowLabel value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6FlowLabel getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6FlabelMasked.Builder setMask(IPv6FlowLabel mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6FlowLabel> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6FlabelMasked build() {
+                IPv6FlowLabel value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv6FlowLabel mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6FlabelMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6FlabelMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6FlowLabel value;
+        private boolean maskSet;
+        private IPv6FlowLabel mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003908L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6FlabelMasked.Builder setValue(IPv6FlowLabel value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6FlowLabel getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6FlabelMasked.Builder setMask(IPv6FlowLabel mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6FlowLabel> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6FlabelMasked build() {
+            IPv6FlowLabel value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv6FlowLabel mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6FlabelMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6FlabelMasked> {
+        @Override
+        public OFOxmIpv6FlabelMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003908L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003908)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003908L(0x80003908L), got="+typeLen);
+            IPv6FlowLabel value = IPv6FlowLabel.read4Bytes(bb);
+            IPv6FlowLabel mask = IPv6FlowLabel.read4Bytes(bb);
+
+            OFOxmIpv6FlabelMaskedVer12 oxmIpv6FlabelMaskedVer12 = new OFOxmIpv6FlabelMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6FlabelMaskedVer12);
+            return oxmIpv6FlabelMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6FlabelMaskedVer12Funnel FUNNEL = new OFOxmIpv6FlabelMaskedVer12Funnel();
+    static class OFOxmIpv6FlabelMaskedVer12Funnel implements Funnel<OFOxmIpv6FlabelMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6FlabelMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003908L
+            sink.putInt((int) 0x80003908);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6FlabelMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6FlabelMaskedVer12 message) {
+            // fixed value property typeLen = 0x80003908L
+            bb.writeInt((int) 0x80003908);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6FlabelMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6FlabelMaskedVer12 other = (OFOxmIpv6FlabelMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6FlabelVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6FlabelVer12.java
new file mode 100644
index 0000000..09796cf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6FlabelVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6FlabelVer12 implements OFOxmIpv6Flabel {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6FlabelVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static IPv6FlowLabel DEFAULT_VALUE = IPv6FlowLabel.NONE;
+
+    // OF message fields
+    private final IPv6FlowLabel value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6FlabelVer12 DEFAULT = new OFOxmIpv6FlabelVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6FlabelVer12(IPv6FlowLabel value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003804L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv6FlowLabel> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv6FlowLabel getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6Flabel.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6Flabel.Builder {
+        final OFOxmIpv6FlabelVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6FlowLabel value;
+
+        BuilderWithParent(OFOxmIpv6FlabelVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003804L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Flabel.Builder setValue(IPv6FlowLabel value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6FlowLabel> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv6FlowLabel getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6Flabel build() {
+                IPv6FlowLabel value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6FlabelVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6Flabel.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6FlowLabel value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003804L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Flabel.Builder setValue(IPv6FlowLabel value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6FlowLabel> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv6FlowLabel getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6Flabel build() {
+            IPv6FlowLabel value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6FlabelVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6Flabel> {
+        @Override
+        public OFOxmIpv6Flabel readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003804L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003804)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003804L(0x80003804L), got="+typeLen);
+            IPv6FlowLabel value = IPv6FlowLabel.read4Bytes(bb);
+
+            OFOxmIpv6FlabelVer12 oxmIpv6FlabelVer12 = new OFOxmIpv6FlabelVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6FlabelVer12);
+            return oxmIpv6FlabelVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6FlabelVer12Funnel FUNNEL = new OFOxmIpv6FlabelVer12Funnel();
+    static class OFOxmIpv6FlabelVer12Funnel implements Funnel<OFOxmIpv6FlabelVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6FlabelVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003804L
+            sink.putInt((int) 0x80003804);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6FlabelVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6FlabelVer12 message) {
+            // fixed value property typeLen = 0x80003804L
+            bb.writeInt((int) 0x80003804);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6FlabelVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6FlabelVer12 other = (OFOxmIpv6FlabelVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdSllMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdSllMaskedVer12.java
new file mode 100644
index 0000000..81a6380
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdSllMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdSllMaskedVer12 implements OFOxmIpv6NdSllMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdSllMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdSllMaskedVer12 DEFAULT = new OFOxmIpv6NdSllMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdSllMaskedVer12(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000410cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6NdSllVer12(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6NdSllMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdSllMasked.Builder {
+        final OFOxmIpv6NdSllMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmIpv6NdSllMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000410cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdSllMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdSllMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdSllMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6NdSllMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdSllMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000410cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdSllMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdSllMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdSllMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6NdSllMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdSllMasked> {
+        @Override
+        public OFOxmIpv6NdSllMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000410cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000410c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000410cL(0x8000410cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmIpv6NdSllMaskedVer12 oxmIpv6NdSllMaskedVer12 = new OFOxmIpv6NdSllMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdSllMaskedVer12);
+            return oxmIpv6NdSllMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdSllMaskedVer12Funnel FUNNEL = new OFOxmIpv6NdSllMaskedVer12Funnel();
+    static class OFOxmIpv6NdSllMaskedVer12Funnel implements Funnel<OFOxmIpv6NdSllMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdSllMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000410cL
+            sink.putInt((int) 0x8000410c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdSllMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdSllMaskedVer12 message) {
+            // fixed value property typeLen = 0x8000410cL
+            bb.writeInt((int) 0x8000410c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdSllMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdSllMaskedVer12 other = (OFOxmIpv6NdSllMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdSllVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdSllVer12.java
new file mode 100644
index 0000000..0da5c58
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdSllVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdSllVer12 implements OFOxmIpv6NdSll {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdSllVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdSllVer12 DEFAULT = new OFOxmIpv6NdSllVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdSllVer12(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6NdSll.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdSll.Builder {
+        final OFOxmIpv6NdSllVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmIpv6NdSllVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdSll.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdSll build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6NdSllVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdSll.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdSll.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdSll build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6NdSllVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdSll> {
+        @Override
+        public OFOxmIpv6NdSll readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004006L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004006)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004006L(0x80004006L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmIpv6NdSllVer12 oxmIpv6NdSllVer12 = new OFOxmIpv6NdSllVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdSllVer12);
+            return oxmIpv6NdSllVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdSllVer12Funnel FUNNEL = new OFOxmIpv6NdSllVer12Funnel();
+    static class OFOxmIpv6NdSllVer12Funnel implements Funnel<OFOxmIpv6NdSllVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdSllVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004006L
+            sink.putInt((int) 0x80004006);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdSllVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdSllVer12 message) {
+            // fixed value property typeLen = 0x80004006L
+            bb.writeInt((int) 0x80004006);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdSllVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdSllVer12 other = (OFOxmIpv6NdSllVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTargetMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTargetMaskedVer12.java
new file mode 100644
index 0000000..0202aff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTargetMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdTargetMaskedVer12 implements OFOxmIpv6NdTargetMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdTargetMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 36;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+        private final static IPv6Address DEFAULT_VALUE_MASK = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+    private final IPv6Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdTargetMaskedVer12 DEFAULT = new OFOxmIpv6NdTargetMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdTargetMaskedVer12(IPv6Address value, IPv6Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003f20L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        if (IPv6Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6NdTargetVer12(value);
+        } else if(IPv6Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6NdTargetMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdTargetMasked.Builder {
+        final OFOxmIpv6NdTargetMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+        BuilderWithParent(OFOxmIpv6NdTargetMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003f20L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTargetMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdTargetMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdTargetMasked build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv6Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6NdTargetMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdTargetMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003f20L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTargetMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdTargetMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdTargetMasked build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv6Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6NdTargetMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdTargetMasked> {
+        @Override
+        public OFOxmIpv6NdTargetMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003f20L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003f20)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003f20L(0x80003f20L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+            IPv6Address mask = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6NdTargetMaskedVer12 oxmIpv6NdTargetMaskedVer12 = new OFOxmIpv6NdTargetMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdTargetMaskedVer12);
+            return oxmIpv6NdTargetMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdTargetMaskedVer12Funnel FUNNEL = new OFOxmIpv6NdTargetMaskedVer12Funnel();
+    static class OFOxmIpv6NdTargetMaskedVer12Funnel implements Funnel<OFOxmIpv6NdTargetMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdTargetMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003f20L
+            sink.putInt((int) 0x80003f20);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdTargetMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdTargetMaskedVer12 message) {
+            // fixed value property typeLen = 0x80003f20L
+            bb.writeInt((int) 0x80003f20);
+            message.value.write16Bytes(bb);
+            message.mask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdTargetMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdTargetMaskedVer12 other = (OFOxmIpv6NdTargetMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTargetVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTargetVer12.java
new file mode 100644
index 0000000..44f582f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTargetVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdTargetVer12 implements OFOxmIpv6NdTarget {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdTargetVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdTargetVer12 DEFAULT = new OFOxmIpv6NdTargetVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdTargetVer12(IPv6Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003e10L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6NdTarget.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdTarget.Builder {
+        final OFOxmIpv6NdTargetVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+        BuilderWithParent(OFOxmIpv6NdTargetVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003e10L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTarget.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdTarget build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6NdTargetVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdTarget.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003e10L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTarget.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdTarget build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6NdTargetVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdTarget> {
+        @Override
+        public OFOxmIpv6NdTarget readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003e10L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003e10)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003e10L(0x80003e10L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6NdTargetVer12 oxmIpv6NdTargetVer12 = new OFOxmIpv6NdTargetVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdTargetVer12);
+            return oxmIpv6NdTargetVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdTargetVer12Funnel FUNNEL = new OFOxmIpv6NdTargetVer12Funnel();
+    static class OFOxmIpv6NdTargetVer12Funnel implements Funnel<OFOxmIpv6NdTargetVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdTargetVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003e10L
+            sink.putInt((int) 0x80003e10);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdTargetVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdTargetVer12 message) {
+            // fixed value property typeLen = 0x80003e10L
+            bb.writeInt((int) 0x80003e10);
+            message.value.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdTargetVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdTargetVer12 other = (OFOxmIpv6NdTargetVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTllMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTllMaskedVer12.java
new file mode 100644
index 0000000..ef213da
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTllMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdTllMaskedVer12 implements OFOxmIpv6NdTllMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdTllMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdTllMaskedVer12 DEFAULT = new OFOxmIpv6NdTllMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdTllMaskedVer12(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000430cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6NdTllVer12(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6NdTllMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdTllMasked.Builder {
+        final OFOxmIpv6NdTllMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmIpv6NdTllMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000430cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTllMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdTllMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdTllMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6NdTllMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdTllMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000430cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTllMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdTllMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdTllMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6NdTllMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdTllMasked> {
+        @Override
+        public OFOxmIpv6NdTllMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000430cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000430c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000430cL(0x8000430cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmIpv6NdTllMaskedVer12 oxmIpv6NdTllMaskedVer12 = new OFOxmIpv6NdTllMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdTllMaskedVer12);
+            return oxmIpv6NdTllMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdTllMaskedVer12Funnel FUNNEL = new OFOxmIpv6NdTllMaskedVer12Funnel();
+    static class OFOxmIpv6NdTllMaskedVer12Funnel implements Funnel<OFOxmIpv6NdTllMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdTllMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000430cL
+            sink.putInt((int) 0x8000430c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdTllMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdTllMaskedVer12 message) {
+            // fixed value property typeLen = 0x8000430cL
+            bb.writeInt((int) 0x8000430c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdTllMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdTllMaskedVer12 other = (OFOxmIpv6NdTllMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTllVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTllVer12.java
new file mode 100644
index 0000000..9508952
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6NdTllVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdTllVer12 implements OFOxmIpv6NdTll {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdTllVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdTllVer12 DEFAULT = new OFOxmIpv6NdTllVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdTllVer12(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6NdTll.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdTll.Builder {
+        final OFOxmIpv6NdTllVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmIpv6NdTllVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTll.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdTll build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6NdTllVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdTll.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTll.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdTll build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6NdTllVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdTll> {
+        @Override
+        public OFOxmIpv6NdTll readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004206L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004206)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004206L(0x80004206L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmIpv6NdTllVer12 oxmIpv6NdTllVer12 = new OFOxmIpv6NdTllVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdTllVer12);
+            return oxmIpv6NdTllVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdTllVer12Funnel FUNNEL = new OFOxmIpv6NdTllVer12Funnel();
+    static class OFOxmIpv6NdTllVer12Funnel implements Funnel<OFOxmIpv6NdTllVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdTllVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004206L
+            sink.putInt((int) 0x80004206);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdTllVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdTllVer12 message) {
+            // fixed value property typeLen = 0x80004206L
+            bb.writeInt((int) 0x80004206);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdTllVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdTllVer12 other = (OFOxmIpv6NdTllVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6SrcMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6SrcMaskedVer12.java
new file mode 100644
index 0000000..bbf5300
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6SrcMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6SrcMaskedVer12 implements OFOxmIpv6SrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6SrcMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 36;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+        private final static IPv6Address DEFAULT_VALUE_MASK = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+    private final IPv6Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6SrcMaskedVer12 DEFAULT = new OFOxmIpv6SrcMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6SrcMaskedVer12(IPv6Address value, IPv6Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003520L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        if (IPv6Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6SrcVer12(value);
+        } else if(IPv6Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6SrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6SrcMasked.Builder {
+        final OFOxmIpv6SrcMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+        BuilderWithParent(OFOxmIpv6SrcMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003520L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6SrcMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6SrcMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6SrcMasked build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv6Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6SrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6SrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003520L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6SrcMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6SrcMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6SrcMasked build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv6Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6SrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6SrcMasked> {
+        @Override
+        public OFOxmIpv6SrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003520L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003520)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003520L(0x80003520L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+            IPv6Address mask = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6SrcMaskedVer12 oxmIpv6SrcMaskedVer12 = new OFOxmIpv6SrcMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6SrcMaskedVer12);
+            return oxmIpv6SrcMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6SrcMaskedVer12Funnel FUNNEL = new OFOxmIpv6SrcMaskedVer12Funnel();
+    static class OFOxmIpv6SrcMaskedVer12Funnel implements Funnel<OFOxmIpv6SrcMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6SrcMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003520L
+            sink.putInt((int) 0x80003520);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6SrcMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6SrcMaskedVer12 message) {
+            // fixed value property typeLen = 0x80003520L
+            bb.writeInt((int) 0x80003520);
+            message.value.write16Bytes(bb);
+            message.mask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6SrcMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6SrcMaskedVer12 other = (OFOxmIpv6SrcMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6SrcVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6SrcVer12.java
new file mode 100644
index 0000000..bf3f3f6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6SrcVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6SrcVer12 implements OFOxmIpv6Src {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6SrcVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6SrcVer12 DEFAULT = new OFOxmIpv6SrcVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6SrcVer12(IPv6Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003410L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmIpv6Src.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6Src.Builder {
+        final OFOxmIpv6SrcVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+        BuilderWithParent(OFOxmIpv6SrcVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003410L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Src.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6Src build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6SrcVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6Src.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003410L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Src.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmIpv6Src build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6SrcVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6Src> {
+        @Override
+        public OFOxmIpv6Src readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003410L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003410)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003410L(0x80003410L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6SrcVer12 oxmIpv6SrcVer12 = new OFOxmIpv6SrcVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6SrcVer12);
+            return oxmIpv6SrcVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6SrcVer12Funnel FUNNEL = new OFOxmIpv6SrcVer12Funnel();
+    static class OFOxmIpv6SrcVer12Funnel implements Funnel<OFOxmIpv6SrcVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6SrcVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003410L
+            sink.putInt((int) 0x80003410);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6SrcVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6SrcVer12 message) {
+            // fixed value property typeLen = 0x80003410L
+            bb.writeInt((int) 0x80003410);
+            message.value.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6SrcVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6SrcVer12 other = (OFOxmIpv6SrcVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMetadataMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMetadataMaskedVer12.java
new file mode 100644
index 0000000..b35110d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMetadataMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMetadataMaskedVer12 implements OFOxmMetadataMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMetadataMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 20;
+
+        private final static OFMetadata DEFAULT_VALUE = OFMetadata.NONE;
+        private final static OFMetadata DEFAULT_VALUE_MASK = OFMetadata.NONE;
+
+    // OF message fields
+    private final OFMetadata value;
+    private final OFMetadata mask;
+//
+    // Immutable default instance
+    final static OFOxmMetadataMaskedVer12 DEFAULT = new OFOxmMetadataMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMetadataMaskedVer12(OFMetadata value, OFMetadata mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000510L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFMetadata getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFMetadata> getCanonical() {
+        if (OFMetadata.NO_MASK.equals(mask)) {
+            return new OFOxmMetadataVer12(value);
+        } else if(OFMetadata.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmMetadataMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMetadataMasked.Builder {
+        final OFOxmMetadataMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFMetadata value;
+        private boolean maskSet;
+        private OFMetadata mask;
+
+        BuilderWithParent(OFOxmMetadataMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000510L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMetadataMasked.Builder setValue(OFMetadata value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFMetadata getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMetadataMasked.Builder setMask(OFMetadata mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFMetadata> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmMetadataMasked build() {
+                OFMetadata value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFMetadata mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmMetadataMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMetadataMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFMetadata value;
+        private boolean maskSet;
+        private OFMetadata mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000510L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMetadataMasked.Builder setValue(OFMetadata value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFMetadata getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMetadataMasked.Builder setMask(OFMetadata mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFMetadata> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmMetadataMasked build() {
+            OFMetadata value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFMetadata mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmMetadataMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMetadataMasked> {
+        @Override
+        public OFOxmMetadataMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000510L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000510)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000510L(0x80000510L), got="+typeLen);
+            OFMetadata value = OFMetadata.read8Bytes(bb);
+            OFMetadata mask = OFMetadata.read8Bytes(bb);
+
+            OFOxmMetadataMaskedVer12 oxmMetadataMaskedVer12 = new OFOxmMetadataMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMetadataMaskedVer12);
+            return oxmMetadataMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMetadataMaskedVer12Funnel FUNNEL = new OFOxmMetadataMaskedVer12Funnel();
+    static class OFOxmMetadataMaskedVer12Funnel implements Funnel<OFOxmMetadataMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMetadataMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000510L
+            sink.putInt((int) 0x80000510);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMetadataMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMetadataMaskedVer12 message) {
+            // fixed value property typeLen = 0x80000510L
+            bb.writeInt((int) 0x80000510);
+            message.value.write8Bytes(bb);
+            message.mask.write8Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMetadataMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMetadataMaskedVer12 other = (OFOxmMetadataMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMetadataVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMetadataVer12.java
new file mode 100644
index 0000000..6d86084
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMetadataVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMetadataVer12 implements OFOxmMetadata {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMetadataVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static OFMetadata DEFAULT_VALUE = OFMetadata.NONE;
+
+    // OF message fields
+    private final OFMetadata value;
+//
+    // Immutable default instance
+    final static OFOxmMetadataVer12 DEFAULT = new OFOxmMetadataVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMetadataVer12(OFMetadata value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000408L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFMetadata> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFMetadata getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmMetadata.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMetadata.Builder {
+        final OFOxmMetadataVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFMetadata value;
+
+        BuilderWithParent(OFOxmMetadataVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000408L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMetadata.Builder setValue(OFMetadata value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFMetadata> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFMetadata getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmMetadata build() {
+                OFMetadata value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmMetadataVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMetadata.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFMetadata value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000408L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMetadata.Builder setValue(OFMetadata value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFMetadata> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFMetadata getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmMetadata build() {
+            OFMetadata value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmMetadataVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMetadata> {
+        @Override
+        public OFOxmMetadata readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000408L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000408)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000408L(0x80000408L), got="+typeLen);
+            OFMetadata value = OFMetadata.read8Bytes(bb);
+
+            OFOxmMetadataVer12 oxmMetadataVer12 = new OFOxmMetadataVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMetadataVer12);
+            return oxmMetadataVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMetadataVer12Funnel FUNNEL = new OFOxmMetadataVer12Funnel();
+    static class OFOxmMetadataVer12Funnel implements Funnel<OFOxmMetadataVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMetadataVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000408L
+            sink.putInt((int) 0x80000408);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMetadataVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMetadataVer12 message) {
+            // fixed value property typeLen = 0x80000408L
+            bb.writeInt((int) 0x80000408);
+            message.value.write8Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMetadataVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMetadataVer12 other = (OFOxmMetadataVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsLabelMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsLabelMaskedVer12.java
new file mode 100644
index 0000000..123fabf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsLabelMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMplsLabelMaskedVer12 implements OFOxmMplsLabelMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMplsLabelMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static U32 DEFAULT_VALUE = U32.ZERO;
+        private final static U32 DEFAULT_VALUE_MASK = U32.ZERO;
+
+    // OF message fields
+    private final U32 value;
+    private final U32 mask;
+//
+    // Immutable default instance
+    final static OFOxmMplsLabelMaskedVer12 DEFAULT = new OFOxmMplsLabelMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMplsLabelMaskedVer12(U32 value, U32 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004508L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public U32 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U32> getCanonical() {
+        if (U32.NO_MASK.equals(mask)) {
+            return new OFOxmMplsLabelVer12(value);
+        } else if(U32.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmMplsLabelMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMplsLabelMasked.Builder {
+        final OFOxmMplsLabelMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U32 value;
+        private boolean maskSet;
+        private U32 mask;
+
+        BuilderWithParent(OFOxmMplsLabelMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004508L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsLabelMasked.Builder setValue(U32 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U32 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMplsLabelMasked.Builder setMask(U32 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U32> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmMplsLabelMasked build() {
+                U32 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U32 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmMplsLabelMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMplsLabelMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U32 value;
+        private boolean maskSet;
+        private U32 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004508L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsLabelMasked.Builder setValue(U32 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U32 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMplsLabelMasked.Builder setMask(U32 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U32> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmMplsLabelMasked build() {
+            U32 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U32 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmMplsLabelMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMplsLabelMasked> {
+        @Override
+        public OFOxmMplsLabelMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004508L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004508)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004508L(0x80004508L), got="+typeLen);
+            U32 value = U32.of(bb.readInt());
+            U32 mask = U32.of(bb.readInt());
+
+            OFOxmMplsLabelMaskedVer12 oxmMplsLabelMaskedVer12 = new OFOxmMplsLabelMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMplsLabelMaskedVer12);
+            return oxmMplsLabelMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMplsLabelMaskedVer12Funnel FUNNEL = new OFOxmMplsLabelMaskedVer12Funnel();
+    static class OFOxmMplsLabelMaskedVer12Funnel implements Funnel<OFOxmMplsLabelMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMplsLabelMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004508L
+            sink.putInt((int) 0x80004508);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMplsLabelMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMplsLabelMaskedVer12 message) {
+            // fixed value property typeLen = 0x80004508L
+            bb.writeInt((int) 0x80004508);
+            bb.writeInt(message.value.getRaw());
+            bb.writeInt(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMplsLabelMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMplsLabelMaskedVer12 other = (OFOxmMplsLabelMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsLabelVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsLabelVer12.java
new file mode 100644
index 0000000..ffbd781
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsLabelVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMplsLabelVer12 implements OFOxmMplsLabel {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMplsLabelVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static U32 DEFAULT_VALUE = U32.ZERO;
+
+    // OF message fields
+    private final U32 value;
+//
+    // Immutable default instance
+    final static OFOxmMplsLabelVer12 DEFAULT = new OFOxmMplsLabelVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMplsLabelVer12(U32 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004404L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U32> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U32 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmMplsLabel.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMplsLabel.Builder {
+        final OFOxmMplsLabelVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U32 value;
+
+        BuilderWithParent(OFOxmMplsLabelVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004404L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsLabel.Builder setValue(U32 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U32> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U32 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmMplsLabel build() {
+                U32 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmMplsLabelVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMplsLabel.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U32 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004404L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsLabel.Builder setValue(U32 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U32> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U32 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmMplsLabel build() {
+            U32 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmMplsLabelVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMplsLabel> {
+        @Override
+        public OFOxmMplsLabel readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004404L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004404)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004404L(0x80004404L), got="+typeLen);
+            U32 value = U32.of(bb.readInt());
+
+            OFOxmMplsLabelVer12 oxmMplsLabelVer12 = new OFOxmMplsLabelVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMplsLabelVer12);
+            return oxmMplsLabelVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMplsLabelVer12Funnel FUNNEL = new OFOxmMplsLabelVer12Funnel();
+    static class OFOxmMplsLabelVer12Funnel implements Funnel<OFOxmMplsLabelVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMplsLabelVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004404L
+            sink.putInt((int) 0x80004404);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMplsLabelVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMplsLabelVer12 message) {
+            // fixed value property typeLen = 0x80004404L
+            bb.writeInt((int) 0x80004404);
+            bb.writeInt(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMplsLabelVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMplsLabelVer12 other = (OFOxmMplsLabelVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsTcMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsTcMaskedVer12.java
new file mode 100644
index 0000000..0e1e014
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsTcMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMplsTcMaskedVer12 implements OFOxmMplsTcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMplsTcMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+        private final static U8 DEFAULT_VALUE_MASK = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+    private final U8 mask;
+//
+    // Immutable default instance
+    final static OFOxmMplsTcMaskedVer12 DEFAULT = new OFOxmMplsTcMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMplsTcMaskedVer12(U8 value, U8 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004702L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        if (U8.NO_MASK.equals(mask)) {
+            return new OFOxmMplsTcVer12(value);
+        } else if(U8.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmMplsTcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMplsTcMasked.Builder {
+        final OFOxmMplsTcMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+        BuilderWithParent(OFOxmMplsTcMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004702L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsTcMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMplsTcMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmMplsTcMasked build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U8 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmMplsTcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMplsTcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004702L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsTcMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMplsTcMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmMplsTcMasked build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U8 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmMplsTcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMplsTcMasked> {
+        @Override
+        public OFOxmMplsTcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004702L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004702)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004702L(0x80004702L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+            U8 mask = U8.of(bb.readByte());
+
+            OFOxmMplsTcMaskedVer12 oxmMplsTcMaskedVer12 = new OFOxmMplsTcMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMplsTcMaskedVer12);
+            return oxmMplsTcMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMplsTcMaskedVer12Funnel FUNNEL = new OFOxmMplsTcMaskedVer12Funnel();
+    static class OFOxmMplsTcMaskedVer12Funnel implements Funnel<OFOxmMplsTcMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMplsTcMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004702L
+            sink.putInt((int) 0x80004702);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMplsTcMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMplsTcMaskedVer12 message) {
+            // fixed value property typeLen = 0x80004702L
+            bb.writeInt((int) 0x80004702);
+            bb.writeByte(message.value.getRaw());
+            bb.writeByte(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMplsTcMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMplsTcMaskedVer12 other = (OFOxmMplsTcMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsTcVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsTcVer12.java
new file mode 100644
index 0000000..63a1f59
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmMplsTcVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMplsTcVer12 implements OFOxmMplsTc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMplsTcVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+//
+    // Immutable default instance
+    final static OFOxmMplsTcVer12 DEFAULT = new OFOxmMplsTcVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMplsTcVer12(U8 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004601L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmMplsTc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMplsTc.Builder {
+        final OFOxmMplsTcVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+        BuilderWithParent(OFOxmMplsTcVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004601L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsTc.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmMplsTc build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmMplsTcVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMplsTc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004601L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsTc.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmMplsTc build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmMplsTcVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMplsTc> {
+        @Override
+        public OFOxmMplsTc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004601L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004601)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004601L(0x80004601L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+
+            OFOxmMplsTcVer12 oxmMplsTcVer12 = new OFOxmMplsTcVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMplsTcVer12);
+            return oxmMplsTcVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMplsTcVer12Funnel FUNNEL = new OFOxmMplsTcVer12Funnel();
+    static class OFOxmMplsTcVer12Funnel implements Funnel<OFOxmMplsTcVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMplsTcVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004601L
+            sink.putInt((int) 0x80004601);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMplsTcVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMplsTcVer12 message) {
+            // fixed value property typeLen = 0x80004601L
+            bb.writeInt((int) 0x80004601);
+            bb.writeByte(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMplsTcVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMplsTcVer12 other = (OFOxmMplsTcVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpDstMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpDstMaskedVer12.java
new file mode 100644
index 0000000..6186bfc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpDstMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmSctpDstMaskedVer12 implements OFOxmSctpDstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmSctpDstMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmSctpDstMaskedVer12 DEFAULT = new OFOxmSctpDstMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmSctpDstMaskedVer12(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002504L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmSctpDstVer12(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmSctpDstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmSctpDstMasked.Builder {
+        final OFOxmSctpDstMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmSctpDstMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002504L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmSctpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmSctpDstMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmSctpDstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmSctpDstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002504L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmSctpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmSctpDstMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmSctpDstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmSctpDstMasked> {
+        @Override
+        public OFOxmSctpDstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002504L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002504)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002504L(0x80002504L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmSctpDstMaskedVer12 oxmSctpDstMaskedVer12 = new OFOxmSctpDstMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmSctpDstMaskedVer12);
+            return oxmSctpDstMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmSctpDstMaskedVer12Funnel FUNNEL = new OFOxmSctpDstMaskedVer12Funnel();
+    static class OFOxmSctpDstMaskedVer12Funnel implements Funnel<OFOxmSctpDstMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmSctpDstMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002504L
+            sink.putInt((int) 0x80002504);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmSctpDstMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmSctpDstMaskedVer12 message) {
+            // fixed value property typeLen = 0x80002504L
+            bb.writeInt((int) 0x80002504);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmSctpDstMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmSctpDstMaskedVer12 other = (OFOxmSctpDstMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpDstVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpDstVer12.java
new file mode 100644
index 0000000..c457e75
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpDstVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmSctpDstVer12 implements OFOxmSctpDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmSctpDstVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmSctpDstVer12 DEFAULT = new OFOxmSctpDstVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmSctpDstVer12(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002402L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmSctpDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmSctpDst.Builder {
+        final OFOxmSctpDstVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmSctpDstVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002402L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmSctpDst build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmSctpDstVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmSctpDst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002402L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmSctpDst build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmSctpDstVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmSctpDst> {
+        @Override
+        public OFOxmSctpDst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002402L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002402)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002402L(0x80002402L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmSctpDstVer12 oxmSctpDstVer12 = new OFOxmSctpDstVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmSctpDstVer12);
+            return oxmSctpDstVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmSctpDstVer12Funnel FUNNEL = new OFOxmSctpDstVer12Funnel();
+    static class OFOxmSctpDstVer12Funnel implements Funnel<OFOxmSctpDstVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmSctpDstVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002402L
+            sink.putInt((int) 0x80002402);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmSctpDstVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmSctpDstVer12 message) {
+            // fixed value property typeLen = 0x80002402L
+            bb.writeInt((int) 0x80002402);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmSctpDstVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmSctpDstVer12 other = (OFOxmSctpDstVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpSrcMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpSrcMaskedVer12.java
new file mode 100644
index 0000000..676ea0b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpSrcMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmSctpSrcMaskedVer12 implements OFOxmSctpSrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmSctpSrcMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmSctpSrcMaskedVer12 DEFAULT = new OFOxmSctpSrcMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmSctpSrcMaskedVer12(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002304L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmSctpSrcVer12(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmSctpSrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmSctpSrcMasked.Builder {
+        final OFOxmSctpSrcMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmSctpSrcMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002304L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmSctpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmSctpSrcMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmSctpSrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmSctpSrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002304L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmSctpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmSctpSrcMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmSctpSrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmSctpSrcMasked> {
+        @Override
+        public OFOxmSctpSrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002304L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002304)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002304L(0x80002304L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmSctpSrcMaskedVer12 oxmSctpSrcMaskedVer12 = new OFOxmSctpSrcMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmSctpSrcMaskedVer12);
+            return oxmSctpSrcMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmSctpSrcMaskedVer12Funnel FUNNEL = new OFOxmSctpSrcMaskedVer12Funnel();
+    static class OFOxmSctpSrcMaskedVer12Funnel implements Funnel<OFOxmSctpSrcMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmSctpSrcMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002304L
+            sink.putInt((int) 0x80002304);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmSctpSrcMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmSctpSrcMaskedVer12 message) {
+            // fixed value property typeLen = 0x80002304L
+            bb.writeInt((int) 0x80002304);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmSctpSrcMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmSctpSrcMaskedVer12 other = (OFOxmSctpSrcMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpSrcVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpSrcVer12.java
new file mode 100644
index 0000000..eaf9ff9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmSctpSrcVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmSctpSrcVer12 implements OFOxmSctpSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmSctpSrcVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmSctpSrcVer12 DEFAULT = new OFOxmSctpSrcVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmSctpSrcVer12(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002202L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmSctpSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmSctpSrc.Builder {
+        final OFOxmSctpSrcVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmSctpSrcVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002202L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmSctpSrc build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmSctpSrcVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmSctpSrc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002202L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmSctpSrc build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmSctpSrcVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmSctpSrc> {
+        @Override
+        public OFOxmSctpSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002202L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002202)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002202L(0x80002202L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmSctpSrcVer12 oxmSctpSrcVer12 = new OFOxmSctpSrcVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmSctpSrcVer12);
+            return oxmSctpSrcVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmSctpSrcVer12Funnel FUNNEL = new OFOxmSctpSrcVer12Funnel();
+    static class OFOxmSctpSrcVer12Funnel implements Funnel<OFOxmSctpSrcVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmSctpSrcVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002202L
+            sink.putInt((int) 0x80002202);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmSctpSrcVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmSctpSrcVer12 message) {
+            // fixed value property typeLen = 0x80002202L
+            bb.writeInt((int) 0x80002202);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmSctpSrcVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmSctpSrcVer12 other = (OFOxmSctpSrcVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpDstMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpDstMaskedVer12.java
new file mode 100644
index 0000000..a3ec85b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpDstMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTcpDstMaskedVer12 implements OFOxmTcpDstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTcpDstMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmTcpDstMaskedVer12 DEFAULT = new OFOxmTcpDstMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTcpDstMaskedVer12(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001d04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmTcpDstVer12(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmTcpDstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTcpDstMasked.Builder {
+        final OFOxmTcpDstMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmTcpDstMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001d04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTcpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmTcpDstMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmTcpDstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTcpDstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001d04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTcpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmTcpDstMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmTcpDstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTcpDstMasked> {
+        @Override
+        public OFOxmTcpDstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001d04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001d04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001d04L(0x80001d04L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmTcpDstMaskedVer12 oxmTcpDstMaskedVer12 = new OFOxmTcpDstMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTcpDstMaskedVer12);
+            return oxmTcpDstMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTcpDstMaskedVer12Funnel FUNNEL = new OFOxmTcpDstMaskedVer12Funnel();
+    static class OFOxmTcpDstMaskedVer12Funnel implements Funnel<OFOxmTcpDstMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTcpDstMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001d04L
+            sink.putInt((int) 0x80001d04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTcpDstMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTcpDstMaskedVer12 message) {
+            // fixed value property typeLen = 0x80001d04L
+            bb.writeInt((int) 0x80001d04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTcpDstMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTcpDstMaskedVer12 other = (OFOxmTcpDstMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpDstVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpDstVer12.java
new file mode 100644
index 0000000..d39907d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpDstVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTcpDstVer12 implements OFOxmTcpDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTcpDstVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmTcpDstVer12 DEFAULT = new OFOxmTcpDstVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTcpDstVer12(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001c02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmTcpDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTcpDst.Builder {
+        final OFOxmTcpDstVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmTcpDstVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001c02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmTcpDst build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmTcpDstVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTcpDst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001c02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmTcpDst build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmTcpDstVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTcpDst> {
+        @Override
+        public OFOxmTcpDst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001c02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001c02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001c02L(0x80001c02L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmTcpDstVer12 oxmTcpDstVer12 = new OFOxmTcpDstVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTcpDstVer12);
+            return oxmTcpDstVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTcpDstVer12Funnel FUNNEL = new OFOxmTcpDstVer12Funnel();
+    static class OFOxmTcpDstVer12Funnel implements Funnel<OFOxmTcpDstVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTcpDstVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001c02L
+            sink.putInt((int) 0x80001c02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTcpDstVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTcpDstVer12 message) {
+            // fixed value property typeLen = 0x80001c02L
+            bb.writeInt((int) 0x80001c02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTcpDstVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTcpDstVer12 other = (OFOxmTcpDstVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpSrcMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpSrcMaskedVer12.java
new file mode 100644
index 0000000..4b36cab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpSrcMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTcpSrcMaskedVer12 implements OFOxmTcpSrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTcpSrcMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmTcpSrcMaskedVer12 DEFAULT = new OFOxmTcpSrcMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTcpSrcMaskedVer12(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001b04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmTcpSrcVer12(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmTcpSrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTcpSrcMasked.Builder {
+        final OFOxmTcpSrcMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmTcpSrcMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001b04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTcpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmTcpSrcMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmTcpSrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTcpSrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001b04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTcpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmTcpSrcMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmTcpSrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTcpSrcMasked> {
+        @Override
+        public OFOxmTcpSrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001b04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001b04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001b04L(0x80001b04L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmTcpSrcMaskedVer12 oxmTcpSrcMaskedVer12 = new OFOxmTcpSrcMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTcpSrcMaskedVer12);
+            return oxmTcpSrcMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTcpSrcMaskedVer12Funnel FUNNEL = new OFOxmTcpSrcMaskedVer12Funnel();
+    static class OFOxmTcpSrcMaskedVer12Funnel implements Funnel<OFOxmTcpSrcMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTcpSrcMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001b04L
+            sink.putInt((int) 0x80001b04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTcpSrcMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTcpSrcMaskedVer12 message) {
+            // fixed value property typeLen = 0x80001b04L
+            bb.writeInt((int) 0x80001b04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTcpSrcMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTcpSrcMaskedVer12 other = (OFOxmTcpSrcMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpSrcVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpSrcVer12.java
new file mode 100644
index 0000000..f0dde4b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmTcpSrcVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTcpSrcVer12 implements OFOxmTcpSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTcpSrcVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmTcpSrcVer12 DEFAULT = new OFOxmTcpSrcVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTcpSrcVer12(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001a02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmTcpSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTcpSrc.Builder {
+        final OFOxmTcpSrcVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmTcpSrcVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001a02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmTcpSrc build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmTcpSrcVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTcpSrc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001a02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmTcpSrc build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmTcpSrcVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTcpSrc> {
+        @Override
+        public OFOxmTcpSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001a02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001a02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001a02L(0x80001a02L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmTcpSrcVer12 oxmTcpSrcVer12 = new OFOxmTcpSrcVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTcpSrcVer12);
+            return oxmTcpSrcVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTcpSrcVer12Funnel FUNNEL = new OFOxmTcpSrcVer12Funnel();
+    static class OFOxmTcpSrcVer12Funnel implements Funnel<OFOxmTcpSrcVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTcpSrcVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001a02L
+            sink.putInt((int) 0x80001a02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTcpSrcVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTcpSrcVer12 message) {
+            // fixed value property typeLen = 0x80001a02L
+            bb.writeInt((int) 0x80001a02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTcpSrcVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTcpSrcVer12 other = (OFOxmTcpSrcVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpDstMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpDstMaskedVer12.java
new file mode 100644
index 0000000..084225f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpDstMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmUdpDstMaskedVer12 implements OFOxmUdpDstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmUdpDstMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmUdpDstMaskedVer12 DEFAULT = new OFOxmUdpDstMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmUdpDstMaskedVer12(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002104L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmUdpDstVer12(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmUdpDstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmUdpDstMasked.Builder {
+        final OFOxmUdpDstMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmUdpDstMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002104L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmUdpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmUdpDstMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmUdpDstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmUdpDstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002104L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmUdpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmUdpDstMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmUdpDstMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmUdpDstMasked> {
+        @Override
+        public OFOxmUdpDstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002104L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002104)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002104L(0x80002104L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmUdpDstMaskedVer12 oxmUdpDstMaskedVer12 = new OFOxmUdpDstMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmUdpDstMaskedVer12);
+            return oxmUdpDstMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmUdpDstMaskedVer12Funnel FUNNEL = new OFOxmUdpDstMaskedVer12Funnel();
+    static class OFOxmUdpDstMaskedVer12Funnel implements Funnel<OFOxmUdpDstMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmUdpDstMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002104L
+            sink.putInt((int) 0x80002104);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmUdpDstMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmUdpDstMaskedVer12 message) {
+            // fixed value property typeLen = 0x80002104L
+            bb.writeInt((int) 0x80002104);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmUdpDstMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmUdpDstMaskedVer12 other = (OFOxmUdpDstMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpDstVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpDstVer12.java
new file mode 100644
index 0000000..e74959a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpDstVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmUdpDstVer12 implements OFOxmUdpDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmUdpDstVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmUdpDstVer12 DEFAULT = new OFOxmUdpDstVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmUdpDstVer12(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002002L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmUdpDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmUdpDst.Builder {
+        final OFOxmUdpDstVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmUdpDstVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002002L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmUdpDst build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmUdpDstVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmUdpDst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002002L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmUdpDst build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmUdpDstVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmUdpDst> {
+        @Override
+        public OFOxmUdpDst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002002L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002002)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002002L(0x80002002L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmUdpDstVer12 oxmUdpDstVer12 = new OFOxmUdpDstVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmUdpDstVer12);
+            return oxmUdpDstVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmUdpDstVer12Funnel FUNNEL = new OFOxmUdpDstVer12Funnel();
+    static class OFOxmUdpDstVer12Funnel implements Funnel<OFOxmUdpDstVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmUdpDstVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002002L
+            sink.putInt((int) 0x80002002);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmUdpDstVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmUdpDstVer12 message) {
+            // fixed value property typeLen = 0x80002002L
+            bb.writeInt((int) 0x80002002);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmUdpDstVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmUdpDstVer12 other = (OFOxmUdpDstVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpSrcMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpSrcMaskedVer12.java
new file mode 100644
index 0000000..b250efd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpSrcMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmUdpSrcMaskedVer12 implements OFOxmUdpSrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmUdpSrcMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmUdpSrcMaskedVer12 DEFAULT = new OFOxmUdpSrcMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmUdpSrcMaskedVer12(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001f04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmUdpSrcVer12(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmUdpSrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmUdpSrcMasked.Builder {
+        final OFOxmUdpSrcMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmUdpSrcMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001f04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmUdpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmUdpSrcMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmUdpSrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmUdpSrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001f04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmUdpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmUdpSrcMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmUdpSrcMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmUdpSrcMasked> {
+        @Override
+        public OFOxmUdpSrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001f04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001f04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001f04L(0x80001f04L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmUdpSrcMaskedVer12 oxmUdpSrcMaskedVer12 = new OFOxmUdpSrcMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmUdpSrcMaskedVer12);
+            return oxmUdpSrcMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmUdpSrcMaskedVer12Funnel FUNNEL = new OFOxmUdpSrcMaskedVer12Funnel();
+    static class OFOxmUdpSrcMaskedVer12Funnel implements Funnel<OFOxmUdpSrcMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmUdpSrcMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001f04L
+            sink.putInt((int) 0x80001f04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmUdpSrcMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmUdpSrcMaskedVer12 message) {
+            // fixed value property typeLen = 0x80001f04L
+            bb.writeInt((int) 0x80001f04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmUdpSrcMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmUdpSrcMaskedVer12 other = (OFOxmUdpSrcMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpSrcVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpSrcVer12.java
new file mode 100644
index 0000000..52fd2c2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmUdpSrcVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmUdpSrcVer12 implements OFOxmUdpSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmUdpSrcVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmUdpSrcVer12 DEFAULT = new OFOxmUdpSrcVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmUdpSrcVer12(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001e02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmUdpSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmUdpSrc.Builder {
+        final OFOxmUdpSrcVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmUdpSrcVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001e02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmUdpSrc build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmUdpSrcVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmUdpSrc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001e02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmUdpSrc build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmUdpSrcVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmUdpSrc> {
+        @Override
+        public OFOxmUdpSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001e02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001e02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001e02L(0x80001e02L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmUdpSrcVer12 oxmUdpSrcVer12 = new OFOxmUdpSrcVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmUdpSrcVer12);
+            return oxmUdpSrcVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmUdpSrcVer12Funnel FUNNEL = new OFOxmUdpSrcVer12Funnel();
+    static class OFOxmUdpSrcVer12Funnel implements Funnel<OFOxmUdpSrcVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmUdpSrcVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001e02L
+            sink.putInt((int) 0x80001e02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmUdpSrcVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmUdpSrcVer12 message) {
+            // fixed value property typeLen = 0x80001e02L
+            bb.writeInt((int) 0x80001e02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmUdpSrcVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmUdpSrcVer12 other = (OFOxmUdpSrcVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVer12.java
new file mode 100644
index 0000000..33160aa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVer12.java
@@ -0,0 +1,374 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFOxmVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFOxmVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFOxm<?>> {
+        @Override
+        public OFOxm<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            int typeLen = bb.readInt();
+            bb.readerIndex(start);
+            switch(typeLen) {
+               case (int) 0x80002a02:
+                   // discriminator value 0x80002a02L=0x80002a02L for class OFOxmArpOpVer12
+                   return OFOxmArpOpVer12.READER.readFrom(bb);
+               case (int) 0x80002b04:
+                   // discriminator value 0x80002b04L=0x80002b04L for class OFOxmArpOpMaskedVer12
+                   return OFOxmArpOpMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80003006:
+                   // discriminator value 0x80003006L=0x80003006L for class OFOxmArpShaVer12
+                   return OFOxmArpShaVer12.READER.readFrom(bb);
+               case (int) 0x8000310c:
+                   // discriminator value 0x8000310cL=0x8000310cL for class OFOxmArpShaMaskedVer12
+                   return OFOxmArpShaMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80002c04:
+                   // discriminator value 0x80002c04L=0x80002c04L for class OFOxmArpSpaVer12
+                   return OFOxmArpSpaVer12.READER.readFrom(bb);
+               case (int) 0x80002d08:
+                   // discriminator value 0x80002d08L=0x80002d08L for class OFOxmArpSpaMaskedVer12
+                   return OFOxmArpSpaMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80003206:
+                   // discriminator value 0x80003206L=0x80003206L for class OFOxmArpThaVer12
+                   return OFOxmArpThaVer12.READER.readFrom(bb);
+               case (int) 0x8000330c:
+                   // discriminator value 0x8000330cL=0x8000330cL for class OFOxmArpThaMaskedVer12
+                   return OFOxmArpThaMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80002e04:
+                   // discriminator value 0x80002e04L=0x80002e04L for class OFOxmArpTpaVer12
+                   return OFOxmArpTpaVer12.READER.readFrom(bb);
+               case (int) 0x80002f08:
+                   // discriminator value 0x80002f08L=0x80002f08L for class OFOxmArpTpaMaskedVer12
+                   return OFOxmArpTpaMaskedVer12.READER.readFrom(bb);
+               case 0x30e04:
+                   // discriminator value 0x30e04L=0x30e04L for class OFOxmBsnEgrPortGroupIdVer12
+                   return OFOxmBsnEgrPortGroupIdVer12.READER.readFrom(bb);
+               case 0x30f08:
+                   // discriminator value 0x30f08L=0x30f08L for class OFOxmBsnEgrPortGroupIdMaskedVer12
+                   return OFOxmBsnEgrPortGroupIdMaskedVer12.READER.readFrom(bb);
+               case 0x30601:
+                   // discriminator value 0x30601L=0x30601L for class OFOxmBsnGlobalVrfAllowedVer12
+                   return OFOxmBsnGlobalVrfAllowedVer12.READER.readFrom(bb);
+               case 0x30702:
+                   // discriminator value 0x30702L=0x30702L for class OFOxmBsnGlobalVrfAllowedMaskedVer12
+                   return OFOxmBsnGlobalVrfAllowedMaskedVer12.READER.readFrom(bb);
+               case 0x30010:
+                   // discriminator value 0x30010L=0x30010L for class OFOxmBsnInPorts128Ver12
+                   return OFOxmBsnInPorts128Ver12.READER.readFrom(bb);
+               case 0x30120:
+                   // discriminator value 0x30120L=0x30120L for class OFOxmBsnInPorts128MaskedVer12
+                   return OFOxmBsnInPorts128MaskedVer12.READER.readFrom(bb);
+               case 0x30c04:
+                   // discriminator value 0x30c04L=0x30c04L for class OFOxmBsnL3DstClassIdVer12
+                   return OFOxmBsnL3DstClassIdVer12.READER.readFrom(bb);
+               case 0x30d08:
+                   // discriminator value 0x30d08L=0x30d08L for class OFOxmBsnL3DstClassIdMaskedVer12
+                   return OFOxmBsnL3DstClassIdMaskedVer12.READER.readFrom(bb);
+               case 0x30804:
+                   // discriminator value 0x30804L=0x30804L for class OFOxmBsnL3InterfaceClassIdVer12
+                   return OFOxmBsnL3InterfaceClassIdVer12.READER.readFrom(bb);
+               case 0x30908:
+                   // discriminator value 0x30908L=0x30908L for class OFOxmBsnL3InterfaceClassIdMaskedVer12
+                   return OFOxmBsnL3InterfaceClassIdMaskedVer12.READER.readFrom(bb);
+               case 0x30a04:
+                   // discriminator value 0x30a04L=0x30a04L for class OFOxmBsnL3SrcClassIdVer12
+                   return OFOxmBsnL3SrcClassIdVer12.READER.readFrom(bb);
+               case 0x30b08:
+                   // discriminator value 0x30b08L=0x30b08L for class OFOxmBsnL3SrcClassIdMaskedVer12
+                   return OFOxmBsnL3SrcClassIdMaskedVer12.READER.readFrom(bb);
+               case 0x30204:
+                   // discriminator value 0x30204L=0x30204L for class OFOxmBsnLagIdVer12
+                   return OFOxmBsnLagIdVer12.READER.readFrom(bb);
+               case 0x30308:
+                   // discriminator value 0x30308L=0x30308L for class OFOxmBsnLagIdMaskedVer12
+                   return OFOxmBsnLagIdMaskedVer12.READER.readFrom(bb);
+               case 0x32002:
+                   // discriminator value 0x32002L=0x32002L for class OFOxmBsnTcpFlagsVer12
+                   return OFOxmBsnTcpFlagsVer12.READER.readFrom(bb);
+               case 0x32104:
+                   // discriminator value 0x32104L=0x32104L for class OFOxmBsnTcpFlagsMaskedVer12
+                   return OFOxmBsnTcpFlagsMaskedVer12.READER.readFrom(bb);
+               case 0x31004:
+                   // discriminator value 0x31004L=0x31004L for class OFOxmBsnUdf0Ver12
+                   return OFOxmBsnUdf0Ver12.READER.readFrom(bb);
+               case 0x31108:
+                   // discriminator value 0x31108L=0x31108L for class OFOxmBsnUdf0MaskedVer12
+                   return OFOxmBsnUdf0MaskedVer12.READER.readFrom(bb);
+               case 0x31204:
+                   // discriminator value 0x31204L=0x31204L for class OFOxmBsnUdf1Ver12
+                   return OFOxmBsnUdf1Ver12.READER.readFrom(bb);
+               case 0x31308:
+                   // discriminator value 0x31308L=0x31308L for class OFOxmBsnUdf1MaskedVer12
+                   return OFOxmBsnUdf1MaskedVer12.READER.readFrom(bb);
+               case 0x31404:
+                   // discriminator value 0x31404L=0x31404L for class OFOxmBsnUdf2Ver12
+                   return OFOxmBsnUdf2Ver12.READER.readFrom(bb);
+               case 0x31508:
+                   // discriminator value 0x31508L=0x31508L for class OFOxmBsnUdf2MaskedVer12
+                   return OFOxmBsnUdf2MaskedVer12.READER.readFrom(bb);
+               case 0x31604:
+                   // discriminator value 0x31604L=0x31604L for class OFOxmBsnUdf3Ver12
+                   return OFOxmBsnUdf3Ver12.READER.readFrom(bb);
+               case 0x31708:
+                   // discriminator value 0x31708L=0x31708L for class OFOxmBsnUdf3MaskedVer12
+                   return OFOxmBsnUdf3MaskedVer12.READER.readFrom(bb);
+               case 0x31804:
+                   // discriminator value 0x31804L=0x31804L for class OFOxmBsnUdf4Ver12
+                   return OFOxmBsnUdf4Ver12.READER.readFrom(bb);
+               case 0x31908:
+                   // discriminator value 0x31908L=0x31908L for class OFOxmBsnUdf4MaskedVer12
+                   return OFOxmBsnUdf4MaskedVer12.READER.readFrom(bb);
+               case 0x31a04:
+                   // discriminator value 0x31a04L=0x31a04L for class OFOxmBsnUdf5Ver12
+                   return OFOxmBsnUdf5Ver12.READER.readFrom(bb);
+               case 0x31b08:
+                   // discriminator value 0x31b08L=0x31b08L for class OFOxmBsnUdf5MaskedVer12
+                   return OFOxmBsnUdf5MaskedVer12.READER.readFrom(bb);
+               case 0x31c04:
+                   // discriminator value 0x31c04L=0x31c04L for class OFOxmBsnUdf6Ver12
+                   return OFOxmBsnUdf6Ver12.READER.readFrom(bb);
+               case 0x31d08:
+                   // discriminator value 0x31d08L=0x31d08L for class OFOxmBsnUdf6MaskedVer12
+                   return OFOxmBsnUdf6MaskedVer12.READER.readFrom(bb);
+               case 0x31e04:
+                   // discriminator value 0x31e04L=0x31e04L for class OFOxmBsnUdf7Ver12
+                   return OFOxmBsnUdf7Ver12.READER.readFrom(bb);
+               case 0x31f08:
+                   // discriminator value 0x31f08L=0x31f08L for class OFOxmBsnUdf7MaskedVer12
+                   return OFOxmBsnUdf7MaskedVer12.READER.readFrom(bb);
+               case 0x32204:
+                   // discriminator value 0x32204L=0x32204L for class OFOxmBsnVlanXlatePortGroupIdVer12
+                   return OFOxmBsnVlanXlatePortGroupIdVer12.READER.readFrom(bb);
+               case 0x32308:
+                   // discriminator value 0x32308L=0x32308L for class OFOxmBsnVlanXlatePortGroupIdMaskedVer12
+                   return OFOxmBsnVlanXlatePortGroupIdMaskedVer12.READER.readFrom(bb);
+               case 0x30404:
+                   // discriminator value 0x30404L=0x30404L for class OFOxmBsnVrfVer12
+                   return OFOxmBsnVrfVer12.READER.readFrom(bb);
+               case 0x30508:
+                   // discriminator value 0x30508L=0x30508L for class OFOxmBsnVrfMaskedVer12
+                   return OFOxmBsnVrfMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80000606:
+                   // discriminator value 0x80000606L=0x80000606L for class OFOxmEthDstVer12
+                   return OFOxmEthDstVer12.READER.readFrom(bb);
+               case (int) 0x8000070c:
+                   // discriminator value 0x8000070cL=0x8000070cL for class OFOxmEthDstMaskedVer12
+                   return OFOxmEthDstMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80000806:
+                   // discriminator value 0x80000806L=0x80000806L for class OFOxmEthSrcVer12
+                   return OFOxmEthSrcVer12.READER.readFrom(bb);
+               case (int) 0x8000090c:
+                   // discriminator value 0x8000090cL=0x8000090cL for class OFOxmEthSrcMaskedVer12
+                   return OFOxmEthSrcMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80000a02:
+                   // discriminator value 0x80000a02L=0x80000a02L for class OFOxmEthTypeVer12
+                   return OFOxmEthTypeVer12.READER.readFrom(bb);
+               case (int) 0x80000b04:
+                   // discriminator value 0x80000b04L=0x80000b04L for class OFOxmEthTypeMaskedVer12
+                   return OFOxmEthTypeMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80002801:
+                   // discriminator value 0x80002801L=0x80002801L for class OFOxmIcmpv4CodeVer12
+                   return OFOxmIcmpv4CodeVer12.READER.readFrom(bb);
+               case (int) 0x80002902:
+                   // discriminator value 0x80002902L=0x80002902L for class OFOxmIcmpv4CodeMaskedVer12
+                   return OFOxmIcmpv4CodeMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80002601:
+                   // discriminator value 0x80002601L=0x80002601L for class OFOxmIcmpv4TypeVer12
+                   return OFOxmIcmpv4TypeVer12.READER.readFrom(bb);
+               case (int) 0x80002702:
+                   // discriminator value 0x80002702L=0x80002702L for class OFOxmIcmpv4TypeMaskedVer12
+                   return OFOxmIcmpv4TypeMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80003c01:
+                   // discriminator value 0x80003c01L=0x80003c01L for class OFOxmIcmpv6CodeVer12
+                   return OFOxmIcmpv6CodeVer12.READER.readFrom(bb);
+               case (int) 0x80003d02:
+                   // discriminator value 0x80003d02L=0x80003d02L for class OFOxmIcmpv6CodeMaskedVer12
+                   return OFOxmIcmpv6CodeMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80003a01:
+                   // discriminator value 0x80003a01L=0x80003a01L for class OFOxmIcmpv6TypeVer12
+                   return OFOxmIcmpv6TypeVer12.READER.readFrom(bb);
+               case (int) 0x80003b02:
+                   // discriminator value 0x80003b02L=0x80003b02L for class OFOxmIcmpv6TypeMaskedVer12
+                   return OFOxmIcmpv6TypeMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80000204:
+                   // discriminator value 0x80000204L=0x80000204L for class OFOxmInPhyPortVer12
+                   return OFOxmInPhyPortVer12.READER.readFrom(bb);
+               case (int) 0x80000308:
+                   // discriminator value 0x80000308L=0x80000308L for class OFOxmInPhyPortMaskedVer12
+                   return OFOxmInPhyPortMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80000004:
+                   // discriminator value 0x80000004L=0x80000004L for class OFOxmInPortVer12
+                   return OFOxmInPortVer12.READER.readFrom(bb);
+               case (int) 0x80000108:
+                   // discriminator value 0x80000108L=0x80000108L for class OFOxmInPortMaskedVer12
+                   return OFOxmInPortMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80001001:
+                   // discriminator value 0x80001001L=0x80001001L for class OFOxmIpDscpVer12
+                   return OFOxmIpDscpVer12.READER.readFrom(bb);
+               case (int) 0x80001102:
+                   // discriminator value 0x80001102L=0x80001102L for class OFOxmIpDscpMaskedVer12
+                   return OFOxmIpDscpMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80001201:
+                   // discriminator value 0x80001201L=0x80001201L for class OFOxmIpEcnVer12
+                   return OFOxmIpEcnVer12.READER.readFrom(bb);
+               case (int) 0x80001302:
+                   // discriminator value 0x80001302L=0x80001302L for class OFOxmIpEcnMaskedVer12
+                   return OFOxmIpEcnMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80001401:
+                   // discriminator value 0x80001401L=0x80001401L for class OFOxmIpProtoVer12
+                   return OFOxmIpProtoVer12.READER.readFrom(bb);
+               case (int) 0x80001502:
+                   // discriminator value 0x80001502L=0x80001502L for class OFOxmIpProtoMaskedVer12
+                   return OFOxmIpProtoMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80001804:
+                   // discriminator value 0x80001804L=0x80001804L for class OFOxmIpv4DstVer12
+                   return OFOxmIpv4DstVer12.READER.readFrom(bb);
+               case (int) 0x80001908:
+                   // discriminator value 0x80001908L=0x80001908L for class OFOxmIpv4DstMaskedVer12
+                   return OFOxmIpv4DstMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80001604:
+                   // discriminator value 0x80001604L=0x80001604L for class OFOxmIpv4SrcVer12
+                   return OFOxmIpv4SrcVer12.READER.readFrom(bb);
+               case (int) 0x80001708:
+                   // discriminator value 0x80001708L=0x80001708L for class OFOxmIpv4SrcMaskedVer12
+                   return OFOxmIpv4SrcMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80003610:
+                   // discriminator value 0x80003610L=0x80003610L for class OFOxmIpv6DstVer12
+                   return OFOxmIpv6DstVer12.READER.readFrom(bb);
+               case (int) 0x80003720:
+                   // discriminator value 0x80003720L=0x80003720L for class OFOxmIpv6DstMaskedVer12
+                   return OFOxmIpv6DstMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80003804:
+                   // discriminator value 0x80003804L=0x80003804L for class OFOxmIpv6FlabelVer12
+                   return OFOxmIpv6FlabelVer12.READER.readFrom(bb);
+               case (int) 0x80003908:
+                   // discriminator value 0x80003908L=0x80003908L for class OFOxmIpv6FlabelMaskedVer12
+                   return OFOxmIpv6FlabelMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80004006:
+                   // discriminator value 0x80004006L=0x80004006L for class OFOxmIpv6NdSllVer12
+                   return OFOxmIpv6NdSllVer12.READER.readFrom(bb);
+               case (int) 0x8000410c:
+                   // discriminator value 0x8000410cL=0x8000410cL for class OFOxmIpv6NdSllMaskedVer12
+                   return OFOxmIpv6NdSllMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80003e10:
+                   // discriminator value 0x80003e10L=0x80003e10L for class OFOxmIpv6NdTargetVer12
+                   return OFOxmIpv6NdTargetVer12.READER.readFrom(bb);
+               case (int) 0x80003f20:
+                   // discriminator value 0x80003f20L=0x80003f20L for class OFOxmIpv6NdTargetMaskedVer12
+                   return OFOxmIpv6NdTargetMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80004206:
+                   // discriminator value 0x80004206L=0x80004206L for class OFOxmIpv6NdTllVer12
+                   return OFOxmIpv6NdTllVer12.READER.readFrom(bb);
+               case (int) 0x8000430c:
+                   // discriminator value 0x8000430cL=0x8000430cL for class OFOxmIpv6NdTllMaskedVer12
+                   return OFOxmIpv6NdTllMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80003410:
+                   // discriminator value 0x80003410L=0x80003410L for class OFOxmIpv6SrcVer12
+                   return OFOxmIpv6SrcVer12.READER.readFrom(bb);
+               case (int) 0x80003520:
+                   // discriminator value 0x80003520L=0x80003520L for class OFOxmIpv6SrcMaskedVer12
+                   return OFOxmIpv6SrcMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80000408:
+                   // discriminator value 0x80000408L=0x80000408L for class OFOxmMetadataVer12
+                   return OFOxmMetadataVer12.READER.readFrom(bb);
+               case (int) 0x80000510:
+                   // discriminator value 0x80000510L=0x80000510L for class OFOxmMetadataMaskedVer12
+                   return OFOxmMetadataMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80004404:
+                   // discriminator value 0x80004404L=0x80004404L for class OFOxmMplsLabelVer12
+                   return OFOxmMplsLabelVer12.READER.readFrom(bb);
+               case (int) 0x80004508:
+                   // discriminator value 0x80004508L=0x80004508L for class OFOxmMplsLabelMaskedVer12
+                   return OFOxmMplsLabelMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80004601:
+                   // discriminator value 0x80004601L=0x80004601L for class OFOxmMplsTcVer12
+                   return OFOxmMplsTcVer12.READER.readFrom(bb);
+               case (int) 0x80004702:
+                   // discriminator value 0x80004702L=0x80004702L for class OFOxmMplsTcMaskedVer12
+                   return OFOxmMplsTcMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80002402:
+                   // discriminator value 0x80002402L=0x80002402L for class OFOxmSctpDstVer12
+                   return OFOxmSctpDstVer12.READER.readFrom(bb);
+               case (int) 0x80002504:
+                   // discriminator value 0x80002504L=0x80002504L for class OFOxmSctpDstMaskedVer12
+                   return OFOxmSctpDstMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80002202:
+                   // discriminator value 0x80002202L=0x80002202L for class OFOxmSctpSrcVer12
+                   return OFOxmSctpSrcVer12.READER.readFrom(bb);
+               case (int) 0x80002304:
+                   // discriminator value 0x80002304L=0x80002304L for class OFOxmSctpSrcMaskedVer12
+                   return OFOxmSctpSrcMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80001c02:
+                   // discriminator value 0x80001c02L=0x80001c02L for class OFOxmTcpDstVer12
+                   return OFOxmTcpDstVer12.READER.readFrom(bb);
+               case (int) 0x80001d04:
+                   // discriminator value 0x80001d04L=0x80001d04L for class OFOxmTcpDstMaskedVer12
+                   return OFOxmTcpDstMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80001a02:
+                   // discriminator value 0x80001a02L=0x80001a02L for class OFOxmTcpSrcVer12
+                   return OFOxmTcpSrcVer12.READER.readFrom(bb);
+               case (int) 0x80001b04:
+                   // discriminator value 0x80001b04L=0x80001b04L for class OFOxmTcpSrcMaskedVer12
+                   return OFOxmTcpSrcMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80002002:
+                   // discriminator value 0x80002002L=0x80002002L for class OFOxmUdpDstVer12
+                   return OFOxmUdpDstVer12.READER.readFrom(bb);
+               case (int) 0x80002104:
+                   // discriminator value 0x80002104L=0x80002104L for class OFOxmUdpDstMaskedVer12
+                   return OFOxmUdpDstMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80001e02:
+                   // discriminator value 0x80001e02L=0x80001e02L for class OFOxmUdpSrcVer12
+                   return OFOxmUdpSrcVer12.READER.readFrom(bb);
+               case (int) 0x80001f04:
+                   // discriminator value 0x80001f04L=0x80001f04L for class OFOxmUdpSrcMaskedVer12
+                   return OFOxmUdpSrcMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80000e01:
+                   // discriminator value 0x80000e01L=0x80000e01L for class OFOxmVlanPcpVer12
+                   return OFOxmVlanPcpVer12.READER.readFrom(bb);
+               case (int) 0x80000f02:
+                   // discriminator value 0x80000f02L=0x80000f02L for class OFOxmVlanPcpMaskedVer12
+                   return OFOxmVlanPcpMaskedVer12.READER.readFrom(bb);
+               case (int) 0x80000c02:
+                   // discriminator value 0x80000c02L=0x80000c02L for class OFOxmVlanVidVer12
+                   return OFOxmVlanVidVer12.READER.readFrom(bb);
+               case (int) 0x80000d04:
+                   // discriminator value 0x80000d04L=0x80000d04L for class OFOxmVlanVidMaskedVer12
+                   return OFOxmVlanVidMaskedVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator typeLen of class OFOxmVer12: " + typeLen);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanPcpMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanPcpMaskedVer12.java
new file mode 100644
index 0000000..7cbc8b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanPcpMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmVlanPcpMaskedVer12 implements OFOxmVlanPcpMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmVlanPcpMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static VlanPcp DEFAULT_VALUE = VlanPcp.NONE;
+        private final static VlanPcp DEFAULT_VALUE_MASK = VlanPcp.NONE;
+
+    // OF message fields
+    private final VlanPcp value;
+    private final VlanPcp mask;
+//
+    // Immutable default instance
+    final static OFOxmVlanPcpMaskedVer12 DEFAULT = new OFOxmVlanPcpMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmVlanPcpMaskedVer12(VlanPcp value, VlanPcp mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000f02L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public VlanPcp getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<VlanPcp> getCanonical() {
+        if (VlanPcp.NO_MASK.equals(mask)) {
+            return new OFOxmVlanPcpVer12(value);
+        } else if(VlanPcp.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmVlanPcpMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmVlanPcpMasked.Builder {
+        final OFOxmVlanPcpMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VlanPcp value;
+        private boolean maskSet;
+        private VlanPcp mask;
+
+        BuilderWithParent(OFOxmVlanPcpMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000f02L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanPcpMasked.Builder setValue(VlanPcp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public VlanPcp getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmVlanPcpMasked.Builder setMask(VlanPcp mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<VlanPcp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmVlanPcpMasked build() {
+                VlanPcp value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                VlanPcp mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmVlanPcpMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmVlanPcpMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VlanPcp value;
+        private boolean maskSet;
+        private VlanPcp mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000f02L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanPcpMasked.Builder setValue(VlanPcp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public VlanPcp getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmVlanPcpMasked.Builder setMask(VlanPcp mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<VlanPcp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmVlanPcpMasked build() {
+            VlanPcp value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            VlanPcp mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmVlanPcpMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmVlanPcpMasked> {
+        @Override
+        public OFOxmVlanPcpMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000f02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000f02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000f02L(0x80000f02L), got="+typeLen);
+            VlanPcp value = VlanPcp.readByte(bb);
+            VlanPcp mask = VlanPcp.readByte(bb);
+
+            OFOxmVlanPcpMaskedVer12 oxmVlanPcpMaskedVer12 = new OFOxmVlanPcpMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmVlanPcpMaskedVer12);
+            return oxmVlanPcpMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmVlanPcpMaskedVer12Funnel FUNNEL = new OFOxmVlanPcpMaskedVer12Funnel();
+    static class OFOxmVlanPcpMaskedVer12Funnel implements Funnel<OFOxmVlanPcpMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmVlanPcpMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000f02L
+            sink.putInt((int) 0x80000f02);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmVlanPcpMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmVlanPcpMaskedVer12 message) {
+            // fixed value property typeLen = 0x80000f02L
+            bb.writeInt((int) 0x80000f02);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmVlanPcpMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmVlanPcpMaskedVer12 other = (OFOxmVlanPcpMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanPcpVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanPcpVer12.java
new file mode 100644
index 0000000..5476e2b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanPcpVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmVlanPcpVer12 implements OFOxmVlanPcp {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmVlanPcpVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 5;
+
+        private final static VlanPcp DEFAULT_VALUE = VlanPcp.NONE;
+
+    // OF message fields
+    private final VlanPcp value;
+//
+    // Immutable default instance
+    final static OFOxmVlanPcpVer12 DEFAULT = new OFOxmVlanPcpVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmVlanPcpVer12(VlanPcp value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000e01L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<VlanPcp> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public VlanPcp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmVlanPcp.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmVlanPcp.Builder {
+        final OFOxmVlanPcpVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VlanPcp value;
+
+        BuilderWithParent(OFOxmVlanPcpVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000e01L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanPcp.Builder setValue(VlanPcp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<VlanPcp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public VlanPcp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmVlanPcp build() {
+                VlanPcp value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmVlanPcpVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmVlanPcp.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VlanPcp value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000e01L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanPcp.Builder setValue(VlanPcp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<VlanPcp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public VlanPcp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmVlanPcp build() {
+            VlanPcp value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmVlanPcpVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmVlanPcp> {
+        @Override
+        public OFOxmVlanPcp readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000e01L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000e01)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000e01L(0x80000e01L), got="+typeLen);
+            VlanPcp value = VlanPcp.readByte(bb);
+
+            OFOxmVlanPcpVer12 oxmVlanPcpVer12 = new OFOxmVlanPcpVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmVlanPcpVer12);
+            return oxmVlanPcpVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmVlanPcpVer12Funnel FUNNEL = new OFOxmVlanPcpVer12Funnel();
+    static class OFOxmVlanPcpVer12Funnel implements Funnel<OFOxmVlanPcpVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmVlanPcpVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000e01L
+            sink.putInt((int) 0x80000e01);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmVlanPcpVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmVlanPcpVer12 message) {
+            // fixed value property typeLen = 0x80000e01L
+            bb.writeInt((int) 0x80000e01);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmVlanPcpVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmVlanPcpVer12 other = (OFOxmVlanPcpVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanVidMaskedVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanVidMaskedVer12.java
new file mode 100644
index 0000000..9a90e44
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanVidMaskedVer12.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmVlanVidMaskedVer12 implements OFOxmVlanVidMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmVlanVidMaskedVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 8;
+
+        private final static OFVlanVidMatch DEFAULT_VALUE = OFVlanVidMatch.NONE;
+        private final static OFVlanVidMatch DEFAULT_VALUE_MASK = OFVlanVidMatch.NONE;
+
+    // OF message fields
+    private final OFVlanVidMatch value;
+    private final OFVlanVidMatch mask;
+//
+    // Immutable default instance
+    final static OFOxmVlanVidMaskedVer12 DEFAULT = new OFOxmVlanVidMaskedVer12(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmVlanVidMaskedVer12(OFVlanVidMatch value, OFVlanVidMatch mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000d04L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVlanVidMatch getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFVlanVidMatch> getCanonical() {
+        if (OFVlanVidMatch.NO_MASK.equals(mask)) {
+            return new OFOxmVlanVidVer12(value);
+        } else if(OFVlanVidMatch.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmVlanVidMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmVlanVidMasked.Builder {
+        final OFOxmVlanVidMaskedVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFVlanVidMatch value;
+        private boolean maskSet;
+        private OFVlanVidMatch mask;
+
+        BuilderWithParent(OFOxmVlanVidMaskedVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000d04L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanVidMasked.Builder setValue(OFVlanVidMatch value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVlanVidMatch getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmVlanVidMasked.Builder setMask(OFVlanVidMatch mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFVlanVidMatch> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmVlanVidMasked build() {
+                OFVlanVidMatch value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFVlanVidMatch mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmVlanVidMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmVlanVidMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFVlanVidMatch value;
+        private boolean maskSet;
+        private OFVlanVidMatch mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000d04L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanVidMasked.Builder setValue(OFVlanVidMatch value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVlanVidMatch getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmVlanVidMasked.Builder setMask(OFVlanVidMatch mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFVlanVidMatch> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmVlanVidMasked build() {
+            OFVlanVidMatch value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFVlanVidMatch mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmVlanVidMaskedVer12(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmVlanVidMasked> {
+        @Override
+        public OFOxmVlanVidMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000d04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000d04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000d04L(0x80000d04L), got="+typeLen);
+            OFVlanVidMatch value = OFVlanVidMatch.read2Bytes(bb);
+            OFVlanVidMatch mask = OFVlanVidMatch.read2Bytes(bb);
+
+            OFOxmVlanVidMaskedVer12 oxmVlanVidMaskedVer12 = new OFOxmVlanVidMaskedVer12(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmVlanVidMaskedVer12);
+            return oxmVlanVidMaskedVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmVlanVidMaskedVer12Funnel FUNNEL = new OFOxmVlanVidMaskedVer12Funnel();
+    static class OFOxmVlanVidMaskedVer12Funnel implements Funnel<OFOxmVlanVidMaskedVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmVlanVidMaskedVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000d04L
+            sink.putInt((int) 0x80000d04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmVlanVidMaskedVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmVlanVidMaskedVer12 message) {
+            // fixed value property typeLen = 0x80000d04L
+            bb.writeInt((int) 0x80000d04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmVlanVidMaskedVer12(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmVlanVidMaskedVer12 other = (OFOxmVlanVidMaskedVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanVidVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanVidVer12.java
new file mode 100644
index 0000000..77ba223
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmVlanVidVer12.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmVlanVidVer12 implements OFOxmVlanVid {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmVlanVidVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 6;
+
+        private final static OFVlanVidMatch DEFAULT_VALUE = OFVlanVidMatch.NONE;
+
+    // OF message fields
+    private final OFVlanVidMatch value;
+//
+    // Immutable default instance
+    final static OFOxmVlanVidVer12 DEFAULT = new OFOxmVlanVidVer12(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmVlanVidVer12(OFVlanVidMatch value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000c02L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFVlanVidMatch> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFVlanVidMatch getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFOxmVlanVid.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmVlanVid.Builder {
+        final OFOxmVlanVidVer12 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFVlanVidMatch value;
+
+        BuilderWithParent(OFOxmVlanVidVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000c02L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanVid.Builder setValue(OFVlanVidMatch value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFVlanVidMatch> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVlanVidMatch getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFOxmVlanVid build() {
+                OFVlanVidMatch value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmVlanVidVer12(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmVlanVid.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFVlanVidMatch value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000c02L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanVid.Builder setValue(OFVlanVidMatch value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFVlanVidMatch> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.2");
+    }
+
+    @Override
+    public OFVlanVidMatch getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFOxmVlanVid build() {
+            OFVlanVidMatch value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmVlanVidVer12(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmVlanVid> {
+        @Override
+        public OFOxmVlanVid readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000c02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000c02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000c02L(0x80000c02L), got="+typeLen);
+            OFVlanVidMatch value = OFVlanVidMatch.read2Bytes(bb);
+
+            OFOxmVlanVidVer12 oxmVlanVidVer12 = new OFOxmVlanVidVer12(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmVlanVidVer12);
+            return oxmVlanVidVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmVlanVidVer12Funnel FUNNEL = new OFOxmVlanVidVer12Funnel();
+    static class OFOxmVlanVidVer12Funnel implements Funnel<OFOxmVlanVidVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmVlanVidVer12 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000c02L
+            sink.putInt((int) 0x80000c02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmVlanVidVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmVlanVidVer12 message) {
+            // fixed value property typeLen = 0x80000c02L
+            bb.writeInt((int) 0x80000c02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmVlanVidVer12(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmVlanVidVer12 other = (OFOxmVlanVidVer12) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmsVer12.java
new file mode 100644
index 0000000..22d90e6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmsVer12.java
@@ -0,0 +1,1435 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFOxmsVer12 implements OFOxms {
+    public final static OFOxmsVer12 INSTANCE = new OFOxmsVer12();
+
+
+
+
+    public OFOxmArpOp.Builder buildArpOp() {
+        return new OFOxmArpOpVer12.Builder();
+    }
+    public OFOxmArpOp arpOp(ArpOpcode value) {
+        return new OFOxmArpOpVer12(
+                value
+                    );
+    }
+
+    public OFOxmArpOpMasked.Builder buildArpOpMasked() {
+        return new OFOxmArpOpMaskedVer12.Builder();
+    }
+    public OFOxmArpOpMasked arpOpMasked(ArpOpcode value, ArpOpcode mask) {
+        return new OFOxmArpOpMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmArpSha.Builder buildArpSha() {
+        return new OFOxmArpShaVer12.Builder();
+    }
+    public OFOxmArpSha arpSha(MacAddress value) {
+        return new OFOxmArpShaVer12(
+                value
+                    );
+    }
+
+    public OFOxmArpShaMasked.Builder buildArpShaMasked() {
+        return new OFOxmArpShaMaskedVer12.Builder();
+    }
+    public OFOxmArpShaMasked arpShaMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmArpShaMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmArpSpa.Builder buildArpSpa() {
+        return new OFOxmArpSpaVer12.Builder();
+    }
+    public OFOxmArpSpa arpSpa(IPv4Address value) {
+        return new OFOxmArpSpaVer12(
+                value
+                    );
+    }
+
+    public OFOxmArpSpaMasked.Builder buildArpSpaMasked() {
+        return new OFOxmArpSpaMaskedVer12.Builder();
+    }
+    public OFOxmArpSpaMasked arpSpaMasked(IPv4Address value, IPv4Address mask) {
+        return new OFOxmArpSpaMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmArpTha.Builder buildArpTha() {
+        return new OFOxmArpThaVer12.Builder();
+    }
+    public OFOxmArpTha arpTha(MacAddress value) {
+        return new OFOxmArpThaVer12(
+                value
+                    );
+    }
+
+    public OFOxmArpThaMasked.Builder buildArpThaMasked() {
+        return new OFOxmArpThaMaskedVer12.Builder();
+    }
+    public OFOxmArpThaMasked arpThaMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmArpThaMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmArpTpa.Builder buildArpTpa() {
+        return new OFOxmArpTpaVer12.Builder();
+    }
+    public OFOxmArpTpa arpTpa(IPv4Address value) {
+        return new OFOxmArpTpaVer12(
+                value
+                    );
+    }
+
+    public OFOxmArpTpaMasked.Builder buildArpTpaMasked() {
+        return new OFOxmArpTpaMaskedVer12.Builder();
+    }
+    public OFOxmArpTpaMasked arpTpaMasked(IPv4Address value, IPv4Address mask) {
+        return new OFOxmArpTpaMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnEgrPortGroupId.Builder buildBsnEgrPortGroupId() {
+        return new OFOxmBsnEgrPortGroupIdVer12.Builder();
+    }
+    public OFOxmBsnEgrPortGroupId bsnEgrPortGroupId(ClassId value) {
+        return new OFOxmBsnEgrPortGroupIdVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnEgrPortGroupIdMasked.Builder buildBsnEgrPortGroupIdMasked() {
+        return new OFOxmBsnEgrPortGroupIdMaskedVer12.Builder();
+    }
+    public OFOxmBsnEgrPortGroupIdMasked bsnEgrPortGroupIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnEgrPortGroupIdMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnGlobalVrfAllowed.Builder buildBsnGlobalVrfAllowed() {
+        return new OFOxmBsnGlobalVrfAllowedVer12.Builder();
+    }
+    public OFOxmBsnGlobalVrfAllowed bsnGlobalVrfAllowed(OFBooleanValue value) {
+        return new OFOxmBsnGlobalVrfAllowedVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder buildBsnGlobalVrfAllowedMasked() {
+        return new OFOxmBsnGlobalVrfAllowedMaskedVer12.Builder();
+    }
+    public OFOxmBsnGlobalVrfAllowedMasked bsnGlobalVrfAllowedMasked(OFBooleanValue value, OFBooleanValue mask) {
+        return new OFOxmBsnGlobalVrfAllowedMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnInPorts128.Builder buildBsnInPorts128() {
+        return new OFOxmBsnInPorts128Ver12.Builder();
+    }
+    public OFOxmBsnInPorts128 bsnInPorts128(OFBitMask128 value) {
+        return new OFOxmBsnInPorts128Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnInPorts128Masked.Builder buildBsnInPorts128Masked() {
+        return new OFOxmBsnInPorts128MaskedVer12.Builder();
+    }
+    public OFOxmBsnInPorts128Masked bsnInPorts128Masked(OFBitMask128 value, OFBitMask128 mask) {
+        return new OFOxmBsnInPorts128MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnL3DstClassId.Builder buildBsnL3DstClassId() {
+        return new OFOxmBsnL3DstClassIdVer12.Builder();
+    }
+    public OFOxmBsnL3DstClassId bsnL3DstClassId(ClassId value) {
+        return new OFOxmBsnL3DstClassIdVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnL3DstClassIdMasked.Builder buildBsnL3DstClassIdMasked() {
+        return new OFOxmBsnL3DstClassIdMaskedVer12.Builder();
+    }
+    public OFOxmBsnL3DstClassIdMasked bsnL3DstClassIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnL3DstClassIdMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnL3InterfaceClassId.Builder buildBsnL3InterfaceClassId() {
+        return new OFOxmBsnL3InterfaceClassIdVer12.Builder();
+    }
+    public OFOxmBsnL3InterfaceClassId bsnL3InterfaceClassId(ClassId value) {
+        return new OFOxmBsnL3InterfaceClassIdVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder buildBsnL3InterfaceClassIdMasked() {
+        return new OFOxmBsnL3InterfaceClassIdMaskedVer12.Builder();
+    }
+    public OFOxmBsnL3InterfaceClassIdMasked bsnL3InterfaceClassIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnL3InterfaceClassIdMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnL3SrcClassId.Builder buildBsnL3SrcClassId() {
+        return new OFOxmBsnL3SrcClassIdVer12.Builder();
+    }
+    public OFOxmBsnL3SrcClassId bsnL3SrcClassId(ClassId value) {
+        return new OFOxmBsnL3SrcClassIdVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnL3SrcClassIdMasked.Builder buildBsnL3SrcClassIdMasked() {
+        return new OFOxmBsnL3SrcClassIdMaskedVer12.Builder();
+    }
+    public OFOxmBsnL3SrcClassIdMasked bsnL3SrcClassIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnL3SrcClassIdMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnLagId.Builder buildBsnLagId() {
+        return new OFOxmBsnLagIdVer12.Builder();
+    }
+    public OFOxmBsnLagId bsnLagId(LagId value) {
+        return new OFOxmBsnLagIdVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnLagIdMasked.Builder buildBsnLagIdMasked() {
+        return new OFOxmBsnLagIdMaskedVer12.Builder();
+    }
+    public OFOxmBsnLagIdMasked bsnLagIdMasked(LagId value, LagId mask) {
+        return new OFOxmBsnLagIdMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnTcpFlags.Builder buildBsnTcpFlags() {
+        return new OFOxmBsnTcpFlagsVer12.Builder();
+    }
+    public OFOxmBsnTcpFlags bsnTcpFlags(U16 value) {
+        return new OFOxmBsnTcpFlagsVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnTcpFlagsMasked.Builder buildBsnTcpFlagsMasked() {
+        return new OFOxmBsnTcpFlagsMaskedVer12.Builder();
+    }
+    public OFOxmBsnTcpFlagsMasked bsnTcpFlagsMasked(U16 value, U16 mask) {
+        return new OFOxmBsnTcpFlagsMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf0.Builder buildBsnUdf0() {
+        return new OFOxmBsnUdf0Ver12.Builder();
+    }
+    public OFOxmBsnUdf0 bsnUdf0(UDF value) {
+        return new OFOxmBsnUdf0Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf0Masked.Builder buildBsnUdf0Masked() {
+        return new OFOxmBsnUdf0MaskedVer12.Builder();
+    }
+    public OFOxmBsnUdf0Masked bsnUdf0Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf0MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf1.Builder buildBsnUdf1() {
+        return new OFOxmBsnUdf1Ver12.Builder();
+    }
+    public OFOxmBsnUdf1 bsnUdf1(UDF value) {
+        return new OFOxmBsnUdf1Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf1Masked.Builder buildBsnUdf1Masked() {
+        return new OFOxmBsnUdf1MaskedVer12.Builder();
+    }
+    public OFOxmBsnUdf1Masked bsnUdf1Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf1MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf2.Builder buildBsnUdf2() {
+        return new OFOxmBsnUdf2Ver12.Builder();
+    }
+    public OFOxmBsnUdf2 bsnUdf2(UDF value) {
+        return new OFOxmBsnUdf2Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf2Masked.Builder buildBsnUdf2Masked() {
+        return new OFOxmBsnUdf2MaskedVer12.Builder();
+    }
+    public OFOxmBsnUdf2Masked bsnUdf2Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf2MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf3.Builder buildBsnUdf3() {
+        return new OFOxmBsnUdf3Ver12.Builder();
+    }
+    public OFOxmBsnUdf3 bsnUdf3(UDF value) {
+        return new OFOxmBsnUdf3Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf3Masked.Builder buildBsnUdf3Masked() {
+        return new OFOxmBsnUdf3MaskedVer12.Builder();
+    }
+    public OFOxmBsnUdf3Masked bsnUdf3Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf3MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf4.Builder buildBsnUdf4() {
+        return new OFOxmBsnUdf4Ver12.Builder();
+    }
+    public OFOxmBsnUdf4 bsnUdf4(UDF value) {
+        return new OFOxmBsnUdf4Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf4Masked.Builder buildBsnUdf4Masked() {
+        return new OFOxmBsnUdf4MaskedVer12.Builder();
+    }
+    public OFOxmBsnUdf4Masked bsnUdf4Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf4MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf5.Builder buildBsnUdf5() {
+        return new OFOxmBsnUdf5Ver12.Builder();
+    }
+    public OFOxmBsnUdf5 bsnUdf5(UDF value) {
+        return new OFOxmBsnUdf5Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf5Masked.Builder buildBsnUdf5Masked() {
+        return new OFOxmBsnUdf5MaskedVer12.Builder();
+    }
+    public OFOxmBsnUdf5Masked bsnUdf5Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf5MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf6.Builder buildBsnUdf6() {
+        return new OFOxmBsnUdf6Ver12.Builder();
+    }
+    public OFOxmBsnUdf6 bsnUdf6(UDF value) {
+        return new OFOxmBsnUdf6Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf6Masked.Builder buildBsnUdf6Masked() {
+        return new OFOxmBsnUdf6MaskedVer12.Builder();
+    }
+    public OFOxmBsnUdf6Masked bsnUdf6Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf6MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf7.Builder buildBsnUdf7() {
+        return new OFOxmBsnUdf7Ver12.Builder();
+    }
+    public OFOxmBsnUdf7 bsnUdf7(UDF value) {
+        return new OFOxmBsnUdf7Ver12(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf7Masked.Builder buildBsnUdf7Masked() {
+        return new OFOxmBsnUdf7MaskedVer12.Builder();
+    }
+    public OFOxmBsnUdf7Masked bsnUdf7Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf7MaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnVlanXlatePortGroupId.Builder buildBsnVlanXlatePortGroupId() {
+        return new OFOxmBsnVlanXlatePortGroupIdVer12.Builder();
+    }
+    public OFOxmBsnVlanXlatePortGroupId bsnVlanXlatePortGroupId(ClassId value) {
+        return new OFOxmBsnVlanXlatePortGroupIdVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder buildBsnVlanXlatePortGroupIdMasked() {
+        return new OFOxmBsnVlanXlatePortGroupIdMaskedVer12.Builder();
+    }
+    public OFOxmBsnVlanXlatePortGroupIdMasked bsnVlanXlatePortGroupIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnVlanXlatePortGroupIdMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnVrf.Builder buildBsnVrf() {
+        return new OFOxmBsnVrfVer12.Builder();
+    }
+    public OFOxmBsnVrf bsnVrf(VRF value) {
+        return new OFOxmBsnVrfVer12(
+                value
+                    );
+    }
+
+    public OFOxmBsnVrfMasked.Builder buildBsnVrfMasked() {
+        return new OFOxmBsnVrfMaskedVer12.Builder();
+    }
+    public OFOxmBsnVrfMasked bsnVrfMasked(VRF value, VRF mask) {
+        return new OFOxmBsnVrfMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmEthDst.Builder buildEthDst() {
+        return new OFOxmEthDstVer12.Builder();
+    }
+    public OFOxmEthDst ethDst(MacAddress value) {
+        return new OFOxmEthDstVer12(
+                value
+                    );
+    }
+
+    public OFOxmEthDstMasked.Builder buildEthDstMasked() {
+        return new OFOxmEthDstMaskedVer12.Builder();
+    }
+    public OFOxmEthDstMasked ethDstMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmEthDstMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmEthSrc.Builder buildEthSrc() {
+        return new OFOxmEthSrcVer12.Builder();
+    }
+    public OFOxmEthSrc ethSrc(MacAddress value) {
+        return new OFOxmEthSrcVer12(
+                value
+                    );
+    }
+
+    public OFOxmEthSrcMasked.Builder buildEthSrcMasked() {
+        return new OFOxmEthSrcMaskedVer12.Builder();
+    }
+    public OFOxmEthSrcMasked ethSrcMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmEthSrcMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmEthType.Builder buildEthType() {
+        return new OFOxmEthTypeVer12.Builder();
+    }
+    public OFOxmEthType ethType(EthType value) {
+        return new OFOxmEthTypeVer12(
+                value
+                    );
+    }
+
+    public OFOxmEthTypeMasked.Builder buildEthTypeMasked() {
+        return new OFOxmEthTypeMaskedVer12.Builder();
+    }
+    public OFOxmEthTypeMasked ethTypeMasked(EthType value, EthType mask) {
+        return new OFOxmEthTypeMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIcmpv4Code.Builder buildIcmpv4Code() {
+        return new OFOxmIcmpv4CodeVer12.Builder();
+    }
+    public OFOxmIcmpv4Code icmpv4Code(ICMPv4Code value) {
+        return new OFOxmIcmpv4CodeVer12(
+                value
+                    );
+    }
+
+    public OFOxmIcmpv4CodeMasked.Builder buildIcmpv4CodeMasked() {
+        return new OFOxmIcmpv4CodeMaskedVer12.Builder();
+    }
+    public OFOxmIcmpv4CodeMasked icmpv4CodeMasked(ICMPv4Code value, ICMPv4Code mask) {
+        return new OFOxmIcmpv4CodeMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIcmpv4Type.Builder buildIcmpv4Type() {
+        return new OFOxmIcmpv4TypeVer12.Builder();
+    }
+    public OFOxmIcmpv4Type icmpv4Type(ICMPv4Type value) {
+        return new OFOxmIcmpv4TypeVer12(
+                value
+                    );
+    }
+
+    public OFOxmIcmpv4TypeMasked.Builder buildIcmpv4TypeMasked() {
+        return new OFOxmIcmpv4TypeMaskedVer12.Builder();
+    }
+    public OFOxmIcmpv4TypeMasked icmpv4TypeMasked(ICMPv4Type value, ICMPv4Type mask) {
+        return new OFOxmIcmpv4TypeMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIcmpv6Code.Builder buildIcmpv6Code() {
+        return new OFOxmIcmpv6CodeVer12.Builder();
+    }
+    public OFOxmIcmpv6Code icmpv6Code(U8 value) {
+        return new OFOxmIcmpv6CodeVer12(
+                value
+                    );
+    }
+
+    public OFOxmIcmpv6CodeMasked.Builder buildIcmpv6CodeMasked() {
+        return new OFOxmIcmpv6CodeMaskedVer12.Builder();
+    }
+    public OFOxmIcmpv6CodeMasked icmpv6CodeMasked(U8 value, U8 mask) {
+        return new OFOxmIcmpv6CodeMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIcmpv6Type.Builder buildIcmpv6Type() {
+        return new OFOxmIcmpv6TypeVer12.Builder();
+    }
+    public OFOxmIcmpv6Type icmpv6Type(U8 value) {
+        return new OFOxmIcmpv6TypeVer12(
+                value
+                    );
+    }
+
+    public OFOxmIcmpv6TypeMasked.Builder buildIcmpv6TypeMasked() {
+        return new OFOxmIcmpv6TypeMaskedVer12.Builder();
+    }
+    public OFOxmIcmpv6TypeMasked icmpv6TypeMasked(U8 value, U8 mask) {
+        return new OFOxmIcmpv6TypeMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmInPhyPort.Builder buildInPhyPort() {
+        return new OFOxmInPhyPortVer12.Builder();
+    }
+    public OFOxmInPhyPort inPhyPort(OFPort value) {
+        return new OFOxmInPhyPortVer12(
+                value
+                    );
+    }
+
+    public OFOxmInPhyPortMasked.Builder buildInPhyPortMasked() {
+        return new OFOxmInPhyPortMaskedVer12.Builder();
+    }
+    public OFOxmInPhyPortMasked inPhyPortMasked(OFPort value, OFPort mask) {
+        return new OFOxmInPhyPortMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmInPort.Builder buildInPort() {
+        return new OFOxmInPortVer12.Builder();
+    }
+    public OFOxmInPort inPort(OFPort value) {
+        return new OFOxmInPortVer12(
+                value
+                    );
+    }
+
+    public OFOxmInPortMasked.Builder buildInPortMasked() {
+        return new OFOxmInPortMaskedVer12.Builder();
+    }
+    public OFOxmInPortMasked inPortMasked(OFPort value, OFPort mask) {
+        return new OFOxmInPortMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpDscp.Builder buildIpDscp() {
+        return new OFOxmIpDscpVer12.Builder();
+    }
+    public OFOxmIpDscp ipDscp(IpDscp value) {
+        return new OFOxmIpDscpVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpDscpMasked.Builder buildIpDscpMasked() {
+        return new OFOxmIpDscpMaskedVer12.Builder();
+    }
+    public OFOxmIpDscpMasked ipDscpMasked(IpDscp value, IpDscp mask) {
+        return new OFOxmIpDscpMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpEcn.Builder buildIpEcn() {
+        return new OFOxmIpEcnVer12.Builder();
+    }
+    public OFOxmIpEcn ipEcn(IpEcn value) {
+        return new OFOxmIpEcnVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpEcnMasked.Builder buildIpEcnMasked() {
+        return new OFOxmIpEcnMaskedVer12.Builder();
+    }
+    public OFOxmIpEcnMasked ipEcnMasked(IpEcn value, IpEcn mask) {
+        return new OFOxmIpEcnMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpProto.Builder buildIpProto() {
+        return new OFOxmIpProtoVer12.Builder();
+    }
+    public OFOxmIpProto ipProto(IpProtocol value) {
+        return new OFOxmIpProtoVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpProtoMasked.Builder buildIpProtoMasked() {
+        return new OFOxmIpProtoMaskedVer12.Builder();
+    }
+    public OFOxmIpProtoMasked ipProtoMasked(IpProtocol value, IpProtocol mask) {
+        return new OFOxmIpProtoMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv4Dst.Builder buildIpv4Dst() {
+        return new OFOxmIpv4DstVer12.Builder();
+    }
+    public OFOxmIpv4Dst ipv4Dst(IPv4Address value) {
+        return new OFOxmIpv4DstVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpv4DstMasked.Builder buildIpv4DstMasked() {
+        return new OFOxmIpv4DstMaskedVer12.Builder();
+    }
+    public OFOxmIpv4DstMasked ipv4DstMasked(IPv4Address value, IPv4Address mask) {
+        return new OFOxmIpv4DstMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv4Src.Builder buildIpv4Src() {
+        return new OFOxmIpv4SrcVer12.Builder();
+    }
+    public OFOxmIpv4Src ipv4Src(IPv4Address value) {
+        return new OFOxmIpv4SrcVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpv4SrcMasked.Builder buildIpv4SrcMasked() {
+        return new OFOxmIpv4SrcMaskedVer12.Builder();
+    }
+    public OFOxmIpv4SrcMasked ipv4SrcMasked(IPv4Address value, IPv4Address mask) {
+        return new OFOxmIpv4SrcMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6Dst.Builder buildIpv6Dst() {
+        return new OFOxmIpv6DstVer12.Builder();
+    }
+    public OFOxmIpv6Dst ipv6Dst(IPv6Address value) {
+        return new OFOxmIpv6DstVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpv6DstMasked.Builder buildIpv6DstMasked() {
+        return new OFOxmIpv6DstMaskedVer12.Builder();
+    }
+    public OFOxmIpv6DstMasked ipv6DstMasked(IPv6Address value, IPv6Address mask) {
+        return new OFOxmIpv6DstMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6Flabel.Builder buildIpv6Flabel() {
+        return new OFOxmIpv6FlabelVer12.Builder();
+    }
+    public OFOxmIpv6Flabel ipv6Flabel(IPv6FlowLabel value) {
+        return new OFOxmIpv6FlabelVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpv6FlabelMasked.Builder buildIpv6FlabelMasked() {
+        return new OFOxmIpv6FlabelMaskedVer12.Builder();
+    }
+    public OFOxmIpv6FlabelMasked ipv6FlabelMasked(IPv6FlowLabel value, IPv6FlowLabel mask) {
+        return new OFOxmIpv6FlabelMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6NdSll.Builder buildIpv6NdSll() {
+        return new OFOxmIpv6NdSllVer12.Builder();
+    }
+    public OFOxmIpv6NdSll ipv6NdSll(MacAddress value) {
+        return new OFOxmIpv6NdSllVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpv6NdSllMasked.Builder buildIpv6NdSllMasked() {
+        return new OFOxmIpv6NdSllMaskedVer12.Builder();
+    }
+    public OFOxmIpv6NdSllMasked ipv6NdSllMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmIpv6NdSllMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6NdTarget.Builder buildIpv6NdTarget() {
+        return new OFOxmIpv6NdTargetVer12.Builder();
+    }
+    public OFOxmIpv6NdTarget ipv6NdTarget(IPv6Address value) {
+        return new OFOxmIpv6NdTargetVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpv6NdTargetMasked.Builder buildIpv6NdTargetMasked() {
+        return new OFOxmIpv6NdTargetMaskedVer12.Builder();
+    }
+    public OFOxmIpv6NdTargetMasked ipv6NdTargetMasked(IPv6Address value, IPv6Address mask) {
+        return new OFOxmIpv6NdTargetMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6NdTll.Builder buildIpv6NdTll() {
+        return new OFOxmIpv6NdTllVer12.Builder();
+    }
+    public OFOxmIpv6NdTll ipv6NdTll(MacAddress value) {
+        return new OFOxmIpv6NdTllVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpv6NdTllMasked.Builder buildIpv6NdTllMasked() {
+        return new OFOxmIpv6NdTllMaskedVer12.Builder();
+    }
+    public OFOxmIpv6NdTllMasked ipv6NdTllMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmIpv6NdTllMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6Src.Builder buildIpv6Src() {
+        return new OFOxmIpv6SrcVer12.Builder();
+    }
+    public OFOxmIpv6Src ipv6Src(IPv6Address value) {
+        return new OFOxmIpv6SrcVer12(
+                value
+                    );
+    }
+
+    public OFOxmIpv6SrcMasked.Builder buildIpv6SrcMasked() {
+        return new OFOxmIpv6SrcMaskedVer12.Builder();
+    }
+    public OFOxmIpv6SrcMasked ipv6SrcMasked(IPv6Address value, IPv6Address mask) {
+        return new OFOxmIpv6SrcMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmMetadata.Builder buildMetadata() {
+        return new OFOxmMetadataVer12.Builder();
+    }
+    public OFOxmMetadata metadata(OFMetadata value) {
+        return new OFOxmMetadataVer12(
+                value
+                    );
+    }
+
+    public OFOxmMetadataMasked.Builder buildMetadataMasked() {
+        return new OFOxmMetadataMaskedVer12.Builder();
+    }
+    public OFOxmMetadataMasked metadataMasked(OFMetadata value, OFMetadata mask) {
+        return new OFOxmMetadataMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmMplsLabel.Builder buildMplsLabel() {
+        return new OFOxmMplsLabelVer12.Builder();
+    }
+    public OFOxmMplsLabel mplsLabel(U32 value) {
+        return new OFOxmMplsLabelVer12(
+                value
+                    );
+    }
+
+    public OFOxmMplsLabelMasked.Builder buildMplsLabelMasked() {
+        return new OFOxmMplsLabelMaskedVer12.Builder();
+    }
+    public OFOxmMplsLabelMasked mplsLabelMasked(U32 value, U32 mask) {
+        return new OFOxmMplsLabelMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmMplsTc.Builder buildMplsTc() {
+        return new OFOxmMplsTcVer12.Builder();
+    }
+    public OFOxmMplsTc mplsTc(U8 value) {
+        return new OFOxmMplsTcVer12(
+                value
+                    );
+    }
+
+    public OFOxmMplsTcMasked.Builder buildMplsTcMasked() {
+        return new OFOxmMplsTcMaskedVer12.Builder();
+    }
+    public OFOxmMplsTcMasked mplsTcMasked(U8 value, U8 mask) {
+        return new OFOxmMplsTcMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmSctpDst.Builder buildSctpDst() {
+        return new OFOxmSctpDstVer12.Builder();
+    }
+    public OFOxmSctpDst sctpDst(TransportPort value) {
+        return new OFOxmSctpDstVer12(
+                value
+                    );
+    }
+
+    public OFOxmSctpDstMasked.Builder buildSctpDstMasked() {
+        return new OFOxmSctpDstMaskedVer12.Builder();
+    }
+    public OFOxmSctpDstMasked sctpDstMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmSctpDstMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmSctpSrc.Builder buildSctpSrc() {
+        return new OFOxmSctpSrcVer12.Builder();
+    }
+    public OFOxmSctpSrc sctpSrc(TransportPort value) {
+        return new OFOxmSctpSrcVer12(
+                value
+                    );
+    }
+
+    public OFOxmSctpSrcMasked.Builder buildSctpSrcMasked() {
+        return new OFOxmSctpSrcMaskedVer12.Builder();
+    }
+    public OFOxmSctpSrcMasked sctpSrcMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmSctpSrcMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmTcpDst.Builder buildTcpDst() {
+        return new OFOxmTcpDstVer12.Builder();
+    }
+    public OFOxmTcpDst tcpDst(TransportPort value) {
+        return new OFOxmTcpDstVer12(
+                value
+                    );
+    }
+
+    public OFOxmTcpDstMasked.Builder buildTcpDstMasked() {
+        return new OFOxmTcpDstMaskedVer12.Builder();
+    }
+    public OFOxmTcpDstMasked tcpDstMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmTcpDstMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmTcpSrc.Builder buildTcpSrc() {
+        return new OFOxmTcpSrcVer12.Builder();
+    }
+    public OFOxmTcpSrc tcpSrc(TransportPort value) {
+        return new OFOxmTcpSrcVer12(
+                value
+                    );
+    }
+
+    public OFOxmTcpSrcMasked.Builder buildTcpSrcMasked() {
+        return new OFOxmTcpSrcMaskedVer12.Builder();
+    }
+    public OFOxmTcpSrcMasked tcpSrcMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmTcpSrcMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmUdpDst.Builder buildUdpDst() {
+        return new OFOxmUdpDstVer12.Builder();
+    }
+    public OFOxmUdpDst udpDst(TransportPort value) {
+        return new OFOxmUdpDstVer12(
+                value
+                    );
+    }
+
+    public OFOxmUdpDstMasked.Builder buildUdpDstMasked() {
+        return new OFOxmUdpDstMaskedVer12.Builder();
+    }
+    public OFOxmUdpDstMasked udpDstMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmUdpDstMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmUdpSrc.Builder buildUdpSrc() {
+        return new OFOxmUdpSrcVer12.Builder();
+    }
+    public OFOxmUdpSrc udpSrc(TransportPort value) {
+        return new OFOxmUdpSrcVer12(
+                value
+                    );
+    }
+
+    public OFOxmUdpSrcMasked.Builder buildUdpSrcMasked() {
+        return new OFOxmUdpSrcMaskedVer12.Builder();
+    }
+    public OFOxmUdpSrcMasked udpSrcMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmUdpSrcMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmVlanPcp.Builder buildVlanPcp() {
+        return new OFOxmVlanPcpVer12.Builder();
+    }
+    public OFOxmVlanPcp vlanPcp(VlanPcp value) {
+        return new OFOxmVlanPcpVer12(
+                value
+                    );
+    }
+
+    public OFOxmVlanPcpMasked.Builder buildVlanPcpMasked() {
+        return new OFOxmVlanPcpMaskedVer12.Builder();
+    }
+    public OFOxmVlanPcpMasked vlanPcpMasked(VlanPcp value, VlanPcp mask) {
+        return new OFOxmVlanPcpMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmVlanVid.Builder buildVlanVid() {
+        return new OFOxmVlanVidVer12.Builder();
+    }
+    public OFOxmVlanVid vlanVid(OFVlanVidMatch value) {
+        return new OFOxmVlanVidVer12(
+                value
+                    );
+    }
+
+    public OFOxmVlanVidMasked.Builder buildVlanVidMasked() {
+        return new OFOxmVlanVidMaskedVer12.Builder();
+    }
+    public OFOxmVlanVidMasked vlanVidMasked(OFVlanVidMatch value, OFVlanVidMatch mask) {
+        return new OFOxmVlanVidMaskedVer12(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmTunnelId.Builder buildTunnelId() {
+        throw new UnsupportedOperationException("OFOxmTunnelId not supported in version 1.2");
+    }
+    public OFOxmTunnelId tunnelId(U64 value) {
+        throw new UnsupportedOperationException("OFOxmTunnelId not supported in version 1.2");
+    }
+
+    public OFOxmTunnelIdMasked.Builder buildTunnelIdMasked() {
+        throw new UnsupportedOperationException("OFOxmTunnelIdMasked not supported in version 1.2");
+    }
+    public OFOxmTunnelIdMasked tunnelIdMasked(U64 value, U64 mask) {
+        throw new UnsupportedOperationException("OFOxmTunnelIdMasked not supported in version 1.2");
+    }
+
+    public OFMessageReader<OFOxm<?>> getReader() {
+        return OFOxmVer12.READER;
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromValue(F value, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOp((ArpOpcode)((Object)value)));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpSha((MacAddress)((Object)value)));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpa((IPv4Address)((Object)value)));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpTha((MacAddress)((Object)value)));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpa((IPv4Address)((Object)value)));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupId((ClassId)((Object)value)));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowed((OFBooleanValue)((Object)value)));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128((OFBitMask128)((Object)value)));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassId((ClassId)((Object)value)));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassId((ClassId)((Object)value)));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassId((ClassId)((Object)value)));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagId((LagId)((Object)value)));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlags((U16)((Object)value)));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0((UDF)((Object)value)));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1((UDF)((Object)value)));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2((UDF)((Object)value)));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3((UDF)((Object)value)));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4((UDF)((Object)value)));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5((UDF)((Object)value)));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6((UDF)((Object)value)));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7((UDF)((Object)value)));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupId((ClassId)((Object)value)));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrf((VRF)((Object)value)));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDst((MacAddress)((Object)value)));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrc((MacAddress)((Object)value)));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethType((EthType)((Object)value)));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4Code((ICMPv4Code)((Object)value)));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4Type((ICMPv4Type)((Object)value)));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6Code((U8)((Object)value)));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6Type((U8)((Object)value)));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPort((OFPort)((Object)value)));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPort((OFPort)((Object)value)));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscp((IpDscp)((Object)value)));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcn((IpEcn)((Object)value)));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProto((IpProtocol)((Object)value)));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4Dst((IPv4Address)((Object)value)));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4Src((IPv4Address)((Object)value)));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6Dst((IPv6Address)((Object)value)));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6Flabel((IPv6FlowLabel)((Object)value)));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSll((MacAddress)((Object)value)));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTarget((IPv6Address)((Object)value)));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTll((MacAddress)((Object)value)));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6Src((IPv6Address)((Object)value)));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadata((OFMetadata)((Object)value)));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabel((U32)((Object)value)));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTc((U8)((Object)value)));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDst((TransportPort)((Object)value)));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrc((TransportPort)((Object)value)));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDst((TransportPort)((Object)value)));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrc((TransportPort)((Object)value)));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDst((TransportPort)((Object)value)));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrc((TransportPort)((Object)value)));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcp((VlanPcp)((Object)value)));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVid((OFVlanVidMatch)((Object)value)));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelId((U64)((Object)value)));
+            default:
+                throw new IllegalArgumentException("No OXM known for match field " + field);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromValueAndMask(F value, F mask, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOpMasked((ArpOpcode)((Object)value), (ArpOpcode)((Object)mask)));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpShaMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpaMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpThaMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpaMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowedMasked((OFBooleanValue)((Object)value), (OFBooleanValue)((Object)mask)));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128Masked((OFBitMask128)((Object)value), (OFBitMask128)((Object)mask)));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagIdMasked((LagId)((Object)value), (LagId)((Object)mask)));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlagsMasked((U16)((Object)value), (U16)((Object)mask)));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrfMasked((VRF)((Object)value), (VRF)((Object)mask)));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDstMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrcMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethTypeMasked((EthType)((Object)value), (EthType)((Object)mask)));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4CodeMasked((ICMPv4Code)((Object)value), (ICMPv4Code)((Object)mask)));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4TypeMasked((ICMPv4Type)((Object)value), (ICMPv4Type)((Object)mask)));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6CodeMasked((U8)((Object)value), (U8)((Object)mask)));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6TypeMasked((U8)((Object)value), (U8)((Object)mask)));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPortMasked((OFPort)((Object)value), (OFPort)((Object)mask)));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPortMasked((OFPort)((Object)value), (OFPort)((Object)mask)));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscpMasked((IpDscp)((Object)value), (IpDscp)((Object)mask)));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcnMasked((IpEcn)((Object)value), (IpEcn)((Object)mask)));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProtoMasked((IpProtocol)((Object)value), (IpProtocol)((Object)mask)));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4DstMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4SrcMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6DstMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6FlabelMasked((IPv6FlowLabel)((Object)value), (IPv6FlowLabel)((Object)mask)));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSllMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTargetMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTllMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6SrcMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadataMasked((OFMetadata)((Object)value), (OFMetadata)((Object)mask)));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabelMasked((U32)((Object)value), (U32)((Object)mask)));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTcMasked((U8)((Object)value), (U8)((Object)mask)));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcpMasked((VlanPcp)((Object)value), (VlanPcp)((Object)mask)));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVidMasked((OFVlanVidMatch)((Object)value), (OFVlanVidMatch)((Object)mask)));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelIdMasked((U64)((Object)value), (U64)((Object)mask)));
+            default:
+                throw new IllegalArgumentException("No OXM known for match field " + field);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromMasked(Masked<F> masked, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOpMasked((ArpOpcode)((Object)(masked.getValue())), (ArpOpcode)((Object)(masked.getMask()))));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpShaMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpaMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpThaMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpaMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowedMasked((OFBooleanValue)((Object)(masked.getValue())), (OFBooleanValue)((Object)(masked.getMask()))));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128Masked((OFBitMask128)((Object)(masked.getValue())), (OFBitMask128)((Object)(masked.getMask()))));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagIdMasked((LagId)((Object)(masked.getValue())), (LagId)((Object)(masked.getMask()))));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlagsMasked((U16)((Object)(masked.getValue())), (U16)((Object)(masked.getMask()))));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrfMasked((VRF)((Object)(masked.getValue())), (VRF)((Object)(masked.getMask()))));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDstMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrcMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethTypeMasked((EthType)((Object)(masked.getValue())), (EthType)((Object)(masked.getMask()))));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4CodeMasked((ICMPv4Code)((Object)(masked.getValue())), (ICMPv4Code)((Object)(masked.getMask()))));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4TypeMasked((ICMPv4Type)((Object)(masked.getValue())), (ICMPv4Type)((Object)(masked.getMask()))));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6CodeMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6TypeMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPortMasked((OFPort)((Object)(masked.getValue())), (OFPort)((Object)(masked.getMask()))));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPortMasked((OFPort)((Object)(masked.getValue())), (OFPort)((Object)(masked.getMask()))));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscpMasked((IpDscp)((Object)(masked.getValue())), (IpDscp)((Object)(masked.getMask()))));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcnMasked((IpEcn)((Object)(masked.getValue())), (IpEcn)((Object)(masked.getMask()))));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProtoMasked((IpProtocol)((Object)(masked.getValue())), (IpProtocol)((Object)(masked.getMask()))));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4DstMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4SrcMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6DstMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6FlabelMasked((IPv6FlowLabel)((Object)(masked.getValue())), (IPv6FlowLabel)((Object)(masked.getMask()))));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSllMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTargetMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTllMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6SrcMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadataMasked((OFMetadata)((Object)(masked.getValue())), (OFMetadata)((Object)(masked.getMask()))));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabelMasked((U32)((Object)(masked.getValue())), (U32)((Object)(masked.getMask()))));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTcMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcpMasked((VlanPcp)((Object)(masked.getValue())), (VlanPcp)((Object)(masked.getMask()))));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVidMasked((OFVlanVidMatch)((Object)(masked.getValue())), (OFVlanVidMatch)((Object)(masked.getMask()))));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelIdMasked((U64)((Object)(masked.getValue())), (U64)((Object)(masked.getMask()))));
+            default:
+                return null;
+        }
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketInReasonSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketInReasonSerializerVer12.java
new file mode 100644
index 0000000..63474d1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketInReasonSerializerVer12.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPacketInReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPacketInReasonSerializerVer12 {
+
+    public final static byte NO_MATCH_VAL = (byte) 0x0;
+    public final static byte ACTION_VAL = (byte) 0x1;
+    public final static byte INVALID_TTL_VAL = (byte) 0x2;
+
+    public static OFPacketInReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPacketInReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFPacketInReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFPacketInReason ofWireValue(byte val) {
+        switch(val) {
+            case NO_MATCH_VAL:
+                return OFPacketInReason.NO_MATCH;
+            case ACTION_VAL:
+                return OFPacketInReason.ACTION;
+            case INVALID_TTL_VAL:
+                return OFPacketInReason.INVALID_TTL;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPacketInReason in version 1.2: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFPacketInReason e) {
+        switch(e) {
+            case NO_MATCH:
+                return NO_MATCH_VAL;
+            case ACTION:
+                return ACTION_VAL;
+            case INVALID_TTL:
+                return INVALID_TTL_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPacketInReason in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketInVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketInVer12.java
new file mode 100644
index 0000000..a36dde6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketInVer12.java
@@ -0,0 +1,658 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFPacketInVer12 implements OFPacketIn {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketInVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 22;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static int DEFAULT_TOTAL_LEN = 0x0;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static Match DEFAULT_MATCH = OFFactoryVer12.MATCH_WILDCARD_ALL;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final OFBufferId bufferId;
+    private final int totalLen;
+    private final OFPacketInReason reason;
+    private final TableId tableId;
+    private final Match match;
+    private final byte[] data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketInVer12(long xid, OFBufferId bufferId, int totalLen, OFPacketInReason reason, TableId tableId, Match match, byte[] data) {
+        this.xid = xid;
+        this.bufferId = bufferId;
+        this.totalLen = totalLen;
+        this.reason = reason;
+        this.tableId = tableId;
+        this.match = match;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPort getInPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPort not supported in version 1.2");
+    }
+
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.2");
+    }
+
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.2");
+    }
+
+
+
+    public OFPacketIn.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketIn.Builder {
+        final OFPacketInVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean totalLenSet;
+        private int totalLen;
+        private boolean reasonSet;
+        private OFPacketInReason reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean matchSet;
+        private Match match;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFPacketInVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketIn.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTotalLen(int totalLen) {
+        this.totalLen = totalLen;
+        this.totalLenSet = true;
+        return this;
+    }
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPacketIn.Builder setReason(OFPacketInReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFPacketIn.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketIn.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPort not supported in version 1.2");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPort(OFPort inPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPort not supported in version 1.2");
+    }
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.2");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.2");
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.2");
+    }
+
+    @Override
+    public OFPacketIn.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.2");
+    }
+
+
+        @Override
+        public OFPacketIn build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                int totalLen = this.totalLenSet ? this.totalLen : parentMessage.totalLen;
+                OFPacketInReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPacketInVer12(
+                    xid,
+                    bufferId,
+                    totalLen,
+                    reason,
+                    tableId,
+                    match,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketIn.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean totalLenSet;
+        private int totalLen;
+        private boolean reasonSet;
+        private OFPacketInReason reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean matchSet;
+        private Match match;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketIn.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTotalLen(int totalLen) {
+        this.totalLen = totalLen;
+        this.totalLenSet = true;
+        return this;
+    }
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPacketIn.Builder setReason(OFPacketInReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFPacketIn.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketIn.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPort not supported in version 1.2");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPort(OFPort inPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPort not supported in version 1.2");
+    }
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.2");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.2");
+    }
+    @Override
+    public U64 getCookie()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property cookie not supported in version 1.2");
+    }
+
+    @Override
+    public OFPacketIn.Builder setCookie(U64 cookie) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property cookie not supported in version 1.2");
+    }
+//
+        @Override
+        public OFPacketIn build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            int totalLen = this.totalLenSet ? this.totalLen : DEFAULT_TOTAL_LEN;
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPacketInVer12(
+                    xid,
+                    bufferId,
+                    totalLen,
+                    reason,
+                    tableId,
+                    match,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketIn> {
+        @Override
+        public OFPacketIn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 10
+            byte type = bb.readByte();
+            if(type != (byte) 0xa)
+                throw new OFParseError("Wrong type: Expected=OFType.PACKET_IN(10), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            int totalLen = U16.f(bb.readShort());
+            OFPacketInReason reason = OFPacketInReasonSerializerVer12.readFrom(bb);
+            TableId tableId = TableId.readByte(bb);
+            Match match = ChannelUtilsVer12.readOFMatch(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFPacketInVer12 packetInVer12 = new OFPacketInVer12(
+                    xid,
+                      bufferId,
+                      totalLen,
+                      reason,
+                      tableId,
+                      match,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetInVer12);
+            return packetInVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketInVer12Funnel FUNNEL = new OFPacketInVer12Funnel();
+    static class OFPacketInVer12Funnel implements Funnel<OFPacketInVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketInVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 10
+            sink.putByte((byte) 0xa);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.bufferId.putTo(sink);
+            sink.putInt(message.totalLen);
+            OFPacketInReasonSerializerVer12.putTo(message.reason, sink);
+            message.tableId.putTo(sink);
+            message.match.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketInVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketInVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 10
+            bb.writeByte((byte) 0xa);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(message.bufferId.getInt());
+            bb.writeShort(U16.t(message.totalLen));
+            OFPacketInReasonSerializerVer12.writeTo(bb, message.reason);
+            message.tableId.writeByte(bb);
+            message.match.writeTo(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketInVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("totalLen=").append(totalLen);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketInVer12 other = (OFPacketInVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if( totalLen != other.totalLen)
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + totalLen;
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketOutVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketOutVer12.java
new file mode 100644
index 0000000..bdcba2b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketOutVer12.java
@@ -0,0 +1,504 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFPacketOutVer12 implements OFPacketOut {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketOutVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_IN_PORT = OFPort.ANY;
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final OFBufferId bufferId;
+    private final OFPort inPort;
+    private final List<OFAction> actions;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFPacketOutVer12 DEFAULT = new OFPacketOutVer12(
+        DEFAULT_XID, DEFAULT_BUFFER_ID, DEFAULT_IN_PORT, DEFAULT_ACTIONS, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketOutVer12(long xid, OFBufferId bufferId, OFPort inPort, List<OFAction> actions, byte[] data) {
+        this.xid = xid;
+        this.bufferId = bufferId;
+        this.inPort = inPort;
+        this.actions = actions;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFPacketOut.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketOut.Builder {
+        final OFPacketOutVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFPacketOutVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketOut.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketOut.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketOut.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFPacketOut.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketOut.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPacketOut build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort;
+                if(inPort == null)
+                    throw new NullPointerException("Property inPort must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPacketOutVer12(
+                    xid,
+                    bufferId,
+                    inPort,
+                    actions,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketOut.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketOut.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketOut.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketOut.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFPacketOut.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketOut.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPacketOut build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT;
+            if(inPort == null)
+                throw new NullPointerException("Property inPort must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPacketOutVer12(
+                    xid,
+                    bufferId,
+                    inPort,
+                    actions,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketOut> {
+        @Override
+        public OFPacketOut readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 13
+            byte type = bb.readByte();
+            if(type != (byte) 0xd)
+                throw new OFParseError("Wrong type: Expected=OFType.PACKET_OUT(13), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort inPort = OFPort.read4Bytes(bb);
+            int actionsLen = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            List<OFAction> actions = ChannelUtils.readList(bb, actionsLen, OFActionVer12.READER);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFPacketOutVer12 packetOutVer12 = new OFPacketOutVer12(
+                    xid,
+                      bufferId,
+                      inPort,
+                      actions,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetOutVer12);
+            return packetOutVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketOutVer12Funnel FUNNEL = new OFPacketOutVer12Funnel();
+    static class OFPacketOutVer12Funnel implements Funnel<OFPacketOutVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketOutVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 13
+            sink.putByte((byte) 0xd);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.bufferId.putTo(sink);
+            message.inPort.putTo(sink);
+            // FIXME: skip funnel of actionsLen
+            // skip pad (6 bytes)
+            FunnelUtils.putList(message.actions, sink);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketOutVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketOutVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 13
+            bb.writeByte((byte) 0xd);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(message.bufferId.getInt());
+            message.inPort.write4Bytes(bb);
+            // actionsLen is length indicator for actions, will be
+            // udpated when actions has been written
+            int actionsLenIndex = bb.writerIndex();
+            bb.writeShort(0);
+            // pad: 6 bytes
+            bb.writeZero(6);
+            int actionsStartIndex = bb.writerIndex();
+            ChannelUtils.writeList(bb, message.actions);
+            // update field length member actionsLen
+            int actionsLength = bb.writerIndex() - actionsStartIndex;
+            bb.setShort(actionsLenIndex, actionsLength);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketOutVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("inPort=").append(inPort);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketOutVer12 other = (OFPacketOutVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (inPort == null) {
+            if (other.inPort != null)
+                return false;
+        } else if (!inPort.equals(other.inPort))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((inPort == null) ? 0 : inPort.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketQueueVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketQueueVer12.java
new file mode 100644
index 0000000..cd059da
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPacketQueueVer12.java
@@ -0,0 +1,357 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPacketQueueVer12 implements OFPacketQueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketQueueVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static List<OFQueueProp> DEFAULT_PROPERTIES = ImmutableList.<OFQueueProp>of();
+
+    // OF message fields
+    private final long queueId;
+    private final OFPort port;
+    private final List<OFQueueProp> properties;
+//
+    // Immutable default instance
+    final static OFPacketQueueVer12 DEFAULT = new OFPacketQueueVer12(
+        DEFAULT_QUEUE_ID, DEFAULT_PORT, DEFAULT_PROPERTIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketQueueVer12(long queueId, OFPort port, List<OFQueueProp> properties) {
+        this.queueId = queueId;
+        this.port = port;
+        this.properties = properties;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFPacketQueue.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketQueue.Builder {
+        final OFPacketQueueVer12 parentMessage;
+
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean portSet;
+        private OFPort port;
+        private boolean propertiesSet;
+        private List<OFQueueProp> properties;
+
+        BuilderWithParent(OFPacketQueueVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setProperties(List<OFQueueProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFPacketQueue build() {
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                List<OFQueueProp> properties = this.propertiesSet ? this.properties : parentMessage.properties;
+                if(properties == null)
+                    throw new NullPointerException("Property properties must not be null");
+
+                //
+                return new OFPacketQueueVer12(
+                    queueId,
+                    port,
+                    properties
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketQueue.Builder {
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean portSet;
+        private OFPort port;
+        private boolean propertiesSet;
+        private List<OFQueueProp> properties;
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setProperties(List<OFQueueProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFPacketQueue build() {
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            List<OFQueueProp> properties = this.propertiesSet ? this.properties : DEFAULT_PROPERTIES;
+            if(properties == null)
+                throw new NullPointerException("Property properties must not be null");
+
+
+            return new OFPacketQueueVer12(
+                    queueId,
+                    port,
+                    properties
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketQueue> {
+        @Override
+        public OFPacketQueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            long queueId = U32.f(bb.readInt());
+            OFPort port = OFPort.read4Bytes(bb);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            List<OFQueueProp> properties = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFQueuePropVer12.READER);
+
+            OFPacketQueueVer12 packetQueueVer12 = new OFPacketQueueVer12(
+                    queueId,
+                      port,
+                      properties
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetQueueVer12);
+            return packetQueueVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketQueueVer12Funnel FUNNEL = new OFPacketQueueVer12Funnel();
+    static class OFPacketQueueVer12Funnel implements Funnel<OFPacketQueueVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketQueueVer12 message, PrimitiveSink sink) {
+            sink.putLong(message.queueId);
+            message.port.putTo(sink);
+            // FIXME: skip funnel of length
+            // skip pad (6 bytes)
+            FunnelUtils.putList(message.properties, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketQueueVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketQueueVer12 message) {
+            int startIndex = bb.writerIndex();
+            bb.writeInt(U32.t(message.queueId));
+            message.port.write4Bytes(bb);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 6 bytes
+            bb.writeZero(6);
+            ChannelUtils.writeList(bb, message.properties);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketQueueVer12(");
+        b.append("queueId=").append(queueId);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("properties=").append(properties);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketQueueVer12 other = (OFPacketQueueVer12) obj;
+
+        if( queueId != other.queueId)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if (properties == null) {
+            if (other.properties != null)
+                return false;
+        } else if (!properties.equals(other.properties))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortConfigSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortConfigSerializerVer12.java
new file mode 100644
index 0000000..df29d8f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortConfigSerializerVer12.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortConfig;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortConfigSerializerVer12 {
+
+    public final static int PORT_DOWN_VAL = 0x1;
+    public final static int NO_RECV_VAL = 0x4;
+    public final static int NO_FWD_VAL = 0x20;
+    public final static int NO_PACKET_IN_VAL = 0x40;
+    public final static int BSN_MIRROR_DEST_VAL = (int) 0x80000000;
+
+    public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortConfig> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortConfig> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortConfig> ofWireValue(int val) {
+        EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);
+
+        if((val & PORT_DOWN_VAL) != 0)
+            set.add(OFPortConfig.PORT_DOWN);
+        if((val & NO_RECV_VAL) != 0)
+            set.add(OFPortConfig.NO_RECV);
+        if((val & NO_FWD_VAL) != 0)
+            set.add(OFPortConfig.NO_FWD);
+        if((val & NO_PACKET_IN_VAL) != 0)
+            set.add(OFPortConfig.NO_PACKET_IN);
+        if((val & BSN_MIRROR_DEST_VAL) != 0)
+            set.add(OFPortConfig.BSN_MIRROR_DEST);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortConfig> set) {
+        int wireValue = 0;
+
+        for(OFPortConfig e: set) {
+            switch(e) {
+                case PORT_DOWN:
+                    wireValue |= PORT_DOWN_VAL;
+                    break;
+                case NO_RECV:
+                    wireValue |= NO_RECV_VAL;
+                    break;
+                case NO_FWD:
+                    wireValue |= NO_FWD_VAL;
+                    break;
+                case NO_PACKET_IN:
+                    wireValue |= NO_PACKET_IN_VAL;
+                    break;
+                case BSN_MIRROR_DEST:
+                    wireValue |= BSN_MIRROR_DEST_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortDescVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortDescVer12.java
new file mode 100644
index 0000000..7b1165b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortDescVer12.java
@@ -0,0 +1,766 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortDescVer12 implements OFPortDesc {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortDescVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 64;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static String DEFAULT_NAME = "";
+        private final static Set<OFPortConfig> DEFAULT_CONFIG = ImmutableSet.<OFPortConfig>of();
+        private final static Set<OFPortState> DEFAULT_STATE = ImmutableSet.<OFPortState>of();
+        private final static Set<OFPortFeatures> DEFAULT_CURR = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_ADVERTISED = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_SUPPORTED = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_PEER = ImmutableSet.<OFPortFeatures>of();
+        private final static long DEFAULT_CURR_SPEED = 0x0L;
+        private final static long DEFAULT_MAX_SPEED = 0x0L;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final MacAddress hwAddr;
+    private final String name;
+    private final Set<OFPortConfig> config;
+    private final Set<OFPortState> state;
+    private final Set<OFPortFeatures> curr;
+    private final Set<OFPortFeatures> advertised;
+    private final Set<OFPortFeatures> supported;
+    private final Set<OFPortFeatures> peer;
+    private final long currSpeed;
+    private final long maxSpeed;
+//
+    // Immutable default instance
+    final static OFPortDescVer12 DEFAULT = new OFPortDescVer12(
+        DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_CONFIG, DEFAULT_STATE, DEFAULT_CURR, DEFAULT_ADVERTISED, DEFAULT_SUPPORTED, DEFAULT_PEER, DEFAULT_CURR_SPEED, DEFAULT_MAX_SPEED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortDescVer12(OFPort portNo, MacAddress hwAddr, String name, Set<OFPortConfig> config, Set<OFPortState> state, Set<OFPortFeatures> curr, Set<OFPortFeatures> advertised, Set<OFPortFeatures> supported, Set<OFPortFeatures> peer, long currSpeed, long maxSpeed) {
+        this.portNo = portNo;
+        this.hwAddr = hwAddr;
+        this.name = name;
+        this.config = config;
+        this.state = state;
+        this.curr = curr;
+        this.advertised = advertised;
+        this.supported = supported;
+        this.peer = peer;
+        this.currSpeed = currSpeed;
+        this.maxSpeed = maxSpeed;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFPortDesc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortDesc.Builder {
+        final OFPortDescVer12 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean configSet;
+        private Set<OFPortConfig> config;
+        private boolean stateSet;
+        private Set<OFPortState> state;
+        private boolean currSet;
+        private Set<OFPortFeatures> curr;
+        private boolean advertisedSet;
+        private Set<OFPortFeatures> advertised;
+        private boolean supportedSet;
+        private Set<OFPortFeatures> supported;
+        private boolean peerSet;
+        private Set<OFPortFeatures> peer;
+        private boolean currSpeedSet;
+        private long currSpeed;
+        private boolean maxSpeedSet;
+        private long maxSpeed;
+
+        BuilderWithParent(OFPortDescVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFPortDesc.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public OFPortDesc.Builder setState(Set<OFPortState> state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) {
+        this.curr = curr;
+        this.currSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) {
+        this.advertised = advertised;
+        this.advertisedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) {
+        this.supported = supported;
+        this.supportedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) {
+        this.peer = peer;
+        this.peerSet = true;
+        return this;
+    }
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurrSpeed(long currSpeed) {
+        this.currSpeed = currSpeed;
+        this.currSpeedSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setMaxSpeed(long maxSpeed) {
+        this.maxSpeed = maxSpeed;
+        this.maxSpeedSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFPortDesc build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                Set<OFPortConfig> config = this.configSet ? this.config : parentMessage.config;
+                if(config == null)
+                    throw new NullPointerException("Property config must not be null");
+                Set<OFPortState> state = this.stateSet ? this.state : parentMessage.state;
+                if(state == null)
+                    throw new NullPointerException("Property state must not be null");
+                Set<OFPortFeatures> curr = this.currSet ? this.curr : parentMessage.curr;
+                if(curr == null)
+                    throw new NullPointerException("Property curr must not be null");
+                Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : parentMessage.advertised;
+                if(advertised == null)
+                    throw new NullPointerException("Property advertised must not be null");
+                Set<OFPortFeatures> supported = this.supportedSet ? this.supported : parentMessage.supported;
+                if(supported == null)
+                    throw new NullPointerException("Property supported must not be null");
+                Set<OFPortFeatures> peer = this.peerSet ? this.peer : parentMessage.peer;
+                if(peer == null)
+                    throw new NullPointerException("Property peer must not be null");
+                long currSpeed = this.currSpeedSet ? this.currSpeed : parentMessage.currSpeed;
+                long maxSpeed = this.maxSpeedSet ? this.maxSpeed : parentMessage.maxSpeed;
+
+                //
+                return new OFPortDescVer12(
+                    portNo,
+                    hwAddr,
+                    name,
+                    config,
+                    state,
+                    curr,
+                    advertised,
+                    supported,
+                    peer,
+                    currSpeed,
+                    maxSpeed
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortDesc.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean configSet;
+        private Set<OFPortConfig> config;
+        private boolean stateSet;
+        private Set<OFPortState> state;
+        private boolean currSet;
+        private Set<OFPortFeatures> curr;
+        private boolean advertisedSet;
+        private Set<OFPortFeatures> advertised;
+        private boolean supportedSet;
+        private Set<OFPortFeatures> supported;
+        private boolean peerSet;
+        private Set<OFPortFeatures> peer;
+        private boolean currSpeedSet;
+        private long currSpeed;
+        private boolean maxSpeedSet;
+        private long maxSpeed;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFPortDesc.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public OFPortDesc.Builder setState(Set<OFPortState> state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) {
+        this.curr = curr;
+        this.currSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) {
+        this.advertised = advertised;
+        this.advertisedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) {
+        this.supported = supported;
+        this.supportedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) {
+        this.peer = peer;
+        this.peerSet = true;
+        return this;
+    }
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurrSpeed(long currSpeed) {
+        this.currSpeed = currSpeed;
+        this.currSpeedSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setMaxSpeed(long maxSpeed) {
+        this.maxSpeed = maxSpeed;
+        this.maxSpeedSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFPortDesc build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            Set<OFPortConfig> config = this.configSet ? this.config : DEFAULT_CONFIG;
+            if(config == null)
+                throw new NullPointerException("Property config must not be null");
+            Set<OFPortState> state = this.stateSet ? this.state : DEFAULT_STATE;
+            if(state == null)
+                throw new NullPointerException("Property state must not be null");
+            Set<OFPortFeatures> curr = this.currSet ? this.curr : DEFAULT_CURR;
+            if(curr == null)
+                throw new NullPointerException("Property curr must not be null");
+            Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : DEFAULT_ADVERTISED;
+            if(advertised == null)
+                throw new NullPointerException("Property advertised must not be null");
+            Set<OFPortFeatures> supported = this.supportedSet ? this.supported : DEFAULT_SUPPORTED;
+            if(supported == null)
+                throw new NullPointerException("Property supported must not be null");
+            Set<OFPortFeatures> peer = this.peerSet ? this.peer : DEFAULT_PEER;
+            if(peer == null)
+                throw new NullPointerException("Property peer must not be null");
+            long currSpeed = this.currSpeedSet ? this.currSpeed : DEFAULT_CURR_SPEED;
+            long maxSpeed = this.maxSpeedSet ? this.maxSpeed : DEFAULT_MAX_SPEED;
+
+
+            return new OFPortDescVer12(
+                    portNo,
+                    hwAddr,
+                    name,
+                    config,
+                    state,
+                    curr,
+                    advertised,
+                    supported,
+                    peer,
+                    currSpeed,
+                    maxSpeed
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortDesc> {
+        @Override
+        public OFPortDesc readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            String name = ChannelUtils.readFixedLengthString(bb, 16);
+            Set<OFPortConfig> config = OFPortConfigSerializerVer12.readFrom(bb);
+            Set<OFPortState> state = OFPortStateSerializerVer12.readFrom(bb);
+            Set<OFPortFeatures> curr = OFPortFeaturesSerializerVer12.readFrom(bb);
+            Set<OFPortFeatures> advertised = OFPortFeaturesSerializerVer12.readFrom(bb);
+            Set<OFPortFeatures> supported = OFPortFeaturesSerializerVer12.readFrom(bb);
+            Set<OFPortFeatures> peer = OFPortFeaturesSerializerVer12.readFrom(bb);
+            long currSpeed = U32.f(bb.readInt());
+            long maxSpeed = U32.f(bb.readInt());
+
+            OFPortDescVer12 portDescVer12 = new OFPortDescVer12(
+                    portNo,
+                      hwAddr,
+                      name,
+                      config,
+                      state,
+                      curr,
+                      advertised,
+                      supported,
+                      peer,
+                      currSpeed,
+                      maxSpeed
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portDescVer12);
+            return portDescVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortDescVer12Funnel FUNNEL = new OFPortDescVer12Funnel();
+    static class OFPortDescVer12Funnel implements Funnel<OFPortDescVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortDescVer12 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putUnencodedChars(message.name);
+            OFPortConfigSerializerVer12.putTo(message.config, sink);
+            OFPortStateSerializerVer12.putTo(message.state, sink);
+            OFPortFeaturesSerializerVer12.putTo(message.curr, sink);
+            OFPortFeaturesSerializerVer12.putTo(message.advertised, sink);
+            OFPortFeaturesSerializerVer12.putTo(message.supported, sink);
+            OFPortFeaturesSerializerVer12.putTo(message.peer, sink);
+            sink.putLong(message.currSpeed);
+            sink.putLong(message.maxSpeed);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortDescVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortDescVer12 message) {
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 16);
+            OFPortConfigSerializerVer12.writeTo(bb, message.config);
+            OFPortStateSerializerVer12.writeTo(bb, message.state);
+            OFPortFeaturesSerializerVer12.writeTo(bb, message.curr);
+            OFPortFeaturesSerializerVer12.writeTo(bb, message.advertised);
+            OFPortFeaturesSerializerVer12.writeTo(bb, message.supported);
+            OFPortFeaturesSerializerVer12.writeTo(bb, message.peer);
+            bb.writeInt(U32.t(message.currSpeed));
+            bb.writeInt(U32.t(message.maxSpeed));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortDescVer12(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("state=").append(state);
+        b.append(", ");
+        b.append("curr=").append(curr);
+        b.append(", ");
+        b.append("advertised=").append(advertised);
+        b.append(", ");
+        b.append("supported=").append(supported);
+        b.append(", ");
+        b.append("peer=").append(peer);
+        b.append(", ");
+        b.append("currSpeed=").append(currSpeed);
+        b.append(", ");
+        b.append("maxSpeed=").append(maxSpeed);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortDescVer12 other = (OFPortDescVer12) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (config == null) {
+            if (other.config != null)
+                return false;
+        } else if (!config.equals(other.config))
+            return false;
+        if (state == null) {
+            if (other.state != null)
+                return false;
+        } else if (!state.equals(other.state))
+            return false;
+        if (curr == null) {
+            if (other.curr != null)
+                return false;
+        } else if (!curr.equals(other.curr))
+            return false;
+        if (advertised == null) {
+            if (other.advertised != null)
+                return false;
+        } else if (!advertised.equals(other.advertised))
+            return false;
+        if (supported == null) {
+            if (other.supported != null)
+                return false;
+        } else if (!supported.equals(other.supported))
+            return false;
+        if (peer == null) {
+            if (other.peer != null)
+                return false;
+        } else if (!peer.equals(other.peer))
+            return false;
+        if( currSpeed != other.currSpeed)
+            return false;
+        if( maxSpeed != other.maxSpeed)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((config == null) ? 0 : config.hashCode());
+        result = prime * result + ((state == null) ? 0 : state.hashCode());
+        result = prime * result + ((curr == null) ? 0 : curr.hashCode());
+        result = prime * result + ((advertised == null) ? 0 : advertised.hashCode());
+        result = prime * result + ((supported == null) ? 0 : supported.hashCode());
+        result = prime * result + ((peer == null) ? 0 : peer.hashCode());
+        result = prime *  (int) (currSpeed ^ (currSpeed >>> 32));
+        result = prime *  (int) (maxSpeed ^ (maxSpeed >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortFeaturesSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortFeaturesSerializerVer12.java
new file mode 100644
index 0000000..4cec3c5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortFeaturesSerializerVer12.java
@@ -0,0 +1,168 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortFeatures;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortFeaturesSerializerVer12 {
+
+    public final static int PF_10MB_HD_VAL = 0x1;
+    public final static int PF_10MB_FD_VAL = 0x2;
+    public final static int PF_100MB_HD_VAL = 0x4;
+    public final static int PF_100MB_FD_VAL = 0x8;
+    public final static int PF_1GB_HD_VAL = 0x10;
+    public final static int PF_1GB_FD_VAL = 0x20;
+    public final static int PF_10GB_FD_VAL = 0x40;
+    public final static int PF_COPPER_VAL = 0x800;
+    public final static int PF_FIBER_VAL = 0x1000;
+    public final static int PF_AUTONEG_VAL = 0x2000;
+    public final static int PF_PAUSE_VAL = 0x4000;
+    public final static int PF_PAUSE_ASYM_VAL = 0x8000;
+    public final static int PF_40GB_FD_VAL = 0x80;
+    public final static int PF_100GB_FD_VAL = 0x100;
+    public final static int PF_1TB_FD_VAL = 0x200;
+    public final static int PF_OTHER_VAL = 0x400;
+
+    public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortFeatures> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortFeatures> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortFeatures> ofWireValue(int val) {
+        EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);
+
+        if((val & PF_10MB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10MB_HD);
+        if((val & PF_10MB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10MB_FD);
+        if((val & PF_100MB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100MB_HD);
+        if((val & PF_100MB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100MB_FD);
+        if((val & PF_1GB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1GB_HD);
+        if((val & PF_1GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1GB_FD);
+        if((val & PF_10GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10GB_FD);
+        if((val & PF_COPPER_VAL) != 0)
+            set.add(OFPortFeatures.PF_COPPER);
+        if((val & PF_FIBER_VAL) != 0)
+            set.add(OFPortFeatures.PF_FIBER);
+        if((val & PF_AUTONEG_VAL) != 0)
+            set.add(OFPortFeatures.PF_AUTONEG);
+        if((val & PF_PAUSE_VAL) != 0)
+            set.add(OFPortFeatures.PF_PAUSE);
+        if((val & PF_PAUSE_ASYM_VAL) != 0)
+            set.add(OFPortFeatures.PF_PAUSE_ASYM);
+        if((val & PF_40GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_40GB_FD);
+        if((val & PF_100GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100GB_FD);
+        if((val & PF_1TB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1TB_FD);
+        if((val & PF_OTHER_VAL) != 0)
+            set.add(OFPortFeatures.PF_OTHER);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortFeatures> set) {
+        int wireValue = 0;
+
+        for(OFPortFeatures e: set) {
+            switch(e) {
+                case PF_10MB_HD:
+                    wireValue |= PF_10MB_HD_VAL;
+                    break;
+                case PF_10MB_FD:
+                    wireValue |= PF_10MB_FD_VAL;
+                    break;
+                case PF_100MB_HD:
+                    wireValue |= PF_100MB_HD_VAL;
+                    break;
+                case PF_100MB_FD:
+                    wireValue |= PF_100MB_FD_VAL;
+                    break;
+                case PF_1GB_HD:
+                    wireValue |= PF_1GB_HD_VAL;
+                    break;
+                case PF_1GB_FD:
+                    wireValue |= PF_1GB_FD_VAL;
+                    break;
+                case PF_10GB_FD:
+                    wireValue |= PF_10GB_FD_VAL;
+                    break;
+                case PF_COPPER:
+                    wireValue |= PF_COPPER_VAL;
+                    break;
+                case PF_FIBER:
+                    wireValue |= PF_FIBER_VAL;
+                    break;
+                case PF_AUTONEG:
+                    wireValue |= PF_AUTONEG_VAL;
+                    break;
+                case PF_PAUSE:
+                    wireValue |= PF_PAUSE_VAL;
+                    break;
+                case PF_PAUSE_ASYM:
+                    wireValue |= PF_PAUSE_ASYM_VAL;
+                    break;
+                case PF_40GB_FD:
+                    wireValue |= PF_40GB_FD_VAL;
+                    break;
+                case PF_100GB_FD:
+                    wireValue |= PF_100GB_FD_VAL;
+                    break;
+                case PF_1TB_FD:
+                    wireValue |= PF_1TB_FD_VAL;
+                    break;
+                case PF_OTHER:
+                    wireValue |= PF_OTHER_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortFeatures in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModFailedCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModFailedCodeSerializerVer12.java
new file mode 100644
index 0000000..e30a18c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModFailedCodeSerializerVer12.java
@@ -0,0 +1,89 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPortModFailedCodeSerializerVer12 {
+
+    public final static short BAD_PORT_VAL = (short) 0x0;
+    public final static short BAD_HW_ADDR_VAL = (short) 0x1;
+    public final static short BAD_CONFIG_VAL = (short) 0x2;
+    public final static short BAD_ADVERTISE_VAL = (short) 0x3;
+    public final static short EPERM_VAL = (short) 0x4;
+
+    public static OFPortModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPortModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFPortModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFPortModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_PORT_VAL:
+                return OFPortModFailedCode.BAD_PORT;
+            case BAD_HW_ADDR_VAL:
+                return OFPortModFailedCode.BAD_HW_ADDR;
+            case BAD_CONFIG_VAL:
+                return OFPortModFailedCode.BAD_CONFIG;
+            case BAD_ADVERTISE_VAL:
+                return OFPortModFailedCode.BAD_ADVERTISE;
+            case EPERM_VAL:
+                return OFPortModFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPortModFailedCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFPortModFailedCode e) {
+        switch(e) {
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_HW_ADDR:
+                return BAD_HW_ADDR_VAL;
+            case BAD_CONFIG:
+                return BAD_CONFIG_VAL;
+            case BAD_ADVERTISE:
+                return BAD_ADVERTISE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPortModFailedCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModFailedErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModFailedErrorMsgVer12.java
new file mode 100644
index 0000000..456c07e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModFailedErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortModFailedErrorMsgVer12 implements OFPortModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortModFailedErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFPortModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortModFailedErrorMsgVer12(long xid, OFPortModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFPortModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortModFailedErrorMsg.Builder {
+        final OFPortModFailedErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFPortModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFPortModFailedErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setCode(OFPortModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPortModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPortModFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFPortModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setCode(OFPortModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPortModFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortModFailedErrorMsg> {
+        @Override
+        public OFPortModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 7
+            short errType = bb.readShort();
+            if(errType != (short) 0x7)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.PORT_MOD_FAILED(7), got="+errType);
+            OFPortModFailedCode code = OFPortModFailedCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFPortModFailedErrorMsgVer12 portModFailedErrorMsgVer12 = new OFPortModFailedErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portModFailedErrorMsgVer12);
+            return portModFailedErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortModFailedErrorMsgVer12Funnel FUNNEL = new OFPortModFailedErrorMsgVer12Funnel();
+    static class OFPortModFailedErrorMsgVer12Funnel implements Funnel<OFPortModFailedErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortModFailedErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 7
+            sink.putShort((short) 0x7);
+            OFPortModFailedCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortModFailedErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortModFailedErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 7
+            bb.writeShort((short) 0x7);
+            OFPortModFailedCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortModFailedErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortModFailedErrorMsgVer12 other = (OFPortModFailedErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModVer12.java
new file mode 100644
index 0000000..0ec0e70
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortModVer12.java
@@ -0,0 +1,532 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortModVer12 implements OFPortMod {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortModVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 40;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static long DEFAULT_CONFIG = 0x0L;
+        private final static long DEFAULT_MASK = 0x0L;
+        private final static long DEFAULT_ADVERTISE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort portNo;
+    private final MacAddress hwAddr;
+    private final long config;
+    private final long mask;
+    private final long advertise;
+//
+    // Immutable default instance
+    final static OFPortModVer12 DEFAULT = new OFPortModVer12(
+        DEFAULT_XID, DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_CONFIG, DEFAULT_MASK, DEFAULT_ADVERTISE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortModVer12(long xid, OFPort portNo, MacAddress hwAddr, long config, long mask, long advertise) {
+        this.xid = xid;
+        this.portNo = portNo;
+        this.hwAddr = hwAddr;
+        this.config = config;
+        this.mask = mask;
+        this.advertise = advertise;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+
+
+    public OFPortMod.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortMod.Builder {
+        final OFPortModVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean configSet;
+        private long config;
+        private boolean maskSet;
+        private long mask;
+        private boolean advertiseSet;
+        private long advertise;
+
+        BuilderWithParent(OFPortModVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortMod.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortMod.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFPortMod.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+    @Override
+    public OFPortMod.Builder setAdvertise(long advertise) {
+        this.advertise = advertise;
+        this.advertiseSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortMod build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                long config = this.configSet ? this.config : parentMessage.config;
+                long mask = this.maskSet ? this.mask : parentMessage.mask;
+                long advertise = this.advertiseSet ? this.advertise : parentMessage.advertise;
+
+                //
+                return new OFPortModVer12(
+                    xid,
+                    portNo,
+                    hwAddr,
+                    config,
+                    mask,
+                    advertise
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortMod.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean configSet;
+        private long config;
+        private boolean maskSet;
+        private long mask;
+        private boolean advertiseSet;
+        private long advertise;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortMod.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortMod.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFPortMod.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+    @Override
+    public OFPortMod.Builder setAdvertise(long advertise) {
+        this.advertise = advertise;
+        this.advertiseSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortMod build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+            long mask = this.maskSet ? this.mask : DEFAULT_MASK;
+            long advertise = this.advertiseSet ? this.advertise : DEFAULT_ADVERTISE;
+
+
+            return new OFPortModVer12(
+                    xid,
+                    portNo,
+                    hwAddr,
+                    config,
+                    mask,
+                    advertise
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortMod> {
+        @Override
+        public OFPortMod readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.PORT_MOD(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 40)
+                throw new OFParseError("Wrong length: Expected=40(40), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long config = U32.f(bb.readInt());
+            long mask = U32.f(bb.readInt());
+            long advertise = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFPortModVer12 portModVer12 = new OFPortModVer12(
+                    xid,
+                      portNo,
+                      hwAddr,
+                      config,
+                      mask,
+                      advertise
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portModVer12);
+            return portModVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortModVer12Funnel FUNNEL = new OFPortModVer12Funnel();
+    static class OFPortModVer12Funnel implements Funnel<OFPortModVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortModVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 40
+            sink.putShort((short) 0x28);
+            sink.putLong(message.xid);
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.config);
+            sink.putLong(message.mask);
+            sink.putLong(message.advertise);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortModVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortModVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 40
+            bb.writeShort((short) 0x28);
+            bb.writeInt(U32.t(message.xid));
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.config));
+            bb.writeInt(U32.t(message.mask));
+            bb.writeInt(U32.t(message.advertise));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortModVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(", ");
+        b.append("advertise=").append(advertise);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortModVer12 other = (OFPortModVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if( config != other.config)
+            return false;
+        if( mask != other.mask)
+            return false;
+        if( advertise != other.advertise)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime *  (int) (config ^ (config >>> 32));
+        result = prime *  (int) (mask ^ (mask >>> 32));
+        result = prime *  (int) (advertise ^ (advertise >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortReasonSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortReasonSerializerVer12.java
new file mode 100644
index 0000000..f27c9f5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortReasonSerializerVer12.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPortReasonSerializerVer12 {
+
+    public final static byte ADD_VAL = (byte) 0x0;
+    public final static byte DELETE_VAL = (byte) 0x1;
+    public final static byte MODIFY_VAL = (byte) 0x2;
+
+    public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPortReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFPortReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFPortReason ofWireValue(byte val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFPortReason.ADD;
+            case DELETE_VAL:
+                return OFPortReason.DELETE;
+            case MODIFY_VAL:
+                return OFPortReason.MODIFY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.2: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFPortReason e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStateSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStateSerializerVer12.java
new file mode 100644
index 0000000..135c957
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStateSerializerVer12.java
@@ -0,0 +1,90 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortState;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortStateSerializerVer12 {
+
+    public final static int LINK_DOWN_VAL = 0x1;
+    public final static int BLOCKED_VAL = 0x2;
+    public final static int LIVE_VAL = 0x4;
+
+    public static Set<OFPortState> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortState> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortState> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortState> ofWireValue(int val) {
+        EnumSet<OFPortState> set = EnumSet.noneOf(OFPortState.class);
+
+        if((val & LINK_DOWN_VAL) != 0)
+            set.add(OFPortState.LINK_DOWN);
+        if((val & BLOCKED_VAL) != 0)
+            set.add(OFPortState.BLOCKED);
+        if((val & LIVE_VAL) != 0)
+            set.add(OFPortState.LIVE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortState> set) {
+        int wireValue = 0;
+
+        for(OFPortState e: set) {
+            switch(e) {
+                case LINK_DOWN:
+                    wireValue |= LINK_DOWN_VAL;
+                    break;
+                case BLOCKED:
+                    wireValue |= BLOCKED_VAL;
+                    break;
+                case LIVE:
+                    wireValue |= LIVE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsEntryVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsEntryVer12.java
new file mode 100644
index 0000000..555dd39
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsEntryVer12.java
@@ -0,0 +1,928 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsEntryVer12 implements OFPortStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsEntryVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 104;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static U64 DEFAULT_RX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_RX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_RX_DROPPED = U64.ZERO;
+        private final static U64 DEFAULT_TX_DROPPED = U64.ZERO;
+        private final static U64 DEFAULT_RX_ERRORS = U64.ZERO;
+        private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
+        private final static U64 DEFAULT_RX_FRAME_ERR = U64.ZERO;
+        private final static U64 DEFAULT_RX_OVER_ERR = U64.ZERO;
+        private final static U64 DEFAULT_RX_CRC_ERR = U64.ZERO;
+        private final static U64 DEFAULT_COLLISIONS = U64.ZERO;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final U64 rxPackets;
+    private final U64 txPackets;
+    private final U64 rxBytes;
+    private final U64 txBytes;
+    private final U64 rxDropped;
+    private final U64 txDropped;
+    private final U64 rxErrors;
+    private final U64 txErrors;
+    private final U64 rxFrameErr;
+    private final U64 rxOverErr;
+    private final U64 rxCrcErr;
+    private final U64 collisions;
+//
+    // Immutable default instance
+    final static OFPortStatsEntryVer12 DEFAULT = new OFPortStatsEntryVer12(
+        DEFAULT_PORT_NO, DEFAULT_RX_PACKETS, DEFAULT_TX_PACKETS, DEFAULT_RX_BYTES, DEFAULT_TX_BYTES, DEFAULT_RX_DROPPED, DEFAULT_TX_DROPPED, DEFAULT_RX_ERRORS, DEFAULT_TX_ERRORS, DEFAULT_RX_FRAME_ERR, DEFAULT_RX_OVER_ERR, DEFAULT_RX_CRC_ERR, DEFAULT_COLLISIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsEntryVer12(OFPort portNo, U64 rxPackets, U64 txPackets, U64 rxBytes, U64 txBytes, U64 rxDropped, U64 txDropped, U64 rxErrors, U64 txErrors, U64 rxFrameErr, U64 rxOverErr, U64 rxCrcErr, U64 collisions) {
+        this.portNo = portNo;
+        this.rxPackets = rxPackets;
+        this.txPackets = txPackets;
+        this.rxBytes = rxBytes;
+        this.txBytes = txBytes;
+        this.rxDropped = rxDropped;
+        this.txDropped = txDropped;
+        this.rxErrors = rxErrors;
+        this.txErrors = txErrors;
+        this.rxFrameErr = rxFrameErr;
+        this.rxOverErr = rxOverErr;
+        this.rxCrcErr = rxCrcErr;
+        this.collisions = collisions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFPortStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsEntry.Builder {
+        final OFPortStatsEntryVer12 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean rxPacketsSet;
+        private U64 rxPackets;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean rxBytesSet;
+        private U64 rxBytes;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean rxDroppedSet;
+        private U64 rxDropped;
+        private boolean txDroppedSet;
+        private U64 txDropped;
+        private boolean rxErrorsSet;
+        private U64 rxErrors;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean rxFrameErrSet;
+        private U64 rxFrameErr;
+        private boolean rxOverErrSet;
+        private U64 rxOverErr;
+        private boolean rxCrcErrSet;
+        private U64 rxCrcErr;
+        private boolean collisionsSet;
+        private U64 collisions;
+
+        BuilderWithParent(OFPortStatsEntryVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxPackets(U64 rxPackets) {
+        this.rxPackets = rxPackets;
+        this.rxPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxBytes(U64 rxBytes) {
+        this.rxBytes = rxBytes;
+        this.rxBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxDropped(U64 rxDropped) {
+        this.rxDropped = rxDropped;
+        this.rxDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxDropped(U64 txDropped) {
+        this.txDropped = txDropped;
+        this.txDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxErrors(U64 rxErrors) {
+        this.rxErrors = rxErrors;
+        this.rxErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxFrameErr(U64 rxFrameErr) {
+        this.rxFrameErr = rxFrameErr;
+        this.rxFrameErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxOverErr(U64 rxOverErr) {
+        this.rxOverErr = rxOverErr;
+        this.rxOverErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxCrcErr(U64 rxCrcErr) {
+        this.rxCrcErr = rxCrcErr;
+        this.rxCrcErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setCollisions(U64 collisions) {
+        this.collisions = collisions;
+        this.collisionsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFPortStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                U64 rxPackets = this.rxPacketsSet ? this.rxPackets : parentMessage.rxPackets;
+                if(rxPackets == null)
+                    throw new NullPointerException("Property rxPackets must not be null");
+                U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
+                if(txPackets == null)
+                    throw new NullPointerException("Property txPackets must not be null");
+                U64 rxBytes = this.rxBytesSet ? this.rxBytes : parentMessage.rxBytes;
+                if(rxBytes == null)
+                    throw new NullPointerException("Property rxBytes must not be null");
+                U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
+                if(txBytes == null)
+                    throw new NullPointerException("Property txBytes must not be null");
+                U64 rxDropped = this.rxDroppedSet ? this.rxDropped : parentMessage.rxDropped;
+                if(rxDropped == null)
+                    throw new NullPointerException("Property rxDropped must not be null");
+                U64 txDropped = this.txDroppedSet ? this.txDropped : parentMessage.txDropped;
+                if(txDropped == null)
+                    throw new NullPointerException("Property txDropped must not be null");
+                U64 rxErrors = this.rxErrorsSet ? this.rxErrors : parentMessage.rxErrors;
+                if(rxErrors == null)
+                    throw new NullPointerException("Property rxErrors must not be null");
+                U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
+                if(txErrors == null)
+                    throw new NullPointerException("Property txErrors must not be null");
+                U64 rxFrameErr = this.rxFrameErrSet ? this.rxFrameErr : parentMessage.rxFrameErr;
+                if(rxFrameErr == null)
+                    throw new NullPointerException("Property rxFrameErr must not be null");
+                U64 rxOverErr = this.rxOverErrSet ? this.rxOverErr : parentMessage.rxOverErr;
+                if(rxOverErr == null)
+                    throw new NullPointerException("Property rxOverErr must not be null");
+                U64 rxCrcErr = this.rxCrcErrSet ? this.rxCrcErr : parentMessage.rxCrcErr;
+                if(rxCrcErr == null)
+                    throw new NullPointerException("Property rxCrcErr must not be null");
+                U64 collisions = this.collisionsSet ? this.collisions : parentMessage.collisions;
+                if(collisions == null)
+                    throw new NullPointerException("Property collisions must not be null");
+
+                //
+                return new OFPortStatsEntryVer12(
+                    portNo,
+                    rxPackets,
+                    txPackets,
+                    rxBytes,
+                    txBytes,
+                    rxDropped,
+                    txDropped,
+                    rxErrors,
+                    txErrors,
+                    rxFrameErr,
+                    rxOverErr,
+                    rxCrcErr,
+                    collisions
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean rxPacketsSet;
+        private U64 rxPackets;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean rxBytesSet;
+        private U64 rxBytes;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean rxDroppedSet;
+        private U64 rxDropped;
+        private boolean txDroppedSet;
+        private U64 txDropped;
+        private boolean rxErrorsSet;
+        private U64 rxErrors;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean rxFrameErrSet;
+        private U64 rxFrameErr;
+        private boolean rxOverErrSet;
+        private U64 rxOverErr;
+        private boolean rxCrcErrSet;
+        private U64 rxCrcErr;
+        private boolean collisionsSet;
+        private U64 collisions;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxPackets(U64 rxPackets) {
+        this.rxPackets = rxPackets;
+        this.rxPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxBytes(U64 rxBytes) {
+        this.rxBytes = rxBytes;
+        this.rxBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxDropped(U64 rxDropped) {
+        this.rxDropped = rxDropped;
+        this.rxDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxDropped(U64 txDropped) {
+        this.txDropped = txDropped;
+        this.txDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxErrors(U64 rxErrors) {
+        this.rxErrors = rxErrors;
+        this.rxErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxFrameErr(U64 rxFrameErr) {
+        this.rxFrameErr = rxFrameErr;
+        this.rxFrameErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxOverErr(U64 rxOverErr) {
+        this.rxOverErr = rxOverErr;
+        this.rxOverErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxCrcErr(U64 rxCrcErr) {
+        this.rxCrcErr = rxCrcErr;
+        this.rxCrcErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setCollisions(U64 collisions) {
+        this.collisions = collisions;
+        this.collisionsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFPortStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            U64 rxPackets = this.rxPacketsSet ? this.rxPackets : DEFAULT_RX_PACKETS;
+            if(rxPackets == null)
+                throw new NullPointerException("Property rxPackets must not be null");
+            U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
+            if(txPackets == null)
+                throw new NullPointerException("Property txPackets must not be null");
+            U64 rxBytes = this.rxBytesSet ? this.rxBytes : DEFAULT_RX_BYTES;
+            if(rxBytes == null)
+                throw new NullPointerException("Property rxBytes must not be null");
+            U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
+            if(txBytes == null)
+                throw new NullPointerException("Property txBytes must not be null");
+            U64 rxDropped = this.rxDroppedSet ? this.rxDropped : DEFAULT_RX_DROPPED;
+            if(rxDropped == null)
+                throw new NullPointerException("Property rxDropped must not be null");
+            U64 txDropped = this.txDroppedSet ? this.txDropped : DEFAULT_TX_DROPPED;
+            if(txDropped == null)
+                throw new NullPointerException("Property txDropped must not be null");
+            U64 rxErrors = this.rxErrorsSet ? this.rxErrors : DEFAULT_RX_ERRORS;
+            if(rxErrors == null)
+                throw new NullPointerException("Property rxErrors must not be null");
+            U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
+            if(txErrors == null)
+                throw new NullPointerException("Property txErrors must not be null");
+            U64 rxFrameErr = this.rxFrameErrSet ? this.rxFrameErr : DEFAULT_RX_FRAME_ERR;
+            if(rxFrameErr == null)
+                throw new NullPointerException("Property rxFrameErr must not be null");
+            U64 rxOverErr = this.rxOverErrSet ? this.rxOverErr : DEFAULT_RX_OVER_ERR;
+            if(rxOverErr == null)
+                throw new NullPointerException("Property rxOverErr must not be null");
+            U64 rxCrcErr = this.rxCrcErrSet ? this.rxCrcErr : DEFAULT_RX_CRC_ERR;
+            if(rxCrcErr == null)
+                throw new NullPointerException("Property rxCrcErr must not be null");
+            U64 collisions = this.collisionsSet ? this.collisions : DEFAULT_COLLISIONS;
+            if(collisions == null)
+                throw new NullPointerException("Property collisions must not be null");
+
+
+            return new OFPortStatsEntryVer12(
+                    portNo,
+                    rxPackets,
+                    txPackets,
+                    rxBytes,
+                    txBytes,
+                    rxDropped,
+                    txDropped,
+                    rxErrors,
+                    txErrors,
+                    rxFrameErr,
+                    rxOverErr,
+                    rxCrcErr,
+                    collisions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsEntry> {
+        @Override
+        public OFPortStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 rxPackets = U64.ofRaw(bb.readLong());
+            U64 txPackets = U64.ofRaw(bb.readLong());
+            U64 rxBytes = U64.ofRaw(bb.readLong());
+            U64 txBytes = U64.ofRaw(bb.readLong());
+            U64 rxDropped = U64.ofRaw(bb.readLong());
+            U64 txDropped = U64.ofRaw(bb.readLong());
+            U64 rxErrors = U64.ofRaw(bb.readLong());
+            U64 txErrors = U64.ofRaw(bb.readLong());
+            U64 rxFrameErr = U64.ofRaw(bb.readLong());
+            U64 rxOverErr = U64.ofRaw(bb.readLong());
+            U64 rxCrcErr = U64.ofRaw(bb.readLong());
+            U64 collisions = U64.ofRaw(bb.readLong());
+
+            OFPortStatsEntryVer12 portStatsEntryVer12 = new OFPortStatsEntryVer12(
+                    portNo,
+                      rxPackets,
+                      txPackets,
+                      rxBytes,
+                      txBytes,
+                      rxDropped,
+                      txDropped,
+                      rxErrors,
+                      txErrors,
+                      rxFrameErr,
+                      rxOverErr,
+                      rxCrcErr,
+                      collisions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsEntryVer12);
+            return portStatsEntryVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsEntryVer12Funnel FUNNEL = new OFPortStatsEntryVer12Funnel();
+    static class OFPortStatsEntryVer12Funnel implements Funnel<OFPortStatsEntryVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsEntryVer12 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.rxPackets.putTo(sink);
+            message.txPackets.putTo(sink);
+            message.rxBytes.putTo(sink);
+            message.txBytes.putTo(sink);
+            message.rxDropped.putTo(sink);
+            message.txDropped.putTo(sink);
+            message.rxErrors.putTo(sink);
+            message.txErrors.putTo(sink);
+            message.rxFrameErr.putTo(sink);
+            message.rxOverErr.putTo(sink);
+            message.rxCrcErr.putTo(sink);
+            message.collisions.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsEntryVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsEntryVer12 message) {
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.rxPackets.getValue());
+            bb.writeLong(message.txPackets.getValue());
+            bb.writeLong(message.rxBytes.getValue());
+            bb.writeLong(message.txBytes.getValue());
+            bb.writeLong(message.rxDropped.getValue());
+            bb.writeLong(message.txDropped.getValue());
+            bb.writeLong(message.rxErrors.getValue());
+            bb.writeLong(message.txErrors.getValue());
+            bb.writeLong(message.rxFrameErr.getValue());
+            bb.writeLong(message.rxOverErr.getValue());
+            bb.writeLong(message.rxCrcErr.getValue());
+            bb.writeLong(message.collisions.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsEntryVer12(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("rxPackets=").append(rxPackets);
+        b.append(", ");
+        b.append("txPackets=").append(txPackets);
+        b.append(", ");
+        b.append("rxBytes=").append(rxBytes);
+        b.append(", ");
+        b.append("txBytes=").append(txBytes);
+        b.append(", ");
+        b.append("rxDropped=").append(rxDropped);
+        b.append(", ");
+        b.append("txDropped=").append(txDropped);
+        b.append(", ");
+        b.append("rxErrors=").append(rxErrors);
+        b.append(", ");
+        b.append("txErrors=").append(txErrors);
+        b.append(", ");
+        b.append("rxFrameErr=").append(rxFrameErr);
+        b.append(", ");
+        b.append("rxOverErr=").append(rxOverErr);
+        b.append(", ");
+        b.append("rxCrcErr=").append(rxCrcErr);
+        b.append(", ");
+        b.append("collisions=").append(collisions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsEntryVer12 other = (OFPortStatsEntryVer12) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (rxPackets == null) {
+            if (other.rxPackets != null)
+                return false;
+        } else if (!rxPackets.equals(other.rxPackets))
+            return false;
+        if (txPackets == null) {
+            if (other.txPackets != null)
+                return false;
+        } else if (!txPackets.equals(other.txPackets))
+            return false;
+        if (rxBytes == null) {
+            if (other.rxBytes != null)
+                return false;
+        } else if (!rxBytes.equals(other.rxBytes))
+            return false;
+        if (txBytes == null) {
+            if (other.txBytes != null)
+                return false;
+        } else if (!txBytes.equals(other.txBytes))
+            return false;
+        if (rxDropped == null) {
+            if (other.rxDropped != null)
+                return false;
+        } else if (!rxDropped.equals(other.rxDropped))
+            return false;
+        if (txDropped == null) {
+            if (other.txDropped != null)
+                return false;
+        } else if (!txDropped.equals(other.txDropped))
+            return false;
+        if (rxErrors == null) {
+            if (other.rxErrors != null)
+                return false;
+        } else if (!rxErrors.equals(other.rxErrors))
+            return false;
+        if (txErrors == null) {
+            if (other.txErrors != null)
+                return false;
+        } else if (!txErrors.equals(other.txErrors))
+            return false;
+        if (rxFrameErr == null) {
+            if (other.rxFrameErr != null)
+                return false;
+        } else if (!rxFrameErr.equals(other.rxFrameErr))
+            return false;
+        if (rxOverErr == null) {
+            if (other.rxOverErr != null)
+                return false;
+        } else if (!rxOverErr.equals(other.rxOverErr))
+            return false;
+        if (rxCrcErr == null) {
+            if (other.rxCrcErr != null)
+                return false;
+        } else if (!rxCrcErr.equals(other.rxCrcErr))
+            return false;
+        if (collisions == null) {
+            if (other.collisions != null)
+                return false;
+        } else if (!collisions.equals(other.collisions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((rxPackets == null) ? 0 : rxPackets.hashCode());
+        result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
+        result = prime * result + ((rxBytes == null) ? 0 : rxBytes.hashCode());
+        result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
+        result = prime * result + ((rxDropped == null) ? 0 : rxDropped.hashCode());
+        result = prime * result + ((txDropped == null) ? 0 : txDropped.hashCode());
+        result = prime * result + ((rxErrors == null) ? 0 : rxErrors.hashCode());
+        result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
+        result = prime * result + ((rxFrameErr == null) ? 0 : rxFrameErr.hashCode());
+        result = prime * result + ((rxOverErr == null) ? 0 : rxOverErr.hashCode());
+        result = prime * result + ((rxCrcErr == null) ? 0 : rxCrcErr.hashCode());
+        result = prime * result + ((collisions == null) ? 0 : collisions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsReplyVer12.java
new file mode 100644
index 0000000..a4b5c1e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsReplyVer12.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsReplyVer12 implements OFPortStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFPortStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFPortStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFPortStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFPortStatsReplyVer12 DEFAULT = new OFPortStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, List<OFPortStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFPortStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsReply.Builder {
+        final OFPortStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortStatsEntry> entries;
+
+        BuilderWithParent(OFPortStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setEntries(List<OFPortStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFPortStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFPortStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setEntries(List<OFPortStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFPortStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFPortStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsReply> {
+        @Override
+        public OFPortStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 4
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x4)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFPortStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPortStatsEntryVer12.READER);
+
+            OFPortStatsReplyVer12 portStatsReplyVer12 = new OFPortStatsReplyVer12(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsReplyVer12);
+            return portStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsReplyVer12Funnel FUNNEL = new OFPortStatsReplyVer12Funnel();
+    static class OFPortStatsReplyVer12Funnel implements Funnel<OFPortStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 4
+            sink.putShort((short) 0x4);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 4
+            bb.writeShort((short) 0x4);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsReplyVer12 other = (OFPortStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsRequestVer12.java
new file mode 100644
index 0000000..d421a73
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatsRequestVer12.java
@@ -0,0 +1,410 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsRequestVer12 implements OFPortStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+//
+    // Immutable default instance
+    final static OFPortStatsRequestVer12 DEFAULT = new OFPortStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+
+
+    public OFPortStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsRequest.Builder {
+        final OFPortStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+        BuilderWithParent(OFPortStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+
+                //
+                return new OFPortStatsRequestVer12(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+
+
+            return new OFPortStatsRequestVer12(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsRequest> {
+        @Override
+        public OFPortStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 4
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x4)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFPortStatsRequestVer12 portStatsRequestVer12 = new OFPortStatsRequestVer12(
+                    xid,
+                      flags,
+                      portNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsRequestVer12);
+            return portStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsRequestVer12Funnel FUNNEL = new OFPortStatsRequestVer12Funnel();
+    static class OFPortStatsRequestVer12Funnel implements Funnel<OFPortStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 4
+            sink.putShort((short) 0x4);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 4
+            bb.writeShort((short) 0x4);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsRequestVer12 other = (OFPortStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatusVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatusVer12.java
new file mode 100644
index 0000000..64af3fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFPortStatusVer12.java
@@ -0,0 +1,377 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatusVer12 implements OFPortStatus {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatusVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 80;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFPortReason reason;
+    private final OFPortDesc desc;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatusVer12(long xid, OFPortReason reason, OFPortDesc desc) {
+        this.xid = xid;
+        this.reason = reason;
+        this.desc = desc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+
+
+    public OFPortStatus.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatus.Builder {
+        final OFPortStatusVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reasonSet;
+        private OFPortReason reason;
+        private boolean descSet;
+        private OFPortDesc desc;
+
+        BuilderWithParent(OFPortStatusVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortStatus.Builder setReason(OFPortReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+    @Override
+    public OFPortStatus.Builder setDesc(OFPortDesc desc) {
+        this.desc = desc;
+        this.descSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatus build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPortReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                OFPortDesc desc = this.descSet ? this.desc : parentMessage.desc;
+                if(desc == null)
+                    throw new NullPointerException("Property desc must not be null");
+
+                //
+                return new OFPortStatusVer12(
+                    xid,
+                    reason,
+                    desc
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatus.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reasonSet;
+        private OFPortReason reason;
+        private boolean descSet;
+        private OFPortDesc desc;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortStatus.Builder setReason(OFPortReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+    @Override
+    public OFPortStatus.Builder setDesc(OFPortDesc desc) {
+        this.desc = desc;
+        this.descSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatus build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            if(!this.descSet)
+                throw new IllegalStateException("Property desc doesn't have default value -- must be set");
+            if(desc == null)
+                throw new NullPointerException("Property desc must not be null");
+
+
+            return new OFPortStatusVer12(
+                    xid,
+                    reason,
+                    desc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatus> {
+        @Override
+        public OFPortStatus readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 12
+            byte type = bb.readByte();
+            if(type != (byte) 0xc)
+                throw new OFParseError("Wrong type: Expected=OFType.PORT_STATUS(12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 80)
+                throw new OFParseError("Wrong length: Expected=80(80), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPortReason reason = OFPortReasonSerializerVer12.readFrom(bb);
+            // pad: 7 bytes
+            bb.skipBytes(7);
+            OFPortDesc desc = OFPortDescVer12.READER.readFrom(bb);
+
+            OFPortStatusVer12 portStatusVer12 = new OFPortStatusVer12(
+                    xid,
+                      reason,
+                      desc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatusVer12);
+            return portStatusVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatusVer12Funnel FUNNEL = new OFPortStatusVer12Funnel();
+    static class OFPortStatusVer12Funnel implements Funnel<OFPortStatusVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatusVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 12
+            sink.putByte((byte) 0xc);
+            // fixed value property length = 80
+            sink.putShort((short) 0x50);
+            sink.putLong(message.xid);
+            OFPortReasonSerializerVer12.putTo(message.reason, sink);
+            // skip pad (7 bytes)
+            message.desc.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatusVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatusVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 12
+            bb.writeByte((byte) 0xc);
+            // fixed value property length = 80
+            bb.writeShort((short) 0x50);
+            bb.writeInt(U32.t(message.xid));
+            OFPortReasonSerializerVer12.writeTo(bb, message.reason);
+            // pad: 7 bytes
+            bb.writeZero(7);
+            message.desc.writeTo(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatusVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("desc=").append(desc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatusVer12 other = (OFPortStatusVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (desc == null) {
+            if (other.desc != null)
+                return false;
+        } else if (!desc.equals(other.desc))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + ((desc == null) ? 0 : desc.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueGetConfigReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueGetConfigReplyVer12.java
new file mode 100644
index 0000000..67c39c6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueGetConfigReplyVer12.java
@@ -0,0 +1,388 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueGetConfigReplyVer12 implements OFQueueGetConfigReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueGetConfigReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static List<OFPacketQueue> DEFAULT_QUEUES = ImmutableList.<OFPacketQueue>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFPort port;
+    private final List<OFPacketQueue> queues;
+//
+    // Immutable default instance
+    final static OFQueueGetConfigReplyVer12 DEFAULT = new OFQueueGetConfigReplyVer12(
+        DEFAULT_XID, DEFAULT_PORT, DEFAULT_QUEUES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueGetConfigReplyVer12(long xid, OFPort port, List<OFPacketQueue> queues) {
+        this.xid = xid;
+        this.port = port;
+        this.queues = queues;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+
+
+    public OFQueueGetConfigReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueGetConfigReply.Builder {
+        final OFQueueGetConfigReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+        private boolean queuesSet;
+        private List<OFPacketQueue> queues;
+
+        BuilderWithParent(OFQueueGetConfigReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setQueues(List<OFPacketQueue> queues) {
+        this.queues = queues;
+        this.queuesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueGetConfigReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                List<OFPacketQueue> queues = this.queuesSet ? this.queues : parentMessage.queues;
+                if(queues == null)
+                    throw new NullPointerException("Property queues must not be null");
+
+                //
+                return new OFQueueGetConfigReplyVer12(
+                    xid,
+                    port,
+                    queues
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueGetConfigReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+        private boolean queuesSet;
+        private List<OFPacketQueue> queues;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setQueues(List<OFPacketQueue> queues) {
+        this.queues = queues;
+        this.queuesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueGetConfigReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            List<OFPacketQueue> queues = this.queuesSet ? this.queues : DEFAULT_QUEUES;
+            if(queues == null)
+                throw new NullPointerException("Property queues must not be null");
+
+
+            return new OFQueueGetConfigReplyVer12(
+                    xid,
+                    port,
+                    queues
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueGetConfigReply> {
+        @Override
+        public OFQueueGetConfigReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 23
+            byte type = bb.readByte();
+            if(type != (byte) 0x17)
+                throw new OFParseError("Wrong type: Expected=OFType.QUEUE_GET_CONFIG_REPLY(23), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort port = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFPacketQueue> queues = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPacketQueueVer12.READER);
+
+            OFQueueGetConfigReplyVer12 queueGetConfigReplyVer12 = new OFQueueGetConfigReplyVer12(
+                    xid,
+                      port,
+                      queues
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueGetConfigReplyVer12);
+            return queueGetConfigReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueGetConfigReplyVer12Funnel FUNNEL = new OFQueueGetConfigReplyVer12Funnel();
+    static class OFQueueGetConfigReplyVer12Funnel implements Funnel<OFQueueGetConfigReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueGetConfigReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 23
+            sink.putByte((byte) 0x17);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.port.putTo(sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.queues, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueGetConfigReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueGetConfigReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 23
+            bb.writeByte((byte) 0x17);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.port.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.queues);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueGetConfigReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("queues=").append(queues);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueGetConfigReplyVer12 other = (OFQueueGetConfigReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if (queues == null) {
+            if (other.queues != null)
+                return false;
+        } else if (!queues.equals(other.queues))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + ((queues == null) ? 0 : queues.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueGetConfigRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueGetConfigRequestVer12.java
new file mode 100644
index 0000000..7a555e2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueGetConfigRequestVer12.java
@@ -0,0 +1,327 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueGetConfigRequestVer12 implements OFQueueGetConfigRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueGetConfigRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort port;
+//
+    // Immutable default instance
+    final static OFQueueGetConfigRequestVer12 DEFAULT = new OFQueueGetConfigRequestVer12(
+        DEFAULT_XID, DEFAULT_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueGetConfigRequestVer12(long xid, OFPort port) {
+        this.xid = xid;
+        this.port = port;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+
+
+    public OFQueueGetConfigRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueGetConfigRequest.Builder {
+        final OFQueueGetConfigRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+
+        BuilderWithParent(OFQueueGetConfigRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueGetConfigRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+
+                //
+                return new OFQueueGetConfigRequestVer12(
+                    xid,
+                    port
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueGetConfigRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueGetConfigRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+
+
+            return new OFQueueGetConfigRequestVer12(
+                    xid,
+                    port
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueGetConfigRequest> {
+        @Override
+        public OFQueueGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 22
+            byte type = bb.readByte();
+            if(type != (byte) 0x16)
+                throw new OFParseError("Wrong type: Expected=OFType.QUEUE_GET_CONFIG_REQUEST(22), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort port = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFQueueGetConfigRequestVer12 queueGetConfigRequestVer12 = new OFQueueGetConfigRequestVer12(
+                    xid,
+                      port
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueGetConfigRequestVer12);
+            return queueGetConfigRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueGetConfigRequestVer12Funnel FUNNEL = new OFQueueGetConfigRequestVer12Funnel();
+    static class OFQueueGetConfigRequestVer12Funnel implements Funnel<OFQueueGetConfigRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueGetConfigRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 22
+            sink.putByte((byte) 0x16);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            message.port.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueGetConfigRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueGetConfigRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 22
+            bb.writeByte((byte) 0x16);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            message.port.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueGetConfigRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueGetConfigRequestVer12 other = (OFQueueGetConfigRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueOpFailedCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueOpFailedCodeSerializerVer12.java
new file mode 100644
index 0000000..2ecf5c1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueOpFailedCodeSerializerVer12.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFQueueOpFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFQueueOpFailedCodeSerializerVer12 {
+
+    public final static short BAD_PORT_VAL = (short) 0x0;
+    public final static short BAD_QUEUE_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+
+    public static OFQueueOpFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFQueueOpFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFQueueOpFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFQueueOpFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_PORT_VAL:
+                return OFQueueOpFailedCode.BAD_PORT;
+            case BAD_QUEUE_VAL:
+                return OFQueueOpFailedCode.BAD_QUEUE;
+            case EPERM_VAL:
+                return OFQueueOpFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFQueueOpFailedCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFQueueOpFailedCode e) {
+        switch(e) {
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_QUEUE:
+                return BAD_QUEUE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFQueueOpFailedCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueOpFailedErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueOpFailedErrorMsgVer12.java
new file mode 100644
index 0000000..b0110c1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueOpFailedErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueOpFailedErrorMsgVer12 implements OFQueueOpFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueOpFailedErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFQueueOpFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueOpFailedErrorMsgVer12(long xid, OFQueueOpFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFQueueOpFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueOpFailedErrorMsg.Builder {
+        final OFQueueOpFailedErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFQueueOpFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFQueueOpFailedErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setCode(OFQueueOpFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueOpFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFQueueOpFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFQueueOpFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueOpFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFQueueOpFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setCode(OFQueueOpFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueOpFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFQueueOpFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueOpFailedErrorMsg> {
+        @Override
+        public OFQueueOpFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 9
+            short errType = bb.readShort();
+            if(errType != (short) 0x9)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.QUEUE_OP_FAILED(9), got="+errType);
+            OFQueueOpFailedCode code = OFQueueOpFailedCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFQueueOpFailedErrorMsgVer12 queueOpFailedErrorMsgVer12 = new OFQueueOpFailedErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueOpFailedErrorMsgVer12);
+            return queueOpFailedErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueOpFailedErrorMsgVer12Funnel FUNNEL = new OFQueueOpFailedErrorMsgVer12Funnel();
+    static class OFQueueOpFailedErrorMsgVer12Funnel implements Funnel<OFQueueOpFailedErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueOpFailedErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 9
+            sink.putShort((short) 0x9);
+            OFQueueOpFailedCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueOpFailedErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueOpFailedErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 9
+            bb.writeShort((short) 0x9);
+            OFQueueOpFailedCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueOpFailedErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueOpFailedErrorMsgVer12 other = (OFQueueOpFailedErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropExperimenterVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropExperimenterVer12.java
new file mode 100644
index 0000000..8371bac
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropExperimenterVer12.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFQueuePropExperimenterVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFQueuePropExperimenterVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFQueuePropExperimenter> {
+        @Override
+        public OFQueuePropExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 0xffff
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=0xffff(0xffff), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFQueuePropExperimenterVer12: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropMaxRateVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropMaxRateVer12.java
new file mode 100644
index 0000000..bd2ed61
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropMaxRateVer12.java
@@ -0,0 +1,270 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueuePropMaxRateVer12 implements OFQueuePropMaxRate {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueuePropMaxRateVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static int DEFAULT_RATE = 0x0;
+
+    // OF message fields
+    private final int rate;
+//
+    // Immutable default instance
+    final static OFQueuePropMaxRateVer12 DEFAULT = new OFQueuePropMaxRateVer12(
+        DEFAULT_RATE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueuePropMaxRateVer12(int rate) {
+        this.rate = rate;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFQueuePropMaxRate.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueuePropMaxRate.Builder {
+        final OFQueuePropMaxRateVer12 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+        BuilderWithParent(OFQueuePropMaxRateVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMaxRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFQueuePropMaxRate build() {
+                int rate = this.rateSet ? this.rate : parentMessage.rate;
+
+                //
+                return new OFQueuePropMaxRateVer12(
+                    rate
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueuePropMaxRate.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMaxRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFQueuePropMaxRate build() {
+            int rate = this.rateSet ? this.rate : DEFAULT_RATE;
+
+
+            return new OFQueuePropMaxRateVer12(
+                    rate
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueuePropMaxRate> {
+        @Override
+        public OFQueuePropMaxRate readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=0x2(0x2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int rate = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFQueuePropMaxRateVer12 queuePropMaxRateVer12 = new OFQueuePropMaxRateVer12(
+                    rate
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queuePropMaxRateVer12);
+            return queuePropMaxRateVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueuePropMaxRateVer12Funnel FUNNEL = new OFQueuePropMaxRateVer12Funnel();
+    static class OFQueuePropMaxRateVer12Funnel implements Funnel<OFQueuePropMaxRateVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueuePropMaxRateVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 0x2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // skip pad (4 bytes)
+            sink.putInt(message.rate);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueuePropMaxRateVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueuePropMaxRateVer12 message) {
+            // fixed value property type = 0x2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeShort(U16.t(message.rate));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueuePropMaxRateVer12(");
+        b.append("rate=").append(rate);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueuePropMaxRateVer12 other = (OFQueuePropMaxRateVer12) obj;
+
+        if( rate != other.rate)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + rate;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropMinRateVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropMinRateVer12.java
new file mode 100644
index 0000000..603a3e8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropMinRateVer12.java
@@ -0,0 +1,270 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueuePropMinRateVer12 implements OFQueuePropMinRate {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueuePropMinRateVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static int DEFAULT_RATE = 0x0;
+
+    // OF message fields
+    private final int rate;
+//
+    // Immutable default instance
+    final static OFQueuePropMinRateVer12 DEFAULT = new OFQueuePropMinRateVer12(
+        DEFAULT_RATE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueuePropMinRateVer12(int rate) {
+        this.rate = rate;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFQueuePropMinRate.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueuePropMinRate.Builder {
+        final OFQueuePropMinRateVer12 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+        BuilderWithParent(OFQueuePropMinRateVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMinRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFQueuePropMinRate build() {
+                int rate = this.rateSet ? this.rate : parentMessage.rate;
+
+                //
+                return new OFQueuePropMinRateVer12(
+                    rate
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueuePropMinRate.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMinRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFQueuePropMinRate build() {
+            int rate = this.rateSet ? this.rate : DEFAULT_RATE;
+
+
+            return new OFQueuePropMinRateVer12(
+                    rate
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueuePropMinRate> {
+        @Override
+        public OFQueuePropMinRate readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int rate = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFQueuePropMinRateVer12 queuePropMinRateVer12 = new OFQueuePropMinRateVer12(
+                    rate
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queuePropMinRateVer12);
+            return queuePropMinRateVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueuePropMinRateVer12Funnel FUNNEL = new OFQueuePropMinRateVer12Funnel();
+    static class OFQueuePropMinRateVer12Funnel implements Funnel<OFQueuePropMinRateVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueuePropMinRateVer12 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // skip pad (4 bytes)
+            sink.putInt(message.rate);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueuePropMinRateVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueuePropMinRateVer12 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeShort(U16.t(message.rate));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueuePropMinRateVer12(");
+        b.append("rate=").append(rate);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueuePropMinRateVer12 other = (OFQueuePropMinRateVer12) obj;
+
+        if( rate != other.rate)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + rate;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropVer12.java
new file mode 100644
index 0000000..896197d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropVer12.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFQueuePropVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFQueuePropVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFQueueProp> {
+        @Override
+        public OFQueueProp readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFQueuePropMinRateVer12
+                   return OFQueuePropMinRateVer12.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value 0xffff=0xffff for class OFQueuePropExperimenterVer12
+                   return OFQueuePropExperimenterVer12.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value 0x2=0x2 for class OFQueuePropMaxRateVer12
+                   return OFQueuePropMaxRateVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFQueuePropVer12: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropertiesSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropertiesSerializerVer12.java
new file mode 100644
index 0000000..62c4edf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropertiesSerializerVer12.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFQueueProperties;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFQueuePropertiesSerializerVer12 {
+
+    public final static short MIN_RATE_VAL = (short) 0x1;
+    public final static short MAX_RATE_VAL = (short) 0x2;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFQueueProperties readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFQueueProperties e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFQueueProperties e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFQueueProperties ofWireValue(short val) {
+        switch(val) {
+            case MIN_RATE_VAL:
+                return OFQueueProperties.MIN_RATE;
+            case MAX_RATE_VAL:
+                return OFQueueProperties.MAX_RATE;
+            case EXPERIMENTER_VAL:
+                return OFQueueProperties.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFQueueProperties in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFQueueProperties e) {
+        switch(e) {
+            case MIN_RATE:
+                return MIN_RATE_VAL;
+            case MAX_RATE:
+                return MAX_RATE_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFQueueProperties in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropsVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropsVer12.java
new file mode 100644
index 0000000..112c21f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueuePropsVer12.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFQueuePropsVer12 implements OFQueueProps {
+    public final static OFQueuePropsVer12 INSTANCE = new OFQueuePropsVer12();
+
+
+
+
+    public OFQueuePropMinRate.Builder buildMinRate() {
+        return new OFQueuePropMinRateVer12.Builder();
+    }
+    public OFQueuePropMinRate minRate(int rate) {
+        return new OFQueuePropMinRateVer12(
+                rate
+                    );
+    }
+
+    public OFQueuePropMaxRate.Builder buildMaxRate() {
+        return new OFQueuePropMaxRateVer12.Builder();
+    }
+    public OFQueuePropMaxRate maxRate(int rate) {
+        return new OFQueuePropMaxRateVer12(
+                rate
+                    );
+    }
+
+    public OFMessageReader<OFQueueProp> getReader() {
+        return OFQueuePropVer12.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_12;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsEntryVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsEntryVer12.java
new file mode 100644
index 0000000..f8ceec0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsEntryVer12.java
@@ -0,0 +1,484 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsEntryVer12 implements OFQueueStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsEntryVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 32;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+        private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final long queueId;
+    private final U64 txBytes;
+    private final U64 txPackets;
+    private final U64 txErrors;
+//
+    // Immutable default instance
+    final static OFQueueStatsEntryVer12 DEFAULT = new OFQueueStatsEntryVer12(
+        DEFAULT_PORT_NO, DEFAULT_QUEUE_ID, DEFAULT_TX_BYTES, DEFAULT_TX_PACKETS, DEFAULT_TX_ERRORS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsEntryVer12(OFPort portNo, long queueId, U64 txBytes, U64 txPackets, U64 txErrors) {
+        this.portNo = portNo;
+        this.queueId = queueId;
+        this.txBytes = txBytes;
+        this.txPackets = txPackets;
+        this.txErrors = txErrors;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFQueueStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsEntry.Builder {
+        final OFQueueStatsEntryVer12 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+
+        BuilderWithParent(OFQueueStatsEntryVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFQueueStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+                U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
+                if(txBytes == null)
+                    throw new NullPointerException("Property txBytes must not be null");
+                U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
+                if(txPackets == null)
+                    throw new NullPointerException("Property txPackets must not be null");
+                U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
+                if(txErrors == null)
+                    throw new NullPointerException("Property txErrors must not be null");
+
+                //
+                return new OFQueueStatsEntryVer12(
+                    portNo,
+                    queueId,
+                    txBytes,
+                    txPackets,
+                    txErrors
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationSec(long durationSec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationSec not supported in version 1.2");
+    }
+    @Override
+    public long getDurationNsec()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property durationNsec not supported in version 1.2");
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFQueueStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+            U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
+            if(txBytes == null)
+                throw new NullPointerException("Property txBytes must not be null");
+            U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
+            if(txPackets == null)
+                throw new NullPointerException("Property txPackets must not be null");
+            U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
+            if(txErrors == null)
+                throw new NullPointerException("Property txErrors must not be null");
+
+
+            return new OFQueueStatsEntryVer12(
+                    portNo,
+                    queueId,
+                    txBytes,
+                    txPackets,
+                    txErrors
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsEntry> {
+        @Override
+        public OFQueueStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            long queueId = U32.f(bb.readInt());
+            U64 txBytes = U64.ofRaw(bb.readLong());
+            U64 txPackets = U64.ofRaw(bb.readLong());
+            U64 txErrors = U64.ofRaw(bb.readLong());
+
+            OFQueueStatsEntryVer12 queueStatsEntryVer12 = new OFQueueStatsEntryVer12(
+                    portNo,
+                      queueId,
+                      txBytes,
+                      txPackets,
+                      txErrors
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsEntryVer12);
+            return queueStatsEntryVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsEntryVer12Funnel FUNNEL = new OFQueueStatsEntryVer12Funnel();
+    static class OFQueueStatsEntryVer12Funnel implements Funnel<OFQueueStatsEntryVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsEntryVer12 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            sink.putLong(message.queueId);
+            message.txBytes.putTo(sink);
+            message.txPackets.putTo(sink);
+            message.txErrors.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsEntryVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsEntryVer12 message) {
+            message.portNo.write4Bytes(bb);
+            bb.writeInt(U32.t(message.queueId));
+            bb.writeLong(message.txBytes.getValue());
+            bb.writeLong(message.txPackets.getValue());
+            bb.writeLong(message.txErrors.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsEntryVer12(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(", ");
+        b.append("txBytes=").append(txBytes);
+        b.append(", ");
+        b.append("txPackets=").append(txPackets);
+        b.append(", ");
+        b.append("txErrors=").append(txErrors);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsEntryVer12 other = (OFQueueStatsEntryVer12) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        if (txBytes == null) {
+            if (other.txBytes != null)
+                return false;
+        } else if (!txBytes.equals(other.txBytes))
+            return false;
+        if (txPackets == null) {
+            if (other.txPackets != null)
+                return false;
+        } else if (!txPackets.equals(other.txPackets))
+            return false;
+        if (txErrors == null) {
+            if (other.txErrors != null)
+                return false;
+        } else if (!txErrors.equals(other.txErrors))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
+        result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
+        result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsReplyVer12.java
new file mode 100644
index 0000000..cadcee4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsReplyVer12.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsReplyVer12 implements OFQueueStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFQueueStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFQueueStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFQueueStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFQueueStatsReplyVer12 DEFAULT = new OFQueueStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, List<OFQueueStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFQueueStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsReply.Builder {
+        final OFQueueStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFQueueStatsEntry> entries;
+
+        BuilderWithParent(OFQueueStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setEntries(List<OFQueueStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFQueueStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFQueueStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFQueueStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setEntries(List<OFQueueStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFQueueStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFQueueStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsReply> {
+        @Override
+        public OFQueueStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 5
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x5)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.QUEUE(5), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFQueueStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFQueueStatsEntryVer12.READER);
+
+            OFQueueStatsReplyVer12 queueStatsReplyVer12 = new OFQueueStatsReplyVer12(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsReplyVer12);
+            return queueStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsReplyVer12Funnel FUNNEL = new OFQueueStatsReplyVer12Funnel();
+    static class OFQueueStatsReplyVer12Funnel implements Funnel<OFQueueStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 5
+            sink.putShort((short) 0x5);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 5
+            bb.writeShort((short) 0x5);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsReplyVer12 other = (OFQueueStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsRequestVer12.java
new file mode 100644
index 0000000..a37743d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFQueueStatsRequestVer12.java
@@ -0,0 +1,452 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsRequestVer12 implements OFQueueStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+    private final long queueId;
+//
+    // Immutable default instance
+    final static OFQueueStatsRequestVer12 DEFAULT = new OFQueueStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO, DEFAULT_QUEUE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo, long queueId) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+        this.queueId = queueId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+
+
+    public OFQueueStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsRequest.Builder {
+        final OFQueueStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+
+        BuilderWithParent(OFQueueStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+
+                //
+                return new OFQueueStatsRequestVer12(
+                    xid,
+                    flags,
+                    portNo,
+                    queueId
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+
+
+            return new OFQueueStatsRequestVer12(
+                    xid,
+                    flags,
+                    portNo,
+                    queueId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsRequest> {
+        @Override
+        public OFQueueStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 5
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x5)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.QUEUE(5), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            long queueId = U32.f(bb.readInt());
+
+            OFQueueStatsRequestVer12 queueStatsRequestVer12 = new OFQueueStatsRequestVer12(
+                    xid,
+                      flags,
+                      portNo,
+                      queueId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsRequestVer12);
+            return queueStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsRequestVer12Funnel FUNNEL = new OFQueueStatsRequestVer12Funnel();
+    static class OFQueueStatsRequestVer12Funnel implements Funnel<OFQueueStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 5
+            sink.putShort((short) 0x5);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.portNo.putTo(sink);
+            sink.putLong(message.queueId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 5
+            bb.writeShort((short) 0x5);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.portNo.write4Bytes(bb);
+            bb.writeInt(U32.t(message.queueId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsRequestVer12 other = (OFQueueStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleReplyVer12.java
new file mode 100644
index 0000000..5e6acdb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleReplyVer12.java
@@ -0,0 +1,377 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFRoleReplyVer12 implements OFRoleReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFRoleReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_GENERATION_ID = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final OFControllerRole role;
+    private final U64 generationId;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFRoleReplyVer12(long xid, OFControllerRole role, U64 generationId) {
+        this.xid = xid;
+        this.role = role;
+        this.generationId = generationId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+
+
+    public OFRoleReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFRoleReply.Builder {
+        final OFRoleReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+        BuilderWithParent(OFRoleReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFRoleReply.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFRoleReply.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFRoleReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFControllerRole role = this.roleSet ? this.role : parentMessage.role;
+                if(role == null)
+                    throw new NullPointerException("Property role must not be null");
+                U64 generationId = this.generationIdSet ? this.generationId : parentMessage.generationId;
+                if(generationId == null)
+                    throw new NullPointerException("Property generationId must not be null");
+
+                //
+                return new OFRoleReplyVer12(
+                    xid,
+                    role,
+                    generationId
+                );
+        }
+
+    }
+
+    static class Builder implements OFRoleReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFRoleReply.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFRoleReply.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFRoleReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.roleSet)
+                throw new IllegalStateException("Property role doesn't have default value -- must be set");
+            if(role == null)
+                throw new NullPointerException("Property role must not be null");
+            U64 generationId = this.generationIdSet ? this.generationId : DEFAULT_GENERATION_ID;
+            if(generationId == null)
+                throw new NullPointerException("Property generationId must not be null");
+
+
+            return new OFRoleReplyVer12(
+                    xid,
+                    role,
+                    generationId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFRoleReply> {
+        @Override
+        public OFRoleReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 25
+            byte type = bb.readByte();
+            if(type != (byte) 0x19)
+                throw new OFParseError("Wrong type: Expected=OFType.ROLE_REPLY(25), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFControllerRole role = OFControllerRoleSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 generationId = U64.ofRaw(bb.readLong());
+
+            OFRoleReplyVer12 roleReplyVer12 = new OFRoleReplyVer12(
+                    xid,
+                      role,
+                      generationId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", roleReplyVer12);
+            return roleReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFRoleReplyVer12Funnel FUNNEL = new OFRoleReplyVer12Funnel();
+    static class OFRoleReplyVer12Funnel implements Funnel<OFRoleReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFRoleReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 25
+            sink.putByte((byte) 0x19);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            OFControllerRoleSerializerVer12.putTo(message.role, sink);
+            // skip pad (4 bytes)
+            message.generationId.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFRoleReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFRoleReplyVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 25
+            bb.writeByte((byte) 0x19);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            OFControllerRoleSerializerVer12.writeTo(bb, message.role);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.generationId.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFRoleReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("role=").append(role);
+        b.append(", ");
+        b.append("generationId=").append(generationId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFRoleReplyVer12 other = (OFRoleReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (role == null) {
+            if (other.role != null)
+                return false;
+        } else if (!role.equals(other.role))
+            return false;
+        if (generationId == null) {
+            if (other.generationId != null)
+                return false;
+        } else if (!generationId.equals(other.generationId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((role == null) ? 0 : role.hashCode());
+        result = prime * result + ((generationId == null) ? 0 : generationId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestFailedCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestFailedCodeSerializerVer12.java
new file mode 100644
index 0000000..a3493f5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestFailedCodeSerializerVer12.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFRoleRequestFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFRoleRequestFailedCodeSerializerVer12 {
+
+    public final static short STALE_VAL = (short) 0x0;
+    public final static short UNSUP_VAL = (short) 0x1;
+    public final static short BAD_ROLE_VAL = (short) 0x2;
+
+    public static OFRoleRequestFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFRoleRequestFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFRoleRequestFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFRoleRequestFailedCode ofWireValue(short val) {
+        switch(val) {
+            case STALE_VAL:
+                return OFRoleRequestFailedCode.STALE;
+            case UNSUP_VAL:
+                return OFRoleRequestFailedCode.UNSUP;
+            case BAD_ROLE_VAL:
+                return OFRoleRequestFailedCode.BAD_ROLE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFRoleRequestFailedCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFRoleRequestFailedCode e) {
+        switch(e) {
+            case STALE:
+                return STALE_VAL;
+            case UNSUP:
+                return UNSUP_VAL;
+            case BAD_ROLE:
+                return BAD_ROLE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFRoleRequestFailedCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestFailedErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestFailedErrorMsgVer12.java
new file mode 100644
index 0000000..1bbe402
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestFailedErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFRoleRequestFailedErrorMsgVer12 implements OFRoleRequestFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFRoleRequestFailedErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFRoleRequestFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFRoleRequestFailedErrorMsgVer12(long xid, OFRoleRequestFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.ROLE_REQUEST_FAILED;
+    }
+
+    @Override
+    public OFRoleRequestFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFRoleRequestFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFRoleRequestFailedErrorMsg.Builder {
+        final OFRoleRequestFailedErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFRoleRequestFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFRoleRequestFailedErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.ROLE_REQUEST_FAILED;
+    }
+
+    @Override
+    public OFRoleRequestFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setCode(OFRoleRequestFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFRoleRequestFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFRoleRequestFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFRoleRequestFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFRoleRequestFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFRoleRequestFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.ROLE_REQUEST_FAILED;
+    }
+
+    @Override
+    public OFRoleRequestFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setCode(OFRoleRequestFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFRoleRequestFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFRoleRequestFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFRoleRequestFailedErrorMsg> {
+        @Override
+        public OFRoleRequestFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 11
+            short errType = bb.readShort();
+            if(errType != (short) 0xb)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.ROLE_REQUEST_FAILED(11), got="+errType);
+            OFRoleRequestFailedCode code = OFRoleRequestFailedCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFRoleRequestFailedErrorMsgVer12 roleRequestFailedErrorMsgVer12 = new OFRoleRequestFailedErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", roleRequestFailedErrorMsgVer12);
+            return roleRequestFailedErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFRoleRequestFailedErrorMsgVer12Funnel FUNNEL = new OFRoleRequestFailedErrorMsgVer12Funnel();
+    static class OFRoleRequestFailedErrorMsgVer12Funnel implements Funnel<OFRoleRequestFailedErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFRoleRequestFailedErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 11
+            sink.putShort((short) 0xb);
+            OFRoleRequestFailedCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFRoleRequestFailedErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFRoleRequestFailedErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 11
+            bb.writeShort((short) 0xb);
+            OFRoleRequestFailedCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFRoleRequestFailedErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFRoleRequestFailedErrorMsgVer12 other = (OFRoleRequestFailedErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestVer12.java
new file mode 100644
index 0000000..483f9da
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFRoleRequestVer12.java
@@ -0,0 +1,377 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFRoleRequestVer12 implements OFRoleRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFRoleRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_GENERATION_ID = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final OFControllerRole role;
+    private final U64 generationId;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFRoleRequestVer12(long xid, OFControllerRole role, U64 generationId) {
+        this.xid = xid;
+        this.role = role;
+        this.generationId = generationId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+
+
+    public OFRoleRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFRoleRequest.Builder {
+        final OFRoleRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+        BuilderWithParent(OFRoleRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFRoleRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFControllerRole role = this.roleSet ? this.role : parentMessage.role;
+                if(role == null)
+                    throw new NullPointerException("Property role must not be null");
+                U64 generationId = this.generationIdSet ? this.generationId : parentMessage.generationId;
+                if(generationId == null)
+                    throw new NullPointerException("Property generationId must not be null");
+
+                //
+                return new OFRoleRequestVer12(
+                    xid,
+                    role,
+                    generationId
+                );
+        }
+
+    }
+
+    static class Builder implements OFRoleRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFRoleRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.roleSet)
+                throw new IllegalStateException("Property role doesn't have default value -- must be set");
+            if(role == null)
+                throw new NullPointerException("Property role must not be null");
+            U64 generationId = this.generationIdSet ? this.generationId : DEFAULT_GENERATION_ID;
+            if(generationId == null)
+                throw new NullPointerException("Property generationId must not be null");
+
+
+            return new OFRoleRequestVer12(
+                    xid,
+                    role,
+                    generationId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFRoleRequest> {
+        @Override
+        public OFRoleRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 24
+            byte type = bb.readByte();
+            if(type != (byte) 0x18)
+                throw new OFParseError("Wrong type: Expected=OFType.ROLE_REQUEST(24), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFControllerRole role = OFControllerRoleSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 generationId = U64.ofRaw(bb.readLong());
+
+            OFRoleRequestVer12 roleRequestVer12 = new OFRoleRequestVer12(
+                    xid,
+                      role,
+                      generationId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", roleRequestVer12);
+            return roleRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFRoleRequestVer12Funnel FUNNEL = new OFRoleRequestVer12Funnel();
+    static class OFRoleRequestVer12Funnel implements Funnel<OFRoleRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFRoleRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 24
+            sink.putByte((byte) 0x18);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            OFControllerRoleSerializerVer12.putTo(message.role, sink);
+            // skip pad (4 bytes)
+            message.generationId.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFRoleRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFRoleRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 24
+            bb.writeByte((byte) 0x18);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            OFControllerRoleSerializerVer12.writeTo(bb, message.role);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.generationId.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFRoleRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("role=").append(role);
+        b.append(", ");
+        b.append("generationId=").append(generationId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFRoleRequestVer12 other = (OFRoleRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (role == null) {
+            if (other.role != null)
+                return false;
+        } else if (!role.equals(other.role))
+            return false;
+        if (generationId == null) {
+            if (other.generationId != null)
+                return false;
+        } else if (!generationId.equals(other.generationId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((role == null) ? 0 : role.hashCode());
+        result = prime * result + ((generationId == null) ? 0 : generationId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSetConfigVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSetConfigVer12.java
new file mode 100644
index 0000000..574234d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSetConfigVer12.java
@@ -0,0 +1,370 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFSetConfigVer12 implements OFSetConfig {
+    private static final Logger logger = LoggerFactory.getLogger(OFSetConfigVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFConfigFlags> DEFAULT_FLAGS = ImmutableSet.<OFConfigFlags>of();
+        private final static int DEFAULT_MISS_SEND_LEN = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFConfigFlags> flags;
+    private final int missSendLen;
+//
+    // Immutable default instance
+    final static OFSetConfigVer12 DEFAULT = new OFSetConfigVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MISS_SEND_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFSetConfigVer12(long xid, Set<OFConfigFlags> flags, int missSendLen) {
+        this.xid = xid;
+        this.flags = flags;
+        this.missSendLen = missSendLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+
+
+    public OFSetConfig.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFSetConfig.Builder {
+        final OFSetConfigVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+        BuilderWithParent(OFSetConfigVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSetConfig.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFSetConfig.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFSetConfig.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFSetConfig build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFConfigFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int missSendLen = this.missSendLenSet ? this.missSendLen : parentMessage.missSendLen;
+
+                //
+                return new OFSetConfigVer12(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFSetConfig.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSetConfig.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFSetConfig.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFSetConfig.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFSetConfig build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFConfigFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int missSendLen = this.missSendLenSet ? this.missSendLen : DEFAULT_MISS_SEND_LEN;
+
+
+            return new OFSetConfigVer12(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFSetConfig> {
+        @Override
+        public OFSetConfig readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 9
+            byte type = bb.readByte();
+            if(type != (byte) 0x9)
+                throw new OFParseError("Wrong type: Expected=OFType.SET_CONFIG(9), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Set<OFConfigFlags> flags = OFConfigFlagsSerializerVer12.readFrom(bb);
+            int missSendLen = U16.f(bb.readShort());
+
+            OFSetConfigVer12 setConfigVer12 = new OFSetConfigVer12(
+                    xid,
+                      flags,
+                      missSendLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", setConfigVer12);
+            return setConfigVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFSetConfigVer12Funnel FUNNEL = new OFSetConfigVer12Funnel();
+    static class OFSetConfigVer12Funnel implements Funnel<OFSetConfigVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFSetConfigVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 9
+            sink.putByte((byte) 0x9);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            OFConfigFlagsSerializerVer12.putTo(message.flags, sink);
+            sink.putInt(message.missSendLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFSetConfigVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFSetConfigVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 9
+            bb.writeByte((byte) 0x9);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            OFConfigFlagsSerializerVer12.writeTo(bb, message.flags);
+            bb.writeShort(U16.t(message.missSendLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFSetConfigVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("missSendLen=").append(missSendLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFSetConfigVer12 other = (OFSetConfigVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( missSendLen != other.missSendLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + missSendLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsReplyFlagsSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsReplyFlagsSerializerVer12.java
new file mode 100644
index 0000000..3daa4b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsReplyFlagsSerializerVer12.java
@@ -0,0 +1,78 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFStatsReplyFlagsSerializerVer12 {
+
+    public final static short REPLY_MORE_VAL = (short) 0x1;
+
+    public static Set<OFStatsReplyFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFStatsReplyFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFStatsReplyFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFStatsReplyFlags> ofWireValue(short val) {
+        EnumSet<OFStatsReplyFlags> set = EnumSet.noneOf(OFStatsReplyFlags.class);
+
+        if((val & REPLY_MORE_VAL) != 0)
+            set.add(OFStatsReplyFlags.REPLY_MORE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFStatsReplyFlags> set) {
+        short wireValue = 0;
+
+        for(OFStatsReplyFlags e: set) {
+            switch(e) {
+                case REPLY_MORE:
+                    wireValue |= REPLY_MORE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFStatsReplyFlags in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsReplyVer12.java
new file mode 100644
index 0000000..ef89367
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsReplyVer12.java
@@ -0,0 +1,92 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFStatsReplyVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFStatsReplyVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFStatsReply> {
+        @Override
+        public OFStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short statsType = bb.readShort();
+            bb.readerIndex(start);
+            switch(statsType) {
+               case (short) 0x2:
+                   // discriminator value OFStatsType.AGGREGATE=2 for class OFAggregateStatsReplyVer12
+                   return OFAggregateStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFStatsType.EXPERIMENTER=65535 for class OFExperimenterStatsReplyVer12
+                   return OFExperimenterStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFStatsType.DESC=0 for class OFDescStatsReplyVer12
+                   return OFDescStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFStatsType.FLOW=1 for class OFFlowStatsReplyVer12
+                   return OFFlowStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFStatsType.PORT=4 for class OFPortStatsReplyVer12
+                   return OFPortStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFStatsType.QUEUE=5 for class OFQueueStatsReplyVer12
+                   return OFQueueStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFStatsType.TABLE=3 for class OFTableStatsReplyVer12
+                   return OFTableStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFStatsType.GROUP_DESC=7 for class OFGroupDescStatsReplyVer12
+                   return OFGroupDescStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFStatsType.GROUP=6 for class OFGroupStatsReplyVer12
+                   return OFGroupStatsReplyVer12.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFStatsType.GROUP_FEATURES=8 for class OFGroupFeaturesStatsReplyVer12
+                   return OFGroupFeaturesStatsReplyVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator statsType of class OFStatsReplyVer12: " + statsType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsRequestFlagsSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsRequestFlagsSerializerVer12.java
new file mode 100644
index 0000000..b0eb8eb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsRequestFlagsSerializerVer12.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsRequestFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFStatsRequestFlagsSerializerVer12 {
+
+
+    public static Set<OFStatsRequestFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFStatsRequestFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFStatsRequestFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFStatsRequestFlags> ofWireValue(short val) {
+        EnumSet<OFStatsRequestFlags> set = EnumSet.noneOf(OFStatsRequestFlags.class);
+
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFStatsRequestFlags> set) {
+        short wireValue = 0;
+
+        for(OFStatsRequestFlags e: set) {
+            switch(e) {
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFStatsRequestFlags in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsRequestVer12.java
new file mode 100644
index 0000000..576504f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsRequestVer12.java
@@ -0,0 +1,92 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFStatsRequestVer12 {
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFStatsRequestVer12.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFStatsRequest<?>> {
+        @Override
+        public OFStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short statsType = bb.readShort();
+            bb.readerIndex(start);
+            switch(statsType) {
+               case (short) 0x2:
+                   // discriminator value OFStatsType.AGGREGATE=2 for class OFAggregateStatsRequestVer12
+                   return OFAggregateStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFStatsType.EXPERIMENTER=65535 for class OFExperimenterStatsRequestVer12
+                   return OFExperimenterStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFStatsType.DESC=0 for class OFDescStatsRequestVer12
+                   return OFDescStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFStatsType.FLOW=1 for class OFFlowStatsRequestVer12
+                   return OFFlowStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFStatsType.PORT=4 for class OFPortStatsRequestVer12
+                   return OFPortStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFStatsType.QUEUE=5 for class OFQueueStatsRequestVer12
+                   return OFQueueStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFStatsType.TABLE=3 for class OFTableStatsRequestVer12
+                   return OFTableStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFStatsType.GROUP_DESC=7 for class OFGroupDescStatsRequestVer12
+                   return OFGroupDescStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFStatsType.GROUP=6 for class OFGroupStatsRequestVer12
+                   return OFGroupStatsRequestVer12.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFStatsType.GROUP_FEATURES=8 for class OFGroupFeaturesStatsRequestVer12
+                   return OFGroupFeaturesStatsRequestVer12.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator statsType of class OFStatsRequestVer12: " + statsType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsTypeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsTypeSerializerVer12.java
new file mode 100644
index 0000000..dc11102
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFStatsTypeSerializerVer12.java
@@ -0,0 +1,114 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFStatsTypeSerializerVer12 {
+
+    public final static short DESC_VAL = (short) 0x0;
+    public final static short FLOW_VAL = (short) 0x1;
+    public final static short AGGREGATE_VAL = (short) 0x2;
+    public final static short TABLE_VAL = (short) 0x3;
+    public final static short PORT_VAL = (short) 0x4;
+    public final static short QUEUE_VAL = (short) 0x5;
+    public final static short GROUP_VAL = (short) 0x6;
+    public final static short GROUP_DESC_VAL = (short) 0x7;
+    public final static short GROUP_FEATURES_VAL = (short) 0x8;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFStatsType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFStatsType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFStatsType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFStatsType ofWireValue(short val) {
+        switch(val) {
+            case DESC_VAL:
+                return OFStatsType.DESC;
+            case FLOW_VAL:
+                return OFStatsType.FLOW;
+            case AGGREGATE_VAL:
+                return OFStatsType.AGGREGATE;
+            case TABLE_VAL:
+                return OFStatsType.TABLE;
+            case PORT_VAL:
+                return OFStatsType.PORT;
+            case QUEUE_VAL:
+                return OFStatsType.QUEUE;
+            case GROUP_VAL:
+                return OFStatsType.GROUP;
+            case GROUP_DESC_VAL:
+                return OFStatsType.GROUP_DESC;
+            case GROUP_FEATURES_VAL:
+                return OFStatsType.GROUP_FEATURES;
+            case EXPERIMENTER_VAL:
+                return OFStatsType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFStatsType e) {
+        switch(e) {
+            case DESC:
+                return DESC_VAL;
+            case FLOW:
+                return FLOW_VAL;
+            case AGGREGATE:
+                return AGGREGATE_VAL;
+            case TABLE:
+                return TABLE_VAL;
+            case PORT:
+                return PORT_VAL;
+            case QUEUE:
+                return QUEUE_VAL;
+            case GROUP:
+                return GROUP_VAL;
+            case GROUP_DESC:
+                return GROUP_DESC_VAL;
+            case GROUP_FEATURES:
+                return GROUP_FEATURES_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSwitchConfigFailedCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSwitchConfigFailedCodeSerializerVer12.java
new file mode 100644
index 0000000..52bec7e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSwitchConfigFailedCodeSerializerVer12.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFSwitchConfigFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFSwitchConfigFailedCodeSerializerVer12 {
+
+    public final static short BAD_FLAGS_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+
+    public static OFSwitchConfigFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFSwitchConfigFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFSwitchConfigFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFSwitchConfigFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_FLAGS_VAL:
+                return OFSwitchConfigFailedCode.BAD_FLAGS;
+            case BAD_LEN_VAL:
+                return OFSwitchConfigFailedCode.BAD_LEN;
+            case EPERM_VAL:
+                return OFSwitchConfigFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFSwitchConfigFailedCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFSwitchConfigFailedCode e) {
+        switch(e) {
+            case BAD_FLAGS:
+                return BAD_FLAGS_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFSwitchConfigFailedCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSwitchConfigFailedErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSwitchConfigFailedErrorMsgVer12.java
new file mode 100644
index 0000000..b130a09
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFSwitchConfigFailedErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFSwitchConfigFailedErrorMsgVer12 implements OFSwitchConfigFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFSwitchConfigFailedErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFSwitchConfigFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFSwitchConfigFailedErrorMsgVer12(long xid, OFSwitchConfigFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFSwitchConfigFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFSwitchConfigFailedErrorMsg.Builder {
+        final OFSwitchConfigFailedErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFSwitchConfigFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFSwitchConfigFailedErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setCode(OFSwitchConfigFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFSwitchConfigFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFSwitchConfigFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFSwitchConfigFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFSwitchConfigFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFSwitchConfigFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setCode(OFSwitchConfigFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFSwitchConfigFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFSwitchConfigFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFSwitchConfigFailedErrorMsg> {
+        @Override
+        public OFSwitchConfigFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 10
+            short errType = bb.readShort();
+            if(errType != (short) 0xa)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.SWITCH_CONFIG_FAILED(10), got="+errType);
+            OFSwitchConfigFailedCode code = OFSwitchConfigFailedCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFSwitchConfigFailedErrorMsgVer12 switchConfigFailedErrorMsgVer12 = new OFSwitchConfigFailedErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", switchConfigFailedErrorMsgVer12);
+            return switchConfigFailedErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFSwitchConfigFailedErrorMsgVer12Funnel FUNNEL = new OFSwitchConfigFailedErrorMsgVer12Funnel();
+    static class OFSwitchConfigFailedErrorMsgVer12Funnel implements Funnel<OFSwitchConfigFailedErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFSwitchConfigFailedErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 10
+            sink.putShort((short) 0xa);
+            OFSwitchConfigFailedCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFSwitchConfigFailedErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFSwitchConfigFailedErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 10
+            bb.writeShort((short) 0xa);
+            OFSwitchConfigFailedCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFSwitchConfigFailedErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFSwitchConfigFailedErrorMsgVer12 other = (OFSwitchConfigFailedErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableConfigSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableConfigSerializerVer12.java
new file mode 100644
index 0000000..c8de78c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableConfigSerializerVer12.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTableConfig;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFTableConfigSerializerVer12 {
+
+    public final static int TABLE_MISS_CONTROLLER_VAL = 0x0;
+    public final static int TABLE_MISS_CONTINUE_VAL = 0x1;
+    public final static int TABLE_MISS_DROP_VAL = 0x2;
+    public final static int TABLE_MISS_MASK_VAL = 0x3;
+
+    public static Set<OFTableConfig> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFTableConfig> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFTableConfig> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFTableConfig> ofWireValue(int val) {
+        EnumSet<OFTableConfig> set = EnumSet.noneOf(OFTableConfig.class);
+
+        if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_CONTROLLER_VAL)
+            set.add(OFTableConfig.TABLE_MISS_CONTROLLER);
+        else if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_CONTINUE_VAL)
+            set.add(OFTableConfig.TABLE_MISS_CONTINUE);
+        else if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_DROP_VAL)
+            set.add(OFTableConfig.TABLE_MISS_DROP);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFTableConfig> set) {
+        int wireValue = 0;
+
+        for(OFTableConfig e: set) {
+            switch(e) {
+                case TABLE_MISS_CONTROLLER:
+                    wireValue |= TABLE_MISS_CONTROLLER_VAL;
+                    break;
+                case TABLE_MISS_CONTINUE:
+                    wireValue |= TABLE_MISS_CONTINUE_VAL;
+                    break;
+                case TABLE_MISS_DROP:
+                    wireValue |= TABLE_MISS_DROP_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFTableConfig in version 1.2: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModFailedCodeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModFailedCodeSerializerVer12.java
new file mode 100644
index 0000000..99ca29a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModFailedCodeSerializerVer12.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTableModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTableModFailedCodeSerializerVer12 {
+
+    public final static short BAD_TABLE_VAL = (short) 0x0;
+    public final static short BAD_CONFIG_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+
+    public static OFTableModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFTableModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFTableModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFTableModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TABLE_VAL:
+                return OFTableModFailedCode.BAD_TABLE;
+            case BAD_CONFIG_VAL:
+                return OFTableModFailedCode.BAD_CONFIG;
+            case EPERM_VAL:
+                return OFTableModFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFTableModFailedCode in version 1.2: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFTableModFailedCode e) {
+        switch(e) {
+            case BAD_TABLE:
+                return BAD_TABLE_VAL;
+            case BAD_CONFIG:
+                return BAD_CONFIG_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFTableModFailedCode in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModFailedErrorMsgVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModFailedErrorMsgVer12.java
new file mode 100644
index 0000000..59c5e2e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModFailedErrorMsgVer12.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableModFailedErrorMsgVer12 implements OFTableModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableModFailedErrorMsgVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFTableModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableModFailedErrorMsgVer12(long xid, OFTableModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFTableModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableModFailedErrorMsg.Builder {
+        final OFTableModFailedErrorMsgVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFTableModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFTableModFailedErrorMsgVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setCode(OFTableModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFTableModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFTableModFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFTableModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setCode(OFTableModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFTableModFailedErrorMsgVer12(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableModFailedErrorMsg> {
+        @Override
+        public OFTableModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 8
+            short errType = bb.readShort();
+            if(errType != (short) 0x8)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.TABLE_MOD_FAILED(8), got="+errType);
+            OFTableModFailedCode code = OFTableModFailedCodeSerializerVer12.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
+
+            OFTableModFailedErrorMsgVer12 tableModFailedErrorMsgVer12 = new OFTableModFailedErrorMsgVer12(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableModFailedErrorMsgVer12);
+            return tableModFailedErrorMsgVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableModFailedErrorMsgVer12Funnel FUNNEL = new OFTableModFailedErrorMsgVer12Funnel();
+    static class OFTableModFailedErrorMsgVer12Funnel implements Funnel<OFTableModFailedErrorMsgVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableModFailedErrorMsgVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 8
+            sink.putShort((short) 0x8);
+            OFTableModFailedCodeSerializerVer12.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableModFailedErrorMsgVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableModFailedErrorMsgVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 8
+            bb.writeShort((short) 0x8);
+            OFTableModFailedCodeSerializerVer12.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableModFailedErrorMsgVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableModFailedErrorMsgVer12 other = (OFTableModFailedErrorMsgVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModVer12.java
new file mode 100644
index 0000000..387fa83
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableModVer12.java
@@ -0,0 +1,374 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableModVer12 implements OFTableMod {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableModVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_CONFIG = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final TableId tableId;
+    private final long config;
+//
+    // Immutable default instance
+    final static OFTableModVer12 DEFAULT = new OFTableModVer12(
+        DEFAULT_XID, DEFAULT_TABLE_ID, DEFAULT_CONFIG
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableModVer12(long xid, TableId tableId, long config) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.config = config;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+
+
+    public OFTableMod.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableMod.Builder {
+        final OFTableModVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean configSet;
+        private long config;
+
+        BuilderWithParent(OFTableModVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableMod.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableMod build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long config = this.configSet ? this.config : parentMessage.config;
+
+                //
+                return new OFTableModVer12(
+                    xid,
+                    tableId,
+                    config
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableMod.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean configSet;
+        private long config;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableMod.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableMod build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+
+
+            return new OFTableModVer12(
+                    xid,
+                    tableId,
+                    config
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableMod> {
+        @Override
+        public OFTableMod readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.TABLE_MOD(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            long config = U32.f(bb.readInt());
+
+            OFTableModVer12 tableModVer12 = new OFTableModVer12(
+                    xid,
+                      tableId,
+                      config
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableModVer12);
+            return tableModVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableModVer12Funnel FUNNEL = new OFTableModVer12Funnel();
+    static class OFTableModVer12Funnel implements Funnel<OFTableModVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableModVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            sink.putLong(message.config);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableModVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableModVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeInt(U32.t(message.config));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableModVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableModVer12 other = (OFTableModVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( config != other.config)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (config ^ (config >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableSerializerVer12.java
new file mode 100644
index 0000000..1372f76
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableSerializerVer12.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTable;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTableSerializerVer12 {
+
+    public final static byte MAX_VAL = (byte) 0xfe;
+    public final static byte ALL_VAL = (byte) 0xff;
+
+    public static OFTable readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFTable e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFTable e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFTable ofWireValue(byte val) {
+        switch(val) {
+            case MAX_VAL:
+                return OFTable.MAX;
+            case ALL_VAL:
+                return OFTable.ALL;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFTable in version 1.2: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFTable e) {
+        switch(e) {
+            case MAX:
+                return MAX_VAL;
+            case ALL:
+                return ALL_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFTable in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsEntryVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsEntryVer12.java
new file mode 100644
index 0000000..a5a6ad5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsEntryVer12.java
@@ -0,0 +1,991 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsEntryVer12 implements OFTableStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsEntryVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 128;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static String DEFAULT_NAME = "";
+        private final static int DEFAULT_WILDCARDS = 0x0;
+        private final static long DEFAULT_WRITE_ACTIONS = 0x0L;
+        private final static long DEFAULT_APPLY_ACTIONS = 0x0L;
+        private final static U64 DEFAULT_WRITE_SETFIELDS = U64.ZERO;
+        private final static U64 DEFAULT_APPLY_SETFIELDS = U64.ZERO;
+        private final static U64 DEFAULT_METADATA_MATCH = U64.ZERO;
+        private final static U64 DEFAULT_METADATA_WRITE = U64.ZERO;
+        private final static long DEFAULT_INSTRUCTIONS = 0x0L;
+        private final static long DEFAULT_CONFIG = 0x0L;
+        private final static long DEFAULT_MAX_ENTRIES = 0x0L;
+        private final static long DEFAULT_ACTIVE_COUNT = 0x0L;
+        private final static U64 DEFAULT_LOOKUP_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_MATCHED_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final TableId tableId;
+    private final String name;
+    private final OFMatchBmap match;
+    private final int wildcards;
+    private final long writeActions;
+    private final long applyActions;
+    private final U64 writeSetfields;
+    private final U64 applySetfields;
+    private final U64 metadataMatch;
+    private final U64 metadataWrite;
+    private final long instructions;
+    private final long config;
+    private final long maxEntries;
+    private final long activeCount;
+    private final U64 lookupCount;
+    private final U64 matchedCount;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsEntryVer12(TableId tableId, String name, OFMatchBmap match, int wildcards, long writeActions, long applyActions, U64 writeSetfields, U64 applySetfields, U64 metadataMatch, U64 metadataWrite, long instructions, long config, long maxEntries, long activeCount, U64 lookupCount, U64 matchedCount) {
+        this.tableId = tableId;
+        this.name = name;
+        this.match = match;
+        this.wildcards = wildcards;
+        this.writeActions = writeActions;
+        this.applyActions = applyActions;
+        this.writeSetfields = writeSetfields;
+        this.applySetfields = applySetfields;
+        this.metadataMatch = metadataMatch;
+        this.metadataWrite = metadataWrite;
+        this.instructions = instructions;
+        this.config = config;
+        this.maxEntries = maxEntries;
+        this.activeCount = activeCount;
+        this.lookupCount = lookupCount;
+        this.matchedCount = matchedCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFMatchBmap getMatch() {
+        return match;
+    }
+
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public long getWriteActions() {
+        return writeActions;
+    }
+
+    @Override
+    public long getApplyActions() {
+        return applyActions;
+    }
+
+    @Override
+    public U64 getWriteSetfields() {
+        return writeSetfields;
+    }
+
+    @Override
+    public U64 getApplySetfields() {
+        return applySetfields;
+    }
+
+    @Override
+    public U64 getMetadataMatch() {
+        return metadataMatch;
+    }
+
+    @Override
+    public U64 getMetadataWrite() {
+        return metadataWrite;
+    }
+
+    @Override
+    public long getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+    public OFTableStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsEntry.Builder {
+        final OFTableStatsEntryVer12 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean matchSet;
+        private OFMatchBmap match;
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean writeActionsSet;
+        private long writeActions;
+        private boolean applyActionsSet;
+        private long applyActions;
+        private boolean writeSetfieldsSet;
+        private U64 writeSetfields;
+        private boolean applySetfieldsSet;
+        private U64 applySetfields;
+        private boolean metadataMatchSet;
+        private U64 metadataMatch;
+        private boolean metadataWriteSet;
+        private U64 metadataWrite;
+        private boolean instructionsSet;
+        private long instructions;
+        private boolean configSet;
+        private long config;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+        private boolean activeCountSet;
+        private long activeCount;
+        private boolean lookupCountSet;
+        private U64 lookupCount;
+        private boolean matchedCountSet;
+        private U64 matchedCount;
+
+        BuilderWithParent(OFTableStatsEntryVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public OFMatchBmap getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatch(OFMatchBmap match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public long getWriteActions() {
+        return writeActions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteActions(long writeActions) {
+        this.writeActions = writeActions;
+        this.writeActionsSet = true;
+        return this;
+    }
+    @Override
+    public long getApplyActions() {
+        return applyActions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplyActions(long applyActions) {
+        this.applyActions = applyActions;
+        this.applyActionsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getWriteSetfields() {
+        return writeSetfields;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteSetfields(U64 writeSetfields) {
+        this.writeSetfields = writeSetfields;
+        this.writeSetfieldsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getApplySetfields() {
+        return applySetfields;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplySetfields(U64 applySetfields) {
+        this.applySetfields = applySetfields;
+        this.applySetfieldsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMatch() {
+        return metadataMatch;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataMatch(U64 metadataMatch) {
+        this.metadataMatch = metadataMatch;
+        this.metadataMatchSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataWrite() {
+        return metadataWrite;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataWrite(U64 metadataWrite) {
+        this.metadataWrite = metadataWrite;
+        this.metadataWriteSet = true;
+        return this;
+    }
+    @Override
+    public long getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setInstructions(long instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setActiveCount(long activeCount) {
+        this.activeCount = activeCount;
+        this.activeCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setLookupCount(U64 lookupCount) {
+        this.lookupCount = lookupCount;
+        this.lookupCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatchedCount(U64 matchedCount) {
+        this.matchedCount = matchedCount;
+        this.matchedCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+
+
+        @Override
+        public OFTableStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                OFMatchBmap match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                int wildcards = this.wildcardsSet ? this.wildcards : parentMessage.wildcards;
+                long writeActions = this.writeActionsSet ? this.writeActions : parentMessage.writeActions;
+                long applyActions = this.applyActionsSet ? this.applyActions : parentMessage.applyActions;
+                U64 writeSetfields = this.writeSetfieldsSet ? this.writeSetfields : parentMessage.writeSetfields;
+                if(writeSetfields == null)
+                    throw new NullPointerException("Property writeSetfields must not be null");
+                U64 applySetfields = this.applySetfieldsSet ? this.applySetfields : parentMessage.applySetfields;
+                if(applySetfields == null)
+                    throw new NullPointerException("Property applySetfields must not be null");
+                U64 metadataMatch = this.metadataMatchSet ? this.metadataMatch : parentMessage.metadataMatch;
+                if(metadataMatch == null)
+                    throw new NullPointerException("Property metadataMatch must not be null");
+                U64 metadataWrite = this.metadataWriteSet ? this.metadataWrite : parentMessage.metadataWrite;
+                if(metadataWrite == null)
+                    throw new NullPointerException("Property metadataWrite must not be null");
+                long instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                long config = this.configSet ? this.config : parentMessage.config;
+                long maxEntries = this.maxEntriesSet ? this.maxEntries : parentMessage.maxEntries;
+                long activeCount = this.activeCountSet ? this.activeCount : parentMessage.activeCount;
+                U64 lookupCount = this.lookupCountSet ? this.lookupCount : parentMessage.lookupCount;
+                if(lookupCount == null)
+                    throw new NullPointerException("Property lookupCount must not be null");
+                U64 matchedCount = this.matchedCountSet ? this.matchedCount : parentMessage.matchedCount;
+                if(matchedCount == null)
+                    throw new NullPointerException("Property matchedCount must not be null");
+
+                //
+                return new OFTableStatsEntryVer12(
+                    tableId,
+                    name,
+                    match,
+                    wildcards,
+                    writeActions,
+                    applyActions,
+                    writeSetfields,
+                    applySetfields,
+                    metadataMatch,
+                    metadataWrite,
+                    instructions,
+                    config,
+                    maxEntries,
+                    activeCount,
+                    lookupCount,
+                    matchedCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean matchSet;
+        private OFMatchBmap match;
+        private boolean wildcardsSet;
+        private int wildcards;
+        private boolean writeActionsSet;
+        private long writeActions;
+        private boolean applyActionsSet;
+        private long applyActions;
+        private boolean writeSetfieldsSet;
+        private U64 writeSetfields;
+        private boolean applySetfieldsSet;
+        private U64 applySetfields;
+        private boolean metadataMatchSet;
+        private U64 metadataMatch;
+        private boolean metadataWriteSet;
+        private U64 metadataWrite;
+        private boolean instructionsSet;
+        private long instructions;
+        private boolean configSet;
+        private long config;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+        private boolean activeCountSet;
+        private long activeCount;
+        private boolean lookupCountSet;
+        private U64 lookupCount;
+        private boolean matchedCountSet;
+        private U64 matchedCount;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public OFMatchBmap getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatch(OFMatchBmap match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public int getWildcards() {
+        return wildcards;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWildcards(int wildcards) {
+        this.wildcards = wildcards;
+        this.wildcardsSet = true;
+        return this;
+    }
+    @Override
+    public long getWriteActions() {
+        return writeActions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteActions(long writeActions) {
+        this.writeActions = writeActions;
+        this.writeActionsSet = true;
+        return this;
+    }
+    @Override
+    public long getApplyActions() {
+        return applyActions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplyActions(long applyActions) {
+        this.applyActions = applyActions;
+        this.applyActionsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getWriteSetfields() {
+        return writeSetfields;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteSetfields(U64 writeSetfields) {
+        this.writeSetfields = writeSetfields;
+        this.writeSetfieldsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getApplySetfields() {
+        return applySetfields;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplySetfields(U64 applySetfields) {
+        this.applySetfields = applySetfields;
+        this.applySetfieldsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMatch() {
+        return metadataMatch;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataMatch(U64 metadataMatch) {
+        this.metadataMatch = metadataMatch;
+        this.metadataMatchSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataWrite() {
+        return metadataWrite;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataWrite(U64 metadataWrite) {
+        this.metadataWrite = metadataWrite;
+        this.metadataWriteSet = true;
+        return this;
+    }
+    @Override
+    public long getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setInstructions(long instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setActiveCount(long activeCount) {
+        this.activeCount = activeCount;
+        this.activeCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setLookupCount(U64 lookupCount) {
+        this.lookupCount = lookupCount;
+        this.lookupCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatchedCount(U64 matchedCount) {
+        this.matchedCount = matchedCount;
+        this.matchedCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+//
+        @Override
+        public OFTableStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            if(!this.matchSet)
+                throw new IllegalStateException("Property match doesn't have default value -- must be set");
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            int wildcards = this.wildcardsSet ? this.wildcards : DEFAULT_WILDCARDS;
+            long writeActions = this.writeActionsSet ? this.writeActions : DEFAULT_WRITE_ACTIONS;
+            long applyActions = this.applyActionsSet ? this.applyActions : DEFAULT_APPLY_ACTIONS;
+            U64 writeSetfields = this.writeSetfieldsSet ? this.writeSetfields : DEFAULT_WRITE_SETFIELDS;
+            if(writeSetfields == null)
+                throw new NullPointerException("Property writeSetfields must not be null");
+            U64 applySetfields = this.applySetfieldsSet ? this.applySetfields : DEFAULT_APPLY_SETFIELDS;
+            if(applySetfields == null)
+                throw new NullPointerException("Property applySetfields must not be null");
+            U64 metadataMatch = this.metadataMatchSet ? this.metadataMatch : DEFAULT_METADATA_MATCH;
+            if(metadataMatch == null)
+                throw new NullPointerException("Property metadataMatch must not be null");
+            U64 metadataWrite = this.metadataWriteSet ? this.metadataWrite : DEFAULT_METADATA_WRITE;
+            if(metadataWrite == null)
+                throw new NullPointerException("Property metadataWrite must not be null");
+            long instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+            long maxEntries = this.maxEntriesSet ? this.maxEntries : DEFAULT_MAX_ENTRIES;
+            long activeCount = this.activeCountSet ? this.activeCount : DEFAULT_ACTIVE_COUNT;
+            U64 lookupCount = this.lookupCountSet ? this.lookupCount : DEFAULT_LOOKUP_COUNT;
+            if(lookupCount == null)
+                throw new NullPointerException("Property lookupCount must not be null");
+            U64 matchedCount = this.matchedCountSet ? this.matchedCount : DEFAULT_MATCHED_COUNT;
+            if(matchedCount == null)
+                throw new NullPointerException("Property matchedCount must not be null");
+
+
+            return new OFTableStatsEntryVer12(
+                    tableId,
+                    name,
+                    match,
+                    wildcards,
+                    writeActions,
+                    applyActions,
+                    writeSetfields,
+                    applySetfields,
+                    metadataMatch,
+                    metadataWrite,
+                    instructions,
+                    config,
+                    maxEntries,
+                    activeCount,
+                    lookupCount,
+                    matchedCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsEntry> {
+        @Override
+        public OFTableStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            TableId tableId = TableId.readByte(bb);
+            // pad: 7 bytes
+            bb.skipBytes(7);
+            String name = ChannelUtils.readFixedLengthString(bb, 32);
+            OFMatchBmap match = ChannelUtilsVer12.readOFMatchBmap(bb);
+            int wildcards = bb.readInt();
+            long writeActions = U32.f(bb.readInt());
+            long applyActions = U32.f(bb.readInt());
+            U64 writeSetfields = U64.ofRaw(bb.readLong());
+            U64 applySetfields = U64.ofRaw(bb.readLong());
+            U64 metadataMatch = U64.ofRaw(bb.readLong());
+            U64 metadataWrite = U64.ofRaw(bb.readLong());
+            long instructions = U32.f(bb.readInt());
+            long config = U32.f(bb.readInt());
+            long maxEntries = U32.f(bb.readInt());
+            long activeCount = U32.f(bb.readInt());
+            U64 lookupCount = U64.ofRaw(bb.readLong());
+            U64 matchedCount = U64.ofRaw(bb.readLong());
+
+            OFTableStatsEntryVer12 tableStatsEntryVer12 = new OFTableStatsEntryVer12(
+                    tableId,
+                      name,
+                      match,
+                      wildcards,
+                      writeActions,
+                      applyActions,
+                      writeSetfields,
+                      applySetfields,
+                      metadataMatch,
+                      metadataWrite,
+                      instructions,
+                      config,
+                      maxEntries,
+                      activeCount,
+                      lookupCount,
+                      matchedCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsEntryVer12);
+            return tableStatsEntryVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsEntryVer12Funnel FUNNEL = new OFTableStatsEntryVer12Funnel();
+    static class OFTableStatsEntryVer12Funnel implements Funnel<OFTableStatsEntryVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsEntryVer12 message, PrimitiveSink sink) {
+            message.tableId.putTo(sink);
+            // skip pad (7 bytes)
+            sink.putUnencodedChars(message.name);
+            message.match.putTo(sink);
+            sink.putInt(message.wildcards);
+            sink.putLong(message.writeActions);
+            sink.putLong(message.applyActions);
+            message.writeSetfields.putTo(sink);
+            message.applySetfields.putTo(sink);
+            message.metadataMatch.putTo(sink);
+            message.metadataWrite.putTo(sink);
+            sink.putLong(message.instructions);
+            sink.putLong(message.config);
+            sink.putLong(message.maxEntries);
+            sink.putLong(message.activeCount);
+            message.lookupCount.putTo(sink);
+            message.matchedCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsEntryVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsEntryVer12 message) {
+            message.tableId.writeByte(bb);
+            // pad: 7 bytes
+            bb.writeZero(7);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 32);
+            ChannelUtilsVer12.writeOFMatchBmap(bb, message.match);
+            bb.writeInt(message.wildcards);
+            bb.writeInt(U32.t(message.writeActions));
+            bb.writeInt(U32.t(message.applyActions));
+            bb.writeLong(message.writeSetfields.getValue());
+            bb.writeLong(message.applySetfields.getValue());
+            bb.writeLong(message.metadataMatch.getValue());
+            bb.writeLong(message.metadataWrite.getValue());
+            bb.writeInt(U32.t(message.instructions));
+            bb.writeInt(U32.t(message.config));
+            bb.writeInt(U32.t(message.maxEntries));
+            bb.writeInt(U32.t(message.activeCount));
+            bb.writeLong(message.lookupCount.getValue());
+            bb.writeLong(message.matchedCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsEntryVer12(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("wildcards=").append(wildcards);
+        b.append(", ");
+        b.append("writeActions=").append(writeActions);
+        b.append(", ");
+        b.append("applyActions=").append(applyActions);
+        b.append(", ");
+        b.append("writeSetfields=").append(writeSetfields);
+        b.append(", ");
+        b.append("applySetfields=").append(applySetfields);
+        b.append(", ");
+        b.append("metadataMatch=").append(metadataMatch);
+        b.append(", ");
+        b.append("metadataWrite=").append(metadataWrite);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("maxEntries=").append(maxEntries);
+        b.append(", ");
+        b.append("activeCount=").append(activeCount);
+        b.append(", ");
+        b.append("lookupCount=").append(lookupCount);
+        b.append(", ");
+        b.append("matchedCount=").append(matchedCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsEntryVer12 other = (OFTableStatsEntryVer12) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if( wildcards != other.wildcards)
+            return false;
+        if( writeActions != other.writeActions)
+            return false;
+        if( applyActions != other.applyActions)
+            return false;
+        if (writeSetfields == null) {
+            if (other.writeSetfields != null)
+                return false;
+        } else if (!writeSetfields.equals(other.writeSetfields))
+            return false;
+        if (applySetfields == null) {
+            if (other.applySetfields != null)
+                return false;
+        } else if (!applySetfields.equals(other.applySetfields))
+            return false;
+        if (metadataMatch == null) {
+            if (other.metadataMatch != null)
+                return false;
+        } else if (!metadataMatch.equals(other.metadataMatch))
+            return false;
+        if (metadataWrite == null) {
+            if (other.metadataWrite != null)
+                return false;
+        } else if (!metadataWrite.equals(other.metadataWrite))
+            return false;
+        if( instructions != other.instructions)
+            return false;
+        if( config != other.config)
+            return false;
+        if( maxEntries != other.maxEntries)
+            return false;
+        if( activeCount != other.activeCount)
+            return false;
+        if (lookupCount == null) {
+            if (other.lookupCount != null)
+                return false;
+        } else if (!lookupCount.equals(other.lookupCount))
+            return false;
+        if (matchedCount == null) {
+            if (other.matchedCount != null)
+                return false;
+        } else if (!matchedCount.equals(other.matchedCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + wildcards;
+        result = prime *  (int) (writeActions ^ (writeActions >>> 32));
+        result = prime *  (int) (applyActions ^ (applyActions >>> 32));
+        result = prime * result + ((writeSetfields == null) ? 0 : writeSetfields.hashCode());
+        result = prime * result + ((applySetfields == null) ? 0 : applySetfields.hashCode());
+        result = prime * result + ((metadataMatch == null) ? 0 : metadataMatch.hashCode());
+        result = prime * result + ((metadataWrite == null) ? 0 : metadataWrite.hashCode());
+        result = prime *  (int) (instructions ^ (instructions >>> 32));
+        result = prime *  (int) (config ^ (config >>> 32));
+        result = prime *  (int) (maxEntries ^ (maxEntries >>> 32));
+        result = prime *  (int) (activeCount ^ (activeCount >>> 32));
+        result = prime * result + ((lookupCount == null) ? 0 : lookupCount.hashCode());
+        result = prime * result + ((matchedCount == null) ? 0 : matchedCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsReplyVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsReplyVer12.java
new file mode 100644
index 0000000..9cf743a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsReplyVer12.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsReplyVer12 implements OFTableStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsReplyVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFTableStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFTableStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFTableStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFTableStatsReplyVer12 DEFAULT = new OFTableStatsReplyVer12(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsReplyVer12(long xid, Set<OFStatsReplyFlags> flags, List<OFTableStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFTableStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsReply.Builder {
+        final OFTableStatsReplyVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableStatsEntry> entries;
+
+        BuilderWithParent(OFTableStatsReplyVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setEntries(List<OFTableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFTableStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFTableStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setEntries(List<OFTableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFTableStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFTableStatsReplyVer12(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsReply> {
+        @Override
+        public OFTableStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 3
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x3)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFTableStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFTableStatsEntryVer12.READER);
+
+            OFTableStatsReplyVer12 tableStatsReplyVer12 = new OFTableStatsReplyVer12(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsReplyVer12);
+            return tableStatsReplyVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsReplyVer12Funnel FUNNEL = new OFTableStatsReplyVer12Funnel();
+    static class OFTableStatsReplyVer12Funnel implements Funnel<OFTableStatsReplyVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsReplyVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 3
+            sink.putShort((short) 0x3);
+            OFStatsReplyFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsReplyVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsReplyVer12 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 3
+            bb.writeShort((short) 0x3);
+            OFStatsReplyFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsReplyVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsReplyVer12 other = (OFTableStatsReplyVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsRequestVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsRequestVer12.java
new file mode 100644
index 0000000..e924e1a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTableStatsRequestVer12.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsRequestVer12 implements OFTableStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsRequestVer12.class);
+    // version: 1.2
+    final static byte WIRE_VERSION = 3;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFTableStatsRequestVer12 DEFAULT = new OFTableStatsRequestVer12(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsRequestVer12(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFTableStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsRequest.Builder {
+        final OFTableStatsRequestVer12 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFTableStatsRequestVer12 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFTableStatsRequestVer12(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_12;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFTableStatsRequestVer12(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsRequest> {
+        @Override
+        public OFTableStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 3
+            byte version = bb.readByte();
+            if(version != (byte) 0x3)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 3
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x3)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer12.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFTableStatsRequestVer12 tableStatsRequestVer12 = new OFTableStatsRequestVer12(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsRequestVer12);
+            return tableStatsRequestVer12;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsRequestVer12Funnel FUNNEL = new OFTableStatsRequestVer12Funnel();
+    static class OFTableStatsRequestVer12Funnel implements Funnel<OFTableStatsRequestVer12> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsRequestVer12 message, PrimitiveSink sink) {
+            // fixed value property version = 3
+            sink.putByte((byte) 0x3);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 3
+            sink.putShort((short) 0x3);
+            OFStatsRequestFlagsSerializerVer12.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsRequestVer12> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsRequestVer12 message) {
+            // fixed value property version = 3
+            bb.writeByte((byte) 0x3);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 3
+            bb.writeShort((short) 0x3);
+            OFStatsRequestFlagsSerializerVer12.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsRequestVer12(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsRequestVer12 other = (OFTableStatsRequestVer12) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTypeSerializerVer12.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTypeSerializerVer12.java
new file mode 100644
index 0000000..e1f4b8e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver12/OFTypeSerializerVer12.java
@@ -0,0 +1,194 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTypeSerializerVer12 {
+
+    public final static byte HELLO_VAL = (byte) 0x0;
+    public final static byte ERROR_VAL = (byte) 0x1;
+    public final static byte ECHO_REQUEST_VAL = (byte) 0x2;
+    public final static byte ECHO_REPLY_VAL = (byte) 0x3;
+    public final static byte EXPERIMENTER_VAL = (byte) 0x4;
+    public final static byte FEATURES_REQUEST_VAL = (byte) 0x5;
+    public final static byte FEATURES_REPLY_VAL = (byte) 0x6;
+    public final static byte GET_CONFIG_REQUEST_VAL = (byte) 0x7;
+    public final static byte GET_CONFIG_REPLY_VAL = (byte) 0x8;
+    public final static byte SET_CONFIG_VAL = (byte) 0x9;
+    public final static byte PACKET_IN_VAL = (byte) 0xa;
+    public final static byte FLOW_REMOVED_VAL = (byte) 0xb;
+    public final static byte PORT_STATUS_VAL = (byte) 0xc;
+    public final static byte PACKET_OUT_VAL = (byte) 0xd;
+    public final static byte FLOW_MOD_VAL = (byte) 0xe;
+    public final static byte GROUP_MOD_VAL = (byte) 0xf;
+    public final static byte PORT_MOD_VAL = (byte) 0x10;
+    public final static byte TABLE_MOD_VAL = (byte) 0x11;
+    public final static byte STATS_REQUEST_VAL = (byte) 0x12;
+    public final static byte STATS_REPLY_VAL = (byte) 0x13;
+    public final static byte BARRIER_REQUEST_VAL = (byte) 0x14;
+    public final static byte BARRIER_REPLY_VAL = (byte) 0x15;
+    public final static byte QUEUE_GET_CONFIG_REQUEST_VAL = (byte) 0x16;
+    public final static byte QUEUE_GET_CONFIG_REPLY_VAL = (byte) 0x17;
+    public final static byte ROLE_REQUEST_VAL = (byte) 0x18;
+    public final static byte ROLE_REPLY_VAL = (byte) 0x19;
+
+    public static OFType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFType e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFType e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFType ofWireValue(byte val) {
+        switch(val) {
+            case HELLO_VAL:
+                return OFType.HELLO;
+            case ERROR_VAL:
+                return OFType.ERROR;
+            case ECHO_REQUEST_VAL:
+                return OFType.ECHO_REQUEST;
+            case ECHO_REPLY_VAL:
+                return OFType.ECHO_REPLY;
+            case EXPERIMENTER_VAL:
+                return OFType.EXPERIMENTER;
+            case FEATURES_REQUEST_VAL:
+                return OFType.FEATURES_REQUEST;
+            case FEATURES_REPLY_VAL:
+                return OFType.FEATURES_REPLY;
+            case GET_CONFIG_REQUEST_VAL:
+                return OFType.GET_CONFIG_REQUEST;
+            case GET_CONFIG_REPLY_VAL:
+                return OFType.GET_CONFIG_REPLY;
+            case SET_CONFIG_VAL:
+                return OFType.SET_CONFIG;
+            case PACKET_IN_VAL:
+                return OFType.PACKET_IN;
+            case FLOW_REMOVED_VAL:
+                return OFType.FLOW_REMOVED;
+            case PORT_STATUS_VAL:
+                return OFType.PORT_STATUS;
+            case PACKET_OUT_VAL:
+                return OFType.PACKET_OUT;
+            case FLOW_MOD_VAL:
+                return OFType.FLOW_MOD;
+            case GROUP_MOD_VAL:
+                return OFType.GROUP_MOD;
+            case PORT_MOD_VAL:
+                return OFType.PORT_MOD;
+            case TABLE_MOD_VAL:
+                return OFType.TABLE_MOD;
+            case STATS_REQUEST_VAL:
+                return OFType.STATS_REQUEST;
+            case STATS_REPLY_VAL:
+                return OFType.STATS_REPLY;
+            case BARRIER_REQUEST_VAL:
+                return OFType.BARRIER_REQUEST;
+            case BARRIER_REPLY_VAL:
+                return OFType.BARRIER_REPLY;
+            case QUEUE_GET_CONFIG_REQUEST_VAL:
+                return OFType.QUEUE_GET_CONFIG_REQUEST;
+            case QUEUE_GET_CONFIG_REPLY_VAL:
+                return OFType.QUEUE_GET_CONFIG_REPLY;
+            case ROLE_REQUEST_VAL:
+                return OFType.ROLE_REQUEST;
+            case ROLE_REPLY_VAL:
+                return OFType.ROLE_REPLY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFType in version 1.2: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFType e) {
+        switch(e) {
+            case HELLO:
+                return HELLO_VAL;
+            case ERROR:
+                return ERROR_VAL;
+            case ECHO_REQUEST:
+                return ECHO_REQUEST_VAL;
+            case ECHO_REPLY:
+                return ECHO_REPLY_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            case FEATURES_REQUEST:
+                return FEATURES_REQUEST_VAL;
+            case FEATURES_REPLY:
+                return FEATURES_REPLY_VAL;
+            case GET_CONFIG_REQUEST:
+                return GET_CONFIG_REQUEST_VAL;
+            case GET_CONFIG_REPLY:
+                return GET_CONFIG_REPLY_VAL;
+            case SET_CONFIG:
+                return SET_CONFIG_VAL;
+            case PACKET_IN:
+                return PACKET_IN_VAL;
+            case FLOW_REMOVED:
+                return FLOW_REMOVED_VAL;
+            case PORT_STATUS:
+                return PORT_STATUS_VAL;
+            case PACKET_OUT:
+                return PACKET_OUT_VAL;
+            case FLOW_MOD:
+                return FLOW_MOD_VAL;
+            case GROUP_MOD:
+                return GROUP_MOD_VAL;
+            case PORT_MOD:
+                return PORT_MOD_VAL;
+            case TABLE_MOD:
+                return TABLE_MOD_VAL;
+            case STATS_REQUEST:
+                return STATS_REQUEST_VAL;
+            case STATS_REPLY:
+                return STATS_REPLY_VAL;
+            case BARRIER_REQUEST:
+                return BARRIER_REQUEST_VAL;
+            case BARRIER_REPLY:
+                return BARRIER_REPLY_VAL;
+            case QUEUE_GET_CONFIG_REQUEST:
+                return QUEUE_GET_CONFIG_REQUEST_VAL;
+            case QUEUE_GET_CONFIG_REPLY:
+                return QUEUE_GET_CONFIG_REPLY_VAL;
+            case ROLE_REQUEST:
+                return ROLE_REQUEST_VAL;
+            case ROLE_REPLY:
+                return ROLE_REPLY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFType in version 1.2: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnChecksumVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnChecksumVer13.java
new file mode 100644
index 0000000..a6c164c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnChecksumVer13.java
@@ -0,0 +1,313 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnChecksumVer13 implements OFActionBsnChecksum {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnChecksumVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 28;
+
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+
+    // OF message fields
+    private final U128 checksum;
+//
+    // Immutable default instance
+    final static OFActionBsnChecksumVer13 DEFAULT = new OFActionBsnChecksumVer13(
+        DEFAULT_CHECKSUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnChecksumVer13(U128 checksum) {
+        this.checksum = checksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionBsnChecksum.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnChecksum.Builder {
+        final OFActionBsnChecksumVer13 parentMessage;
+
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+        BuilderWithParent(OFActionBsnChecksumVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFActionBsnChecksum.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionBsnChecksum build() {
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+
+                //
+                return new OFActionBsnChecksumVer13(
+                    checksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnChecksum.Builder {
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFActionBsnChecksum.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionBsnChecksum build() {
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+
+
+            return new OFActionBsnChecksumVer13(
+                    checksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnChecksum> {
+        @Override
+        public OFActionBsnChecksum readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 28)
+                throw new OFParseError("Wrong length: Expected=28(28), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            U128 checksum = U128.read16Bytes(bb);
+
+            OFActionBsnChecksumVer13 actionBsnChecksumVer13 = new OFActionBsnChecksumVer13(
+                    checksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnChecksumVer13);
+            return actionBsnChecksumVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnChecksumVer13Funnel FUNNEL = new OFActionBsnChecksumVer13Funnel();
+    static class OFActionBsnChecksumVer13Funnel implements Funnel<OFActionBsnChecksumVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnChecksumVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 28
+            sink.putShort((short) 0x1c);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            message.checksum.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnChecksumVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnChecksumVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 28
+            bb.writeShort((short) 0x1c);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            message.checksum.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnChecksumVer13(");
+        b.append("checksum=").append(checksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnChecksumVer13 other = (OFActionBsnChecksumVer13) obj;
+
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnMirrorVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnMirrorVer13.java
new file mode 100644
index 0000000..1c86a08
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnMirrorVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnMirrorVer13 implements OFActionBsnMirror {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnMirrorVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static OFPort DEFAULT_DEST_PORT = OFPort.ANY;
+        private final static long DEFAULT_VLAN_TAG = 0x0L;
+        private final static short DEFAULT_COPY_STAGE = (short) 0x0;
+
+    // OF message fields
+    private final OFPort destPort;
+    private final long vlanTag;
+    private final short copyStage;
+//
+    // Immutable default instance
+    final static OFActionBsnMirrorVer13 DEFAULT = new OFActionBsnMirrorVer13(
+        DEFAULT_DEST_PORT, DEFAULT_VLAN_TAG, DEFAULT_COPY_STAGE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnMirrorVer13(OFPort destPort, long vlanTag, short copyStage) {
+        this.destPort = destPort;
+        this.vlanTag = vlanTag;
+        this.copyStage = copyStage;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionBsnMirror.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnMirror.Builder {
+        final OFActionBsnMirrorVer13 parentMessage;
+
+        // OF message fields
+        private boolean destPortSet;
+        private OFPort destPort;
+        private boolean vlanTagSet;
+        private long vlanTag;
+        private boolean copyStageSet;
+        private short copyStage;
+
+        BuilderWithParent(OFActionBsnMirrorVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setDestPort(OFPort destPort) {
+        this.destPort = destPort;
+        this.destPortSet = true;
+        return this;
+    }
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setVlanTag(long vlanTag) {
+        this.vlanTag = vlanTag;
+        this.vlanTagSet = true;
+        return this;
+    }
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setCopyStage(short copyStage) {
+        this.copyStage = copyStage;
+        this.copyStageSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionBsnMirror build() {
+                OFPort destPort = this.destPortSet ? this.destPort : parentMessage.destPort;
+                if(destPort == null)
+                    throw new NullPointerException("Property destPort must not be null");
+                long vlanTag = this.vlanTagSet ? this.vlanTag : parentMessage.vlanTag;
+                short copyStage = this.copyStageSet ? this.copyStage : parentMessage.copyStage;
+
+                //
+                return new OFActionBsnMirrorVer13(
+                    destPort,
+                    vlanTag,
+                    copyStage
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnMirror.Builder {
+        // OF message fields
+        private boolean destPortSet;
+        private OFPort destPort;
+        private boolean vlanTagSet;
+        private long vlanTag;
+        private boolean copyStageSet;
+        private short copyStage;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFPort getDestPort() {
+        return destPort;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setDestPort(OFPort destPort) {
+        this.destPort = destPort;
+        this.destPortSet = true;
+        return this;
+    }
+    @Override
+    public long getVlanTag() {
+        return vlanTag;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setVlanTag(long vlanTag) {
+        this.vlanTag = vlanTag;
+        this.vlanTagSet = true;
+        return this;
+    }
+    @Override
+    public short getCopyStage() {
+        return copyStage;
+    }
+
+    @Override
+    public OFActionBsnMirror.Builder setCopyStage(short copyStage) {
+        this.copyStage = copyStage;
+        this.copyStageSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionBsnMirror build() {
+            OFPort destPort = this.destPortSet ? this.destPort : DEFAULT_DEST_PORT;
+            if(destPort == null)
+                throw new NullPointerException("Property destPort must not be null");
+            long vlanTag = this.vlanTagSet ? this.vlanTag : DEFAULT_VLAN_TAG;
+            short copyStage = this.copyStageSet ? this.copyStage : DEFAULT_COPY_STAGE;
+
+
+            return new OFActionBsnMirrorVer13(
+                    destPort,
+                    vlanTag,
+                    copyStage
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnMirror> {
+        @Override
+        public OFActionBsnMirror readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+            OFPort destPort = OFPort.read4Bytes(bb);
+            long vlanTag = U32.f(bb.readInt());
+            short copyStage = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionBsnMirrorVer13 actionBsnMirrorVer13 = new OFActionBsnMirrorVer13(
+                    destPort,
+                      vlanTag,
+                      copyStage
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnMirrorVer13);
+            return actionBsnMirrorVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnMirrorVer13Funnel FUNNEL = new OFActionBsnMirrorVer13Funnel();
+    static class OFActionBsnMirrorVer13Funnel implements Funnel<OFActionBsnMirrorVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnMirrorVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+            message.destPort.putTo(sink);
+            sink.putLong(message.vlanTag);
+            sink.putShort(message.copyStage);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnMirrorVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnMirrorVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+            message.destPort.write4Bytes(bb);
+            bb.writeInt(U32.t(message.vlanTag));
+            bb.writeByte(U8.t(message.copyStage));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnMirrorVer13(");
+        b.append("destPort=").append(destPort);
+        b.append(", ");
+        b.append("vlanTag=").append(vlanTag);
+        b.append(", ");
+        b.append("copyStage=").append(copyStage);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnMirrorVer13 other = (OFActionBsnMirrorVer13) obj;
+
+        if (destPort == null) {
+            if (other.destPort != null)
+                return false;
+        } else if (!destPort.equals(other.destPort))
+            return false;
+        if( vlanTag != other.vlanTag)
+            return false;
+        if( copyStage != other.copyStage)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((destPort == null) ? 0 : destPort.hashCode());
+        result = prime *  (int) (vlanTag ^ (vlanTag >>> 32));
+        result = prime * result + copyStage;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnSetTunnelDstVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnSetTunnelDstVer13.java
new file mode 100644
index 0000000..32cd4d0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnSetTunnelDstVer13.java
@@ -0,0 +1,306 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionBsnSetTunnelDstVer13 implements OFActionBsnSetTunnelDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionBsnSetTunnelDstVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_DST = 0x0L;
+
+    // OF message fields
+    private final long dst;
+//
+    // Immutable default instance
+    final static OFActionBsnSetTunnelDstVer13 DEFAULT = new OFActionBsnSetTunnelDstVer13(
+        DEFAULT_DST
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionBsnSetTunnelDstVer13(long dst) {
+        this.dst = dst;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionBsnSetTunnelDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionBsnSetTunnelDst.Builder {
+        final OFActionBsnSetTunnelDstVer13 parentMessage;
+
+        // OF message fields
+        private boolean dstSet;
+        private long dst;
+
+        BuilderWithParent(OFActionBsnSetTunnelDstVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFActionBsnSetTunnelDst.Builder setDst(long dst) {
+        this.dst = dst;
+        this.dstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionBsnSetTunnelDst build() {
+                long dst = this.dstSet ? this.dst : parentMessage.dst;
+
+                //
+                return new OFActionBsnSetTunnelDstVer13(
+                    dst
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionBsnSetTunnelDst.Builder {
+        // OF message fields
+        private boolean dstSet;
+        private long dst;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public long getDst() {
+        return dst;
+    }
+
+    @Override
+    public OFActionBsnSetTunnelDst.Builder setDst(long dst) {
+        this.dst = dst;
+        this.dstSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionBsnSetTunnelDst build() {
+            long dst = this.dstSet ? this.dst : DEFAULT_DST;
+
+
+            return new OFActionBsnSetTunnelDstVer13(
+                    dst
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionBsnSetTunnelDst> {
+        @Override
+        public OFActionBsnSetTunnelDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+            long dst = U32.f(bb.readInt());
+
+            OFActionBsnSetTunnelDstVer13 actionBsnSetTunnelDstVer13 = new OFActionBsnSetTunnelDstVer13(
+                    dst
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionBsnSetTunnelDstVer13);
+            return actionBsnSetTunnelDstVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionBsnSetTunnelDstVer13Funnel FUNNEL = new OFActionBsnSetTunnelDstVer13Funnel();
+    static class OFActionBsnSetTunnelDstVer13Funnel implements Funnel<OFActionBsnSetTunnelDstVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionBsnSetTunnelDstVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+            sink.putLong(message.dst);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionBsnSetTunnelDstVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionBsnSetTunnelDstVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+            bb.writeInt(U32.t(message.dst));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionBsnSetTunnelDstVer13(");
+        b.append("dst=").append(dst);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionBsnSetTunnelDstVer13 other = (OFActionBsnSetTunnelDstVer13) obj;
+
+        if( dst != other.dst)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (dst ^ (dst >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnVer13.java
new file mode 100644
index 0000000..02a568d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionBsnVer13.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionBsnVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFActionBsnVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionBsn> {
+        @Override
+        public OFActionBsn readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFActionBsnChecksumVer13
+                   return OFActionBsnChecksumVer13.READER.readFrom(bb);
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFActionBsnMirrorVer13
+                   return OFActionBsnMirrorVer13.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFActionBsnSetTunnelDstVer13
+                   return OFActionBsnSetTunnelDstVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionBsnVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionCopyTtlInVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionCopyTtlInVer13.java
new file mode 100644
index 0000000..6713acc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionCopyTtlInVer13.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionCopyTtlInVer13 implements OFActionCopyTtlIn {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionCopyTtlInVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionCopyTtlInVer13 DEFAULT = new OFActionCopyTtlInVer13(
+
+    );
+
+    final static OFActionCopyTtlInVer13 INSTANCE = new OFActionCopyTtlInVer13();
+    // private empty constructor - use shared instance!
+    private OFActionCopyTtlInVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.COPY_TTL_IN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionCopyTtlIn.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionCopyTtlInVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionCopyTtlIn> {
+        @Override
+        public OFActionCopyTtlIn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 12
+            short type = bb.readShort();
+            if(type != (short) 0xc)
+                throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_IN(12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionCopyTtlInVer13Funnel FUNNEL = new OFActionCopyTtlInVer13Funnel();
+    static class OFActionCopyTtlInVer13Funnel implements Funnel<OFActionCopyTtlInVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionCopyTtlInVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 12
+            sink.putShort((short) 0xc);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionCopyTtlInVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionCopyTtlInVer13 message) {
+            // fixed value property type = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionCopyTtlInVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionCopyTtlOutVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionCopyTtlOutVer13.java
new file mode 100644
index 0000000..dd1939f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionCopyTtlOutVer13.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionCopyTtlOutVer13 implements OFActionCopyTtlOut {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionCopyTtlOutVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionCopyTtlOutVer13 DEFAULT = new OFActionCopyTtlOutVer13(
+
+    );
+
+    final static OFActionCopyTtlOutVer13 INSTANCE = new OFActionCopyTtlOutVer13();
+    // private empty constructor - use shared instance!
+    private OFActionCopyTtlOutVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.COPY_TTL_OUT;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionCopyTtlOut.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionCopyTtlOutVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionCopyTtlOut> {
+        @Override
+        public OFActionCopyTtlOut readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 11
+            short type = bb.readShort();
+            if(type != (short) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_OUT(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionCopyTtlOutVer13Funnel FUNNEL = new OFActionCopyTtlOutVer13Funnel();
+    static class OFActionCopyTtlOutVer13Funnel implements Funnel<OFActionCopyTtlOutVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionCopyTtlOutVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 11
+            sink.putShort((short) 0xb);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionCopyTtlOutVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionCopyTtlOutVer13 message) {
+            // fixed value property type = 11
+            bb.writeShort((short) 0xb);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionCopyTtlOutVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionDecMplsTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionDecMplsTtlVer13.java
new file mode 100644
index 0000000..8538f06
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionDecMplsTtlVer13.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionDecMplsTtlVer13 implements OFActionDecMplsTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionDecMplsTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionDecMplsTtlVer13 DEFAULT = new OFActionDecMplsTtlVer13(
+
+    );
+
+    final static OFActionDecMplsTtlVer13 INSTANCE = new OFActionDecMplsTtlVer13();
+    // private empty constructor - use shared instance!
+    private OFActionDecMplsTtlVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.DEC_MPLS_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionDecMplsTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionDecMplsTtlVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionDecMplsTtl> {
+        @Override
+        public OFActionDecMplsTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 16
+            short type = bb.readShort();
+            if(type != (short) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFActionType.DEC_MPLS_TTL(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionDecMplsTtlVer13Funnel FUNNEL = new OFActionDecMplsTtlVer13Funnel();
+    static class OFActionDecMplsTtlVer13Funnel implements Funnel<OFActionDecMplsTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionDecMplsTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 16
+            sink.putShort((short) 0x10);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionDecMplsTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionDecMplsTtlVer13 message) {
+            // fixed value property type = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionDecMplsTtlVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionDecNwTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionDecNwTtlVer13.java
new file mode 100644
index 0000000..5f4bb3f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionDecNwTtlVer13.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionDecNwTtlVer13 implements OFActionDecNwTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionDecNwTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionDecNwTtlVer13 DEFAULT = new OFActionDecNwTtlVer13(
+
+    );
+
+    final static OFActionDecNwTtlVer13 INSTANCE = new OFActionDecNwTtlVer13();
+    // private empty constructor - use shared instance!
+    private OFActionDecNwTtlVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.DEC_NW_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionDecNwTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionDecNwTtlVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionDecNwTtl> {
+        @Override
+        public OFActionDecNwTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 24
+            short type = bb.readShort();
+            if(type != (short) 0x18)
+                throw new OFParseError("Wrong type: Expected=OFActionType.DEC_NW_TTL(24), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionDecNwTtlVer13Funnel FUNNEL = new OFActionDecNwTtlVer13Funnel();
+    static class OFActionDecNwTtlVer13Funnel implements Funnel<OFActionDecNwTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionDecNwTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 24
+            sink.putShort((short) 0x18);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionDecNwTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionDecNwTtlVer13 message) {
+            // fixed value property type = 24
+            bb.writeShort((short) 0x18);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionDecNwTtlVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionExperimenterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionExperimenterVer13.java
new file mode 100644
index 0000000..b92de30
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionExperimenterVer13.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionExperimenterVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionExperimenterVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionExperimenter> {
+        @Override
+        public OFActionExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFActionBsnVer13
+                   return OFActionBsnVer13.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFActionNiciraVer13
+                   return OFActionNiciraVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFActionExperimenterVer13: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionGroupVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionGroupVer13.java
new file mode 100644
index 0000000..0f1f292
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionGroupVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionGroupVer13 implements OFActionGroup {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionGroupVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+
+    // OF message fields
+    private final OFGroup group;
+//
+    // Immutable default instance
+    final static OFActionGroupVer13 DEFAULT = new OFActionGroupVer13(
+        DEFAULT_GROUP_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionGroupVer13(OFGroup group) {
+        this.group = group;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionGroup.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionGroup.Builder {
+        final OFActionGroupVer13 parentMessage;
+
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+
+        BuilderWithParent(OFActionGroupVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFActionGroup.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionGroup build() {
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+
+                //
+                return new OFActionGroupVer13(
+                    group
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionGroup.Builder {
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFActionGroup.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionGroup build() {
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+
+
+            return new OFActionGroupVer13(
+                    group
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionGroup> {
+        @Override
+        public OFActionGroup readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 22
+            short type = bb.readShort();
+            if(type != (short) 0x16)
+                throw new OFParseError("Wrong type: Expected=OFActionType.GROUP(22), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFGroup group = OFGroup.read4Bytes(bb);
+
+            OFActionGroupVer13 actionGroupVer13 = new OFActionGroupVer13(
+                    group
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionGroupVer13);
+            return actionGroupVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionGroupVer13Funnel FUNNEL = new OFActionGroupVer13Funnel();
+    static class OFActionGroupVer13Funnel implements Funnel<OFActionGroupVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionGroupVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 22
+            sink.putShort((short) 0x16);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.group.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionGroupVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionGroupVer13 message) {
+            // fixed value property type = 22
+            bb.writeShort((short) 0x16);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.group.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionGroupVer13(");
+        b.append("group=").append(group);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionGroupVer13 other = (OFActionGroupVer13) obj;
+
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnChecksumVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnChecksumVer13.java
new file mode 100644
index 0000000..58cd114
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnChecksumVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdBsnChecksumVer13 implements OFActionIdBsnChecksum {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdBsnChecksumVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdBsnChecksumVer13 DEFAULT = new OFActionIdBsnChecksumVer13(
+
+    );
+
+    final static OFActionIdBsnChecksumVer13 INSTANCE = new OFActionIdBsnChecksumVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdBsnChecksumVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdBsnChecksum.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdBsnChecksumVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdBsnChecksum> {
+        @Override
+        public OFActionIdBsnChecksum readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdBsnChecksumVer13Funnel FUNNEL = new OFActionIdBsnChecksumVer13Funnel();
+    static class OFActionIdBsnChecksumVer13Funnel implements Funnel<OFActionIdBsnChecksumVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdBsnChecksumVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdBsnChecksumVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdBsnChecksumVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdBsnChecksumVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnMirrorVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnMirrorVer13.java
new file mode 100644
index 0000000..f518ed8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnMirrorVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdBsnMirrorVer13 implements OFActionIdBsnMirror {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdBsnMirrorVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdBsnMirrorVer13 DEFAULT = new OFActionIdBsnMirrorVer13(
+
+    );
+
+    final static OFActionIdBsnMirrorVer13 INSTANCE = new OFActionIdBsnMirrorVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdBsnMirrorVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdBsnMirror.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdBsnMirrorVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdBsnMirror> {
+        @Override
+        public OFActionIdBsnMirror readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdBsnMirrorVer13Funnel FUNNEL = new OFActionIdBsnMirrorVer13Funnel();
+    static class OFActionIdBsnMirrorVer13Funnel implements Funnel<OFActionIdBsnMirrorVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdBsnMirrorVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdBsnMirrorVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdBsnMirrorVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdBsnMirrorVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnSetTunnelDstVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnSetTunnelDstVer13.java
new file mode 100644
index 0000000..433e6fb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnSetTunnelDstVer13.java
@@ -0,0 +1,183 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdBsnSetTunnelDstVer13 implements OFActionIdBsnSetTunnelDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdBsnSetTunnelDstVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdBsnSetTunnelDstVer13 DEFAULT = new OFActionIdBsnSetTunnelDstVer13(
+
+    );
+
+    final static OFActionIdBsnSetTunnelDstVer13 INSTANCE = new OFActionIdBsnSetTunnelDstVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdBsnSetTunnelDstVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdBsnSetTunnelDst.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdBsnSetTunnelDstVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdBsnSetTunnelDst> {
+        @Override
+        public OFActionIdBsnSetTunnelDst readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdBsnSetTunnelDstVer13Funnel FUNNEL = new OFActionIdBsnSetTunnelDstVer13Funnel();
+    static class OFActionIdBsnSetTunnelDstVer13Funnel implements Funnel<OFActionIdBsnSetTunnelDstVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdBsnSetTunnelDstVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdBsnSetTunnelDstVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdBsnSetTunnelDstVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdBsnSetTunnelDstVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnVer13.java
new file mode 100644
index 0000000..24f3819
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdBsnVer13.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionIdBsnVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+
+    public final static OFActionIdBsnVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionIdBsn> {
+        @Override
+        public OFActionIdBsn readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFActionIdBsnChecksumVer13
+                   return OFActionIdBsnChecksumVer13.READER.readFrom(bb);
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFActionIdBsnMirrorVer13
+                   return OFActionIdBsnMirrorVer13.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFActionIdBsnSetTunnelDstVer13
+                   return OFActionIdBsnSetTunnelDstVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionIdBsnVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdCopyTtlInVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdCopyTtlInVer13.java
new file mode 100644
index 0000000..6a99bcf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdCopyTtlInVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdCopyTtlInVer13 implements OFActionIdCopyTtlIn {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdCopyTtlInVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdCopyTtlInVer13 DEFAULT = new OFActionIdCopyTtlInVer13(
+
+    );
+
+    final static OFActionIdCopyTtlInVer13 INSTANCE = new OFActionIdCopyTtlInVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdCopyTtlInVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.COPY_TTL_IN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdCopyTtlIn.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdCopyTtlInVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdCopyTtlIn> {
+        @Override
+        public OFActionIdCopyTtlIn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 12
+            short type = bb.readShort();
+            if(type != (short) 0xc)
+                throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_IN(12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdCopyTtlInVer13Funnel FUNNEL = new OFActionIdCopyTtlInVer13Funnel();
+    static class OFActionIdCopyTtlInVer13Funnel implements Funnel<OFActionIdCopyTtlInVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdCopyTtlInVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 12
+            sink.putShort((short) 0xc);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdCopyTtlInVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdCopyTtlInVer13 message) {
+            // fixed value property type = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdCopyTtlInVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdCopyTtlOutVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdCopyTtlOutVer13.java
new file mode 100644
index 0000000..5e3c7b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdCopyTtlOutVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdCopyTtlOutVer13 implements OFActionIdCopyTtlOut {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdCopyTtlOutVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdCopyTtlOutVer13 DEFAULT = new OFActionIdCopyTtlOutVer13(
+
+    );
+
+    final static OFActionIdCopyTtlOutVer13 INSTANCE = new OFActionIdCopyTtlOutVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdCopyTtlOutVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.COPY_TTL_OUT;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdCopyTtlOut.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdCopyTtlOutVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdCopyTtlOut> {
+        @Override
+        public OFActionIdCopyTtlOut readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 11
+            short type = bb.readShort();
+            if(type != (short) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFActionType.COPY_TTL_OUT(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdCopyTtlOutVer13Funnel FUNNEL = new OFActionIdCopyTtlOutVer13Funnel();
+    static class OFActionIdCopyTtlOutVer13Funnel implements Funnel<OFActionIdCopyTtlOutVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdCopyTtlOutVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 11
+            sink.putShort((short) 0xb);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdCopyTtlOutVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdCopyTtlOutVer13 message) {
+            // fixed value property type = 11
+            bb.writeShort((short) 0xb);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdCopyTtlOutVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdDecMplsTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdDecMplsTtlVer13.java
new file mode 100644
index 0000000..b74d82f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdDecMplsTtlVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdDecMplsTtlVer13 implements OFActionIdDecMplsTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdDecMplsTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdDecMplsTtlVer13 DEFAULT = new OFActionIdDecMplsTtlVer13(
+
+    );
+
+    final static OFActionIdDecMplsTtlVer13 INSTANCE = new OFActionIdDecMplsTtlVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdDecMplsTtlVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.DEC_MPLS_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdDecMplsTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdDecMplsTtlVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdDecMplsTtl> {
+        @Override
+        public OFActionIdDecMplsTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 16
+            short type = bb.readShort();
+            if(type != (short) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFActionType.DEC_MPLS_TTL(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdDecMplsTtlVer13Funnel FUNNEL = new OFActionIdDecMplsTtlVer13Funnel();
+    static class OFActionIdDecMplsTtlVer13Funnel implements Funnel<OFActionIdDecMplsTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdDecMplsTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 16
+            sink.putShort((short) 0x10);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdDecMplsTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdDecMplsTtlVer13 message) {
+            // fixed value property type = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdDecMplsTtlVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdDecNwTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdDecNwTtlVer13.java
new file mode 100644
index 0000000..31b13d1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdDecNwTtlVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdDecNwTtlVer13 implements OFActionIdDecNwTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdDecNwTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdDecNwTtlVer13 DEFAULT = new OFActionIdDecNwTtlVer13(
+
+    );
+
+    final static OFActionIdDecNwTtlVer13 INSTANCE = new OFActionIdDecNwTtlVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdDecNwTtlVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.DEC_NW_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdDecNwTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdDecNwTtlVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdDecNwTtl> {
+        @Override
+        public OFActionIdDecNwTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 24
+            short type = bb.readShort();
+            if(type != (short) 0x18)
+                throw new OFParseError("Wrong type: Expected=OFActionType.DEC_NW_TTL(24), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdDecNwTtlVer13Funnel FUNNEL = new OFActionIdDecNwTtlVer13Funnel();
+    static class OFActionIdDecNwTtlVer13Funnel implements Funnel<OFActionIdDecNwTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdDecNwTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 24
+            sink.putShort((short) 0x18);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdDecNwTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdDecNwTtlVer13 message) {
+            // fixed value property type = 24
+            bb.writeShort((short) 0x18);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdDecNwTtlVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdExperimenterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdExperimenterVer13.java
new file mode 100644
index 0000000..5a82711
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdExperimenterVer13.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionIdExperimenterVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionIdExperimenterVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionIdExperimenter> {
+        @Override
+        public OFActionIdExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFActionIdBsnVer13
+                   return OFActionIdBsnVer13.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFActionIdNiciraVer13
+                   return OFActionIdNiciraVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFActionIdExperimenterVer13: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdGroupVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdGroupVer13.java
new file mode 100644
index 0000000..b9db55f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdGroupVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdGroupVer13 implements OFActionIdGroup {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdGroupVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdGroupVer13 DEFAULT = new OFActionIdGroupVer13(
+
+    );
+
+    final static OFActionIdGroupVer13 INSTANCE = new OFActionIdGroupVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdGroupVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.GROUP;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdGroup.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdGroupVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdGroup> {
+        @Override
+        public OFActionIdGroup readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 22
+            short type = bb.readShort();
+            if(type != (short) 0x16)
+                throw new OFParseError("Wrong type: Expected=OFActionType.GROUP(22), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdGroupVer13Funnel FUNNEL = new OFActionIdGroupVer13Funnel();
+    static class OFActionIdGroupVer13Funnel implements Funnel<OFActionIdGroupVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdGroupVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 22
+            sink.putShort((short) 0x16);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdGroupVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdGroupVer13 message) {
+            // fixed value property type = 22
+            bb.writeShort((short) 0x16);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdGroupVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdNiciraDecTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdNiciraDecTtlVer13.java
new file mode 100644
index 0000000..3bd530b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdNiciraDecTtlVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdNiciraDecTtlVer13 implements OFActionIdNiciraDecTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdNiciraDecTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 10;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdNiciraDecTtlVer13 DEFAULT = new OFActionIdNiciraDecTtlVer13(
+
+    );
+
+    final static OFActionIdNiciraDecTtlVer13 INSTANCE = new OFActionIdNiciraDecTtlVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdNiciraDecTtlVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public int getSubtype() {
+        return 0x12;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdNiciraDecTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdNiciraDecTtlVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdNiciraDecTtl> {
+        @Override
+        public OFActionIdNiciraDecTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 10)
+                throw new OFParseError("Wrong length: Expected=10(10), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            // fixed value property subtype == 0x12
+            short subtype = bb.readShort();
+            if(subtype != (short) 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12(0x12), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdNiciraDecTtlVer13Funnel FUNNEL = new OFActionIdNiciraDecTtlVer13Funnel();
+    static class OFActionIdNiciraDecTtlVer13Funnel implements Funnel<OFActionIdNiciraDecTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdNiciraDecTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 10
+            sink.putShort((short) 0xa);
+            // fixed value property experimenter = 0x2320L
+            sink.putInt(0x2320);
+            // fixed value property subtype = 0x12
+            sink.putShort((short) 0x12);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdNiciraDecTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdNiciraDecTtlVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 10
+            bb.writeShort((short) 0xa);
+            // fixed value property experimenter = 0x2320L
+            bb.writeInt(0x2320);
+            // fixed value property subtype = 0x12
+            bb.writeShort((short) 0x12);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdNiciraDecTtlVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdNiciraVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdNiciraVer13.java
new file mode 100644
index 0000000..096d41a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdNiciraVer13.java
@@ -0,0 +1,64 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionIdNiciraVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 10;
+
+
+    public final static OFActionIdNiciraVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionIdNicira> {
+        @Override
+        public OFActionIdNicira readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            short subtype = bb.readShort();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case (short) 0x12:
+                   // discriminator value 0x12=0x12 for class OFActionIdNiciraDecTtlVer13
+                   return OFActionIdNiciraDecTtlVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionIdNiciraVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdOutputVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdOutputVer13.java
new file mode 100644
index 0000000..2bc085d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdOutputVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdOutputVer13 implements OFActionIdOutput {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdOutputVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdOutputVer13 DEFAULT = new OFActionIdOutputVer13(
+
+    );
+
+    final static OFActionIdOutputVer13 INSTANCE = new OFActionIdOutputVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdOutputVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdOutput.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdOutputVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdOutput> {
+        @Override
+        public OFActionIdOutput readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFActionType.OUTPUT(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdOutputVer13Funnel FUNNEL = new OFActionIdOutputVer13Funnel();
+    static class OFActionIdOutputVer13Funnel implements Funnel<OFActionIdOutputVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdOutputVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdOutputVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdOutputVer13 message) {
+            // fixed value property type = 0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdOutputVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopMplsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopMplsVer13.java
new file mode 100644
index 0000000..8c4ba21
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopMplsVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdPopMplsVer13 implements OFActionIdPopMpls {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdPopMplsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdPopMplsVer13 DEFAULT = new OFActionIdPopMplsVer13(
+
+    );
+
+    final static OFActionIdPopMplsVer13 INSTANCE = new OFActionIdPopMplsVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdPopMplsVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdPopMpls.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdPopMplsVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdPopMpls> {
+        @Override
+        public OFActionIdPopMpls readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 20
+            short type = bb.readShort();
+            if(type != (short) 0x14)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_MPLS(20), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdPopMplsVer13Funnel FUNNEL = new OFActionIdPopMplsVer13Funnel();
+    static class OFActionIdPopMplsVer13Funnel implements Funnel<OFActionIdPopMplsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdPopMplsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 20
+            sink.putShort((short) 0x14);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdPopMplsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdPopMplsVer13 message) {
+            // fixed value property type = 20
+            bb.writeShort((short) 0x14);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdPopMplsVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopPbbVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopPbbVer13.java
new file mode 100644
index 0000000..6abc5f1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopPbbVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdPopPbbVer13 implements OFActionIdPopPbb {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdPopPbbVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdPopPbbVer13 DEFAULT = new OFActionIdPopPbbVer13(
+
+    );
+
+    final static OFActionIdPopPbbVer13 INSTANCE = new OFActionIdPopPbbVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdPopPbbVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_PBB;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdPopPbb.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdPopPbbVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdPopPbb> {
+        @Override
+        public OFActionIdPopPbb readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 27
+            short type = bb.readShort();
+            if(type != (short) 0x1b)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_PBB(27), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdPopPbbVer13Funnel FUNNEL = new OFActionIdPopPbbVer13Funnel();
+    static class OFActionIdPopPbbVer13Funnel implements Funnel<OFActionIdPopPbbVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdPopPbbVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 27
+            sink.putShort((short) 0x1b);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdPopPbbVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdPopPbbVer13 message) {
+            // fixed value property type = 27
+            bb.writeShort((short) 0x1b);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdPopPbbVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopVlanVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopVlanVer13.java
new file mode 100644
index 0000000..20100bd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPopVlanVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdPopVlanVer13 implements OFActionIdPopVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdPopVlanVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdPopVlanVer13 DEFAULT = new OFActionIdPopVlanVer13(
+
+    );
+
+    final static OFActionIdPopVlanVer13 INSTANCE = new OFActionIdPopVlanVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdPopVlanVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_VLAN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdPopVlan.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdPopVlanVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdPopVlan> {
+        @Override
+        public OFActionIdPopVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 18
+            short type = bb.readShort();
+            if(type != (short) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_VLAN(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdPopVlanVer13Funnel FUNNEL = new OFActionIdPopVlanVer13Funnel();
+    static class OFActionIdPopVlanVer13Funnel implements Funnel<OFActionIdPopVlanVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdPopVlanVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 18
+            sink.putShort((short) 0x12);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdPopVlanVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdPopVlanVer13 message) {
+            // fixed value property type = 18
+            bb.writeShort((short) 0x12);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdPopVlanVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushMplsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushMplsVer13.java
new file mode 100644
index 0000000..b320104
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushMplsVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdPushMplsVer13 implements OFActionIdPushMpls {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdPushMplsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdPushMplsVer13 DEFAULT = new OFActionIdPushMplsVer13(
+
+    );
+
+    final static OFActionIdPushMplsVer13 INSTANCE = new OFActionIdPushMplsVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdPushMplsVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdPushMpls.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdPushMplsVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdPushMpls> {
+        @Override
+        public OFActionIdPushMpls readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 19
+            short type = bb.readShort();
+            if(type != (short) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_MPLS(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdPushMplsVer13Funnel FUNNEL = new OFActionIdPushMplsVer13Funnel();
+    static class OFActionIdPushMplsVer13Funnel implements Funnel<OFActionIdPushMplsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdPushMplsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 19
+            sink.putShort((short) 0x13);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdPushMplsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdPushMplsVer13 message) {
+            // fixed value property type = 19
+            bb.writeShort((short) 0x13);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdPushMplsVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushPbbVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushPbbVer13.java
new file mode 100644
index 0000000..9a648e5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushPbbVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdPushPbbVer13 implements OFActionIdPushPbb {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdPushPbbVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdPushPbbVer13 DEFAULT = new OFActionIdPushPbbVer13(
+
+    );
+
+    final static OFActionIdPushPbbVer13 INSTANCE = new OFActionIdPushPbbVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdPushPbbVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_PBB;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdPushPbb.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdPushPbbVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdPushPbb> {
+        @Override
+        public OFActionIdPushPbb readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 26
+            short type = bb.readShort();
+            if(type != (short) 0x1a)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_PBB(26), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdPushPbbVer13Funnel FUNNEL = new OFActionIdPushPbbVer13Funnel();
+    static class OFActionIdPushPbbVer13Funnel implements Funnel<OFActionIdPushPbbVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdPushPbbVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 26
+            sink.putShort((short) 0x1a);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdPushPbbVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdPushPbbVer13 message) {
+            // fixed value property type = 26
+            bb.writeShort((short) 0x1a);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdPushPbbVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushVlanVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushVlanVer13.java
new file mode 100644
index 0000000..aa27c85
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdPushVlanVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdPushVlanVer13 implements OFActionIdPushVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdPushVlanVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdPushVlanVer13 DEFAULT = new OFActionIdPushVlanVer13(
+
+    );
+
+    final static OFActionIdPushVlanVer13 INSTANCE = new OFActionIdPushVlanVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdPushVlanVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdPushVlan.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdPushVlanVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdPushVlan> {
+        @Override
+        public OFActionIdPushVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 17
+            short type = bb.readShort();
+            if(type != (short) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_VLAN(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdPushVlanVer13Funnel FUNNEL = new OFActionIdPushVlanVer13Funnel();
+    static class OFActionIdPushVlanVer13Funnel implements Funnel<OFActionIdPushVlanVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdPushVlanVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 17
+            sink.putShort((short) 0x11);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdPushVlanVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdPushVlanVer13 message) {
+            // fixed value property type = 17
+            bb.writeShort((short) 0x11);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdPushVlanVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetFieldVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetFieldVer13.java
new file mode 100644
index 0000000..d5c3c5d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetFieldVer13.java
@@ -0,0 +1,157 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdSetFieldVer13 implements OFActionIdSetField {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdSetFieldVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdSetFieldVer13 DEFAULT = new OFActionIdSetFieldVer13(
+
+    );
+
+    final static OFActionIdSetFieldVer13 INSTANCE = new OFActionIdSetFieldVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdSetFieldVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_FIELD;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdSetField.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdSetFieldVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdSetField> {
+        @Override
+        public OFActionIdSetField readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 25
+            short type = bb.readShort();
+            if(type != (short) 0x19)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_FIELD(25), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdSetFieldVer13Funnel FUNNEL = new OFActionIdSetFieldVer13Funnel();
+    static class OFActionIdSetFieldVer13Funnel implements Funnel<OFActionIdSetFieldVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdSetFieldVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 25
+            sink.putShort((short) 0x19);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdSetFieldVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdSetFieldVer13 message) {
+            // fixed value property type = 25
+            bb.writeShort((short) 0x19);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdSetFieldVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetMplsTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetMplsTtlVer13.java
new file mode 100644
index 0000000..04f3b85
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetMplsTtlVer13.java
@@ -0,0 +1,157 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdSetMplsTtlVer13 implements OFActionIdSetMplsTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdSetMplsTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdSetMplsTtlVer13 DEFAULT = new OFActionIdSetMplsTtlVer13(
+
+    );
+
+    final static OFActionIdSetMplsTtlVer13 INSTANCE = new OFActionIdSetMplsTtlVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdSetMplsTtlVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdSetMplsTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdSetMplsTtlVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdSetMplsTtl> {
+        @Override
+        public OFActionIdSetMplsTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 15
+            short type = bb.readShort();
+            if(type != (short) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_MPLS_TTL(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdSetMplsTtlVer13Funnel FUNNEL = new OFActionIdSetMplsTtlVer13Funnel();
+    static class OFActionIdSetMplsTtlVer13Funnel implements Funnel<OFActionIdSetMplsTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdSetMplsTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 15
+            sink.putShort((short) 0xf);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdSetMplsTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdSetMplsTtlVer13 message) {
+            // fixed value property type = 15
+            bb.writeShort((short) 0xf);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdSetMplsTtlVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetNwTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetNwTtlVer13.java
new file mode 100644
index 0000000..92b94c5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetNwTtlVer13.java
@@ -0,0 +1,157 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdSetNwTtlVer13 implements OFActionIdSetNwTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdSetNwTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdSetNwTtlVer13 DEFAULT = new OFActionIdSetNwTtlVer13(
+
+    );
+
+    final static OFActionIdSetNwTtlVer13 INSTANCE = new OFActionIdSetNwTtlVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdSetNwTtlVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdSetNwTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdSetNwTtlVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdSetNwTtl> {
+        @Override
+        public OFActionIdSetNwTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 23
+            short type = bb.readShort();
+            if(type != (short) 0x17)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_TTL(23), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdSetNwTtlVer13Funnel FUNNEL = new OFActionIdSetNwTtlVer13Funnel();
+    static class OFActionIdSetNwTtlVer13Funnel implements Funnel<OFActionIdSetNwTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdSetNwTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 23
+            sink.putShort((short) 0x17);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdSetNwTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdSetNwTtlVer13 message) {
+            // fixed value property type = 23
+            bb.writeShort((short) 0x17);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdSetNwTtlVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetQueueVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetQueueVer13.java
new file mode 100644
index 0000000..a32a4c4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdSetQueueVer13.java
@@ -0,0 +1,157 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionIdSetQueueVer13 implements OFActionIdSetQueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionIdSetQueueVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionIdSetQueueVer13 DEFAULT = new OFActionIdSetQueueVer13(
+
+    );
+
+    final static OFActionIdSetQueueVer13 INSTANCE = new OFActionIdSetQueueVer13();
+    // private empty constructor - use shared instance!
+    private OFActionIdSetQueueVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionIdSetQueue.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionIdSetQueueVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionIdSetQueue> {
+        @Override
+        public OFActionIdSetQueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 21
+            short type = bb.readShort();
+            if(type != (short) 0x15)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_QUEUE(21), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionIdSetQueueVer13Funnel FUNNEL = new OFActionIdSetQueueVer13Funnel();
+    static class OFActionIdSetQueueVer13Funnel implements Funnel<OFActionIdSetQueueVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionIdSetQueueVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 21
+            sink.putShort((short) 0x15);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionIdSetQueueVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionIdSetQueueVer13 message) {
+            // fixed value property type = 21
+            bb.writeShort((short) 0x15);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionIdSetQueueVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdVer13.java
new file mode 100644
index 0000000..c7d70ad
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdVer13.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionIdVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFActionIdVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionId> {
+        @Override
+        public OFActionId readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0xffff:
+                   // discriminator value OFActionType.EXPERIMENTER=65535 for class OFActionIdExperimenterVer13
+                   return OFActionIdExperimenterVer13.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value OFActionType.COPY_TTL_IN=12 for class OFActionIdCopyTtlInVer13
+                   return OFActionIdCopyTtlInVer13.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFActionType.COPY_TTL_OUT=11 for class OFActionIdCopyTtlOutVer13
+                   return OFActionIdCopyTtlOutVer13.READER.readFrom(bb);
+               case (short) 0x10:
+                   // discriminator value OFActionType.DEC_MPLS_TTL=16 for class OFActionIdDecMplsTtlVer13
+                   return OFActionIdDecMplsTtlVer13.READER.readFrom(bb);
+               case (short) 0x18:
+                   // discriminator value OFActionType.DEC_NW_TTL=24 for class OFActionIdDecNwTtlVer13
+                   return OFActionIdDecNwTtlVer13.READER.readFrom(bb);
+               case (short) 0x16:
+                   // discriminator value OFActionType.GROUP=22 for class OFActionIdGroupVer13
+                   return OFActionIdGroupVer13.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFActionType.OUTPUT=0 for class OFActionIdOutputVer13
+                   return OFActionIdOutputVer13.READER.readFrom(bb);
+               case (short) 0x14:
+                   // discriminator value OFActionType.POP_MPLS=20 for class OFActionIdPopMplsVer13
+                   return OFActionIdPopMplsVer13.READER.readFrom(bb);
+               case (short) 0x1b:
+                   // discriminator value OFActionType.POP_PBB=27 for class OFActionIdPopPbbVer13
+                   return OFActionIdPopPbbVer13.READER.readFrom(bb);
+               case (short) 0x12:
+                   // discriminator value OFActionType.POP_VLAN=18 for class OFActionIdPopVlanVer13
+                   return OFActionIdPopVlanVer13.READER.readFrom(bb);
+               case (short) 0x13:
+                   // discriminator value OFActionType.PUSH_MPLS=19 for class OFActionIdPushMplsVer13
+                   return OFActionIdPushMplsVer13.READER.readFrom(bb);
+               case (short) 0x1a:
+                   // discriminator value OFActionType.PUSH_PBB=26 for class OFActionIdPushPbbVer13
+                   return OFActionIdPushPbbVer13.READER.readFrom(bb);
+               case (short) 0x11:
+                   // discriminator value OFActionType.PUSH_VLAN=17 for class OFActionIdPushVlanVer13
+                   return OFActionIdPushVlanVer13.READER.readFrom(bb);
+               case (short) 0x19:
+                   // discriminator value OFActionType.SET_FIELD=25 for class OFActionIdSetFieldVer13
+                   return OFActionIdSetFieldVer13.READER.readFrom(bb);
+               case (short) 0xf:
+                   // discriminator value OFActionType.SET_MPLS_TTL=15 for class OFActionIdSetMplsTtlVer13
+                   return OFActionIdSetMplsTtlVer13.READER.readFrom(bb);
+               case (short) 0x17:
+                   // discriminator value OFActionType.SET_NW_TTL=23 for class OFActionIdSetNwTtlVer13
+                   return OFActionIdSetNwTtlVer13.READER.readFrom(bb);
+               case (short) 0x15:
+                   // discriminator value OFActionType.SET_QUEUE=21 for class OFActionIdSetQueueVer13
+                   return OFActionIdSetQueueVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFActionIdVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdsVer13.java
new file mode 100644
index 0000000..a9dc914
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdsVer13.java
@@ -0,0 +1,123 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+
+public class OFActionIdsVer13 implements OFActionIds {
+    public final static OFActionIdsVer13 INSTANCE = new OFActionIdsVer13();
+
+
+
+
+    public OFActionIdBsnChecksum bsnChecksum() {
+        return OFActionIdBsnChecksumVer13.INSTANCE;
+    }
+
+    public OFActionIdBsnMirror bsnMirror() {
+        return OFActionIdBsnMirrorVer13.INSTANCE;
+    }
+
+    public OFActionIdBsnSetTunnelDst bsnSetTunnelDst() {
+        return OFActionIdBsnSetTunnelDstVer13.INSTANCE;
+    }
+
+    public OFActionIdCopyTtlIn copyTtlIn() {
+        return OFActionIdCopyTtlInVer13.INSTANCE;
+    }
+
+    public OFActionIdCopyTtlOut copyTtlOut() {
+        return OFActionIdCopyTtlOutVer13.INSTANCE;
+    }
+
+    public OFActionIdDecMplsTtl decMplsTtl() {
+        return OFActionIdDecMplsTtlVer13.INSTANCE;
+    }
+
+    public OFActionIdDecNwTtl decNwTtl() {
+        return OFActionIdDecNwTtlVer13.INSTANCE;
+    }
+
+    public OFActionIdGroup group() {
+        return OFActionIdGroupVer13.INSTANCE;
+    }
+
+    public OFActionIdNiciraDecTtl niciraDecTtl() {
+        return OFActionIdNiciraDecTtlVer13.INSTANCE;
+    }
+
+    public OFActionIdOutput output() {
+        return OFActionIdOutputVer13.INSTANCE;
+    }
+
+    public OFActionIdPopMpls popMpls() {
+        return OFActionIdPopMplsVer13.INSTANCE;
+    }
+
+    public OFActionIdPopPbb popPbb() {
+        return OFActionIdPopPbbVer13.INSTANCE;
+    }
+
+    public OFActionIdPopVlan popVlan() {
+        return OFActionIdPopVlanVer13.INSTANCE;
+    }
+
+    public OFActionIdPushMpls pushMpls() {
+        return OFActionIdPushMplsVer13.INSTANCE;
+    }
+
+    public OFActionIdPushPbb pushPbb() {
+        return OFActionIdPushPbbVer13.INSTANCE;
+    }
+
+    public OFActionIdPushVlan pushVlan() {
+        return OFActionIdPushVlanVer13.INSTANCE;
+    }
+
+    public OFActionIdSetField setField() {
+        return OFActionIdSetFieldVer13.INSTANCE;
+    }
+
+    public OFActionIdSetMplsTtl setMplsTtl() {
+        return OFActionIdSetMplsTtlVer13.INSTANCE;
+    }
+
+    public OFActionIdSetNwTtl setNwTtl() {
+        return OFActionIdSetNwTtlVer13.INSTANCE;
+    }
+
+    public OFActionIdSetQueue setQueue() {
+        return OFActionIdSetQueueVer13.INSTANCE;
+    }
+
+    public OFMessageReader<OFActionId> getReader() {
+        return OFActionIdVer13.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionNiciraDecTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionNiciraDecTtlVer13.java
new file mode 100644
index 0000000..e0b5ff2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionNiciraDecTtlVer13.java
@@ -0,0 +1,192 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionNiciraDecTtlVer13 implements OFActionNiciraDecTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionNiciraDecTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionNiciraDecTtlVer13 DEFAULT = new OFActionNiciraDecTtlVer13(
+
+    );
+
+    final static OFActionNiciraDecTtlVer13 INSTANCE = new OFActionNiciraDecTtlVer13();
+    // private empty constructor - use shared instance!
+    private OFActionNiciraDecTtlVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x2320L;
+    }
+
+    @Override
+    public int getSubtype() {
+        return 0x12;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionNiciraDecTtl.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionNiciraDecTtlVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionNiciraDecTtl> {
+        @Override
+        public OFActionNiciraDecTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            // fixed value property subtype == 0x12
+            short subtype = bb.readShort();
+            if(subtype != (short) 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12(0x12), got="+subtype);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionNiciraDecTtlVer13Funnel FUNNEL = new OFActionNiciraDecTtlVer13Funnel();
+    static class OFActionNiciraDecTtlVer13Funnel implements Funnel<OFActionNiciraDecTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionNiciraDecTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x2320L
+            sink.putInt(0x2320);
+            // fixed value property subtype = 0x12
+            sink.putShort((short) 0x12);
+            // skip pad (2 bytes)
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionNiciraDecTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionNiciraDecTtlVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x2320L
+            bb.writeInt(0x2320);
+            // fixed value property subtype = 0x12
+            bb.writeShort((short) 0x12);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionNiciraDecTtlVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionNiciraVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionNiciraVer13.java
new file mode 100644
index 0000000..44adebe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionNiciraVer13.java
@@ -0,0 +1,64 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFActionNiciraVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFActionNiciraVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFActionNicira> {
+        @Override
+        public OFActionNicira readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            short subtype = bb.readShort();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case (short) 0x12:
+                   // discriminator value 0x12=0x12 for class OFActionNiciraDecTtlVer13
+                   return OFActionNiciraDecTtlVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFActionNiciraVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionOutputVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionOutputVer13.java
new file mode 100644
index 0000000..6e43bbd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionOutputVer13.java
@@ -0,0 +1,319 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionOutputVer13 implements OFActionOutput {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionOutputVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static int DEFAULT_MAX_LEN = 0x0;
+
+    // OF message fields
+    private final OFPort port;
+    private final int maxLen;
+//
+    // Immutable default instance
+    final static OFActionOutputVer13 DEFAULT = new OFActionOutputVer13(
+        DEFAULT_PORT, DEFAULT_MAX_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionOutputVer13(OFPort port, int maxLen) {
+        this.port = port;
+        this.maxLen = maxLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionOutput.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionOutput.Builder {
+        final OFActionOutputVer13 parentMessage;
+
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean maxLenSet;
+        private int maxLen;
+
+        BuilderWithParent(OFActionOutputVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionOutput.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFActionOutput.Builder setMaxLen(int maxLen) {
+        this.maxLen = maxLen;
+        this.maxLenSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionOutput build() {
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                int maxLen = this.maxLenSet ? this.maxLen : parentMessage.maxLen;
+
+                //
+                return new OFActionOutputVer13(
+                    port,
+                    maxLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionOutput.Builder {
+        // OF message fields
+        private boolean portSet;
+        private OFPort port;
+        private boolean maxLenSet;
+        private int maxLen;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.OUTPUT;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFActionOutput.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public int getMaxLen() {
+        return maxLen;
+    }
+
+    @Override
+    public OFActionOutput.Builder setMaxLen(int maxLen) {
+        this.maxLen = maxLen;
+        this.maxLenSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionOutput build() {
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            int maxLen = this.maxLenSet ? this.maxLen : DEFAULT_MAX_LEN;
+
+
+            return new OFActionOutputVer13(
+                    port,
+                    maxLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionOutput> {
+        @Override
+        public OFActionOutput readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFActionType.OUTPUT(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFPort port = OFPort.read4Bytes(bb);
+            int maxLen = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFActionOutputVer13 actionOutputVer13 = new OFActionOutputVer13(
+                    port,
+                      maxLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionOutputVer13);
+            return actionOutputVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionOutputVer13Funnel FUNNEL = new OFActionOutputVer13Funnel();
+    static class OFActionOutputVer13Funnel implements Funnel<OFActionOutputVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionOutputVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            message.port.putTo(sink);
+            sink.putInt(message.maxLen);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionOutputVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionOutputVer13 message) {
+            // fixed value property type = 0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            message.port.write4Bytes(bb);
+            bb.writeShort(U16.t(message.maxLen));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionOutputVer13(");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("maxLen=").append(maxLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionOutputVer13 other = (OFActionOutputVer13) obj;
+
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if( maxLen != other.maxLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + maxLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopMplsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopMplsVer13.java
new file mode 100644
index 0000000..dd218f9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopMplsVer13.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPopMplsVer13 implements OFActionPopMpls {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPopMplsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPopMplsVer13 DEFAULT = new OFActionPopMplsVer13(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPopMplsVer13(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionPopMpls.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPopMpls.Builder {
+        final OFActionPopMplsVer13 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPopMplsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPopMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionPopMpls build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPopMplsVer13(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPopMpls.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPopMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionPopMpls build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPopMplsVer13(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPopMpls> {
+        @Override
+        public OFActionPopMpls readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 20
+            short type = bb.readShort();
+            if(type != (short) 0x14)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_MPLS(20), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPopMplsVer13 actionPopMplsVer13 = new OFActionPopMplsVer13(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPopMplsVer13);
+            return actionPopMplsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPopMplsVer13Funnel FUNNEL = new OFActionPopMplsVer13Funnel();
+    static class OFActionPopMplsVer13Funnel implements Funnel<OFActionPopMplsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPopMplsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 20
+            sink.putShort((short) 0x14);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPopMplsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPopMplsVer13 message) {
+            // fixed value property type = 20
+            bb.writeShort((short) 0x14);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPopMplsVer13(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPopMplsVer13 other = (OFActionPopMplsVer13) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopPbbVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopPbbVer13.java
new file mode 100644
index 0000000..79a18fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopPbbVer13.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPopPbbVer13 implements OFActionPopPbb {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPopPbbVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionPopPbbVer13 DEFAULT = new OFActionPopPbbVer13(
+
+    );
+
+    final static OFActionPopPbbVer13 INSTANCE = new OFActionPopPbbVer13();
+    // private empty constructor - use shared instance!
+    private OFActionPopPbbVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_PBB;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionPopPbb.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionPopPbbVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPopPbb> {
+        @Override
+        public OFActionPopPbb readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 27
+            short type = bb.readShort();
+            if(type != (short) 0x1b)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_PBB(27), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPopPbbVer13Funnel FUNNEL = new OFActionPopPbbVer13Funnel();
+    static class OFActionPopPbbVer13Funnel implements Funnel<OFActionPopPbbVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPopPbbVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 27
+            sink.putShort((short) 0x1b);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPopPbbVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPopPbbVer13 message) {
+            // fixed value property type = 27
+            bb.writeShort((short) 0x1b);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPopPbbVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopVlanVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopVlanVer13.java
new file mode 100644
index 0000000..60c1da5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPopVlanVer13.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPopVlanVer13 implements OFActionPopVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPopVlanVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFActionPopVlanVer13 DEFAULT = new OFActionPopVlanVer13(
+
+    );
+
+    final static OFActionPopVlanVer13 INSTANCE = new OFActionPopVlanVer13();
+    // private empty constructor - use shared instance!
+    private OFActionPopVlanVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.POP_VLAN;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFActionPopVlan.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFActionPopVlanVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPopVlan> {
+        @Override
+        public OFActionPopVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 18
+            short type = bb.readShort();
+            if(type != (short) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFActionType.POP_VLAN(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPopVlanVer13Funnel FUNNEL = new OFActionPopVlanVer13Funnel();
+    static class OFActionPopVlanVer13Funnel implements Funnel<OFActionPopVlanVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPopVlanVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 18
+            sink.putShort((short) 0x12);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPopVlanVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPopVlanVer13 message) {
+            // fixed value property type = 18
+            bb.writeShort((short) 0x12);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPopVlanVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushMplsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushMplsVer13.java
new file mode 100644
index 0000000..7059fe1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushMplsVer13.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPushMplsVer13 implements OFActionPushMpls {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPushMplsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPushMplsVer13 DEFAULT = new OFActionPushMplsVer13(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPushMplsVer13(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionPushMpls.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPushMpls.Builder {
+        final OFActionPushMplsVer13 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPushMplsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionPushMpls build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPushMplsVer13(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPushMpls.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_MPLS;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushMpls.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionPushMpls build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPushMplsVer13(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPushMpls> {
+        @Override
+        public OFActionPushMpls readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 19
+            short type = bb.readShort();
+            if(type != (short) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_MPLS(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPushMplsVer13 actionPushMplsVer13 = new OFActionPushMplsVer13(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPushMplsVer13);
+            return actionPushMplsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPushMplsVer13Funnel FUNNEL = new OFActionPushMplsVer13Funnel();
+    static class OFActionPushMplsVer13Funnel implements Funnel<OFActionPushMplsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPushMplsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 19
+            sink.putShort((short) 0x13);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPushMplsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPushMplsVer13 message) {
+            // fixed value property type = 19
+            bb.writeShort((short) 0x13);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPushMplsVer13(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPushMplsVer13 other = (OFActionPushMplsVer13) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushPbbVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushPbbVer13.java
new file mode 100644
index 0000000..7e28c10
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushPbbVer13.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPushPbbVer13 implements OFActionPushPbb {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPushPbbVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPushPbbVer13 DEFAULT = new OFActionPushPbbVer13(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPushPbbVer13(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_PBB;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionPushPbb.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPushPbb.Builder {
+        final OFActionPushPbbVer13 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPushPbbVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_PBB;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushPbb.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionPushPbb build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPushPbbVer13(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPushPbb.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_PBB;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushPbb.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionPushPbb build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPushPbbVer13(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPushPbb> {
+        @Override
+        public OFActionPushPbb readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 26
+            short type = bb.readShort();
+            if(type != (short) 0x1a)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_PBB(26), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPushPbbVer13 actionPushPbbVer13 = new OFActionPushPbbVer13(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPushPbbVer13);
+            return actionPushPbbVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPushPbbVer13Funnel FUNNEL = new OFActionPushPbbVer13Funnel();
+    static class OFActionPushPbbVer13Funnel implements Funnel<OFActionPushPbbVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPushPbbVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 26
+            sink.putShort((short) 0x1a);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPushPbbVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPushPbbVer13 message) {
+            // fixed value property type = 26
+            bb.writeShort((short) 0x1a);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPushPbbVer13(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPushPbbVer13 other = (OFActionPushPbbVer13) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushVlanVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushVlanVer13.java
new file mode 100644
index 0000000..b71a948
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionPushVlanVer13.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionPushVlanVer13 implements OFActionPushVlan {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionPushVlanVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_ETHERTYPE = EthType.NONE;
+
+    // OF message fields
+    private final EthType ethertype;
+//
+    // Immutable default instance
+    final static OFActionPushVlanVer13 DEFAULT = new OFActionPushVlanVer13(
+        DEFAULT_ETHERTYPE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionPushVlanVer13(EthType ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionPushVlan.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionPushVlan.Builder {
+        final OFActionPushVlanVer13 parentMessage;
+
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+        BuilderWithParent(OFActionPushVlanVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushVlan.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionPushVlan build() {
+                EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype;
+                if(ethertype == null)
+                    throw new NullPointerException("Property ethertype must not be null");
+
+                //
+                return new OFActionPushVlanVer13(
+                    ethertype
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionPushVlan.Builder {
+        // OF message fields
+        private boolean ethertypeSet;
+        private EthType ethertype;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.PUSH_VLAN;
+    }
+
+    @Override
+    public EthType getEthertype() {
+        return ethertype;
+    }
+
+    @Override
+    public OFActionPushVlan.Builder setEthertype(EthType ethertype) {
+        this.ethertype = ethertype;
+        this.ethertypeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionPushVlan build() {
+            EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE;
+            if(ethertype == null)
+                throw new NullPointerException("Property ethertype must not be null");
+
+
+            return new OFActionPushVlanVer13(
+                    ethertype
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionPushVlan> {
+        @Override
+        public OFActionPushVlan readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 17
+            short type = bb.readShort();
+            if(type != (short) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_VLAN(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            EthType ethertype = EthType.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFActionPushVlanVer13 actionPushVlanVer13 = new OFActionPushVlanVer13(
+                    ethertype
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionPushVlanVer13);
+            return actionPushVlanVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionPushVlanVer13Funnel FUNNEL = new OFActionPushVlanVer13Funnel();
+    static class OFActionPushVlanVer13Funnel implements Funnel<OFActionPushVlanVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionPushVlanVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 17
+            sink.putShort((short) 0x11);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.ethertype.putTo(sink);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionPushVlanVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionPushVlanVer13 message) {
+            // fixed value property type = 17
+            bb.writeShort((short) 0x11);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.ethertype.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionPushVlanVer13(");
+        b.append("ethertype=").append(ethertype);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionPushVlanVer13 other = (OFActionPushVlanVer13) obj;
+
+        if (ethertype == null) {
+            if (other.ethertype != null)
+                return false;
+        } else if (!ethertype.equals(other.ethertype))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((ethertype == null) ? 0 : ethertype.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13.java
new file mode 100644
index 0000000..a2ff506
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13.java
@@ -0,0 +1,273 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetFieldVer13 implements OFActionSetField {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetFieldVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    // OF message fields
+    private final OFOxm<?> field;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetFieldVer13(OFOxm<?> field) {
+        this.field = field;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_FIELD;
+    }
+
+    @Override
+    public OFOxm<?> getField() {
+        return field;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionSetField.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetField.Builder {
+        final OFActionSetFieldVer13 parentMessage;
+
+        // OF message fields
+        private boolean fieldSet;
+        private OFOxm<?> field;
+
+        BuilderWithParent(OFActionSetFieldVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_FIELD;
+    }
+
+    @Override
+    public OFOxm<?> getField() {
+        return field;
+    }
+
+    @Override
+    public OFActionSetField.Builder setField(OFOxm<?> field) {
+        this.field = field;
+        this.fieldSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionSetField build() {
+                OFOxm<?> field = this.fieldSet ? this.field : parentMessage.field;
+                if(field == null)
+                    throw new NullPointerException("Property field must not be null");
+
+                //
+                return new OFActionSetFieldVer13(
+                    field
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetField.Builder {
+        // OF message fields
+        private boolean fieldSet;
+        private OFOxm<?> field;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_FIELD;
+    }
+
+    @Override
+    public OFOxm<?> getField() {
+        return field;
+    }
+
+    @Override
+    public OFActionSetField.Builder setField(OFOxm<?> field) {
+        this.field = field;
+        this.fieldSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionSetField build() {
+            if(!this.fieldSet)
+                throw new IllegalStateException("Property field doesn't have default value -- must be set");
+            if(field == null)
+                throw new NullPointerException("Property field must not be null");
+
+
+            return new OFActionSetFieldVer13(
+                    field
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetField> {
+        @Override
+        public OFActionSetField readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 25
+            short type = bb.readShort();
+            if(type != (short) 0x19)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_FIELD(25), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFOxm<?> field = OFOxmVer13.READER.readFrom(bb);
+            // align message to 8 bytes (length contains aligned value)
+            bb.skipBytes(length - (bb.readerIndex() - start));
+
+            OFActionSetFieldVer13 actionSetFieldVer13 = new OFActionSetFieldVer13(
+                    field
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetFieldVer13);
+            return actionSetFieldVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetFieldVer13Funnel FUNNEL = new OFActionSetFieldVer13Funnel();
+    static class OFActionSetFieldVer13Funnel implements Funnel<OFActionSetFieldVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetFieldVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 25
+            sink.putShort((short) 0x19);
+            // FIXME: skip funnel of length
+            message.field.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetFieldVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetFieldVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 25
+            bb.writeShort((short) 0x19);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.field.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            int alignedLength = ((length + 7)/8 * 8);
+            bb.setShort(lengthIndex, alignedLength);
+            // align message to 8 bytes
+            bb.writeZero(alignedLength - length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetFieldVer13(");
+        b.append("field=").append(field);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetFieldVer13 other = (OFActionSetFieldVer13) obj;
+
+        if (field == null) {
+            if (other.field != null)
+                return false;
+        } else if (!field.equals(other.field))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((field == null) ? 0 : field.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetMplsTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetMplsTtlVer13.java
new file mode 100644
index 0000000..16a5150
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetMplsTtlVer13.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetMplsTtlVer13 implements OFActionSetMplsTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetMplsTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_MPLS_TTL = (short) 0x0;
+
+    // OF message fields
+    private final short mplsTtl;
+//
+    // Immutable default instance
+    final static OFActionSetMplsTtlVer13 DEFAULT = new OFActionSetMplsTtlVer13(
+        DEFAULT_MPLS_TTL
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetMplsTtlVer13(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionSetMplsTtl.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetMplsTtl.Builder {
+        final OFActionSetMplsTtlVer13 parentMessage;
+
+        // OF message fields
+        private boolean mplsTtlSet;
+        private short mplsTtl;
+
+        BuilderWithParent(OFActionSetMplsTtlVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFActionSetMplsTtl.Builder setMplsTtl(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+        this.mplsTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionSetMplsTtl build() {
+                short mplsTtl = this.mplsTtlSet ? this.mplsTtl : parentMessage.mplsTtl;
+
+                //
+                return new OFActionSetMplsTtlVer13(
+                    mplsTtl
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetMplsTtl.Builder {
+        // OF message fields
+        private boolean mplsTtlSet;
+        private short mplsTtl;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_MPLS_TTL;
+    }
+
+    @Override
+    public short getMplsTtl() {
+        return mplsTtl;
+    }
+
+    @Override
+    public OFActionSetMplsTtl.Builder setMplsTtl(short mplsTtl) {
+        this.mplsTtl = mplsTtl;
+        this.mplsTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionSetMplsTtl build() {
+            short mplsTtl = this.mplsTtlSet ? this.mplsTtl : DEFAULT_MPLS_TTL;
+
+
+            return new OFActionSetMplsTtlVer13(
+                    mplsTtl
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetMplsTtl> {
+        @Override
+        public OFActionSetMplsTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 15
+            short type = bb.readShort();
+            if(type != (short) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_MPLS_TTL(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short mplsTtl = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetMplsTtlVer13 actionSetMplsTtlVer13 = new OFActionSetMplsTtlVer13(
+                    mplsTtl
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetMplsTtlVer13);
+            return actionSetMplsTtlVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetMplsTtlVer13Funnel FUNNEL = new OFActionSetMplsTtlVer13Funnel();
+    static class OFActionSetMplsTtlVer13Funnel implements Funnel<OFActionSetMplsTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetMplsTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 15
+            sink.putShort((short) 0xf);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.mplsTtl);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetMplsTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetMplsTtlVer13 message) {
+            // fixed value property type = 15
+            bb.writeShort((short) 0xf);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.mplsTtl));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetMplsTtlVer13(");
+        b.append("mplsTtl=").append(mplsTtl);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetMplsTtlVer13 other = (OFActionSetMplsTtlVer13) obj;
+
+        if( mplsTtl != other.mplsTtl)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + mplsTtl;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetNwTtlVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetNwTtlVer13.java
new file mode 100644
index 0000000..2dd35e2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetNwTtlVer13.java
@@ -0,0 +1,265 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetNwTtlVer13 implements OFActionSetNwTtl {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetNwTtlVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static short DEFAULT_NW_TTL = (short) 0x0;
+
+    // OF message fields
+    private final short nwTtl;
+//
+    // Immutable default instance
+    final static OFActionSetNwTtlVer13 DEFAULT = new OFActionSetNwTtlVer13(
+        DEFAULT_NW_TTL
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetNwTtlVer13(short nwTtl) {
+        this.nwTtl = nwTtl;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionSetNwTtl.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetNwTtl.Builder {
+        final OFActionSetNwTtlVer13 parentMessage;
+
+        // OF message fields
+        private boolean nwTtlSet;
+        private short nwTtl;
+
+        BuilderWithParent(OFActionSetNwTtlVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFActionSetNwTtl.Builder setNwTtl(short nwTtl) {
+        this.nwTtl = nwTtl;
+        this.nwTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionSetNwTtl build() {
+                short nwTtl = this.nwTtlSet ? this.nwTtl : parentMessage.nwTtl;
+
+                //
+                return new OFActionSetNwTtlVer13(
+                    nwTtl
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetNwTtl.Builder {
+        // OF message fields
+        private boolean nwTtlSet;
+        private short nwTtl;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_NW_TTL;
+    }
+
+    @Override
+    public short getNwTtl() {
+        return nwTtl;
+    }
+
+    @Override
+    public OFActionSetNwTtl.Builder setNwTtl(short nwTtl) {
+        this.nwTtl = nwTtl;
+        this.nwTtlSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionSetNwTtl build() {
+            short nwTtl = this.nwTtlSet ? this.nwTtl : DEFAULT_NW_TTL;
+
+
+            return new OFActionSetNwTtlVer13(
+                    nwTtl
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetNwTtl> {
+        @Override
+        public OFActionSetNwTtl readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 23
+            short type = bb.readShort();
+            if(type != (short) 0x17)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_NW_TTL(23), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short nwTtl = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFActionSetNwTtlVer13 actionSetNwTtlVer13 = new OFActionSetNwTtlVer13(
+                    nwTtl
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetNwTtlVer13);
+            return actionSetNwTtlVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetNwTtlVer13Funnel FUNNEL = new OFActionSetNwTtlVer13Funnel();
+    static class OFActionSetNwTtlVer13Funnel implements Funnel<OFActionSetNwTtlVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetNwTtlVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 23
+            sink.putShort((short) 0x17);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putShort(message.nwTtl);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetNwTtlVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetNwTtlVer13 message) {
+            // fixed value property type = 23
+            bb.writeShort((short) 0x17);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeByte(U8.t(message.nwTtl));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetNwTtlVer13(");
+        b.append("nwTtl=").append(nwTtl);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetNwTtlVer13 other = (OFActionSetNwTtlVer13) obj;
+
+        if( nwTtl != other.nwTtl)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + nwTtl;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetQueueVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetQueueVer13.java
new file mode 100644
index 0000000..380f286
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetQueueVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFActionSetQueueVer13 implements OFActionSetQueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFActionSetQueueVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+
+    // OF message fields
+    private final long queueId;
+//
+    // Immutable default instance
+    final static OFActionSetQueueVer13 DEFAULT = new OFActionSetQueueVer13(
+        DEFAULT_QUEUE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFActionSetQueueVer13(long queueId) {
+        this.queueId = queueId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFActionSetQueue.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFActionSetQueue.Builder {
+        final OFActionSetQueueVer13 parentMessage;
+
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+
+        BuilderWithParent(OFActionSetQueueVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFActionSetQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFActionSetQueue build() {
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+
+                //
+                return new OFActionSetQueueVer13(
+                    queueId
+                );
+        }
+
+    }
+
+    static class Builder implements OFActionSetQueue.Builder {
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+
+    @Override
+    public OFActionType getType() {
+        return OFActionType.SET_QUEUE;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFActionSetQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFActionSetQueue build() {
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+
+
+            return new OFActionSetQueueVer13(
+                    queueId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFActionSetQueue> {
+        @Override
+        public OFActionSetQueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 21
+            short type = bb.readShort();
+            if(type != (short) 0x15)
+                throw new OFParseError("Wrong type: Expected=OFActionType.SET_QUEUE(21), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long queueId = U32.f(bb.readInt());
+
+            OFActionSetQueueVer13 actionSetQueueVer13 = new OFActionSetQueueVer13(
+                    queueId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", actionSetQueueVer13);
+            return actionSetQueueVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFActionSetQueueVer13Funnel FUNNEL = new OFActionSetQueueVer13Funnel();
+    static class OFActionSetQueueVer13Funnel implements Funnel<OFActionSetQueueVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFActionSetQueueVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 21
+            sink.putShort((short) 0x15);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.queueId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFActionSetQueueVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFActionSetQueueVer13 message) {
+            // fixed value property type = 21
+            bb.writeShort((short) 0x15);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.queueId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFActionSetQueueVer13(");
+        b.append("queueId=").append(queueId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFActionSetQueueVer13 other = (OFActionSetQueueVer13) obj;
+
+        if( queueId != other.queueId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionTypeSerializerVer13.java
new file mode 100644
index 0000000..108caf0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionTypeSerializerVer13.java
@@ -0,0 +1,149 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFActionType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFActionTypeSerializerVer13 {
+
+    public final static short OUTPUT_VAL = (short) 0x0;
+    public final static short COPY_TTL_OUT_VAL = (short) 0xb;
+    public final static short COPY_TTL_IN_VAL = (short) 0xc;
+    public final static short SET_MPLS_TTL_VAL = (short) 0xf;
+    public final static short DEC_MPLS_TTL_VAL = (short) 0x10;
+    public final static short PUSH_VLAN_VAL = (short) 0x11;
+    public final static short POP_VLAN_VAL = (short) 0x12;
+    public final static short PUSH_MPLS_VAL = (short) 0x13;
+    public final static short POP_MPLS_VAL = (short) 0x14;
+    public final static short SET_QUEUE_VAL = (short) 0x15;
+    public final static short GROUP_VAL = (short) 0x16;
+    public final static short SET_NW_TTL_VAL = (short) 0x17;
+    public final static short DEC_NW_TTL_VAL = (short) 0x18;
+    public final static short SET_FIELD_VAL = (short) 0x19;
+    public final static short PUSH_PBB_VAL = (short) 0x1a;
+    public final static short POP_PBB_VAL = (short) 0x1b;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFActionType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFActionType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFActionType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFActionType ofWireValue(short val) {
+        switch(val) {
+            case OUTPUT_VAL:
+                return OFActionType.OUTPUT;
+            case COPY_TTL_OUT_VAL:
+                return OFActionType.COPY_TTL_OUT;
+            case COPY_TTL_IN_VAL:
+                return OFActionType.COPY_TTL_IN;
+            case SET_MPLS_TTL_VAL:
+                return OFActionType.SET_MPLS_TTL;
+            case DEC_MPLS_TTL_VAL:
+                return OFActionType.DEC_MPLS_TTL;
+            case PUSH_VLAN_VAL:
+                return OFActionType.PUSH_VLAN;
+            case POP_VLAN_VAL:
+                return OFActionType.POP_VLAN;
+            case PUSH_MPLS_VAL:
+                return OFActionType.PUSH_MPLS;
+            case POP_MPLS_VAL:
+                return OFActionType.POP_MPLS;
+            case SET_QUEUE_VAL:
+                return OFActionType.SET_QUEUE;
+            case GROUP_VAL:
+                return OFActionType.GROUP;
+            case SET_NW_TTL_VAL:
+                return OFActionType.SET_NW_TTL;
+            case DEC_NW_TTL_VAL:
+                return OFActionType.DEC_NW_TTL;
+            case SET_FIELD_VAL:
+                return OFActionType.SET_FIELD;
+            case PUSH_PBB_VAL:
+                return OFActionType.PUSH_PBB;
+            case POP_PBB_VAL:
+                return OFActionType.POP_PBB;
+            case EXPERIMENTER_VAL:
+                return OFActionType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFActionType in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFActionType e) {
+        switch(e) {
+            case OUTPUT:
+                return OUTPUT_VAL;
+            case COPY_TTL_OUT:
+                return COPY_TTL_OUT_VAL;
+            case COPY_TTL_IN:
+                return COPY_TTL_IN_VAL;
+            case SET_MPLS_TTL:
+                return SET_MPLS_TTL_VAL;
+            case DEC_MPLS_TTL:
+                return DEC_MPLS_TTL_VAL;
+            case PUSH_VLAN:
+                return PUSH_VLAN_VAL;
+            case POP_VLAN:
+                return POP_VLAN_VAL;
+            case PUSH_MPLS:
+                return PUSH_MPLS_VAL;
+            case POP_MPLS:
+                return POP_MPLS_VAL;
+            case SET_QUEUE:
+                return SET_QUEUE_VAL;
+            case GROUP:
+                return GROUP_VAL;
+            case SET_NW_TTL:
+                return SET_NW_TTL_VAL;
+            case DEC_NW_TTL:
+                return DEC_NW_TTL_VAL;
+            case SET_FIELD:
+                return SET_FIELD_VAL;
+            case PUSH_PBB:
+                return PUSH_PBB_VAL;
+            case POP_PBB:
+                return POP_PBB_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFActionType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionVer13.java
new file mode 100644
index 0000000..7715767
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionVer13.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFActionVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFActionVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFAction> {
+        @Override
+        public OFAction readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0xffff:
+                   // discriminator value OFActionType.EXPERIMENTER=65535 for class OFActionExperimenterVer13
+                   return OFActionExperimenterVer13.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFActionType.OUTPUT=0 for class OFActionOutputVer13
+                   return OFActionOutputVer13.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value OFActionType.COPY_TTL_IN=12 for class OFActionCopyTtlInVer13
+                   return OFActionCopyTtlInVer13.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFActionType.COPY_TTL_OUT=11 for class OFActionCopyTtlOutVer13
+                   return OFActionCopyTtlOutVer13.READER.readFrom(bb);
+               case (short) 0x10:
+                   // discriminator value OFActionType.DEC_MPLS_TTL=16 for class OFActionDecMplsTtlVer13
+                   return OFActionDecMplsTtlVer13.READER.readFrom(bb);
+               case (short) 0x18:
+                   // discriminator value OFActionType.DEC_NW_TTL=24 for class OFActionDecNwTtlVer13
+                   return OFActionDecNwTtlVer13.READER.readFrom(bb);
+               case (short) 0x16:
+                   // discriminator value OFActionType.GROUP=22 for class OFActionGroupVer13
+                   return OFActionGroupVer13.READER.readFrom(bb);
+               case (short) 0x14:
+                   // discriminator value OFActionType.POP_MPLS=20 for class OFActionPopMplsVer13
+                   return OFActionPopMplsVer13.READER.readFrom(bb);
+               case (short) 0x12:
+                   // discriminator value OFActionType.POP_VLAN=18 for class OFActionPopVlanVer13
+                   return OFActionPopVlanVer13.READER.readFrom(bb);
+               case (short) 0x13:
+                   // discriminator value OFActionType.PUSH_MPLS=19 for class OFActionPushMplsVer13
+                   return OFActionPushMplsVer13.READER.readFrom(bb);
+               case (short) 0x11:
+                   // discriminator value OFActionType.PUSH_VLAN=17 for class OFActionPushVlanVer13
+                   return OFActionPushVlanVer13.READER.readFrom(bb);
+               case (short) 0xf:
+                   // discriminator value OFActionType.SET_MPLS_TTL=15 for class OFActionSetMplsTtlVer13
+                   return OFActionSetMplsTtlVer13.READER.readFrom(bb);
+               case (short) 0x17:
+                   // discriminator value OFActionType.SET_NW_TTL=23 for class OFActionSetNwTtlVer13
+                   return OFActionSetNwTtlVer13.READER.readFrom(bb);
+               case (short) 0x15:
+                   // discriminator value OFActionType.SET_QUEUE=21 for class OFActionSetQueueVer13
+                   return OFActionSetQueueVer13.READER.readFrom(bb);
+               case (short) 0x19:
+                   // discriminator value OFActionType.SET_FIELD=25 for class OFActionSetFieldVer13
+                   return OFActionSetFieldVer13.READER.readFrom(bb);
+               case (short) 0x1b:
+                   // discriminator value OFActionType.POP_PBB=27 for class OFActionPopPbbVer13
+                   return OFActionPopPbbVer13.READER.readFrom(bb);
+               case (short) 0x1a:
+                   // discriminator value OFActionType.PUSH_PBB=26 for class OFActionPushPbbVer13
+                   return OFActionPushPbbVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFActionVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionsVer13.java
new file mode 100644
index 0000000..f96b112
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFActionsVer13.java
@@ -0,0 +1,279 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+
+
+public class OFActionsVer13 implements OFActions {
+    public final static OFActionsVer13 INSTANCE = new OFActionsVer13();
+
+
+
+
+    public OFActionBsnChecksum.Builder buildBsnChecksum() {
+        return new OFActionBsnChecksumVer13.Builder();
+    }
+    public OFActionBsnChecksum bsnChecksum(U128 checksum) {
+        return new OFActionBsnChecksumVer13(
+                checksum
+                    );
+    }
+
+    public OFActionBsnMirror.Builder buildBsnMirror() {
+        return new OFActionBsnMirrorVer13.Builder();
+    }
+
+    public OFActionBsnSetTunnelDst.Builder buildBsnSetTunnelDst() {
+        return new OFActionBsnSetTunnelDstVer13.Builder();
+    }
+    public OFActionBsnSetTunnelDst bsnSetTunnelDst(long dst) {
+        return new OFActionBsnSetTunnelDstVer13(
+                dst
+                    );
+    }
+
+    public OFActionEnqueue.Builder buildEnqueue() {
+        throw new UnsupportedOperationException("OFActionEnqueue not supported in version 1.3");
+    }
+    public OFActionEnqueue enqueue(OFPort port, long queueId) {
+        throw new UnsupportedOperationException("OFActionEnqueue not supported in version 1.3");
+    }
+
+    public OFActionNiciraDecTtl niciraDecTtl() {
+        return OFActionNiciraDecTtlVer13.INSTANCE;
+    }
+
+    public OFActionOutput.Builder buildOutput() {
+        return new OFActionOutputVer13.Builder();
+    }
+    public OFActionOutput output(OFPort port, int maxLen) {
+        return new OFActionOutputVer13(
+                port,
+                      maxLen
+                    );
+    }
+
+    public OFActionSetDlDst.Builder buildSetDlDst() {
+        throw new UnsupportedOperationException("OFActionSetDlDst not supported in version 1.3");
+    }
+    public OFActionSetDlDst setDlDst(MacAddress dlAddr) {
+        throw new UnsupportedOperationException("OFActionSetDlDst not supported in version 1.3");
+    }
+
+    public OFActionSetDlSrc.Builder buildSetDlSrc() {
+        throw new UnsupportedOperationException("OFActionSetDlSrc not supported in version 1.3");
+    }
+    public OFActionSetDlSrc setDlSrc(MacAddress dlAddr) {
+        throw new UnsupportedOperationException("OFActionSetDlSrc not supported in version 1.3");
+    }
+
+    public OFActionSetNwDst.Builder buildSetNwDst() {
+        throw new UnsupportedOperationException("OFActionSetNwDst not supported in version 1.3");
+    }
+    public OFActionSetNwDst setNwDst(IPv4Address nwAddr) {
+        throw new UnsupportedOperationException("OFActionSetNwDst not supported in version 1.3");
+    }
+
+    public OFActionSetNwSrc.Builder buildSetNwSrc() {
+        throw new UnsupportedOperationException("OFActionSetNwSrc not supported in version 1.3");
+    }
+    public OFActionSetNwSrc setNwSrc(IPv4Address nwAddr) {
+        throw new UnsupportedOperationException("OFActionSetNwSrc not supported in version 1.3");
+    }
+
+    public OFActionSetNwTos.Builder buildSetNwTos() {
+        throw new UnsupportedOperationException("OFActionSetNwTos not supported in version 1.3");
+    }
+    public OFActionSetNwTos setNwTos(short nwTos) {
+        throw new UnsupportedOperationException("OFActionSetNwTos not supported in version 1.3");
+    }
+
+    public OFActionSetTpDst.Builder buildSetTpDst() {
+        throw new UnsupportedOperationException("OFActionSetTpDst not supported in version 1.3");
+    }
+    public OFActionSetTpDst setTpDst(TransportPort tpPort) {
+        throw new UnsupportedOperationException("OFActionSetTpDst not supported in version 1.3");
+    }
+
+    public OFActionSetTpSrc.Builder buildSetTpSrc() {
+        throw new UnsupportedOperationException("OFActionSetTpSrc not supported in version 1.3");
+    }
+    public OFActionSetTpSrc setTpSrc(TransportPort tpPort) {
+        throw new UnsupportedOperationException("OFActionSetTpSrc not supported in version 1.3");
+    }
+
+    public OFActionSetVlanPcp.Builder buildSetVlanPcp() {
+        throw new UnsupportedOperationException("OFActionSetVlanPcp not supported in version 1.3");
+    }
+    public OFActionSetVlanPcp setVlanPcp(VlanPcp vlanPcp) {
+        throw new UnsupportedOperationException("OFActionSetVlanPcp not supported in version 1.3");
+    }
+
+    public OFActionSetVlanVid.Builder buildSetVlanVid() {
+        throw new UnsupportedOperationException("OFActionSetVlanVid not supported in version 1.3");
+    }
+    public OFActionSetVlanVid setVlanVid(VlanVid vlanVid) {
+        throw new UnsupportedOperationException("OFActionSetVlanVid not supported in version 1.3");
+    }
+
+    public OFActionStripVlan stripVlan() {
+        throw new UnsupportedOperationException("OFActionStripVlan not supported in version 1.3");
+    }
+
+    public OFActionCopyTtlIn copyTtlIn() {
+        return OFActionCopyTtlInVer13.INSTANCE;
+    }
+
+    public OFActionCopyTtlOut copyTtlOut() {
+        return OFActionCopyTtlOutVer13.INSTANCE;
+    }
+
+    public OFActionDecMplsTtl decMplsTtl() {
+        return OFActionDecMplsTtlVer13.INSTANCE;
+    }
+
+    public OFActionDecNwTtl decNwTtl() {
+        return OFActionDecNwTtlVer13.INSTANCE;
+    }
+
+    public OFActionGroup.Builder buildGroup() {
+        return new OFActionGroupVer13.Builder();
+    }
+    public OFActionGroup group(OFGroup group) {
+        return new OFActionGroupVer13(
+                group
+                    );
+    }
+
+    public OFActionPopMpls.Builder buildPopMpls() {
+        return new OFActionPopMplsVer13.Builder();
+    }
+    public OFActionPopMpls popMpls(EthType ethertype) {
+        return new OFActionPopMplsVer13(
+                ethertype
+                    );
+    }
+
+    public OFActionPopVlan popVlan() {
+        return OFActionPopVlanVer13.INSTANCE;
+    }
+
+    public OFActionPushMpls.Builder buildPushMpls() {
+        return new OFActionPushMplsVer13.Builder();
+    }
+    public OFActionPushMpls pushMpls(EthType ethertype) {
+        return new OFActionPushMplsVer13(
+                ethertype
+                    );
+    }
+
+    public OFActionPushVlan.Builder buildPushVlan() {
+        return new OFActionPushVlanVer13.Builder();
+    }
+    public OFActionPushVlan pushVlan(EthType ethertype) {
+        return new OFActionPushVlanVer13(
+                ethertype
+                    );
+    }
+
+    public OFActionSetMplsLabel.Builder buildSetMplsLabel() {
+        throw new UnsupportedOperationException("OFActionSetMplsLabel not supported in version 1.3");
+    }
+    public OFActionSetMplsLabel setMplsLabel(long mplsLabel) {
+        throw new UnsupportedOperationException("OFActionSetMplsLabel not supported in version 1.3");
+    }
+
+    public OFActionSetMplsTc.Builder buildSetMplsTc() {
+        throw new UnsupportedOperationException("OFActionSetMplsTc not supported in version 1.3");
+    }
+    public OFActionSetMplsTc setMplsTc(short mplsTc) {
+        throw new UnsupportedOperationException("OFActionSetMplsTc not supported in version 1.3");
+    }
+
+    public OFActionSetMplsTtl.Builder buildSetMplsTtl() {
+        return new OFActionSetMplsTtlVer13.Builder();
+    }
+    public OFActionSetMplsTtl setMplsTtl(short mplsTtl) {
+        return new OFActionSetMplsTtlVer13(
+                mplsTtl
+                    );
+    }
+
+    public OFActionSetNwEcn.Builder buildSetNwEcn() {
+        throw new UnsupportedOperationException("OFActionSetNwEcn not supported in version 1.3");
+    }
+    public OFActionSetNwEcn setNwEcn(IpEcn nwEcn) {
+        throw new UnsupportedOperationException("OFActionSetNwEcn not supported in version 1.3");
+    }
+
+    public OFActionSetNwTtl.Builder buildSetNwTtl() {
+        return new OFActionSetNwTtlVer13.Builder();
+    }
+    public OFActionSetNwTtl setNwTtl(short nwTtl) {
+        return new OFActionSetNwTtlVer13(
+                nwTtl
+                    );
+    }
+
+    public OFActionSetQueue.Builder buildSetQueue() {
+        return new OFActionSetQueueVer13.Builder();
+    }
+    public OFActionSetQueue setQueue(long queueId) {
+        return new OFActionSetQueueVer13(
+                queueId
+                    );
+    }
+
+    public OFActionSetField.Builder buildSetField() {
+        return new OFActionSetFieldVer13.Builder();
+    }
+    public OFActionSetField setField(OFOxm<?> field) {
+        return new OFActionSetFieldVer13(
+                field
+                    );
+    }
+
+    public OFActionPopPbb popPbb() {
+        return OFActionPopPbbVer13.INSTANCE;
+    }
+
+    public OFActionPushPbb.Builder buildPushPbb() {
+        return new OFActionPushPbbVer13.Builder();
+    }
+    public OFActionPushPbb pushPbb(EthType ethertype) {
+        return new OFActionPushPbbVer13(
+                ethertype
+                    );
+    }
+
+    public OFMessageReader<OFAction> getReader() {
+        return OFActionVer13.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAggregateStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAggregateStatsReplyVer13.java
new file mode 100644
index 0000000..0c827e5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAggregateStatsReplyVer13.java
@@ -0,0 +1,511 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAggregateStatsReplyVer13 implements OFAggregateStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 40;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static long DEFAULT_FLOW_COUNT = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final long flowCount;
+//
+    // Immutable default instance
+    final static OFAggregateStatsReplyVer13 DEFAULT = new OFAggregateStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_FLOW_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAggregateStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, U64 packetCount, U64 byteCount, long flowCount) {
+        this.xid = xid;
+        this.flags = flags;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.flowCount = flowCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+
+
+    public OFAggregateStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAggregateStatsReply.Builder {
+        final OFAggregateStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean flowCountSet;
+        private long flowCount;
+
+        BuilderWithParent(OFAggregateStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAggregateStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                long flowCount = this.flowCountSet ? this.flowCount : parentMessage.flowCount;
+
+                //
+                return new OFAggregateStatsReplyVer13(
+                    xid,
+                    flags,
+                    packetCount,
+                    byteCount,
+                    flowCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFAggregateStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean flowCountSet;
+        private long flowCount;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFAggregateStatsReply.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAggregateStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            long flowCount = this.flowCountSet ? this.flowCount : DEFAULT_FLOW_COUNT;
+
+
+            return new OFAggregateStatsReplyVer13(
+                    xid,
+                    flags,
+                    packetCount,
+                    byteCount,
+                    flowCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAggregateStatsReply> {
+        @Override
+        public OFAggregateStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 40)
+                throw new OFParseError("Wrong length: Expected=40(40), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 2
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x2)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.AGGREGATE(2), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            long flowCount = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFAggregateStatsReplyVer13 aggregateStatsReplyVer13 = new OFAggregateStatsReplyVer13(
+                    xid,
+                      flags,
+                      packetCount,
+                      byteCount,
+                      flowCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", aggregateStatsReplyVer13);
+            return aggregateStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAggregateStatsReplyVer13Funnel FUNNEL = new OFAggregateStatsReplyVer13Funnel();
+    static class OFAggregateStatsReplyVer13Funnel implements Funnel<OFAggregateStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAggregateStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 40
+            sink.putShort((short) 0x28);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 2
+            sink.putShort((short) 0x2);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            sink.putLong(message.flowCount);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAggregateStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFAggregateStatsReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 40
+            bb.writeShort((short) 0x28);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 2
+            bb.writeShort((short) 0x2);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            bb.writeInt(U32.t(message.flowCount));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAggregateStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("flowCount=").append(flowCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAggregateStatsReplyVer13 other = (OFAggregateStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if( flowCount != other.flowCount)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime *  (int) (flowCount ^ (flowCount >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAggregateStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAggregateStatsRequestVer13.java
new file mode 100644
index 0000000..da1821b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAggregateStatsRequestVer13.java
@@ -0,0 +1,690 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAggregateStatsRequestVer13 implements OFAggregateStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFAggregateStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final TableId tableId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFAggregateStatsRequestVer13 DEFAULT = new OFAggregateStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TABLE_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAggregateStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, TableId tableId, OFPort outPort, OFGroup outGroup, U64 cookie, U64 cookieMask, Match match) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFAggregateStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAggregateStatsRequest.Builder {
+        final OFAggregateStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFAggregateStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAggregateStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFAggregateStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFAggregateStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.AGGREGATE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFAggregateStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAggregateStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFAggregateStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAggregateStatsRequest> {
+        @Override
+        public OFAggregateStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 2
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x2)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.AGGREGATE(2), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+
+            OFAggregateStatsRequestVer13 aggregateStatsRequestVer13 = new OFAggregateStatsRequestVer13(
+                    xid,
+                      flags,
+                      tableId,
+                      outPort,
+                      outGroup,
+                      cookie,
+                      cookieMask,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", aggregateStatsRequestVer13);
+            return aggregateStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAggregateStatsRequestVer13Funnel FUNNEL = new OFAggregateStatsRequestVer13Funnel();
+    static class OFAggregateStatsRequestVer13Funnel implements Funnel<OFAggregateStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAggregateStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 2
+            sink.putShort((short) 0x2);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            // skip pad (4 bytes)
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAggregateStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFAggregateStatsRequestVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 2
+            bb.writeShort((short) 0x2);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.match.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAggregateStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAggregateStatsRequestVer13 other = (OFAggregateStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncGetReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncGetReplyVer13.java
new file mode 100644
index 0000000..6eb86cc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncGetReplyVer13.java
@@ -0,0 +1,550 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAsyncGetReplyVer13 implements OFAsyncGetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFAsyncGetReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_PACKET_IN_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_PACKET_IN_MASK_SLAVE = 0x0L;
+        private final static long DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_PORT_STATUS_MASK_SLAVE = 0x0L;
+        private final static long DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_FLOW_REMOVED_MASK_SLAVE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long packetInMaskEqualMaster;
+    private final long packetInMaskSlave;
+    private final long portStatusMaskEqualMaster;
+    private final long portStatusMaskSlave;
+    private final long flowRemovedMaskEqualMaster;
+    private final long flowRemovedMaskSlave;
+//
+    // Immutable default instance
+    final static OFAsyncGetReplyVer13 DEFAULT = new OFAsyncGetReplyVer13(
+        DEFAULT_XID, DEFAULT_PACKET_IN_MASK_EQUAL_MASTER, DEFAULT_PACKET_IN_MASK_SLAVE, DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER, DEFAULT_PORT_STATUS_MASK_SLAVE, DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER, DEFAULT_FLOW_REMOVED_MASK_SLAVE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAsyncGetReplyVer13(long xid, long packetInMaskEqualMaster, long packetInMaskSlave, long portStatusMaskEqualMaster, long portStatusMaskSlave, long flowRemovedMaskEqualMaster, long flowRemovedMaskSlave) {
+        this.xid = xid;
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_ASYNC_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+
+
+    public OFAsyncGetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAsyncGetReply.Builder {
+        final OFAsyncGetReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean packetInMaskEqualMasterSet;
+        private long packetInMaskEqualMaster;
+        private boolean packetInMaskSlaveSet;
+        private long packetInMaskSlave;
+        private boolean portStatusMaskEqualMasterSet;
+        private long portStatusMaskEqualMaster;
+        private boolean portStatusMaskSlaveSet;
+        private long portStatusMaskSlave;
+        private boolean flowRemovedMaskEqualMasterSet;
+        private long flowRemovedMaskEqualMaster;
+        private boolean flowRemovedMaskSlaveSet;
+        private long flowRemovedMaskSlave;
+
+        BuilderWithParent(OFAsyncGetReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_ASYNC_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster) {
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setPacketInMaskSlave(long packetInMaskSlave) {
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.packetInMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster) {
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setPortStatusMaskSlave(long portStatusMaskSlave) {
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.portStatusMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster) {
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave) {
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+        this.flowRemovedMaskSlaveSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAsyncGetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long packetInMaskEqualMaster = this.packetInMaskEqualMasterSet ? this.packetInMaskEqualMaster : parentMessage.packetInMaskEqualMaster;
+                long packetInMaskSlave = this.packetInMaskSlaveSet ? this.packetInMaskSlave : parentMessage.packetInMaskSlave;
+                long portStatusMaskEqualMaster = this.portStatusMaskEqualMasterSet ? this.portStatusMaskEqualMaster : parentMessage.portStatusMaskEqualMaster;
+                long portStatusMaskSlave = this.portStatusMaskSlaveSet ? this.portStatusMaskSlave : parentMessage.portStatusMaskSlave;
+                long flowRemovedMaskEqualMaster = this.flowRemovedMaskEqualMasterSet ? this.flowRemovedMaskEqualMaster : parentMessage.flowRemovedMaskEqualMaster;
+                long flowRemovedMaskSlave = this.flowRemovedMaskSlaveSet ? this.flowRemovedMaskSlave : parentMessage.flowRemovedMaskSlave;
+
+                //
+                return new OFAsyncGetReplyVer13(
+                    xid,
+                    packetInMaskEqualMaster,
+                    packetInMaskSlave,
+                    portStatusMaskEqualMaster,
+                    portStatusMaskSlave,
+                    flowRemovedMaskEqualMaster,
+                    flowRemovedMaskSlave
+                );
+        }
+
+    }
+
+    static class Builder implements OFAsyncGetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean packetInMaskEqualMasterSet;
+        private long packetInMaskEqualMaster;
+        private boolean packetInMaskSlaveSet;
+        private long packetInMaskSlave;
+        private boolean portStatusMaskEqualMasterSet;
+        private long portStatusMaskEqualMaster;
+        private boolean portStatusMaskSlaveSet;
+        private long portStatusMaskSlave;
+        private boolean flowRemovedMaskEqualMasterSet;
+        private long flowRemovedMaskEqualMaster;
+        private boolean flowRemovedMaskSlaveSet;
+        private long flowRemovedMaskSlave;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_ASYNC_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster) {
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setPacketInMaskSlave(long packetInMaskSlave) {
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.packetInMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster) {
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setPortStatusMaskSlave(long portStatusMaskSlave) {
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.portStatusMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster) {
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetReply.Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave) {
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+        this.flowRemovedMaskSlaveSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAsyncGetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long packetInMaskEqualMaster = this.packetInMaskEqualMasterSet ? this.packetInMaskEqualMaster : DEFAULT_PACKET_IN_MASK_EQUAL_MASTER;
+            long packetInMaskSlave = this.packetInMaskSlaveSet ? this.packetInMaskSlave : DEFAULT_PACKET_IN_MASK_SLAVE;
+            long portStatusMaskEqualMaster = this.portStatusMaskEqualMasterSet ? this.portStatusMaskEqualMaster : DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER;
+            long portStatusMaskSlave = this.portStatusMaskSlaveSet ? this.portStatusMaskSlave : DEFAULT_PORT_STATUS_MASK_SLAVE;
+            long flowRemovedMaskEqualMaster = this.flowRemovedMaskEqualMasterSet ? this.flowRemovedMaskEqualMaster : DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER;
+            long flowRemovedMaskSlave = this.flowRemovedMaskSlaveSet ? this.flowRemovedMaskSlave : DEFAULT_FLOW_REMOVED_MASK_SLAVE;
+
+
+            return new OFAsyncGetReplyVer13(
+                    xid,
+                    packetInMaskEqualMaster,
+                    packetInMaskSlave,
+                    portStatusMaskEqualMaster,
+                    portStatusMaskSlave,
+                    flowRemovedMaskEqualMaster,
+                    flowRemovedMaskSlave
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAsyncGetReply> {
+        @Override
+        public OFAsyncGetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 27
+            byte type = bb.readByte();
+            if(type != (byte) 0x1b)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_ASYNC_REPLY(27), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            long packetInMaskEqualMaster = U32.f(bb.readInt());
+            long packetInMaskSlave = U32.f(bb.readInt());
+            long portStatusMaskEqualMaster = U32.f(bb.readInt());
+            long portStatusMaskSlave = U32.f(bb.readInt());
+            long flowRemovedMaskEqualMaster = U32.f(bb.readInt());
+            long flowRemovedMaskSlave = U32.f(bb.readInt());
+
+            OFAsyncGetReplyVer13 asyncGetReplyVer13 = new OFAsyncGetReplyVer13(
+                    xid,
+                      packetInMaskEqualMaster,
+                      packetInMaskSlave,
+                      portStatusMaskEqualMaster,
+                      portStatusMaskSlave,
+                      flowRemovedMaskEqualMaster,
+                      flowRemovedMaskSlave
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", asyncGetReplyVer13);
+            return asyncGetReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAsyncGetReplyVer13Funnel FUNNEL = new OFAsyncGetReplyVer13Funnel();
+    static class OFAsyncGetReplyVer13Funnel implements Funnel<OFAsyncGetReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAsyncGetReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 27
+            sink.putByte((byte) 0x1b);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            sink.putLong(message.packetInMaskEqualMaster);
+            sink.putLong(message.packetInMaskSlave);
+            sink.putLong(message.portStatusMaskEqualMaster);
+            sink.putLong(message.portStatusMaskSlave);
+            sink.putLong(message.flowRemovedMaskEqualMaster);
+            sink.putLong(message.flowRemovedMaskSlave);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAsyncGetReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFAsyncGetReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 27
+            bb.writeByte((byte) 0x1b);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(U32.t(message.packetInMaskEqualMaster));
+            bb.writeInt(U32.t(message.packetInMaskSlave));
+            bb.writeInt(U32.t(message.portStatusMaskEqualMaster));
+            bb.writeInt(U32.t(message.portStatusMaskSlave));
+            bb.writeInt(U32.t(message.flowRemovedMaskEqualMaster));
+            bb.writeInt(U32.t(message.flowRemovedMaskSlave));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAsyncGetReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("packetInMaskEqualMaster=").append(packetInMaskEqualMaster);
+        b.append(", ");
+        b.append("packetInMaskSlave=").append(packetInMaskSlave);
+        b.append(", ");
+        b.append("portStatusMaskEqualMaster=").append(portStatusMaskEqualMaster);
+        b.append(", ");
+        b.append("portStatusMaskSlave=").append(portStatusMaskSlave);
+        b.append(", ");
+        b.append("flowRemovedMaskEqualMaster=").append(flowRemovedMaskEqualMaster);
+        b.append(", ");
+        b.append("flowRemovedMaskSlave=").append(flowRemovedMaskSlave);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAsyncGetReplyVer13 other = (OFAsyncGetReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( packetInMaskEqualMaster != other.packetInMaskEqualMaster)
+            return false;
+        if( packetInMaskSlave != other.packetInMaskSlave)
+            return false;
+        if( portStatusMaskEqualMaster != other.portStatusMaskEqualMaster)
+            return false;
+        if( portStatusMaskSlave != other.portStatusMaskSlave)
+            return false;
+        if( flowRemovedMaskEqualMaster != other.flowRemovedMaskEqualMaster)
+            return false;
+        if( flowRemovedMaskSlave != other.flowRemovedMaskSlave)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (packetInMaskEqualMaster ^ (packetInMaskEqualMaster >>> 32));
+        result = prime *  (int) (packetInMaskSlave ^ (packetInMaskSlave >>> 32));
+        result = prime *  (int) (portStatusMaskEqualMaster ^ (portStatusMaskEqualMaster >>> 32));
+        result = prime *  (int) (portStatusMaskSlave ^ (portStatusMaskSlave >>> 32));
+        result = prime *  (int) (flowRemovedMaskEqualMaster ^ (flowRemovedMaskEqualMaster >>> 32));
+        result = prime *  (int) (flowRemovedMaskSlave ^ (flowRemovedMaskSlave >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncGetRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncGetRequestVer13.java
new file mode 100644
index 0000000..a430e07
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncGetRequestVer13.java
@@ -0,0 +1,550 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAsyncGetRequestVer13 implements OFAsyncGetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFAsyncGetRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_PACKET_IN_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_PACKET_IN_MASK_SLAVE = 0x0L;
+        private final static long DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_PORT_STATUS_MASK_SLAVE = 0x0L;
+        private final static long DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_FLOW_REMOVED_MASK_SLAVE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long packetInMaskEqualMaster;
+    private final long packetInMaskSlave;
+    private final long portStatusMaskEqualMaster;
+    private final long portStatusMaskSlave;
+    private final long flowRemovedMaskEqualMaster;
+    private final long flowRemovedMaskSlave;
+//
+    // Immutable default instance
+    final static OFAsyncGetRequestVer13 DEFAULT = new OFAsyncGetRequestVer13(
+        DEFAULT_XID, DEFAULT_PACKET_IN_MASK_EQUAL_MASTER, DEFAULT_PACKET_IN_MASK_SLAVE, DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER, DEFAULT_PORT_STATUS_MASK_SLAVE, DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER, DEFAULT_FLOW_REMOVED_MASK_SLAVE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAsyncGetRequestVer13(long xid, long packetInMaskEqualMaster, long packetInMaskSlave, long portStatusMaskEqualMaster, long portStatusMaskSlave, long flowRemovedMaskEqualMaster, long flowRemovedMaskSlave) {
+        this.xid = xid;
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_ASYNC_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+
+
+    public OFAsyncGetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAsyncGetRequest.Builder {
+        final OFAsyncGetRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean packetInMaskEqualMasterSet;
+        private long packetInMaskEqualMaster;
+        private boolean packetInMaskSlaveSet;
+        private long packetInMaskSlave;
+        private boolean portStatusMaskEqualMasterSet;
+        private long portStatusMaskEqualMaster;
+        private boolean portStatusMaskSlaveSet;
+        private long portStatusMaskSlave;
+        private boolean flowRemovedMaskEqualMasterSet;
+        private long flowRemovedMaskEqualMaster;
+        private boolean flowRemovedMaskSlaveSet;
+        private long flowRemovedMaskSlave;
+
+        BuilderWithParent(OFAsyncGetRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_ASYNC_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster) {
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setPacketInMaskSlave(long packetInMaskSlave) {
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.packetInMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster) {
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setPortStatusMaskSlave(long portStatusMaskSlave) {
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.portStatusMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster) {
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave) {
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+        this.flowRemovedMaskSlaveSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAsyncGetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long packetInMaskEqualMaster = this.packetInMaskEqualMasterSet ? this.packetInMaskEqualMaster : parentMessage.packetInMaskEqualMaster;
+                long packetInMaskSlave = this.packetInMaskSlaveSet ? this.packetInMaskSlave : parentMessage.packetInMaskSlave;
+                long portStatusMaskEqualMaster = this.portStatusMaskEqualMasterSet ? this.portStatusMaskEqualMaster : parentMessage.portStatusMaskEqualMaster;
+                long portStatusMaskSlave = this.portStatusMaskSlaveSet ? this.portStatusMaskSlave : parentMessage.portStatusMaskSlave;
+                long flowRemovedMaskEqualMaster = this.flowRemovedMaskEqualMasterSet ? this.flowRemovedMaskEqualMaster : parentMessage.flowRemovedMaskEqualMaster;
+                long flowRemovedMaskSlave = this.flowRemovedMaskSlaveSet ? this.flowRemovedMaskSlave : parentMessage.flowRemovedMaskSlave;
+
+                //
+                return new OFAsyncGetRequestVer13(
+                    xid,
+                    packetInMaskEqualMaster,
+                    packetInMaskSlave,
+                    portStatusMaskEqualMaster,
+                    portStatusMaskSlave,
+                    flowRemovedMaskEqualMaster,
+                    flowRemovedMaskSlave
+                );
+        }
+
+    }
+
+    static class Builder implements OFAsyncGetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean packetInMaskEqualMasterSet;
+        private long packetInMaskEqualMaster;
+        private boolean packetInMaskSlaveSet;
+        private long packetInMaskSlave;
+        private boolean portStatusMaskEqualMasterSet;
+        private long portStatusMaskEqualMaster;
+        private boolean portStatusMaskSlaveSet;
+        private long portStatusMaskSlave;
+        private boolean flowRemovedMaskEqualMasterSet;
+        private long flowRemovedMaskEqualMaster;
+        private boolean flowRemovedMaskSlaveSet;
+        private long flowRemovedMaskSlave;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_ASYNC_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster) {
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setPacketInMaskSlave(long packetInMaskSlave) {
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.packetInMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster) {
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setPortStatusMaskSlave(long portStatusMaskSlave) {
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.portStatusMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster) {
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+    @Override
+    public OFAsyncGetRequest.Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave) {
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+        this.flowRemovedMaskSlaveSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAsyncGetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long packetInMaskEqualMaster = this.packetInMaskEqualMasterSet ? this.packetInMaskEqualMaster : DEFAULT_PACKET_IN_MASK_EQUAL_MASTER;
+            long packetInMaskSlave = this.packetInMaskSlaveSet ? this.packetInMaskSlave : DEFAULT_PACKET_IN_MASK_SLAVE;
+            long portStatusMaskEqualMaster = this.portStatusMaskEqualMasterSet ? this.portStatusMaskEqualMaster : DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER;
+            long portStatusMaskSlave = this.portStatusMaskSlaveSet ? this.portStatusMaskSlave : DEFAULT_PORT_STATUS_MASK_SLAVE;
+            long flowRemovedMaskEqualMaster = this.flowRemovedMaskEqualMasterSet ? this.flowRemovedMaskEqualMaster : DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER;
+            long flowRemovedMaskSlave = this.flowRemovedMaskSlaveSet ? this.flowRemovedMaskSlave : DEFAULT_FLOW_REMOVED_MASK_SLAVE;
+
+
+            return new OFAsyncGetRequestVer13(
+                    xid,
+                    packetInMaskEqualMaster,
+                    packetInMaskSlave,
+                    portStatusMaskEqualMaster,
+                    portStatusMaskSlave,
+                    flowRemovedMaskEqualMaster,
+                    flowRemovedMaskSlave
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAsyncGetRequest> {
+        @Override
+        public OFAsyncGetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 26
+            byte type = bb.readByte();
+            if(type != (byte) 0x1a)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_ASYNC_REQUEST(26), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            long packetInMaskEqualMaster = U32.f(bb.readInt());
+            long packetInMaskSlave = U32.f(bb.readInt());
+            long portStatusMaskEqualMaster = U32.f(bb.readInt());
+            long portStatusMaskSlave = U32.f(bb.readInt());
+            long flowRemovedMaskEqualMaster = U32.f(bb.readInt());
+            long flowRemovedMaskSlave = U32.f(bb.readInt());
+
+            OFAsyncGetRequestVer13 asyncGetRequestVer13 = new OFAsyncGetRequestVer13(
+                    xid,
+                      packetInMaskEqualMaster,
+                      packetInMaskSlave,
+                      portStatusMaskEqualMaster,
+                      portStatusMaskSlave,
+                      flowRemovedMaskEqualMaster,
+                      flowRemovedMaskSlave
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", asyncGetRequestVer13);
+            return asyncGetRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAsyncGetRequestVer13Funnel FUNNEL = new OFAsyncGetRequestVer13Funnel();
+    static class OFAsyncGetRequestVer13Funnel implements Funnel<OFAsyncGetRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAsyncGetRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 26
+            sink.putByte((byte) 0x1a);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            sink.putLong(message.packetInMaskEqualMaster);
+            sink.putLong(message.packetInMaskSlave);
+            sink.putLong(message.portStatusMaskEqualMaster);
+            sink.putLong(message.portStatusMaskSlave);
+            sink.putLong(message.flowRemovedMaskEqualMaster);
+            sink.putLong(message.flowRemovedMaskSlave);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAsyncGetRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFAsyncGetRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 26
+            bb.writeByte((byte) 0x1a);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(U32.t(message.packetInMaskEqualMaster));
+            bb.writeInt(U32.t(message.packetInMaskSlave));
+            bb.writeInt(U32.t(message.portStatusMaskEqualMaster));
+            bb.writeInt(U32.t(message.portStatusMaskSlave));
+            bb.writeInt(U32.t(message.flowRemovedMaskEqualMaster));
+            bb.writeInt(U32.t(message.flowRemovedMaskSlave));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAsyncGetRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("packetInMaskEqualMaster=").append(packetInMaskEqualMaster);
+        b.append(", ");
+        b.append("packetInMaskSlave=").append(packetInMaskSlave);
+        b.append(", ");
+        b.append("portStatusMaskEqualMaster=").append(portStatusMaskEqualMaster);
+        b.append(", ");
+        b.append("portStatusMaskSlave=").append(portStatusMaskSlave);
+        b.append(", ");
+        b.append("flowRemovedMaskEqualMaster=").append(flowRemovedMaskEqualMaster);
+        b.append(", ");
+        b.append("flowRemovedMaskSlave=").append(flowRemovedMaskSlave);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAsyncGetRequestVer13 other = (OFAsyncGetRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( packetInMaskEqualMaster != other.packetInMaskEqualMaster)
+            return false;
+        if( packetInMaskSlave != other.packetInMaskSlave)
+            return false;
+        if( portStatusMaskEqualMaster != other.portStatusMaskEqualMaster)
+            return false;
+        if( portStatusMaskSlave != other.portStatusMaskSlave)
+            return false;
+        if( flowRemovedMaskEqualMaster != other.flowRemovedMaskEqualMaster)
+            return false;
+        if( flowRemovedMaskSlave != other.flowRemovedMaskSlave)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (packetInMaskEqualMaster ^ (packetInMaskEqualMaster >>> 32));
+        result = prime *  (int) (packetInMaskSlave ^ (packetInMaskSlave >>> 32));
+        result = prime *  (int) (portStatusMaskEqualMaster ^ (portStatusMaskEqualMaster >>> 32));
+        result = prime *  (int) (portStatusMaskSlave ^ (portStatusMaskSlave >>> 32));
+        result = prime *  (int) (flowRemovedMaskEqualMaster ^ (flowRemovedMaskEqualMaster >>> 32));
+        result = prime *  (int) (flowRemovedMaskSlave ^ (flowRemovedMaskSlave >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncSetVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncSetVer13.java
new file mode 100644
index 0000000..9bc7524
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFAsyncSetVer13.java
@@ -0,0 +1,550 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFAsyncSetVer13 implements OFAsyncSet {
+    private static final Logger logger = LoggerFactory.getLogger(OFAsyncSetVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_PACKET_IN_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_PACKET_IN_MASK_SLAVE = 0x0L;
+        private final static long DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_PORT_STATUS_MASK_SLAVE = 0x0L;
+        private final static long DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER = 0x0L;
+        private final static long DEFAULT_FLOW_REMOVED_MASK_SLAVE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long packetInMaskEqualMaster;
+    private final long packetInMaskSlave;
+    private final long portStatusMaskEqualMaster;
+    private final long portStatusMaskSlave;
+    private final long flowRemovedMaskEqualMaster;
+    private final long flowRemovedMaskSlave;
+//
+    // Immutable default instance
+    final static OFAsyncSetVer13 DEFAULT = new OFAsyncSetVer13(
+        DEFAULT_XID, DEFAULT_PACKET_IN_MASK_EQUAL_MASTER, DEFAULT_PACKET_IN_MASK_SLAVE, DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER, DEFAULT_PORT_STATUS_MASK_SLAVE, DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER, DEFAULT_FLOW_REMOVED_MASK_SLAVE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFAsyncSetVer13(long xid, long packetInMaskEqualMaster, long packetInMaskSlave, long portStatusMaskEqualMaster, long portStatusMaskSlave, long flowRemovedMaskEqualMaster, long flowRemovedMaskSlave) {
+        this.xid = xid;
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_ASYNC;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+
+
+    public OFAsyncSet.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFAsyncSet.Builder {
+        final OFAsyncSetVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean packetInMaskEqualMasterSet;
+        private long packetInMaskEqualMaster;
+        private boolean packetInMaskSlaveSet;
+        private long packetInMaskSlave;
+        private boolean portStatusMaskEqualMasterSet;
+        private long portStatusMaskEqualMaster;
+        private boolean portStatusMaskSlaveSet;
+        private long portStatusMaskSlave;
+        private boolean flowRemovedMaskEqualMasterSet;
+        private long flowRemovedMaskEqualMaster;
+        private boolean flowRemovedMaskSlaveSet;
+        private long flowRemovedMaskSlave;
+
+        BuilderWithParent(OFAsyncSetVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_ASYNC;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster) {
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setPacketInMaskSlave(long packetInMaskSlave) {
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.packetInMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster) {
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setPortStatusMaskSlave(long portStatusMaskSlave) {
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.portStatusMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster) {
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave) {
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+        this.flowRemovedMaskSlaveSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFAsyncSet build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long packetInMaskEqualMaster = this.packetInMaskEqualMasterSet ? this.packetInMaskEqualMaster : parentMessage.packetInMaskEqualMaster;
+                long packetInMaskSlave = this.packetInMaskSlaveSet ? this.packetInMaskSlave : parentMessage.packetInMaskSlave;
+                long portStatusMaskEqualMaster = this.portStatusMaskEqualMasterSet ? this.portStatusMaskEqualMaster : parentMessage.portStatusMaskEqualMaster;
+                long portStatusMaskSlave = this.portStatusMaskSlaveSet ? this.portStatusMaskSlave : parentMessage.portStatusMaskSlave;
+                long flowRemovedMaskEqualMaster = this.flowRemovedMaskEqualMasterSet ? this.flowRemovedMaskEqualMaster : parentMessage.flowRemovedMaskEqualMaster;
+                long flowRemovedMaskSlave = this.flowRemovedMaskSlaveSet ? this.flowRemovedMaskSlave : parentMessage.flowRemovedMaskSlave;
+
+                //
+                return new OFAsyncSetVer13(
+                    xid,
+                    packetInMaskEqualMaster,
+                    packetInMaskSlave,
+                    portStatusMaskEqualMaster,
+                    portStatusMaskSlave,
+                    flowRemovedMaskEqualMaster,
+                    flowRemovedMaskSlave
+                );
+        }
+
+    }
+
+    static class Builder implements OFAsyncSet.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean packetInMaskEqualMasterSet;
+        private long packetInMaskEqualMaster;
+        private boolean packetInMaskSlaveSet;
+        private long packetInMaskSlave;
+        private boolean portStatusMaskEqualMasterSet;
+        private long portStatusMaskEqualMaster;
+        private boolean portStatusMaskSlaveSet;
+        private long portStatusMaskSlave;
+        private boolean flowRemovedMaskEqualMasterSet;
+        private long flowRemovedMaskEqualMaster;
+        private boolean flowRemovedMaskSlaveSet;
+        private long flowRemovedMaskSlave;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_ASYNC;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskEqualMaster() {
+        return packetInMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setPacketInMaskEqualMaster(long packetInMaskEqualMaster) {
+        this.packetInMaskEqualMaster = packetInMaskEqualMaster;
+        this.packetInMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPacketInMaskSlave() {
+        return packetInMaskSlave;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setPacketInMaskSlave(long packetInMaskSlave) {
+        this.packetInMaskSlave = packetInMaskSlave;
+        this.packetInMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskEqualMaster() {
+        return portStatusMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setPortStatusMaskEqualMaster(long portStatusMaskEqualMaster) {
+        this.portStatusMaskEqualMaster = portStatusMaskEqualMaster;
+        this.portStatusMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getPortStatusMaskSlave() {
+        return portStatusMaskSlave;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setPortStatusMaskSlave(long portStatusMaskSlave) {
+        this.portStatusMaskSlave = portStatusMaskSlave;
+        this.portStatusMaskSlaveSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskEqualMaster() {
+        return flowRemovedMaskEqualMaster;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setFlowRemovedMaskEqualMaster(long flowRemovedMaskEqualMaster) {
+        this.flowRemovedMaskEqualMaster = flowRemovedMaskEqualMaster;
+        this.flowRemovedMaskEqualMasterSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowRemovedMaskSlave() {
+        return flowRemovedMaskSlave;
+    }
+
+    @Override
+    public OFAsyncSet.Builder setFlowRemovedMaskSlave(long flowRemovedMaskSlave) {
+        this.flowRemovedMaskSlave = flowRemovedMaskSlave;
+        this.flowRemovedMaskSlaveSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFAsyncSet build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long packetInMaskEqualMaster = this.packetInMaskEqualMasterSet ? this.packetInMaskEqualMaster : DEFAULT_PACKET_IN_MASK_EQUAL_MASTER;
+            long packetInMaskSlave = this.packetInMaskSlaveSet ? this.packetInMaskSlave : DEFAULT_PACKET_IN_MASK_SLAVE;
+            long portStatusMaskEqualMaster = this.portStatusMaskEqualMasterSet ? this.portStatusMaskEqualMaster : DEFAULT_PORT_STATUS_MASK_EQUAL_MASTER;
+            long portStatusMaskSlave = this.portStatusMaskSlaveSet ? this.portStatusMaskSlave : DEFAULT_PORT_STATUS_MASK_SLAVE;
+            long flowRemovedMaskEqualMaster = this.flowRemovedMaskEqualMasterSet ? this.flowRemovedMaskEqualMaster : DEFAULT_FLOW_REMOVED_MASK_EQUAL_MASTER;
+            long flowRemovedMaskSlave = this.flowRemovedMaskSlaveSet ? this.flowRemovedMaskSlave : DEFAULT_FLOW_REMOVED_MASK_SLAVE;
+
+
+            return new OFAsyncSetVer13(
+                    xid,
+                    packetInMaskEqualMaster,
+                    packetInMaskSlave,
+                    portStatusMaskEqualMaster,
+                    portStatusMaskSlave,
+                    flowRemovedMaskEqualMaster,
+                    flowRemovedMaskSlave
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFAsyncSet> {
+        @Override
+        public OFAsyncSet readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 28
+            byte type = bb.readByte();
+            if(type != (byte) 0x1c)
+                throw new OFParseError("Wrong type: Expected=OFType.SET_ASYNC(28), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            long packetInMaskEqualMaster = U32.f(bb.readInt());
+            long packetInMaskSlave = U32.f(bb.readInt());
+            long portStatusMaskEqualMaster = U32.f(bb.readInt());
+            long portStatusMaskSlave = U32.f(bb.readInt());
+            long flowRemovedMaskEqualMaster = U32.f(bb.readInt());
+            long flowRemovedMaskSlave = U32.f(bb.readInt());
+
+            OFAsyncSetVer13 asyncSetVer13 = new OFAsyncSetVer13(
+                    xid,
+                      packetInMaskEqualMaster,
+                      packetInMaskSlave,
+                      portStatusMaskEqualMaster,
+                      portStatusMaskSlave,
+                      flowRemovedMaskEqualMaster,
+                      flowRemovedMaskSlave
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", asyncSetVer13);
+            return asyncSetVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFAsyncSetVer13Funnel FUNNEL = new OFAsyncSetVer13Funnel();
+    static class OFAsyncSetVer13Funnel implements Funnel<OFAsyncSetVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFAsyncSetVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 28
+            sink.putByte((byte) 0x1c);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            sink.putLong(message.packetInMaskEqualMaster);
+            sink.putLong(message.packetInMaskSlave);
+            sink.putLong(message.portStatusMaskEqualMaster);
+            sink.putLong(message.portStatusMaskSlave);
+            sink.putLong(message.flowRemovedMaskEqualMaster);
+            sink.putLong(message.flowRemovedMaskSlave);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFAsyncSetVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFAsyncSetVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 28
+            bb.writeByte((byte) 0x1c);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(U32.t(message.packetInMaskEqualMaster));
+            bb.writeInt(U32.t(message.packetInMaskSlave));
+            bb.writeInt(U32.t(message.portStatusMaskEqualMaster));
+            bb.writeInt(U32.t(message.portStatusMaskSlave));
+            bb.writeInt(U32.t(message.flowRemovedMaskEqualMaster));
+            bb.writeInt(U32.t(message.flowRemovedMaskSlave));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFAsyncSetVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("packetInMaskEqualMaster=").append(packetInMaskEqualMaster);
+        b.append(", ");
+        b.append("packetInMaskSlave=").append(packetInMaskSlave);
+        b.append(", ");
+        b.append("portStatusMaskEqualMaster=").append(portStatusMaskEqualMaster);
+        b.append(", ");
+        b.append("portStatusMaskSlave=").append(portStatusMaskSlave);
+        b.append(", ");
+        b.append("flowRemovedMaskEqualMaster=").append(flowRemovedMaskEqualMaster);
+        b.append(", ");
+        b.append("flowRemovedMaskSlave=").append(flowRemovedMaskSlave);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFAsyncSetVer13 other = (OFAsyncSetVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( packetInMaskEqualMaster != other.packetInMaskEqualMaster)
+            return false;
+        if( packetInMaskSlave != other.packetInMaskSlave)
+            return false;
+        if( portStatusMaskEqualMaster != other.portStatusMaskEqualMaster)
+            return false;
+        if( portStatusMaskSlave != other.portStatusMaskSlave)
+            return false;
+        if( flowRemovedMaskEqualMaster != other.flowRemovedMaskEqualMaster)
+            return false;
+        if( flowRemovedMaskSlave != other.flowRemovedMaskSlave)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (packetInMaskEqualMaster ^ (packetInMaskEqualMaster >>> 32));
+        result = prime *  (int) (packetInMaskSlave ^ (packetInMaskSlave >>> 32));
+        result = prime *  (int) (portStatusMaskEqualMaster ^ (portStatusMaskEqualMaster >>> 32));
+        result = prime *  (int) (portStatusMaskSlave ^ (portStatusMaskSlave >>> 32));
+        result = prime *  (int) (flowRemovedMaskEqualMaster ^ (flowRemovedMaskEqualMaster >>> 32));
+        result = prime *  (int) (flowRemovedMaskSlave ^ (flowRemovedMaskSlave >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadActionCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadActionCodeSerializerVer13.java
new file mode 100644
index 0000000..5294b00
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadActionCodeSerializerVer13.java
@@ -0,0 +1,144 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadActionCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadActionCodeSerializerVer13 {
+
+    public final static short BAD_TYPE_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x2;
+    public final static short BAD_EXPERIMENTER_TYPE_VAL = (short) 0x3;
+    public final static short BAD_OUT_PORT_VAL = (short) 0x4;
+    public final static short BAD_ARGUMENT_VAL = (short) 0x5;
+    public final static short EPERM_VAL = (short) 0x6;
+    public final static short TOO_MANY_VAL = (short) 0x7;
+    public final static short BAD_QUEUE_VAL = (short) 0x8;
+    public final static short BAD_OUT_GROUP_VAL = (short) 0x9;
+    public final static short MATCH_INCONSISTENT_VAL = (short) 0xa;
+    public final static short UNSUPPORTED_ORDER_VAL = (short) 0xb;
+    public final static short BAD_TAG_VAL = (short) 0xc;
+    public final static short BAD_SET_TYPE_VAL = (short) 0xd;
+    public final static short BAD_SET_LEN_VAL = (short) 0xe;
+    public final static short BAD_SET_ARGUMENT_VAL = (short) 0xf;
+
+    public static OFBadActionCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadActionCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadActionCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadActionCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TYPE_VAL:
+                return OFBadActionCode.BAD_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadActionCode.BAD_LEN;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadActionCode.BAD_EXPERIMENTER;
+            case BAD_EXPERIMENTER_TYPE_VAL:
+                return OFBadActionCode.BAD_EXPERIMENTER_TYPE;
+            case BAD_OUT_PORT_VAL:
+                return OFBadActionCode.BAD_OUT_PORT;
+            case BAD_ARGUMENT_VAL:
+                return OFBadActionCode.BAD_ARGUMENT;
+            case EPERM_VAL:
+                return OFBadActionCode.EPERM;
+            case TOO_MANY_VAL:
+                return OFBadActionCode.TOO_MANY;
+            case BAD_QUEUE_VAL:
+                return OFBadActionCode.BAD_QUEUE;
+            case BAD_OUT_GROUP_VAL:
+                return OFBadActionCode.BAD_OUT_GROUP;
+            case MATCH_INCONSISTENT_VAL:
+                return OFBadActionCode.MATCH_INCONSISTENT;
+            case UNSUPPORTED_ORDER_VAL:
+                return OFBadActionCode.UNSUPPORTED_ORDER;
+            case BAD_TAG_VAL:
+                return OFBadActionCode.BAD_TAG;
+            case BAD_SET_TYPE_VAL:
+                return OFBadActionCode.BAD_SET_TYPE;
+            case BAD_SET_LEN_VAL:
+                return OFBadActionCode.BAD_SET_LEN;
+            case BAD_SET_ARGUMENT_VAL:
+                return OFBadActionCode.BAD_SET_ARGUMENT;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadActionCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadActionCode e) {
+        switch(e) {
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_EXPERIMENTER_TYPE:
+                return BAD_EXPERIMENTER_TYPE_VAL;
+            case BAD_OUT_PORT:
+                return BAD_OUT_PORT_VAL;
+            case BAD_ARGUMENT:
+                return BAD_ARGUMENT_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case TOO_MANY:
+                return TOO_MANY_VAL;
+            case BAD_QUEUE:
+                return BAD_QUEUE_VAL;
+            case BAD_OUT_GROUP:
+                return BAD_OUT_GROUP_VAL;
+            case MATCH_INCONSISTENT:
+                return MATCH_INCONSISTENT_VAL;
+            case UNSUPPORTED_ORDER:
+                return UNSUPPORTED_ORDER_VAL;
+            case BAD_TAG:
+                return BAD_TAG_VAL;
+            case BAD_SET_TYPE:
+                return BAD_SET_TYPE_VAL;
+            case BAD_SET_LEN:
+                return BAD_SET_LEN_VAL;
+            case BAD_SET_ARGUMENT:
+                return BAD_SET_ARGUMENT_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadActionCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadActionErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadActionErrorMsgVer13.java
new file mode 100644
index 0000000..ceee8c2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadActionErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadActionErrorMsgVer13 implements OFBadActionErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadActionErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadActionCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadActionErrorMsgVer13(long xid, OFBadActionCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadActionErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadActionErrorMsg.Builder {
+        final OFBadActionErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadActionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadActionErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setCode(OFBadActionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadActionErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadActionCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadActionErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadActionErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadActionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_ACTION;
+    }
+
+    @Override
+    public OFBadActionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setCode(OFBadActionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadActionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadActionErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadActionErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadActionErrorMsg> {
+        @Override
+        public OFBadActionErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 2
+            short errType = bb.readShort();
+            if(errType != (short) 0x2)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_ACTION(2), got="+errType);
+            OFBadActionCode code = OFBadActionCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFBadActionErrorMsgVer13 badActionErrorMsgVer13 = new OFBadActionErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badActionErrorMsgVer13);
+            return badActionErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadActionErrorMsgVer13Funnel FUNNEL = new OFBadActionErrorMsgVer13Funnel();
+    static class OFBadActionErrorMsgVer13Funnel implements Funnel<OFBadActionErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadActionErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 2
+            sink.putShort((short) 0x2);
+            OFBadActionCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadActionErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadActionErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 2
+            bb.writeShort((short) 0x2);
+            OFBadActionCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadActionErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadActionErrorMsgVer13 other = (OFBadActionErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadInstructionCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadInstructionCodeSerializerVer13.java
new file mode 100644
index 0000000..86f6777
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadInstructionCodeSerializerVer13.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadInstructionCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadInstructionCodeSerializerVer13 {
+
+    public final static short UNKNOWN_INST_VAL = (short) 0x0;
+    public final static short UNSUP_INST_VAL = (short) 0x1;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x2;
+    public final static short UNSUP_METADATA_VAL = (short) 0x3;
+    public final static short UNSUP_METADATA_MASK_VAL = (short) 0x4;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x5;
+    public final static short BAD_EXPERIMENTER_TYPE_VAL = (short) 0x6;
+    public final static short BAD_LEN_VAL = (short) 0x7;
+    public final static short EPERM_VAL = (short) 0x8;
+
+    public static OFBadInstructionCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadInstructionCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadInstructionCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadInstructionCode ofWireValue(short val) {
+        switch(val) {
+            case UNKNOWN_INST_VAL:
+                return OFBadInstructionCode.UNKNOWN_INST;
+            case UNSUP_INST_VAL:
+                return OFBadInstructionCode.UNSUP_INST;
+            case BAD_TABLE_ID_VAL:
+                return OFBadInstructionCode.BAD_TABLE_ID;
+            case UNSUP_METADATA_VAL:
+                return OFBadInstructionCode.UNSUP_METADATA;
+            case UNSUP_METADATA_MASK_VAL:
+                return OFBadInstructionCode.UNSUP_METADATA_MASK;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadInstructionCode.BAD_EXPERIMENTER;
+            case BAD_EXPERIMENTER_TYPE_VAL:
+                return OFBadInstructionCode.BAD_EXPERIMENTER_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadInstructionCode.BAD_LEN;
+            case EPERM_VAL:
+                return OFBadInstructionCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadInstructionCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadInstructionCode e) {
+        switch(e) {
+            case UNKNOWN_INST:
+                return UNKNOWN_INST_VAL;
+            case UNSUP_INST:
+                return UNSUP_INST_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            case UNSUP_METADATA:
+                return UNSUP_METADATA_VAL;
+            case UNSUP_METADATA_MASK:
+                return UNSUP_METADATA_MASK_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_EXPERIMENTER_TYPE:
+                return BAD_EXPERIMENTER_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadInstructionCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadInstructionErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadInstructionErrorMsgVer13.java
new file mode 100644
index 0000000..135e3f5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadInstructionErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadInstructionErrorMsgVer13 implements OFBadInstructionErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadInstructionErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadInstructionCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadInstructionErrorMsgVer13(long xid, OFBadInstructionCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadInstructionErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadInstructionErrorMsg.Builder {
+        final OFBadInstructionErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadInstructionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadInstructionErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setCode(OFBadInstructionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadInstructionErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadInstructionCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadInstructionErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadInstructionErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadInstructionCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_INSTRUCTION;
+    }
+
+    @Override
+    public OFBadInstructionCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setCode(OFBadInstructionCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadInstructionErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadInstructionErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadInstructionErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadInstructionErrorMsg> {
+        @Override
+        public OFBadInstructionErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 3
+            short errType = bb.readShort();
+            if(errType != (short) 0x3)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_INSTRUCTION(3), got="+errType);
+            OFBadInstructionCode code = OFBadInstructionCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFBadInstructionErrorMsgVer13 badInstructionErrorMsgVer13 = new OFBadInstructionErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badInstructionErrorMsgVer13);
+            return badInstructionErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadInstructionErrorMsgVer13Funnel FUNNEL = new OFBadInstructionErrorMsgVer13Funnel();
+    static class OFBadInstructionErrorMsgVer13Funnel implements Funnel<OFBadInstructionErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadInstructionErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 3
+            sink.putShort((short) 0x3);
+            OFBadInstructionCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadInstructionErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadInstructionErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 3
+            bb.writeShort((short) 0x3);
+            OFBadInstructionCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadInstructionErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadInstructionErrorMsgVer13 other = (OFBadInstructionErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchCodeSerializerVer13.java
new file mode 100644
index 0000000..e5a41a8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchCodeSerializerVer13.java
@@ -0,0 +1,124 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadMatchCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadMatchCodeSerializerVer13 {
+
+    public final static short BAD_TYPE_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short BAD_TAG_VAL = (short) 0x2;
+    public final static short BAD_DL_ADDR_MASK_VAL = (short) 0x3;
+    public final static short BAD_NW_ADDR_MASK_VAL = (short) 0x4;
+    public final static short BAD_WILDCARDS_VAL = (short) 0x5;
+    public final static short BAD_FIELD_VAL = (short) 0x6;
+    public final static short BAD_VALUE_VAL = (short) 0x7;
+    public final static short BAD_MASK_VAL = (short) 0x8;
+    public final static short BAD_PREREQ_VAL = (short) 0x9;
+    public final static short DUP_FIELD_VAL = (short) 0xa;
+    public final static short EPERM_VAL = (short) 0xb;
+
+    public static OFBadMatchCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadMatchCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadMatchCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadMatchCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TYPE_VAL:
+                return OFBadMatchCode.BAD_TYPE;
+            case BAD_LEN_VAL:
+                return OFBadMatchCode.BAD_LEN;
+            case BAD_TAG_VAL:
+                return OFBadMatchCode.BAD_TAG;
+            case BAD_DL_ADDR_MASK_VAL:
+                return OFBadMatchCode.BAD_DL_ADDR_MASK;
+            case BAD_NW_ADDR_MASK_VAL:
+                return OFBadMatchCode.BAD_NW_ADDR_MASK;
+            case BAD_WILDCARDS_VAL:
+                return OFBadMatchCode.BAD_WILDCARDS;
+            case BAD_FIELD_VAL:
+                return OFBadMatchCode.BAD_FIELD;
+            case BAD_VALUE_VAL:
+                return OFBadMatchCode.BAD_VALUE;
+            case BAD_MASK_VAL:
+                return OFBadMatchCode.BAD_MASK;
+            case BAD_PREREQ_VAL:
+                return OFBadMatchCode.BAD_PREREQ;
+            case DUP_FIELD_VAL:
+                return OFBadMatchCode.DUP_FIELD;
+            case EPERM_VAL:
+                return OFBadMatchCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadMatchCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadMatchCode e) {
+        switch(e) {
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BAD_TAG:
+                return BAD_TAG_VAL;
+            case BAD_DL_ADDR_MASK:
+                return BAD_DL_ADDR_MASK_VAL;
+            case BAD_NW_ADDR_MASK:
+                return BAD_NW_ADDR_MASK_VAL;
+            case BAD_WILDCARDS:
+                return BAD_WILDCARDS_VAL;
+            case BAD_FIELD:
+                return BAD_FIELD_VAL;
+            case BAD_VALUE:
+                return BAD_VALUE_VAL;
+            case BAD_MASK:
+                return BAD_MASK_VAL;
+            case BAD_PREREQ:
+                return BAD_PREREQ_VAL;
+            case DUP_FIELD:
+                return DUP_FIELD_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadMatchCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchErrorMsgVer13.java
new file mode 100644
index 0000000..bcdb0fa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadMatchErrorMsgVer13 implements OFBadMatchErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadMatchErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadMatchCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadMatchErrorMsgVer13(long xid, OFBadMatchCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadMatchErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadMatchErrorMsg.Builder {
+        final OFBadMatchErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadMatchCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadMatchErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setCode(OFBadMatchCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadMatchErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadMatchCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadMatchErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadMatchErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadMatchCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_MATCH;
+    }
+
+    @Override
+    public OFBadMatchCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setCode(OFBadMatchCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadMatchErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadMatchErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadMatchErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadMatchErrorMsg> {
+        @Override
+        public OFBadMatchErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 4
+            short errType = bb.readShort();
+            if(errType != (short) 0x4)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_MATCH(4), got="+errType);
+            OFBadMatchCode code = OFBadMatchCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFBadMatchErrorMsgVer13 badMatchErrorMsgVer13 = new OFBadMatchErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badMatchErrorMsgVer13);
+            return badMatchErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadMatchErrorMsgVer13Funnel FUNNEL = new OFBadMatchErrorMsgVer13Funnel();
+    static class OFBadMatchErrorMsgVer13Funnel implements Funnel<OFBadMatchErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadMatchErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 4
+            sink.putShort((short) 0x4);
+            OFBadMatchCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadMatchErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadMatchErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 4
+            bb.writeShort((short) 0x4);
+            OFBadMatchCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadMatchErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadMatchErrorMsgVer13 other = (OFBadMatchErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestCodeSerializerVer13.java
new file mode 100644
index 0000000..6f47134
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestCodeSerializerVer13.java
@@ -0,0 +1,134 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBadRequestCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBadRequestCodeSerializerVer13 {
+
+    public final static short BAD_VERSION_VAL = (short) 0x0;
+    public final static short BAD_TYPE_VAL = (short) 0x1;
+    public final static short BAD_STAT_VAL = (short) 0x2;
+    public final static short BAD_EXPERIMENTER_VAL = (short) 0x3;
+    public final static short BAD_EXPERIMENTER_TYPE_VAL = (short) 0x4;
+    public final static short EPERM_VAL = (short) 0x5;
+    public final static short BAD_LEN_VAL = (short) 0x6;
+    public final static short BUFFER_EMPTY_VAL = (short) 0x7;
+    public final static short BUFFER_UNKNOWN_VAL = (short) 0x8;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x9;
+    public final static short IS_SLAVE_VAL = (short) 0xa;
+    public final static short BAD_PORT_VAL = (short) 0xb;
+    public final static short BAD_PACKET_VAL = (short) 0xc;
+    public final static short MULTIPART_BUFFER_OVERFLOW_VAL = (short) 0xd;
+
+    public static OFBadRequestCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBadRequestCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBadRequestCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBadRequestCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_VERSION_VAL:
+                return OFBadRequestCode.BAD_VERSION;
+            case BAD_TYPE_VAL:
+                return OFBadRequestCode.BAD_TYPE;
+            case BAD_STAT_VAL:
+                return OFBadRequestCode.BAD_STAT;
+            case BAD_EXPERIMENTER_VAL:
+                return OFBadRequestCode.BAD_EXPERIMENTER;
+            case BAD_EXPERIMENTER_TYPE_VAL:
+                return OFBadRequestCode.BAD_EXPERIMENTER_TYPE;
+            case EPERM_VAL:
+                return OFBadRequestCode.EPERM;
+            case BAD_LEN_VAL:
+                return OFBadRequestCode.BAD_LEN;
+            case BUFFER_EMPTY_VAL:
+                return OFBadRequestCode.BUFFER_EMPTY;
+            case BUFFER_UNKNOWN_VAL:
+                return OFBadRequestCode.BUFFER_UNKNOWN;
+            case BAD_TABLE_ID_VAL:
+                return OFBadRequestCode.BAD_TABLE_ID;
+            case IS_SLAVE_VAL:
+                return OFBadRequestCode.IS_SLAVE;
+            case BAD_PORT_VAL:
+                return OFBadRequestCode.BAD_PORT;
+            case BAD_PACKET_VAL:
+                return OFBadRequestCode.BAD_PACKET;
+            case MULTIPART_BUFFER_OVERFLOW_VAL:
+                return OFBadRequestCode.MULTIPART_BUFFER_OVERFLOW;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBadRequestCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBadRequestCode e) {
+        switch(e) {
+            case BAD_VERSION:
+                return BAD_VERSION_VAL;
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_STAT:
+                return BAD_STAT_VAL;
+            case BAD_EXPERIMENTER:
+                return BAD_EXPERIMENTER_VAL;
+            case BAD_EXPERIMENTER_TYPE:
+                return BAD_EXPERIMENTER_TYPE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BUFFER_EMPTY:
+                return BUFFER_EMPTY_VAL;
+            case BUFFER_UNKNOWN:
+                return BUFFER_UNKNOWN_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            case IS_SLAVE:
+                return IS_SLAVE_VAL;
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_PACKET:
+                return BAD_PACKET_VAL;
+            case MULTIPART_BUFFER_OVERFLOW:
+                return MULTIPART_BUFFER_OVERFLOW_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBadRequestCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestErrorMsgVer13.java
new file mode 100644
index 0000000..f3a9109
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBadRequestErrorMsgVer13 implements OFBadRequestErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFBadRequestErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFBadRequestCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBadRequestErrorMsgVer13(long xid, OFBadRequestCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFBadRequestErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBadRequestErrorMsg.Builder {
+        final OFBadRequestErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadRequestCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFBadRequestErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setCode(OFBadRequestCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBadRequestErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBadRequestCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBadRequestErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBadRequestErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFBadRequestCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.BAD_REQUEST;
+    }
+
+    @Override
+    public OFBadRequestCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setCode(OFBadRequestCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFBadRequestErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBadRequestErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBadRequestErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBadRequestErrorMsg> {
+        @Override
+        public OFBadRequestErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 1
+            short errType = bb.readShort();
+            if(errType != (short) 0x1)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.BAD_REQUEST(1), got="+errType);
+            OFBadRequestCode code = OFBadRequestCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFBadRequestErrorMsgVer13 badRequestErrorMsgVer13 = new OFBadRequestErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", badRequestErrorMsgVer13);
+            return badRequestErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBadRequestErrorMsgVer13Funnel FUNNEL = new OFBadRequestErrorMsgVer13Funnel();
+    static class OFBadRequestErrorMsgVer13Funnel implements Funnel<OFBadRequestErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBadRequestErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 1
+            sink.putShort((short) 0x1);
+            OFBadRequestCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBadRequestErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBadRequestErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 1
+            bb.writeShort((short) 0x1);
+            OFBadRequestCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBadRequestErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBadRequestErrorMsgVer13 other = (OFBadRequestErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBarrierReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBarrierReplyVer13.java
new file mode 100644
index 0000000..a0b2ee1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBarrierReplyVer13.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBarrierReplyVer13 implements OFBarrierReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBarrierReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBarrierReplyVer13 DEFAULT = new OFBarrierReplyVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBarrierReplyVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFBarrierReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBarrierReply.Builder {
+        final OFBarrierReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBarrierReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBarrierReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBarrierReplyVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBarrierReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBarrierReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBarrierReplyVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBarrierReply> {
+        @Override
+        public OFBarrierReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 21
+            byte type = bb.readByte();
+            if(type != (byte) 0x15)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REPLY(21), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFBarrierReplyVer13 barrierReplyVer13 = new OFBarrierReplyVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", barrierReplyVer13);
+            return barrierReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBarrierReplyVer13Funnel FUNNEL = new OFBarrierReplyVer13Funnel();
+    static class OFBarrierReplyVer13Funnel implements Funnel<OFBarrierReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBarrierReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 21
+            sink.putByte((byte) 0x15);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBarrierReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBarrierReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 21
+            bb.writeByte((byte) 0x15);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBarrierReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBarrierReplyVer13 other = (OFBarrierReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBarrierRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBarrierRequestVer13.java
new file mode 100644
index 0000000..542294e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBarrierRequestVer13.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBarrierRequestVer13 implements OFBarrierRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBarrierRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBarrierRequestVer13 DEFAULT = new OFBarrierRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBarrierRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFBarrierRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBarrierRequest.Builder {
+        final OFBarrierRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBarrierRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBarrierRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBarrierRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBarrierRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.BARRIER_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBarrierRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBarrierRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBarrierRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBarrierRequest> {
+        @Override
+        public OFBarrierRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 20
+            byte type = bb.readByte();
+            if(type != (byte) 0x14)
+                throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REQUEST(20), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFBarrierRequestVer13 barrierRequestVer13 = new OFBarrierRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", barrierRequestVer13);
+            return barrierRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBarrierRequestVer13Funnel FUNNEL = new OFBarrierRequestVer13Funnel();
+    static class OFBarrierRequestVer13Funnel implements Funnel<OFBarrierRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBarrierRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 20
+            sink.putByte((byte) 0x14);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBarrierRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBarrierRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 20
+            bb.writeByte((byte) 0x14);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBarrierRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBarrierRequestVer13 other = (OFBarrierRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnArpIdleVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnArpIdleVer13.java
new file mode 100644
index 0000000..d9142d0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnArpIdleVer13.java
@@ -0,0 +1,420 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnArpIdleVer13 implements OFBsnArpIdle {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnArpIdleVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static int DEFAULT_VLAN_VID = 0x0;
+        private final static IPv4Address DEFAULT_IPV4_ADDR = IPv4Address.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final int vlanVid;
+    private final IPv4Address ipv4Addr;
+//
+    // Immutable default instance
+    final static OFBsnArpIdleVer13 DEFAULT = new OFBsnArpIdleVer13(
+        DEFAULT_XID, DEFAULT_VLAN_VID, DEFAULT_IPV4_ADDR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnArpIdleVer13(long xid, int vlanVid, IPv4Address ipv4Addr) {
+        this.xid = xid;
+        this.vlanVid = vlanVid;
+        this.ipv4Addr = ipv4Addr;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3cL;
+    }
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+
+
+    public OFBsnArpIdle.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnArpIdle.Builder {
+        final OFBsnArpIdleVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vlanVidSet;
+        private int vlanVid;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+
+        BuilderWithParent(OFBsnArpIdleVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnArpIdle.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3cL;
+    }
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFBsnArpIdle.Builder setVlanVid(int vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnArpIdle.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnArpIdle build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                int vlanVid = this.vlanVidSet ? this.vlanVid : parentMessage.vlanVid;
+                IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : parentMessage.ipv4Addr;
+                if(ipv4Addr == null)
+                    throw new NullPointerException("Property ipv4Addr must not be null");
+
+                //
+                return new OFBsnArpIdleVer13(
+                    xid,
+                    vlanVid,
+                    ipv4Addr
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnArpIdle.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vlanVidSet;
+        private int vlanVid;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnArpIdle.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3cL;
+    }
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFBsnArpIdle.Builder setVlanVid(int vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnArpIdle.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnArpIdle build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            int vlanVid = this.vlanVidSet ? this.vlanVid : DEFAULT_VLAN_VID;
+            IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : DEFAULT_IPV4_ADDR;
+            if(ipv4Addr == null)
+                throw new NullPointerException("Property ipv4Addr must not be null");
+
+
+            return new OFBsnArpIdleVer13(
+                    xid,
+                    vlanVid,
+                    ipv4Addr
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnArpIdle> {
+        @Override
+        public OFBsnArpIdle readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3cL
+            int subtype = bb.readInt();
+            if(subtype != 0x3c)
+                throw new OFParseError("Wrong subtype: Expected=0x3cL(0x3cL), got="+subtype);
+            int vlanVid = U16.f(bb.readShort());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            IPv4Address ipv4Addr = IPv4Address.read4Bytes(bb);
+
+            OFBsnArpIdleVer13 bsnArpIdleVer13 = new OFBsnArpIdleVer13(
+                    xid,
+                      vlanVid,
+                      ipv4Addr
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnArpIdleVer13);
+            return bsnArpIdleVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnArpIdleVer13Funnel FUNNEL = new OFBsnArpIdleVer13Funnel();
+    static class OFBsnArpIdleVer13Funnel implements Funnel<OFBsnArpIdleVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnArpIdleVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3cL
+            sink.putInt(0x3c);
+            sink.putInt(message.vlanVid);
+            // skip pad (2 bytes)
+            message.ipv4Addr.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnArpIdleVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnArpIdleVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3cL
+            bb.writeInt(0x3c);
+            bb.writeShort(U16.t(message.vlanVid));
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.ipv4Addr.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnArpIdleVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vlanVid=").append(vlanVid);
+        b.append(", ");
+        b.append("ipv4Addr=").append(ipv4Addr);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnArpIdleVer13 other = (OFBsnArpIdleVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( vlanVid != other.vlanVid)
+            return false;
+        if (ipv4Addr == null) {
+            if (other.ipv4Addr != null)
+                return false;
+        } else if (!ipv4Addr.equals(other.ipv4Addr))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + vlanVid;
+        result = prime * result + ((ipv4Addr == null) ? 0 : ipv4Addr.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwClearDataReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwClearDataReplyVer13.java
new file mode 100644
index 0000000..76559ed
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwClearDataReplyVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwClearDataReplyVer13 implements OFBsnBwClearDataReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwClearDataReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnBwClearDataReplyVer13 DEFAULT = new OFBsnBwClearDataReplyVer13(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwClearDataReplyVer13(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnBwClearDataReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwClearDataReply.Builder {
+        final OFBsnBwClearDataReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnBwClearDataReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwClearDataReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnBwClearDataReplyVer13(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwClearDataReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x16L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwClearDataReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwClearDataReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnBwClearDataReplyVer13(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwClearDataReply> {
+        @Override
+        public OFBsnBwClearDataReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x16L
+            int subtype = bb.readInt();
+            if(subtype != 0x16)
+                throw new OFParseError("Wrong subtype: Expected=0x16L(0x16L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnBwClearDataReplyVer13 bsnBwClearDataReplyVer13 = new OFBsnBwClearDataReplyVer13(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwClearDataReplyVer13);
+            return bsnBwClearDataReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwClearDataReplyVer13Funnel FUNNEL = new OFBsnBwClearDataReplyVer13Funnel();
+    static class OFBsnBwClearDataReplyVer13Funnel implements Funnel<OFBsnBwClearDataReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwClearDataReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x16L
+            sink.putInt(0x16);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwClearDataReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwClearDataReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x16L
+            bb.writeInt(0x16);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwClearDataReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwClearDataReplyVer13 other = (OFBsnBwClearDataReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwClearDataRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwClearDataRequestVer13.java
new file mode 100644
index 0000000..3d7a03e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwClearDataRequestVer13.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwClearDataRequestVer13 implements OFBsnBwClearDataRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwClearDataRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnBwClearDataRequestVer13 DEFAULT = new OFBsnBwClearDataRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwClearDataRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+
+
+    public OFBsnBwClearDataRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwClearDataRequest.Builder {
+        final OFBsnBwClearDataRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnBwClearDataRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+
+
+        @Override
+        public OFBsnBwClearDataRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnBwClearDataRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwClearDataRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwClearDataRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x15L;
+    }
+
+//
+        @Override
+        public OFBsnBwClearDataRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnBwClearDataRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwClearDataRequest> {
+        @Override
+        public OFBsnBwClearDataRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x15L
+            int subtype = bb.readInt();
+            if(subtype != 0x15)
+                throw new OFParseError("Wrong subtype: Expected=0x15L(0x15L), got="+subtype);
+
+            OFBsnBwClearDataRequestVer13 bsnBwClearDataRequestVer13 = new OFBsnBwClearDataRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwClearDataRequestVer13);
+            return bsnBwClearDataRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwClearDataRequestVer13Funnel FUNNEL = new OFBsnBwClearDataRequestVer13Funnel();
+    static class OFBsnBwClearDataRequestVer13Funnel implements Funnel<OFBsnBwClearDataRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwClearDataRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x15L
+            sink.putInt(0x15);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwClearDataRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwClearDataRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x15L
+            bb.writeInt(0x15);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwClearDataRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwClearDataRequestVer13 other = (OFBsnBwClearDataRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableGetReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableGetReplyVer13.java
new file mode 100644
index 0000000..790cf84
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableGetReplyVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableGetReplyVer13 implements OFBsnBwEnableGetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableGetReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLED = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enabled;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableGetReplyVer13 DEFAULT = new OFBsnBwEnableGetReplyVer13(
+        DEFAULT_XID, DEFAULT_ENABLED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableGetReplyVer13(long xid, long enabled) {
+        this.xid = xid;
+        this.enabled = enabled;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+
+
+    public OFBsnBwEnableGetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableGetReply.Builder {
+        final OFBsnBwEnableGetReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+        BuilderWithParent(OFBsnBwEnableGetReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableGetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+
+                //
+                return new OFBsnBwEnableGetReplyVer13(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableGetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x14L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnBwEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableGetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+
+
+            return new OFBsnBwEnableGetReplyVer13(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableGetReply> {
+        @Override
+        public OFBsnBwEnableGetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x14L
+            int subtype = bb.readInt();
+            if(subtype != 0x14)
+                throw new OFParseError("Wrong subtype: Expected=0x14L(0x14L), got="+subtype);
+            long enabled = U32.f(bb.readInt());
+
+            OFBsnBwEnableGetReplyVer13 bsnBwEnableGetReplyVer13 = new OFBsnBwEnableGetReplyVer13(
+                    xid,
+                      enabled
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableGetReplyVer13);
+            return bsnBwEnableGetReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableGetReplyVer13Funnel FUNNEL = new OFBsnBwEnableGetReplyVer13Funnel();
+    static class OFBsnBwEnableGetReplyVer13Funnel implements Funnel<OFBsnBwEnableGetReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableGetReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x14L
+            sink.putInt(0x14);
+            sink.putLong(message.enabled);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableGetReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableGetReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x14L
+            bb.writeInt(0x14);
+            bb.writeInt(U32.t(message.enabled));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableGetReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableGetReplyVer13 other = (OFBsnBwEnableGetReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enabled ^ (enabled >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableGetRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableGetRequestVer13.java
new file mode 100644
index 0000000..f53670a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableGetRequestVer13.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableGetRequestVer13 implements OFBsnBwEnableGetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableGetRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableGetRequestVer13 DEFAULT = new OFBsnBwEnableGetRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableGetRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+
+
+    public OFBsnBwEnableGetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableGetRequest.Builder {
+        final OFBsnBwEnableGetRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnBwEnableGetRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+
+
+        @Override
+        public OFBsnBwEnableGetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnBwEnableGetRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableGetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x13L;
+    }
+
+//
+        @Override
+        public OFBsnBwEnableGetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnBwEnableGetRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableGetRequest> {
+        @Override
+        public OFBsnBwEnableGetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x13L
+            int subtype = bb.readInt();
+            if(subtype != 0x13)
+                throw new OFParseError("Wrong subtype: Expected=0x13L(0x13L), got="+subtype);
+
+            OFBsnBwEnableGetRequestVer13 bsnBwEnableGetRequestVer13 = new OFBsnBwEnableGetRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableGetRequestVer13);
+            return bsnBwEnableGetRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableGetRequestVer13Funnel FUNNEL = new OFBsnBwEnableGetRequestVer13Funnel();
+    static class OFBsnBwEnableGetRequestVer13Funnel implements Funnel<OFBsnBwEnableGetRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableGetRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x13L
+            sink.putInt(0x13);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableGetRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableGetRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x13L
+            bb.writeInt(0x13);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableGetRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableGetRequestVer13 other = (OFBsnBwEnableGetRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableSetReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableSetReplyVer13.java
new file mode 100644
index 0000000..31c4e20
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableSetReplyVer13.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableSetReplyVer13 implements OFBsnBwEnableSetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableSetReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableSetReplyVer13 DEFAULT = new OFBsnBwEnableSetReplyVer13(
+        DEFAULT_XID, DEFAULT_ENABLE, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableSetReplyVer13(long xid, long enable, long status) {
+        this.xid = xid;
+        this.enable = enable;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnBwEnableSetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableSetReply.Builder {
+        final OFBsnBwEnableSetReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnBwEnableSetReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableSetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnBwEnableSetReplyVer13(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableSetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x17L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnBwEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableSetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnBwEnableSetReplyVer13(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableSetReply> {
+        @Override
+        public OFBsnBwEnableSetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x17L
+            int subtype = bb.readInt();
+            if(subtype != 0x17)
+                throw new OFParseError("Wrong subtype: Expected=0x17L(0x17L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+            long status = U32.f(bb.readInt());
+
+            OFBsnBwEnableSetReplyVer13 bsnBwEnableSetReplyVer13 = new OFBsnBwEnableSetReplyVer13(
+                    xid,
+                      enable,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableSetReplyVer13);
+            return bsnBwEnableSetReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableSetReplyVer13Funnel FUNNEL = new OFBsnBwEnableSetReplyVer13Funnel();
+    static class OFBsnBwEnableSetReplyVer13Funnel implements Funnel<OFBsnBwEnableSetReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableSetReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x17L
+            sink.putInt(0x17);
+            sink.putLong(message.enable);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableSetReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableSetReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x17L
+            bb.writeInt(0x17);
+            bb.writeInt(U32.t(message.enable));
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableSetReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableSetReplyVer13 other = (OFBsnBwEnableSetReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableSetRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableSetRequestVer13.java
new file mode 100644
index 0000000..c11d81f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnBwEnableSetRequestVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnBwEnableSetRequestVer13 implements OFBsnBwEnableSetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnBwEnableSetRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+//
+    // Immutable default instance
+    final static OFBsnBwEnableSetRequestVer13 DEFAULT = new OFBsnBwEnableSetRequestVer13(
+        DEFAULT_XID, DEFAULT_ENABLE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnBwEnableSetRequestVer13(long xid, long enable) {
+        this.xid = xid;
+        this.enable = enable;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+
+
+    public OFBsnBwEnableSetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnBwEnableSetRequest.Builder {
+        final OFBsnBwEnableSetRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+        BuilderWithParent(OFBsnBwEnableSetRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnBwEnableSetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+
+                //
+                return new OFBsnBwEnableSetRequestVer13(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnBwEnableSetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x12L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnBwEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnBwEnableSetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+
+
+            return new OFBsnBwEnableSetRequestVer13(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnBwEnableSetRequest> {
+        @Override
+        public OFBsnBwEnableSetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x12L
+            int subtype = bb.readInt();
+            if(subtype != 0x12)
+                throw new OFParseError("Wrong subtype: Expected=0x12L(0x12L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+
+            OFBsnBwEnableSetRequestVer13 bsnBwEnableSetRequestVer13 = new OFBsnBwEnableSetRequestVer13(
+                    xid,
+                      enable
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnBwEnableSetRequestVer13);
+            return bsnBwEnableSetRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnBwEnableSetRequestVer13Funnel FUNNEL = new OFBsnBwEnableSetRequestVer13Funnel();
+    static class OFBsnBwEnableSetRequestVer13Funnel implements Funnel<OFBsnBwEnableSetRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnBwEnableSetRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x12L
+            sink.putInt(0x12);
+            sink.putLong(message.enable);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnBwEnableSetRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnBwEnableSetRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x12L
+            bb.writeInt(0x12);
+            bb.writeInt(U32.t(message.enable));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnBwEnableSetRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnBwEnableSetRequestVer13 other = (OFBsnBwEnableSetRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionStateSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionStateSerializerVer13.java
new file mode 100644
index 0000000..176c93f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionStateSerializerVer13.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnControllerConnectionState;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnControllerConnectionStateSerializerVer13 {
+
+    public final static byte BSN_CONTROLLER_CONNECTION_STATE_DISCONNECTED_VAL = (byte) 0x0;
+    public final static byte BSN_CONTROLLER_CONNECTION_STATE_CONNECTED_VAL = (byte) 0x1;
+
+    public static OFBsnControllerConnectionState readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnControllerConnectionState e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnControllerConnectionState e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnControllerConnectionState ofWireValue(byte val) {
+        switch(val) {
+            case BSN_CONTROLLER_CONNECTION_STATE_DISCONNECTED_VAL:
+                return OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_DISCONNECTED;
+            case BSN_CONTROLLER_CONNECTION_STATE_CONNECTED_VAL:
+                return OFBsnControllerConnectionState.BSN_CONTROLLER_CONNECTION_STATE_CONNECTED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnControllerConnectionState in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnControllerConnectionState e) {
+        switch(e) {
+            case BSN_CONTROLLER_CONNECTION_STATE_DISCONNECTED:
+                return BSN_CONTROLLER_CONNECTION_STATE_DISCONNECTED_VAL;
+            case BSN_CONTROLLER_CONNECTION_STATE_CONNECTED:
+                return BSN_CONTROLLER_CONNECTION_STATE_CONNECTED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnControllerConnectionState in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionVer13.java
new file mode 100644
index 0000000..d2c9aa6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionVer13.java
@@ -0,0 +1,392 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnControllerConnectionVer13 implements OFBsnControllerConnection {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnControllerConnectionVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 264;
+
+        private final static OFAuxId DEFAULT_AUXILIARY_ID = OFAuxId.MAIN;
+        private final static String DEFAULT_URI = "";
+
+    // OF message fields
+    private final OFBsnControllerConnectionState state;
+    private final OFAuxId auxiliaryId;
+    private final OFControllerRole role;
+    private final String uri;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnControllerConnectionVer13(OFBsnControllerConnectionState state, OFAuxId auxiliaryId, OFControllerRole role, String uri) {
+        this.state = state;
+        this.auxiliaryId = auxiliaryId;
+        this.role = role;
+        this.uri = uri;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFBsnControllerConnectionState getState() {
+        return state;
+    }
+
+    @Override
+    public OFAuxId getAuxiliaryId() {
+        return auxiliaryId;
+    }
+
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public String getUri() {
+        return uri;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnControllerConnection.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnControllerConnection.Builder {
+        final OFBsnControllerConnectionVer13 parentMessage;
+
+        // OF message fields
+        private boolean stateSet;
+        private OFBsnControllerConnectionState state;
+        private boolean auxiliaryIdSet;
+        private OFAuxId auxiliaryId;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean uriSet;
+        private String uri;
+
+        BuilderWithParent(OFBsnControllerConnectionVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFBsnControllerConnectionState getState() {
+        return state;
+    }
+
+    @Override
+    public OFBsnControllerConnection.Builder setState(OFBsnControllerConnectionState state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public OFAuxId getAuxiliaryId() {
+        return auxiliaryId;
+    }
+
+    @Override
+    public OFBsnControllerConnection.Builder setAuxiliaryId(OFAuxId auxiliaryId) {
+        this.auxiliaryId = auxiliaryId;
+        this.auxiliaryIdSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFBsnControllerConnection.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public String getUri() {
+        return uri;
+    }
+
+    @Override
+    public OFBsnControllerConnection.Builder setUri(String uri) {
+        this.uri = uri;
+        this.uriSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnControllerConnection build() {
+                OFBsnControllerConnectionState state = this.stateSet ? this.state : parentMessage.state;
+                if(state == null)
+                    throw new NullPointerException("Property state must not be null");
+                OFAuxId auxiliaryId = this.auxiliaryIdSet ? this.auxiliaryId : parentMessage.auxiliaryId;
+                if(auxiliaryId == null)
+                    throw new NullPointerException("Property auxiliaryId must not be null");
+                OFControllerRole role = this.roleSet ? this.role : parentMessage.role;
+                if(role == null)
+                    throw new NullPointerException("Property role must not be null");
+                String uri = this.uriSet ? this.uri : parentMessage.uri;
+                if(uri == null)
+                    throw new NullPointerException("Property uri must not be null");
+
+                //
+                return new OFBsnControllerConnectionVer13(
+                    state,
+                    auxiliaryId,
+                    role,
+                    uri
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnControllerConnection.Builder {
+        // OF message fields
+        private boolean stateSet;
+        private OFBsnControllerConnectionState state;
+        private boolean auxiliaryIdSet;
+        private OFAuxId auxiliaryId;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean uriSet;
+        private String uri;
+
+    @Override
+    public OFBsnControllerConnectionState getState() {
+        return state;
+    }
+
+    @Override
+    public OFBsnControllerConnection.Builder setState(OFBsnControllerConnectionState state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public OFAuxId getAuxiliaryId() {
+        return auxiliaryId;
+    }
+
+    @Override
+    public OFBsnControllerConnection.Builder setAuxiliaryId(OFAuxId auxiliaryId) {
+        this.auxiliaryId = auxiliaryId;
+        this.auxiliaryIdSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFBsnControllerConnection.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public String getUri() {
+        return uri;
+    }
+
+    @Override
+    public OFBsnControllerConnection.Builder setUri(String uri) {
+        this.uri = uri;
+        this.uriSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnControllerConnection build() {
+            if(!this.stateSet)
+                throw new IllegalStateException("Property state doesn't have default value -- must be set");
+            if(state == null)
+                throw new NullPointerException("Property state must not be null");
+            OFAuxId auxiliaryId = this.auxiliaryIdSet ? this.auxiliaryId : DEFAULT_AUXILIARY_ID;
+            if(auxiliaryId == null)
+                throw new NullPointerException("Property auxiliaryId must not be null");
+            if(!this.roleSet)
+                throw new IllegalStateException("Property role doesn't have default value -- must be set");
+            if(role == null)
+                throw new NullPointerException("Property role must not be null");
+            String uri = this.uriSet ? this.uri : DEFAULT_URI;
+            if(uri == null)
+                throw new NullPointerException("Property uri must not be null");
+
+
+            return new OFBsnControllerConnectionVer13(
+                    state,
+                    auxiliaryId,
+                    role,
+                    uri
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnControllerConnection> {
+        @Override
+        public OFBsnControllerConnection readFrom(ChannelBuffer bb) throws OFParseError {
+            OFBsnControllerConnectionState state = OFBsnControllerConnectionStateSerializerVer13.readFrom(bb);
+            OFAuxId auxiliaryId = OFAuxId.readByte(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            OFControllerRole role = OFControllerRoleSerializerVer13.readFrom(bb);
+            String uri = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFBsnControllerConnectionVer13 bsnControllerConnectionVer13 = new OFBsnControllerConnectionVer13(
+                    state,
+                      auxiliaryId,
+                      role,
+                      uri
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnControllerConnectionVer13);
+            return bsnControllerConnectionVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnControllerConnectionVer13Funnel FUNNEL = new OFBsnControllerConnectionVer13Funnel();
+    static class OFBsnControllerConnectionVer13Funnel implements Funnel<OFBsnControllerConnectionVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnControllerConnectionVer13 message, PrimitiveSink sink) {
+            OFBsnControllerConnectionStateSerializerVer13.putTo(message.state, sink);
+            message.auxiliaryId.putTo(sink);
+            // skip pad (2 bytes)
+            OFControllerRoleSerializerVer13.putTo(message.role, sink);
+            sink.putUnencodedChars(message.uri);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnControllerConnectionVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnControllerConnectionVer13 message) {
+            OFBsnControllerConnectionStateSerializerVer13.writeTo(bb, message.state);
+            message.auxiliaryId.writeByte(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            OFControllerRoleSerializerVer13.writeTo(bb, message.role);
+            ChannelUtils.writeFixedLengthString(bb, message.uri, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnControllerConnectionVer13(");
+        b.append("state=").append(state);
+        b.append(", ");
+        b.append("auxiliaryId=").append(auxiliaryId);
+        b.append(", ");
+        b.append("role=").append(role);
+        b.append(", ");
+        b.append("uri=").append(uri);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnControllerConnectionVer13 other = (OFBsnControllerConnectionVer13) obj;
+
+        if (state == null) {
+            if (other.state != null)
+                return false;
+        } else if (!state.equals(other.state))
+            return false;
+        if (auxiliaryId == null) {
+            if (other.auxiliaryId != null)
+                return false;
+        } else if (!auxiliaryId.equals(other.auxiliaryId))
+            return false;
+        if (role == null) {
+            if (other.role != null)
+                return false;
+        } else if (!role.equals(other.role))
+            return false;
+        if (uri == null) {
+            if (other.uri != null)
+                return false;
+        } else if (!uri.equals(other.uri))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((state == null) ? 0 : state.hashCode());
+        result = prime * result + ((auxiliaryId == null) ? 0 : auxiliaryId.hashCode());
+        result = prime * result + ((role == null) ? 0 : role.hashCode());
+        result = prime * result + ((uri == null) ? 0 : uri.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionsReplyVer13.java
new file mode 100644
index 0000000..0491ffb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionsReplyVer13.java
@@ -0,0 +1,375 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnControllerConnectionsReplyVer13 implements OFBsnControllerConnectionsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnControllerConnectionsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static List<OFBsnControllerConnection> DEFAULT_CONNECTIONS = ImmutableList.<OFBsnControllerConnection>of();
+
+    // OF message fields
+    private final long xid;
+    private final List<OFBsnControllerConnection> connections;
+//
+    // Immutable default instance
+    final static OFBsnControllerConnectionsReplyVer13 DEFAULT = new OFBsnControllerConnectionsReplyVer13(
+        DEFAULT_XID, DEFAULT_CONNECTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnControllerConnectionsReplyVer13(long xid, List<OFBsnControllerConnection> connections) {
+        this.xid = xid;
+        this.connections = connections;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x39L;
+    }
+
+    @Override
+    public List<OFBsnControllerConnection> getConnections() {
+        return connections;
+    }
+
+
+
+    public OFBsnControllerConnectionsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnControllerConnectionsReply.Builder {
+        final OFBsnControllerConnectionsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean connectionsSet;
+        private List<OFBsnControllerConnection> connections;
+
+        BuilderWithParent(OFBsnControllerConnectionsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnControllerConnectionsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x39L;
+    }
+
+    @Override
+    public List<OFBsnControllerConnection> getConnections() {
+        return connections;
+    }
+
+    @Override
+    public OFBsnControllerConnectionsReply.Builder setConnections(List<OFBsnControllerConnection> connections) {
+        this.connections = connections;
+        this.connectionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnControllerConnectionsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                List<OFBsnControllerConnection> connections = this.connectionsSet ? this.connections : parentMessage.connections;
+                if(connections == null)
+                    throw new NullPointerException("Property connections must not be null");
+
+                //
+                return new OFBsnControllerConnectionsReplyVer13(
+                    xid,
+                    connections
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnControllerConnectionsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean connectionsSet;
+        private List<OFBsnControllerConnection> connections;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnControllerConnectionsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x39L;
+    }
+
+    @Override
+    public List<OFBsnControllerConnection> getConnections() {
+        return connections;
+    }
+
+    @Override
+    public OFBsnControllerConnectionsReply.Builder setConnections(List<OFBsnControllerConnection> connections) {
+        this.connections = connections;
+        this.connectionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnControllerConnectionsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            List<OFBsnControllerConnection> connections = this.connectionsSet ? this.connections : DEFAULT_CONNECTIONS;
+            if(connections == null)
+                throw new NullPointerException("Property connections must not be null");
+
+
+            return new OFBsnControllerConnectionsReplyVer13(
+                    xid,
+                    connections
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnControllerConnectionsReply> {
+        @Override
+        public OFBsnControllerConnectionsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x39L
+            int subtype = bb.readInt();
+            if(subtype != 0x39)
+                throw new OFParseError("Wrong subtype: Expected=0x39L(0x39L), got="+subtype);
+            List<OFBsnControllerConnection> connections = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnControllerConnectionVer13.READER);
+
+            OFBsnControllerConnectionsReplyVer13 bsnControllerConnectionsReplyVer13 = new OFBsnControllerConnectionsReplyVer13(
+                    xid,
+                      connections
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnControllerConnectionsReplyVer13);
+            return bsnControllerConnectionsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnControllerConnectionsReplyVer13Funnel FUNNEL = new OFBsnControllerConnectionsReplyVer13Funnel();
+    static class OFBsnControllerConnectionsReplyVer13Funnel implements Funnel<OFBsnControllerConnectionsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnControllerConnectionsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x39L
+            sink.putInt(0x39);
+            FunnelUtils.putList(message.connections, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnControllerConnectionsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnControllerConnectionsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x39L
+            bb.writeInt(0x39);
+            ChannelUtils.writeList(bb, message.connections);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnControllerConnectionsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("connections=").append(connections);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnControllerConnectionsReplyVer13 other = (OFBsnControllerConnectionsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (connections == null) {
+            if (other.connections != null)
+                return false;
+        } else if (!connections.equals(other.connections))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((connections == null) ? 0 : connections.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionsRequestVer13.java
new file mode 100644
index 0000000..52dc1bb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerConnectionsRequestVer13.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnControllerConnectionsRequestVer13 implements OFBsnControllerConnectionsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnControllerConnectionsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnControllerConnectionsRequestVer13 DEFAULT = new OFBsnControllerConnectionsRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnControllerConnectionsRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x38L;
+    }
+
+
+
+    public OFBsnControllerConnectionsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnControllerConnectionsRequest.Builder {
+        final OFBsnControllerConnectionsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnControllerConnectionsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnControllerConnectionsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x38L;
+    }
+
+
+
+        @Override
+        public OFBsnControllerConnectionsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnControllerConnectionsRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnControllerConnectionsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnControllerConnectionsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x38L;
+    }
+
+//
+        @Override
+        public OFBsnControllerConnectionsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnControllerConnectionsRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnControllerConnectionsRequest> {
+        @Override
+        public OFBsnControllerConnectionsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x38L
+            int subtype = bb.readInt();
+            if(subtype != 0x38)
+                throw new OFParseError("Wrong subtype: Expected=0x38L(0x38L), got="+subtype);
+
+            OFBsnControllerConnectionsRequestVer13 bsnControllerConnectionsRequestVer13 = new OFBsnControllerConnectionsRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnControllerConnectionsRequestVer13);
+            return bsnControllerConnectionsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnControllerConnectionsRequestVer13Funnel FUNNEL = new OFBsnControllerConnectionsRequestVer13Funnel();
+    static class OFBsnControllerConnectionsRequestVer13Funnel implements Funnel<OFBsnControllerConnectionsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnControllerConnectionsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x38L
+            sink.putInt(0x38);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnControllerConnectionsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnControllerConnectionsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x38L
+            bb.writeInt(0x38);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnControllerConnectionsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnControllerConnectionsRequestVer13 other = (OFBsnControllerConnectionsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerRoleReasonSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerRoleReasonSerializerVer13.java
new file mode 100644
index 0000000..0e19498
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnControllerRoleReasonSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnControllerRoleReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnControllerRoleReasonSerializerVer13 {
+
+    public final static byte BSN_CONTROLLER_ROLE_REASON_MASTER_REQUEST_VAL = (byte) 0x0;
+    public final static byte BSN_CONTROLLER_ROLE_REASON_CONFIG_VAL = (byte) 0x1;
+    public final static byte BSN_CONTROLLER_ROLE_REASON_EXPERIMENTER_VAL = (byte) 0x2;
+
+    public static OFBsnControllerRoleReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnControllerRoleReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnControllerRoleReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnControllerRoleReason ofWireValue(byte val) {
+        switch(val) {
+            case BSN_CONTROLLER_ROLE_REASON_MASTER_REQUEST_VAL:
+                return OFBsnControllerRoleReason.BSN_CONTROLLER_ROLE_REASON_MASTER_REQUEST;
+            case BSN_CONTROLLER_ROLE_REASON_CONFIG_VAL:
+                return OFBsnControllerRoleReason.BSN_CONTROLLER_ROLE_REASON_CONFIG;
+            case BSN_CONTROLLER_ROLE_REASON_EXPERIMENTER_VAL:
+                return OFBsnControllerRoleReason.BSN_CONTROLLER_ROLE_REASON_EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnControllerRoleReason in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnControllerRoleReason e) {
+        switch(e) {
+            case BSN_CONTROLLER_ROLE_REASON_MASTER_REQUEST:
+                return BSN_CONTROLLER_ROLE_REASON_MASTER_REQUEST_VAL;
+            case BSN_CONTROLLER_ROLE_REASON_CONFIG:
+                return BSN_CONTROLLER_ROLE_REASON_CONFIG_VAL;
+            case BSN_CONTROLLER_ROLE_REASON_EXPERIMENTER:
+                return BSN_CONTROLLER_ROLE_REASON_EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnControllerRoleReason in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsEntryVer13.java
new file mode 100644
index 0000000..dd61e5c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsEntryVer13.java
@@ -0,0 +1,337 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnDebugCounterDescStatsEntryVer13 implements OFBsnDebugCounterDescStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnDebugCounterDescStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 328;
+
+        private final static U64 DEFAULT_COUNTER_ID = U64.ZERO;
+        private final static String DEFAULT_NAME = "";
+        private final static String DEFAULT_DESCRIPTION = "";
+
+    // OF message fields
+    private final U64 counterId;
+    private final String name;
+    private final String description;
+//
+    // Immutable default instance
+    final static OFBsnDebugCounterDescStatsEntryVer13 DEFAULT = new OFBsnDebugCounterDescStatsEntryVer13(
+        DEFAULT_COUNTER_ID, DEFAULT_NAME, DEFAULT_DESCRIPTION
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnDebugCounterDescStatsEntryVer13(U64 counterId, String name, String description) {
+        this.counterId = counterId;
+        this.name = name;
+        this.description = description;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U64 getCounterId() {
+        return counterId;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnDebugCounterDescStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnDebugCounterDescStatsEntry.Builder {
+        final OFBsnDebugCounterDescStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean counterIdSet;
+        private U64 counterId;
+        private boolean nameSet;
+        private String name;
+        private boolean descriptionSet;
+        private String description;
+
+        BuilderWithParent(OFBsnDebugCounterDescStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U64 getCounterId() {
+        return counterId;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsEntry.Builder setCounterId(U64 counterId) {
+        this.counterId = counterId;
+        this.counterIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsEntry.Builder setDescription(String description) {
+        this.description = description;
+        this.descriptionSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnDebugCounterDescStatsEntry build() {
+                U64 counterId = this.counterIdSet ? this.counterId : parentMessage.counterId;
+                if(counterId == null)
+                    throw new NullPointerException("Property counterId must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                String description = this.descriptionSet ? this.description : parentMessage.description;
+                if(description == null)
+                    throw new NullPointerException("Property description must not be null");
+
+                //
+                return new OFBsnDebugCounterDescStatsEntryVer13(
+                    counterId,
+                    name,
+                    description
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnDebugCounterDescStatsEntry.Builder {
+        // OF message fields
+        private boolean counterIdSet;
+        private U64 counterId;
+        private boolean nameSet;
+        private String name;
+        private boolean descriptionSet;
+        private String description;
+
+    @Override
+    public U64 getCounterId() {
+        return counterId;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsEntry.Builder setCounterId(U64 counterId) {
+        this.counterId = counterId;
+        this.counterIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public String getDescription() {
+        return description;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsEntry.Builder setDescription(String description) {
+        this.description = description;
+        this.descriptionSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnDebugCounterDescStatsEntry build() {
+            U64 counterId = this.counterIdSet ? this.counterId : DEFAULT_COUNTER_ID;
+            if(counterId == null)
+                throw new NullPointerException("Property counterId must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            String description = this.descriptionSet ? this.description : DEFAULT_DESCRIPTION;
+            if(description == null)
+                throw new NullPointerException("Property description must not be null");
+
+
+            return new OFBsnDebugCounterDescStatsEntryVer13(
+                    counterId,
+                    name,
+                    description
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnDebugCounterDescStatsEntry> {
+        @Override
+        public OFBsnDebugCounterDescStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            U64 counterId = U64.ofRaw(bb.readLong());
+            String name = ChannelUtils.readFixedLengthString(bb, 64);
+            String description = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFBsnDebugCounterDescStatsEntryVer13 bsnDebugCounterDescStatsEntryVer13 = new OFBsnDebugCounterDescStatsEntryVer13(
+                    counterId,
+                      name,
+                      description
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnDebugCounterDescStatsEntryVer13);
+            return bsnDebugCounterDescStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnDebugCounterDescStatsEntryVer13Funnel FUNNEL = new OFBsnDebugCounterDescStatsEntryVer13Funnel();
+    static class OFBsnDebugCounterDescStatsEntryVer13Funnel implements Funnel<OFBsnDebugCounterDescStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnDebugCounterDescStatsEntryVer13 message, PrimitiveSink sink) {
+            message.counterId.putTo(sink);
+            sink.putUnencodedChars(message.name);
+            sink.putUnencodedChars(message.description);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnDebugCounterDescStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnDebugCounterDescStatsEntryVer13 message) {
+            bb.writeLong(message.counterId.getValue());
+            ChannelUtils.writeFixedLengthString(bb, message.name, 64);
+            ChannelUtils.writeFixedLengthString(bb, message.description, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnDebugCounterDescStatsEntryVer13(");
+        b.append("counterId=").append(counterId);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("description=").append(description);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnDebugCounterDescStatsEntryVer13 other = (OFBsnDebugCounterDescStatsEntryVer13) obj;
+
+        if (counterId == null) {
+            if (other.counterId != null)
+                return false;
+        } else if (!counterId.equals(other.counterId))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (description == null) {
+            if (other.description != null)
+                return false;
+        } else if (!description.equals(other.description))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((counterId == null) ? 0 : counterId.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((description == null) ? 0 : description.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsReplyVer13.java
new file mode 100644
index 0000000..d28c78a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnDebugCounterDescStatsReplyVer13 implements OFBsnDebugCounterDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnDebugCounterDescStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnDebugCounterDescStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnDebugCounterDescStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnDebugCounterDescStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnDebugCounterDescStatsReplyVer13 DEFAULT = new OFBsnDebugCounterDescStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnDebugCounterDescStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnDebugCounterDescStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+    @Override
+    public List<OFBsnDebugCounterDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnDebugCounterDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnDebugCounterDescStatsReply.Builder {
+        final OFBsnDebugCounterDescStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnDebugCounterDescStatsEntry> entries;
+
+        BuilderWithParent(OFBsnDebugCounterDescStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+    @Override
+    public List<OFBsnDebugCounterDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsReply.Builder setEntries(List<OFBsnDebugCounterDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnDebugCounterDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnDebugCounterDescStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnDebugCounterDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnDebugCounterDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnDebugCounterDescStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+    @Override
+    public List<OFBsnDebugCounterDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsReply.Builder setEntries(List<OFBsnDebugCounterDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnDebugCounterDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnDebugCounterDescStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnDebugCounterDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnDebugCounterDescStatsReply> {
+        @Override
+        public OFBsnDebugCounterDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xdL
+            int subtype = bb.readInt();
+            if(subtype != 0xd)
+                throw new OFParseError("Wrong subtype: Expected=0xdL(0xdL), got="+subtype);
+            List<OFBsnDebugCounterDescStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnDebugCounterDescStatsEntryVer13.READER);
+
+            OFBsnDebugCounterDescStatsReplyVer13 bsnDebugCounterDescStatsReplyVer13 = new OFBsnDebugCounterDescStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnDebugCounterDescStatsReplyVer13);
+            return bsnDebugCounterDescStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnDebugCounterDescStatsReplyVer13Funnel FUNNEL = new OFBsnDebugCounterDescStatsReplyVer13Funnel();
+    static class OFBsnDebugCounterDescStatsReplyVer13Funnel implements Funnel<OFBsnDebugCounterDescStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnDebugCounterDescStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xdL
+            sink.putInt(0xd);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnDebugCounterDescStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnDebugCounterDescStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xdL
+            bb.writeInt(0xd);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnDebugCounterDescStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnDebugCounterDescStatsReplyVer13 other = (OFBsnDebugCounterDescStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsRequestVer13.java
new file mode 100644
index 0000000..c190f18
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterDescStatsRequestVer13.java
@@ -0,0 +1,397 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnDebugCounterDescStatsRequestVer13 implements OFBsnDebugCounterDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnDebugCounterDescStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFBsnDebugCounterDescStatsRequestVer13 DEFAULT = new OFBsnDebugCounterDescStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnDebugCounterDescStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+
+
+    public OFBsnDebugCounterDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnDebugCounterDescStatsRequest.Builder {
+        final OFBsnDebugCounterDescStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFBsnDebugCounterDescStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+
+
+        @Override
+        public OFBsnDebugCounterDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFBsnDebugCounterDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnDebugCounterDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnDebugCounterDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xdL;
+    }
+
+//
+        @Override
+        public OFBsnDebugCounterDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFBsnDebugCounterDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnDebugCounterDescStatsRequest> {
+        @Override
+        public OFBsnDebugCounterDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xdL
+            int subtype = bb.readInt();
+            if(subtype != 0xd)
+                throw new OFParseError("Wrong subtype: Expected=0xdL(0xdL), got="+subtype);
+
+            OFBsnDebugCounterDescStatsRequestVer13 bsnDebugCounterDescStatsRequestVer13 = new OFBsnDebugCounterDescStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnDebugCounterDescStatsRequestVer13);
+            return bsnDebugCounterDescStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnDebugCounterDescStatsRequestVer13Funnel FUNNEL = new OFBsnDebugCounterDescStatsRequestVer13Funnel();
+    static class OFBsnDebugCounterDescStatsRequestVer13Funnel implements Funnel<OFBsnDebugCounterDescStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnDebugCounterDescStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xdL
+            sink.putInt(0xd);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnDebugCounterDescStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnDebugCounterDescStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xdL
+            bb.writeInt(0xd);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnDebugCounterDescStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnDebugCounterDescStatsRequestVer13 other = (OFBsnDebugCounterDescStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsEntryVer13.java
new file mode 100644
index 0000000..8fecd3e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsEntryVer13.java
@@ -0,0 +1,283 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnDebugCounterStatsEntryVer13 implements OFBsnDebugCounterStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnDebugCounterStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static U64 DEFAULT_COUNTER_ID = U64.ZERO;
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 counterId;
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFBsnDebugCounterStatsEntryVer13 DEFAULT = new OFBsnDebugCounterStatsEntryVer13(
+        DEFAULT_COUNTER_ID, DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnDebugCounterStatsEntryVer13(U64 counterId, U64 value) {
+        this.counterId = counterId;
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U64 getCounterId() {
+        return counterId;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnDebugCounterStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnDebugCounterStatsEntry.Builder {
+        final OFBsnDebugCounterStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean counterIdSet;
+        private U64 counterId;
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFBsnDebugCounterStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U64 getCounterId() {
+        return counterId;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsEntry.Builder setCounterId(U64 counterId) {
+        this.counterId = counterId;
+        this.counterIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsEntry.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnDebugCounterStatsEntry build() {
+                U64 counterId = this.counterIdSet ? this.counterId : parentMessage.counterId;
+                if(counterId == null)
+                    throw new NullPointerException("Property counterId must not be null");
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnDebugCounterStatsEntryVer13(
+                    counterId,
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnDebugCounterStatsEntry.Builder {
+        // OF message fields
+        private boolean counterIdSet;
+        private U64 counterId;
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public U64 getCounterId() {
+        return counterId;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsEntry.Builder setCounterId(U64 counterId) {
+        this.counterId = counterId;
+        this.counterIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsEntry.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnDebugCounterStatsEntry build() {
+            U64 counterId = this.counterIdSet ? this.counterId : DEFAULT_COUNTER_ID;
+            if(counterId == null)
+                throw new NullPointerException("Property counterId must not be null");
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnDebugCounterStatsEntryVer13(
+                    counterId,
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnDebugCounterStatsEntry> {
+        @Override
+        public OFBsnDebugCounterStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            U64 counterId = U64.ofRaw(bb.readLong());
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFBsnDebugCounterStatsEntryVer13 bsnDebugCounterStatsEntryVer13 = new OFBsnDebugCounterStatsEntryVer13(
+                    counterId,
+                      value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnDebugCounterStatsEntryVer13);
+            return bsnDebugCounterStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnDebugCounterStatsEntryVer13Funnel FUNNEL = new OFBsnDebugCounterStatsEntryVer13Funnel();
+    static class OFBsnDebugCounterStatsEntryVer13Funnel implements Funnel<OFBsnDebugCounterStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnDebugCounterStatsEntryVer13 message, PrimitiveSink sink) {
+            message.counterId.putTo(sink);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnDebugCounterStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnDebugCounterStatsEntryVer13 message) {
+            bb.writeLong(message.counterId.getValue());
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnDebugCounterStatsEntryVer13(");
+        b.append("counterId=").append(counterId);
+        b.append(", ");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnDebugCounterStatsEntryVer13 other = (OFBsnDebugCounterStatsEntryVer13) obj;
+
+        if (counterId == null) {
+            if (other.counterId != null)
+                return false;
+        } else if (!counterId.equals(other.counterId))
+            return false;
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((counterId == null) ? 0 : counterId.hashCode());
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsReplyVer13.java
new file mode 100644
index 0000000..9d967ce
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnDebugCounterStatsReplyVer13 implements OFBsnDebugCounterStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnDebugCounterStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnDebugCounterStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnDebugCounterStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnDebugCounterStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnDebugCounterStatsReplyVer13 DEFAULT = new OFBsnDebugCounterStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnDebugCounterStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnDebugCounterStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+    @Override
+    public List<OFBsnDebugCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnDebugCounterStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnDebugCounterStatsReply.Builder {
+        final OFBsnDebugCounterStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnDebugCounterStatsEntry> entries;
+
+        BuilderWithParent(OFBsnDebugCounterStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+    @Override
+    public List<OFBsnDebugCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsReply.Builder setEntries(List<OFBsnDebugCounterStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnDebugCounterStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnDebugCounterStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnDebugCounterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnDebugCounterStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnDebugCounterStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+    @Override
+    public List<OFBsnDebugCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsReply.Builder setEntries(List<OFBsnDebugCounterStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnDebugCounterStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnDebugCounterStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnDebugCounterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnDebugCounterStatsReply> {
+        @Override
+        public OFBsnDebugCounterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xcL
+            int subtype = bb.readInt();
+            if(subtype != 0xc)
+                throw new OFParseError("Wrong subtype: Expected=0xcL(0xcL), got="+subtype);
+            List<OFBsnDebugCounterStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnDebugCounterStatsEntryVer13.READER);
+
+            OFBsnDebugCounterStatsReplyVer13 bsnDebugCounterStatsReplyVer13 = new OFBsnDebugCounterStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnDebugCounterStatsReplyVer13);
+            return bsnDebugCounterStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnDebugCounterStatsReplyVer13Funnel FUNNEL = new OFBsnDebugCounterStatsReplyVer13Funnel();
+    static class OFBsnDebugCounterStatsReplyVer13Funnel implements Funnel<OFBsnDebugCounterStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnDebugCounterStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xcL
+            sink.putInt(0xc);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnDebugCounterStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnDebugCounterStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xcL
+            bb.writeInt(0xc);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnDebugCounterStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnDebugCounterStatsReplyVer13 other = (OFBsnDebugCounterStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsRequestVer13.java
new file mode 100644
index 0000000..d57eff6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnDebugCounterStatsRequestVer13.java
@@ -0,0 +1,397 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnDebugCounterStatsRequestVer13 implements OFBsnDebugCounterStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnDebugCounterStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFBsnDebugCounterStatsRequestVer13 DEFAULT = new OFBsnDebugCounterStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnDebugCounterStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+
+
+    public OFBsnDebugCounterStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnDebugCounterStatsRequest.Builder {
+        final OFBsnDebugCounterStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFBsnDebugCounterStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+
+
+        @Override
+        public OFBsnDebugCounterStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFBsnDebugCounterStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnDebugCounterStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnDebugCounterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xcL;
+    }
+
+//
+        @Override
+        public OFBsnDebugCounterStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFBsnDebugCounterStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnDebugCounterStatsRequest> {
+        @Override
+        public OFBsnDebugCounterStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xcL
+            int subtype = bb.readInt();
+            if(subtype != 0xc)
+                throw new OFParseError("Wrong subtype: Expected=0xcL(0xcL), got="+subtype);
+
+            OFBsnDebugCounterStatsRequestVer13 bsnDebugCounterStatsRequestVer13 = new OFBsnDebugCounterStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnDebugCounterStatsRequestVer13);
+            return bsnDebugCounterStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnDebugCounterStatsRequestVer13Funnel FUNNEL = new OFBsnDebugCounterStatsRequestVer13Funnel();
+    static class OFBsnDebugCounterStatsRequestVer13Funnel implements Funnel<OFBsnDebugCounterStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnDebugCounterStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xcL
+            sink.putInt(0xc);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnDebugCounterStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnDebugCounterStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xcL
+            bb.writeInt(0xc);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnDebugCounterStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnDebugCounterStatsRequestVer13 other = (OFBsnDebugCounterStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsEntryVer13.java
new file mode 100644
index 0000000..5540700
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsEntryVer13.java
@@ -0,0 +1,229 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnFlowChecksumBucketStatsEntryVer13 implements OFBsnFlowChecksumBucketStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowChecksumBucketStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static U64 DEFAULT_CHECKSUM = U64.ZERO;
+
+    // OF message fields
+    private final U64 checksum;
+//
+    // Immutable default instance
+    final static OFBsnFlowChecksumBucketStatsEntryVer13 DEFAULT = new OFBsnFlowChecksumBucketStatsEntryVer13(
+        DEFAULT_CHECKSUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnFlowChecksumBucketStatsEntryVer13(U64 checksum) {
+        this.checksum = checksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U64 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnFlowChecksumBucketStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnFlowChecksumBucketStatsEntry.Builder {
+        final OFBsnFlowChecksumBucketStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean checksumSet;
+        private U64 checksum;
+
+        BuilderWithParent(OFBsnFlowChecksumBucketStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U64 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsEntry.Builder setChecksum(U64 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnFlowChecksumBucketStatsEntry build() {
+                U64 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+
+                //
+                return new OFBsnFlowChecksumBucketStatsEntryVer13(
+                    checksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnFlowChecksumBucketStatsEntry.Builder {
+        // OF message fields
+        private boolean checksumSet;
+        private U64 checksum;
+
+    @Override
+    public U64 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsEntry.Builder setChecksum(U64 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnFlowChecksumBucketStatsEntry build() {
+            U64 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+
+
+            return new OFBsnFlowChecksumBucketStatsEntryVer13(
+                    checksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnFlowChecksumBucketStatsEntry> {
+        @Override
+        public OFBsnFlowChecksumBucketStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            U64 checksum = U64.ofRaw(bb.readLong());
+
+            OFBsnFlowChecksumBucketStatsEntryVer13 bsnFlowChecksumBucketStatsEntryVer13 = new OFBsnFlowChecksumBucketStatsEntryVer13(
+                    checksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnFlowChecksumBucketStatsEntryVer13);
+            return bsnFlowChecksumBucketStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnFlowChecksumBucketStatsEntryVer13Funnel FUNNEL = new OFBsnFlowChecksumBucketStatsEntryVer13Funnel();
+    static class OFBsnFlowChecksumBucketStatsEntryVer13Funnel implements Funnel<OFBsnFlowChecksumBucketStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnFlowChecksumBucketStatsEntryVer13 message, PrimitiveSink sink) {
+            message.checksum.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnFlowChecksumBucketStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnFlowChecksumBucketStatsEntryVer13 message) {
+            bb.writeLong(message.checksum.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnFlowChecksumBucketStatsEntryVer13(");
+        b.append("checksum=").append(checksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnFlowChecksumBucketStatsEntryVer13 other = (OFBsnFlowChecksumBucketStatsEntryVer13) obj;
+
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsReplyVer13.java
new file mode 100644
index 0000000..be34e7c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnFlowChecksumBucketStatsReplyVer13 implements OFBsnFlowChecksumBucketStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowChecksumBucketStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnFlowChecksumBucketStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnFlowChecksumBucketStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnFlowChecksumBucketStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnFlowChecksumBucketStatsReplyVer13 DEFAULT = new OFBsnFlowChecksumBucketStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnFlowChecksumBucketStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnFlowChecksumBucketStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnFlowChecksumBucketStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnFlowChecksumBucketStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnFlowChecksumBucketStatsReply.Builder {
+        final OFBsnFlowChecksumBucketStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnFlowChecksumBucketStatsEntry> entries;
+
+        BuilderWithParent(OFBsnFlowChecksumBucketStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnFlowChecksumBucketStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsReply.Builder setEntries(List<OFBsnFlowChecksumBucketStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnFlowChecksumBucketStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnFlowChecksumBucketStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnFlowChecksumBucketStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnFlowChecksumBucketStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnFlowChecksumBucketStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnFlowChecksumBucketStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsReply.Builder setEntries(List<OFBsnFlowChecksumBucketStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnFlowChecksumBucketStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnFlowChecksumBucketStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnFlowChecksumBucketStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnFlowChecksumBucketStatsReply> {
+        @Override
+        public OFBsnFlowChecksumBucketStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xaL
+            int subtype = bb.readInt();
+            if(subtype != 0xa)
+                throw new OFParseError("Wrong subtype: Expected=0xaL(0xaL), got="+subtype);
+            List<OFBsnFlowChecksumBucketStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnFlowChecksumBucketStatsEntryVer13.READER);
+
+            OFBsnFlowChecksumBucketStatsReplyVer13 bsnFlowChecksumBucketStatsReplyVer13 = new OFBsnFlowChecksumBucketStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnFlowChecksumBucketStatsReplyVer13);
+            return bsnFlowChecksumBucketStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnFlowChecksumBucketStatsReplyVer13Funnel FUNNEL = new OFBsnFlowChecksumBucketStatsReplyVer13Funnel();
+    static class OFBsnFlowChecksumBucketStatsReplyVer13Funnel implements Funnel<OFBsnFlowChecksumBucketStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnFlowChecksumBucketStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            sink.putInt(0xa);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnFlowChecksumBucketStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnFlowChecksumBucketStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            bb.writeInt(0xa);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnFlowChecksumBucketStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnFlowChecksumBucketStatsReplyVer13 other = (OFBsnFlowChecksumBucketStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsRequestVer13.java
new file mode 100644
index 0000000..5ed672b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowChecksumBucketStatsRequestVer13.java
@@ -0,0 +1,451 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnFlowChecksumBucketStatsRequestVer13 implements OFBsnFlowChecksumBucketStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowChecksumBucketStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 25;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final TableId tableId;
+//
+    // Immutable default instance
+    final static OFBsnFlowChecksumBucketStatsRequestVer13 DEFAULT = new OFBsnFlowChecksumBucketStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TABLE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnFlowChecksumBucketStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, TableId tableId) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+
+
+    public OFBsnFlowChecksumBucketStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnFlowChecksumBucketStatsRequest.Builder {
+        final OFBsnFlowChecksumBucketStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+
+        BuilderWithParent(OFBsnFlowChecksumBucketStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnFlowChecksumBucketStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+
+                //
+                return new OFBsnFlowChecksumBucketStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnFlowChecksumBucketStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnFlowChecksumBucketStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnFlowChecksumBucketStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+
+
+            return new OFBsnFlowChecksumBucketStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnFlowChecksumBucketStatsRequest> {
+        @Override
+        public OFBsnFlowChecksumBucketStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 25)
+                throw new OFParseError("Wrong length: Expected=25(25), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xaL
+            int subtype = bb.readInt();
+            if(subtype != 0xa)
+                throw new OFParseError("Wrong subtype: Expected=0xaL(0xaL), got="+subtype);
+            TableId tableId = TableId.readByte(bb);
+
+            OFBsnFlowChecksumBucketStatsRequestVer13 bsnFlowChecksumBucketStatsRequestVer13 = new OFBsnFlowChecksumBucketStatsRequestVer13(
+                    xid,
+                      flags,
+                      tableId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnFlowChecksumBucketStatsRequestVer13);
+            return bsnFlowChecksumBucketStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnFlowChecksumBucketStatsRequestVer13Funnel FUNNEL = new OFBsnFlowChecksumBucketStatsRequestVer13Funnel();
+    static class OFBsnFlowChecksumBucketStatsRequestVer13Funnel implements Funnel<OFBsnFlowChecksumBucketStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnFlowChecksumBucketStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 25
+            sink.putShort((short) 0x19);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            sink.putInt(0xa);
+            message.tableId.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnFlowChecksumBucketStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnFlowChecksumBucketStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 25
+            bb.writeShort((short) 0x19);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            bb.writeInt(0xa);
+            message.tableId.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnFlowChecksumBucketStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnFlowChecksumBucketStatsRequestVer13 other = (OFBsnFlowChecksumBucketStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableGetReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableGetReplyVer13.java
new file mode 100644
index 0000000..288377a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableGetReplyVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnFlowIdleEnableGetReplyVer13 implements OFBsnFlowIdleEnableGetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowIdleEnableGetReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLED = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enabled;
+//
+    // Immutable default instance
+    final static OFBsnFlowIdleEnableGetReplyVer13 DEFAULT = new OFBsnFlowIdleEnableGetReplyVer13(
+        DEFAULT_XID, DEFAULT_ENABLED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnFlowIdleEnableGetReplyVer13(long xid, long enabled) {
+        this.xid = xid;
+        this.enabled = enabled;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x27L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+
+
+    public OFBsnFlowIdleEnableGetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnFlowIdleEnableGetReply.Builder {
+        final OFBsnFlowIdleEnableGetReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+        BuilderWithParent(OFBsnFlowIdleEnableGetReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x27L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnFlowIdleEnableGetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+
+                //
+                return new OFBsnFlowIdleEnableGetReplyVer13(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnFlowIdleEnableGetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private long enabled;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableGetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x27L;
+    }
+
+    @Override
+    public long getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableGetReply.Builder setEnabled(long enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnFlowIdleEnableGetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+
+
+            return new OFBsnFlowIdleEnableGetReplyVer13(
+                    xid,
+                    enabled
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnFlowIdleEnableGetReply> {
+        @Override
+        public OFBsnFlowIdleEnableGetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x27L
+            int subtype = bb.readInt();
+            if(subtype != 0x27)
+                throw new OFParseError("Wrong subtype: Expected=0x27L(0x27L), got="+subtype);
+            long enabled = U32.f(bb.readInt());
+
+            OFBsnFlowIdleEnableGetReplyVer13 bsnFlowIdleEnableGetReplyVer13 = new OFBsnFlowIdleEnableGetReplyVer13(
+                    xid,
+                      enabled
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnFlowIdleEnableGetReplyVer13);
+            return bsnFlowIdleEnableGetReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnFlowIdleEnableGetReplyVer13Funnel FUNNEL = new OFBsnFlowIdleEnableGetReplyVer13Funnel();
+    static class OFBsnFlowIdleEnableGetReplyVer13Funnel implements Funnel<OFBsnFlowIdleEnableGetReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnFlowIdleEnableGetReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x27L
+            sink.putInt(0x27);
+            sink.putLong(message.enabled);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnFlowIdleEnableGetReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnFlowIdleEnableGetReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x27L
+            bb.writeInt(0x27);
+            bb.writeInt(U32.t(message.enabled));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnFlowIdleEnableGetReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnFlowIdleEnableGetReplyVer13 other = (OFBsnFlowIdleEnableGetReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enabled ^ (enabled >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableGetRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableGetRequestVer13.java
new file mode 100644
index 0000000..af54989
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableGetRequestVer13.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnFlowIdleEnableGetRequestVer13 implements OFBsnFlowIdleEnableGetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowIdleEnableGetRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnFlowIdleEnableGetRequestVer13 DEFAULT = new OFBsnFlowIdleEnableGetRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnFlowIdleEnableGetRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x26L;
+    }
+
+
+
+    public OFBsnFlowIdleEnableGetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnFlowIdleEnableGetRequest.Builder {
+        final OFBsnFlowIdleEnableGetRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnFlowIdleEnableGetRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x26L;
+    }
+
+
+
+        @Override
+        public OFBsnFlowIdleEnableGetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnFlowIdleEnableGetRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnFlowIdleEnableGetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableGetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x26L;
+    }
+
+//
+        @Override
+        public OFBsnFlowIdleEnableGetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnFlowIdleEnableGetRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnFlowIdleEnableGetRequest> {
+        @Override
+        public OFBsnFlowIdleEnableGetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x26L
+            int subtype = bb.readInt();
+            if(subtype != 0x26)
+                throw new OFParseError("Wrong subtype: Expected=0x26L(0x26L), got="+subtype);
+
+            OFBsnFlowIdleEnableGetRequestVer13 bsnFlowIdleEnableGetRequestVer13 = new OFBsnFlowIdleEnableGetRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnFlowIdleEnableGetRequestVer13);
+            return bsnFlowIdleEnableGetRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnFlowIdleEnableGetRequestVer13Funnel FUNNEL = new OFBsnFlowIdleEnableGetRequestVer13Funnel();
+    static class OFBsnFlowIdleEnableGetRequestVer13Funnel implements Funnel<OFBsnFlowIdleEnableGetRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnFlowIdleEnableGetRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x26L
+            sink.putInt(0x26);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnFlowIdleEnableGetRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnFlowIdleEnableGetRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x26L
+            bb.writeInt(0x26);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnFlowIdleEnableGetRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnFlowIdleEnableGetRequestVer13 other = (OFBsnFlowIdleEnableGetRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableSetReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableSetReplyVer13.java
new file mode 100644
index 0000000..12e255f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableSetReplyVer13.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnFlowIdleEnableSetReplyVer13 implements OFBsnFlowIdleEnableSetReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowIdleEnableSetReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnFlowIdleEnableSetReplyVer13 DEFAULT = new OFBsnFlowIdleEnableSetReplyVer13(
+        DEFAULT_XID, DEFAULT_ENABLE, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnFlowIdleEnableSetReplyVer13(long xid, long enable, long status) {
+        this.xid = xid;
+        this.enable = enable;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x25L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnFlowIdleEnableSetReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnFlowIdleEnableSetReply.Builder {
+        final OFBsnFlowIdleEnableSetReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnFlowIdleEnableSetReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x25L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnFlowIdleEnableSetReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnFlowIdleEnableSetReplyVer13(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnFlowIdleEnableSetReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x25L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetReply.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnFlowIdleEnableSetReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnFlowIdleEnableSetReplyVer13(
+                    xid,
+                    enable,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnFlowIdleEnableSetReply> {
+        @Override
+        public OFBsnFlowIdleEnableSetReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x25L
+            int subtype = bb.readInt();
+            if(subtype != 0x25)
+                throw new OFParseError("Wrong subtype: Expected=0x25L(0x25L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+            long status = U32.f(bb.readInt());
+
+            OFBsnFlowIdleEnableSetReplyVer13 bsnFlowIdleEnableSetReplyVer13 = new OFBsnFlowIdleEnableSetReplyVer13(
+                    xid,
+                      enable,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnFlowIdleEnableSetReplyVer13);
+            return bsnFlowIdleEnableSetReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnFlowIdleEnableSetReplyVer13Funnel FUNNEL = new OFBsnFlowIdleEnableSetReplyVer13Funnel();
+    static class OFBsnFlowIdleEnableSetReplyVer13Funnel implements Funnel<OFBsnFlowIdleEnableSetReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnFlowIdleEnableSetReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x25L
+            sink.putInt(0x25);
+            sink.putLong(message.enable);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnFlowIdleEnableSetReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnFlowIdleEnableSetReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x25L
+            bb.writeInt(0x25);
+            bb.writeInt(U32.t(message.enable));
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnFlowIdleEnableSetReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnFlowIdleEnableSetReplyVer13 other = (OFBsnFlowIdleEnableSetReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableSetRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableSetRequestVer13.java
new file mode 100644
index 0000000..a4a5a16
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleEnableSetRequestVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnFlowIdleEnableSetRequestVer13 implements OFBsnFlowIdleEnableSetRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowIdleEnableSetRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_ENABLE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long enable;
+//
+    // Immutable default instance
+    final static OFBsnFlowIdleEnableSetRequestVer13 DEFAULT = new OFBsnFlowIdleEnableSetRequestVer13(
+        DEFAULT_XID, DEFAULT_ENABLE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnFlowIdleEnableSetRequestVer13(long xid, long enable) {
+        this.xid = xid;
+        this.enable = enable;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x24L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+
+
+    public OFBsnFlowIdleEnableSetRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnFlowIdleEnableSetRequest.Builder {
+        final OFBsnFlowIdleEnableSetRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+        BuilderWithParent(OFBsnFlowIdleEnableSetRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x24L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnFlowIdleEnableSetRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long enable = this.enableSet ? this.enable : parentMessage.enable;
+
+                //
+                return new OFBsnFlowIdleEnableSetRequestVer13(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnFlowIdleEnableSetRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enableSet;
+        private long enable;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x24L;
+    }
+
+    @Override
+    public long getEnable() {
+        return enable;
+    }
+
+    @Override
+    public OFBsnFlowIdleEnableSetRequest.Builder setEnable(long enable) {
+        this.enable = enable;
+        this.enableSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnFlowIdleEnableSetRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long enable = this.enableSet ? this.enable : DEFAULT_ENABLE;
+
+
+            return new OFBsnFlowIdleEnableSetRequestVer13(
+                    xid,
+                    enable
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnFlowIdleEnableSetRequest> {
+        @Override
+        public OFBsnFlowIdleEnableSetRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x24L
+            int subtype = bb.readInt();
+            if(subtype != 0x24)
+                throw new OFParseError("Wrong subtype: Expected=0x24L(0x24L), got="+subtype);
+            long enable = U32.f(bb.readInt());
+
+            OFBsnFlowIdleEnableSetRequestVer13 bsnFlowIdleEnableSetRequestVer13 = new OFBsnFlowIdleEnableSetRequestVer13(
+                    xid,
+                      enable
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnFlowIdleEnableSetRequestVer13);
+            return bsnFlowIdleEnableSetRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnFlowIdleEnableSetRequestVer13Funnel FUNNEL = new OFBsnFlowIdleEnableSetRequestVer13Funnel();
+    static class OFBsnFlowIdleEnableSetRequestVer13Funnel implements Funnel<OFBsnFlowIdleEnableSetRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnFlowIdleEnableSetRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x24L
+            sink.putInt(0x24);
+            sink.putLong(message.enable);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnFlowIdleEnableSetRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnFlowIdleEnableSetRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x24L
+            bb.writeInt(0x24);
+            bb.writeInt(U32.t(message.enable));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnFlowIdleEnableSetRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enable=").append(enable);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnFlowIdleEnableSetRequestVer13 other = (OFBsnFlowIdleEnableSetRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enable != other.enable)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (enable ^ (enable >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleVer13.java
new file mode 100644
index 0000000..1b2bfd2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleVer13.java
@@ -0,0 +1,533 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnFlowIdleVer13 implements OFBsnFlowIdle {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnFlowIdleVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 40;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final int priority;
+    private final TableId tableId;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFBsnFlowIdleVer13 DEFAULT = new OFBsnFlowIdleVer13(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_PRIORITY, DEFAULT_TABLE_ID, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnFlowIdleVer13(long xid, U64 cookie, int priority, TableId tableId, Match match) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.priority = priority;
+        this.tableId = tableId;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x28L;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFBsnFlowIdle.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnFlowIdle.Builder {
+        final OFBsnFlowIdleVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFBsnFlowIdleVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x28L;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnFlowIdle build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFBsnFlowIdleVer13(
+                    xid,
+                    cookie,
+                    priority,
+                    tableId,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnFlowIdle.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x28L;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFBsnFlowIdle.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnFlowIdle build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFBsnFlowIdleVer13(
+                    xid,
+                    cookie,
+                    priority,
+                    tableId,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnFlowIdle> {
+        @Override
+        public OFBsnFlowIdle readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x28L
+            int subtype = bb.readInt();
+            if(subtype != 0x28)
+                throw new OFParseError("Wrong subtype: Expected=0x28L(0x28L), got="+subtype);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            int priority = U16.f(bb.readShort());
+            TableId tableId = TableId.readByte(bb);
+            // pad: 5 bytes
+            bb.skipBytes(5);
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+
+            OFBsnFlowIdleVer13 bsnFlowIdleVer13 = new OFBsnFlowIdleVer13(
+                    xid,
+                      cookie,
+                      priority,
+                      tableId,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnFlowIdleVer13);
+            return bsnFlowIdleVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnFlowIdleVer13Funnel FUNNEL = new OFBsnFlowIdleVer13Funnel();
+    static class OFBsnFlowIdleVer13Funnel implements Funnel<OFBsnFlowIdleVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnFlowIdleVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x28L
+            sink.putInt(0x28);
+            message.cookie.putTo(sink);
+            sink.putInt(message.priority);
+            message.tableId.putTo(sink);
+            // skip pad (5 bytes)
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnFlowIdleVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnFlowIdleVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x28L
+            bb.writeInt(0x28);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeShort(U16.t(message.priority));
+            message.tableId.writeByte(bb);
+            // pad: 5 bytes
+            bb.writeZero(5);
+            message.match.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnFlowIdleVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnFlowIdleVer13 other = (OFBsnFlowIdleVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + priority;
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsEntryVer13.java
new file mode 100644
index 0000000..7d332b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsEntryVer13.java
@@ -0,0 +1,229 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableBucketStatsEntryVer13 implements OFBsnGentableBucketStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableBucketStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+
+    // OF message fields
+    private final U128 checksum;
+//
+    // Immutable default instance
+    final static OFBsnGentableBucketStatsEntryVer13 DEFAULT = new OFBsnGentableBucketStatsEntryVer13(
+        DEFAULT_CHECKSUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableBucketStatsEntryVer13(U128 checksum) {
+        this.checksum = checksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnGentableBucketStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableBucketStatsEntry.Builder {
+        final OFBsnGentableBucketStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+        BuilderWithParent(OFBsnGentableBucketStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsEntry.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnGentableBucketStatsEntry build() {
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+
+                //
+                return new OFBsnGentableBucketStatsEntryVer13(
+                    checksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableBucketStatsEntry.Builder {
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsEntry.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnGentableBucketStatsEntry build() {
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+
+
+            return new OFBsnGentableBucketStatsEntryVer13(
+                    checksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableBucketStatsEntry> {
+        @Override
+        public OFBsnGentableBucketStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            U128 checksum = U128.read16Bytes(bb);
+
+            OFBsnGentableBucketStatsEntryVer13 bsnGentableBucketStatsEntryVer13 = new OFBsnGentableBucketStatsEntryVer13(
+                    checksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableBucketStatsEntryVer13);
+            return bsnGentableBucketStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableBucketStatsEntryVer13Funnel FUNNEL = new OFBsnGentableBucketStatsEntryVer13Funnel();
+    static class OFBsnGentableBucketStatsEntryVer13Funnel implements Funnel<OFBsnGentableBucketStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableBucketStatsEntryVer13 message, PrimitiveSink sink) {
+            message.checksum.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableBucketStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableBucketStatsEntryVer13 message) {
+            message.checksum.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableBucketStatsEntryVer13(");
+        b.append("checksum=").append(checksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableBucketStatsEntryVer13 other = (OFBsnGentableBucketStatsEntryVer13) obj;
+
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsReplyVer13.java
new file mode 100644
index 0000000..2c991f5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableBucketStatsReplyVer13 implements OFBsnGentableBucketStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableBucketStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnGentableBucketStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnGentableBucketStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnGentableBucketStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnGentableBucketStatsReplyVer13 DEFAULT = new OFBsnGentableBucketStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableBucketStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnGentableBucketStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public List<OFBsnGentableBucketStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnGentableBucketStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableBucketStatsReply.Builder {
+        final OFBsnGentableBucketStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableBucketStatsEntry> entries;
+
+        BuilderWithParent(OFBsnGentableBucketStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public List<OFBsnGentableBucketStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsReply.Builder setEntries(List<OFBsnGentableBucketStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableBucketStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnGentableBucketStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnGentableBucketStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableBucketStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableBucketStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public List<OFBsnGentableBucketStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsReply.Builder setEntries(List<OFBsnGentableBucketStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableBucketStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnGentableBucketStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnGentableBucketStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableBucketStatsReply> {
+        @Override
+        public OFBsnGentableBucketStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x5L
+            int subtype = bb.readInt();
+            if(subtype != 0x5)
+                throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got="+subtype);
+            List<OFBsnGentableBucketStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnGentableBucketStatsEntryVer13.READER);
+
+            OFBsnGentableBucketStatsReplyVer13 bsnGentableBucketStatsReplyVer13 = new OFBsnGentableBucketStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableBucketStatsReplyVer13);
+            return bsnGentableBucketStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableBucketStatsReplyVer13Funnel FUNNEL = new OFBsnGentableBucketStatsReplyVer13Funnel();
+    static class OFBsnGentableBucketStatsReplyVer13Funnel implements Funnel<OFBsnGentableBucketStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableBucketStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            sink.putInt(0x5);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableBucketStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableBucketStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            bb.writeInt(0x5);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableBucketStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableBucketStatsReplyVer13 other = (OFBsnGentableBucketStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsRequestVer13.java
new file mode 100644
index 0000000..285afd3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsRequestVer13.java
@@ -0,0 +1,447 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableBucketStatsRequestVer13 implements OFBsnGentableBucketStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableBucketStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 26;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final GenTableId tableId;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableBucketStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, GenTableId tableId) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+
+
+    public OFBsnGentableBucketStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableBucketStatsRequest.Builder {
+        final OFBsnGentableBucketStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+
+        BuilderWithParent(OFBsnGentableBucketStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsRequest.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableBucketStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+
+                //
+                return new OFBsnGentableBucketStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableBucketStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableBucketStatsRequest.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableBucketStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+
+
+            return new OFBsnGentableBucketStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableBucketStatsRequest> {
+        @Override
+        public OFBsnGentableBucketStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 26)
+                throw new OFParseError("Wrong length: Expected=26(26), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x5L
+            int subtype = bb.readInt();
+            if(subtype != 0x5)
+                throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got="+subtype);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+
+            OFBsnGentableBucketStatsRequestVer13 bsnGentableBucketStatsRequestVer13 = new OFBsnGentableBucketStatsRequestVer13(
+                    xid,
+                      flags,
+                      tableId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableBucketStatsRequestVer13);
+            return bsnGentableBucketStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableBucketStatsRequestVer13Funnel FUNNEL = new OFBsnGentableBucketStatsRequestVer13Funnel();
+    static class OFBsnGentableBucketStatsRequestVer13Funnel implements Funnel<OFBsnGentableBucketStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableBucketStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 26
+            sink.putShort((short) 0x1a);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            sink.putInt(0x5);
+            message.tableId.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableBucketStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableBucketStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 26
+            bb.writeShort((short) 0x1a);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            bb.writeInt(0x5);
+            message.tableId.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableBucketStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableBucketStatsRequestVer13 other = (OFBsnGentableBucketStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearReplyVer13.java
new file mode 100644
index 0000000..75465ec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearReplyVer13.java
@@ -0,0 +1,463 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableClearReplyVer13 implements OFBsnGentableClearReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableClearReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_DELETED_COUNT = 0x0L;
+        private final static long DEFAULT_ERROR_COUNT = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final GenTableId tableId;
+    private final long deletedCount;
+    private final long errorCount;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableClearReplyVer13(long xid, GenTableId tableId, long deletedCount, long errorCount) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.deletedCount = deletedCount;
+        this.errorCount = errorCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x31L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getDeletedCount() {
+        return deletedCount;
+    }
+
+    @Override
+    public long getErrorCount() {
+        return errorCount;
+    }
+
+
+
+    public OFBsnGentableClearReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableClearReply.Builder {
+        final OFBsnGentableClearReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean deletedCountSet;
+        private long deletedCount;
+        private boolean errorCountSet;
+        private long errorCount;
+
+        BuilderWithParent(OFBsnGentableClearReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableClearReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x31L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableClearReply.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDeletedCount() {
+        return deletedCount;
+    }
+
+    @Override
+    public OFBsnGentableClearReply.Builder setDeletedCount(long deletedCount) {
+        this.deletedCount = deletedCount;
+        this.deletedCountSet = true;
+        return this;
+    }
+    @Override
+    public long getErrorCount() {
+        return errorCount;
+    }
+
+    @Override
+    public OFBsnGentableClearReply.Builder setErrorCount(long errorCount) {
+        this.errorCount = errorCount;
+        this.errorCountSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableClearReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long deletedCount = this.deletedCountSet ? this.deletedCount : parentMessage.deletedCount;
+                long errorCount = this.errorCountSet ? this.errorCount : parentMessage.errorCount;
+
+                //
+                return new OFBsnGentableClearReplyVer13(
+                    xid,
+                    tableId,
+                    deletedCount,
+                    errorCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableClearReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean deletedCountSet;
+        private long deletedCount;
+        private boolean errorCountSet;
+        private long errorCount;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableClearReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x31L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableClearReply.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDeletedCount() {
+        return deletedCount;
+    }
+
+    @Override
+    public OFBsnGentableClearReply.Builder setDeletedCount(long deletedCount) {
+        this.deletedCount = deletedCount;
+        this.deletedCountSet = true;
+        return this;
+    }
+    @Override
+    public long getErrorCount() {
+        return errorCount;
+    }
+
+    @Override
+    public OFBsnGentableClearReply.Builder setErrorCount(long errorCount) {
+        this.errorCount = errorCount;
+        this.errorCountSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableClearReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long deletedCount = this.deletedCountSet ? this.deletedCount : DEFAULT_DELETED_COUNT;
+            long errorCount = this.errorCountSet ? this.errorCount : DEFAULT_ERROR_COUNT;
+
+
+            return new OFBsnGentableClearReplyVer13(
+                    xid,
+                    tableId,
+                    deletedCount,
+                    errorCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableClearReply> {
+        @Override
+        public OFBsnGentableClearReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 28)
+                throw new OFParseError("Wrong length: Expected=28(28), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x31L
+            int subtype = bb.readInt();
+            if(subtype != 0x31)
+                throw new OFParseError("Wrong subtype: Expected=0x31L(0x31L), got="+subtype);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long deletedCount = U32.f(bb.readInt());
+            long errorCount = U32.f(bb.readInt());
+
+            OFBsnGentableClearReplyVer13 bsnGentableClearReplyVer13 = new OFBsnGentableClearReplyVer13(
+                    xid,
+                      tableId,
+                      deletedCount,
+                      errorCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableClearReplyVer13);
+            return bsnGentableClearReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableClearReplyVer13Funnel FUNNEL = new OFBsnGentableClearReplyVer13Funnel();
+    static class OFBsnGentableClearReplyVer13Funnel implements Funnel<OFBsnGentableClearReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableClearReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 28
+            sink.putShort((short) 0x1c);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x31L
+            sink.putInt(0x31);
+            message.tableId.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.deletedCount);
+            sink.putLong(message.errorCount);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableClearReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableClearReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 28
+            bb.writeShort((short) 0x1c);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x31L
+            bb.writeInt(0x31);
+            message.tableId.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.deletedCount));
+            bb.writeInt(U32.t(message.errorCount));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableClearReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("deletedCount=").append(deletedCount);
+        b.append(", ");
+        b.append("errorCount=").append(errorCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableClearReplyVer13 other = (OFBsnGentableClearReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( deletedCount != other.deletedCount)
+            return false;
+        if( errorCount != other.errorCount)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (deletedCount ^ (deletedCount >>> 32));
+        result = prime *  (int) (errorCount ^ (errorCount >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearRequestVer13.java
new file mode 100644
index 0000000..9c96e4b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearRequestVer13.java
@@ -0,0 +1,477 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableClearRequestVer13 implements OFBsnGentableClearRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableClearRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 52;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+        private final static U128 DEFAULT_CHECKSUM_MASK = U128.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final GenTableId tableId;
+    private final U128 checksum;
+    private final U128 checksumMask;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableClearRequestVer13(long xid, GenTableId tableId, U128 checksum, U128 checksumMask) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.checksum = checksum;
+        this.checksumMask = checksumMask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x30L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+
+
+    public OFBsnGentableClearRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableClearRequest.Builder {
+        final OFBsnGentableClearRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean checksumMaskSet;
+        private U128 checksumMask;
+
+        BuilderWithParent(OFBsnGentableClearRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableClearRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x30L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableClearRequest.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableClearRequest.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+    @Override
+    public OFBsnGentableClearRequest.Builder setChecksumMask(U128 checksumMask) {
+        this.checksumMask = checksumMask;
+        this.checksumMaskSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableClearRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+                U128 checksumMask = this.checksumMaskSet ? this.checksumMask : parentMessage.checksumMask;
+                if(checksumMask == null)
+                    throw new NullPointerException("Property checksumMask must not be null");
+
+                //
+                return new OFBsnGentableClearRequestVer13(
+                    xid,
+                    tableId,
+                    checksum,
+                    checksumMask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableClearRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean checksumMaskSet;
+        private U128 checksumMask;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableClearRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x30L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableClearRequest.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableClearRequest.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+    @Override
+    public OFBsnGentableClearRequest.Builder setChecksumMask(U128 checksumMask) {
+        this.checksumMask = checksumMask;
+        this.checksumMaskSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableClearRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+            U128 checksumMask = this.checksumMaskSet ? this.checksumMask : DEFAULT_CHECKSUM_MASK;
+            if(checksumMask == null)
+                throw new NullPointerException("Property checksumMask must not be null");
+
+
+            return new OFBsnGentableClearRequestVer13(
+                    xid,
+                    tableId,
+                    checksum,
+                    checksumMask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableClearRequest> {
+        @Override
+        public OFBsnGentableClearRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 52)
+                throw new OFParseError("Wrong length: Expected=52(52), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x30L
+            int subtype = bb.readInt();
+            if(subtype != 0x30)
+                throw new OFParseError("Wrong subtype: Expected=0x30L(0x30L), got="+subtype);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            U128 checksum = U128.read16Bytes(bb);
+            U128 checksumMask = U128.read16Bytes(bb);
+
+            OFBsnGentableClearRequestVer13 bsnGentableClearRequestVer13 = new OFBsnGentableClearRequestVer13(
+                    xid,
+                      tableId,
+                      checksum,
+                      checksumMask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableClearRequestVer13);
+            return bsnGentableClearRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableClearRequestVer13Funnel FUNNEL = new OFBsnGentableClearRequestVer13Funnel();
+    static class OFBsnGentableClearRequestVer13Funnel implements Funnel<OFBsnGentableClearRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableClearRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 52
+            sink.putShort((short) 0x34);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x30L
+            sink.putInt(0x30);
+            message.tableId.putTo(sink);
+            // skip pad (2 bytes)
+            message.checksum.putTo(sink);
+            message.checksumMask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableClearRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableClearRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 52
+            bb.writeShort((short) 0x34);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x30L
+            bb.writeInt(0x30);
+            message.tableId.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.checksum.write16Bytes(bb);
+            message.checksumMask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableClearRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("checksum=").append(checksum);
+        b.append(", ");
+        b.append("checksumMask=").append(checksumMask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableClearRequestVer13 other = (OFBsnGentableClearRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        if (checksumMask == null) {
+            if (other.checksumMask != null)
+                return false;
+        } else if (!checksumMask.equals(other.checksumMask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        result = prime * result + ((checksumMask == null) ? 0 : checksumMask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsEntryVer13.java
new file mode 100644
index 0000000..058b2b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsEntryVer13.java
@@ -0,0 +1,393 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableDescStatsEntryVer13 implements OFBsnGentableDescStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableDescStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 48;
+
+        private final static String DEFAULT_NAME = "";
+        private final static long DEFAULT_BUCKETS_SIZE = 0x0L;
+        private final static long DEFAULT_MAX_ENTRIES = 0x0L;
+
+    // OF message fields
+    private final GenTableId tableId;
+    private final String name;
+    private final long bucketsSize;
+    private final long maxEntries;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableDescStatsEntryVer13(GenTableId tableId, String name, long bucketsSize, long maxEntries) {
+        this.tableId = tableId;
+        this.name = name;
+        this.bucketsSize = bucketsSize;
+        this.maxEntries = maxEntries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnGentableDescStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableDescStatsEntry.Builder {
+        final OFBsnGentableDescStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean bucketsSizeSet;
+        private long bucketsSize;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+
+        BuilderWithParent(OFBsnGentableDescStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsEntry.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsEntry.Builder setBucketsSize(long bucketsSize) {
+        this.bucketsSize = bucketsSize;
+        this.bucketsSizeSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsEntry.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnGentableDescStatsEntry build() {
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                long bucketsSize = this.bucketsSizeSet ? this.bucketsSize : parentMessage.bucketsSize;
+                long maxEntries = this.maxEntriesSet ? this.maxEntries : parentMessage.maxEntries;
+
+                //
+                return new OFBsnGentableDescStatsEntryVer13(
+                    tableId,
+                    name,
+                    bucketsSize,
+                    maxEntries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableDescStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean bucketsSizeSet;
+        private long bucketsSize;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsEntry.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsEntry.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsEntry.Builder setBucketsSize(long bucketsSize) {
+        this.bucketsSize = bucketsSize;
+        this.bucketsSizeSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsEntry.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnGentableDescStatsEntry build() {
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            long bucketsSize = this.bucketsSizeSet ? this.bucketsSize : DEFAULT_BUCKETS_SIZE;
+            long maxEntries = this.maxEntriesSet ? this.maxEntries : DEFAULT_MAX_ENTRIES;
+
+
+            return new OFBsnGentableDescStatsEntryVer13(
+                    tableId,
+                    name,
+                    bucketsSize,
+                    maxEntries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableDescStatsEntry> {
+        @Override
+        public OFBsnGentableDescStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length != 48)
+                throw new OFParseError("Wrong length: Expected=48(48), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            String name = ChannelUtils.readFixedLengthString(bb, 32);
+            long bucketsSize = U32.f(bb.readInt());
+            long maxEntries = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFBsnGentableDescStatsEntryVer13 bsnGentableDescStatsEntryVer13 = new OFBsnGentableDescStatsEntryVer13(
+                    tableId,
+                      name,
+                      bucketsSize,
+                      maxEntries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableDescStatsEntryVer13);
+            return bsnGentableDescStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableDescStatsEntryVer13Funnel FUNNEL = new OFBsnGentableDescStatsEntryVer13Funnel();
+    static class OFBsnGentableDescStatsEntryVer13Funnel implements Funnel<OFBsnGentableDescStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableDescStatsEntryVer13 message, PrimitiveSink sink) {
+            // fixed value property length = 48
+            sink.putShort((short) 0x30);
+            message.tableId.putTo(sink);
+            sink.putUnencodedChars(message.name);
+            sink.putLong(message.bucketsSize);
+            sink.putLong(message.maxEntries);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableDescStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableDescStatsEntryVer13 message) {
+            // fixed value property length = 48
+            bb.writeShort((short) 0x30);
+            message.tableId.write2Bytes(bb);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 32);
+            bb.writeInt(U32.t(message.bucketsSize));
+            bb.writeInt(U32.t(message.maxEntries));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableDescStatsEntryVer13(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("bucketsSize=").append(bucketsSize);
+        b.append(", ");
+        b.append("maxEntries=").append(maxEntries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableDescStatsEntryVer13 other = (OFBsnGentableDescStatsEntryVer13) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if( bucketsSize != other.bucketsSize)
+            return false;
+        if( maxEntries != other.maxEntries)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime *  (int) (bucketsSize ^ (bucketsSize >>> 32));
+        result = prime *  (int) (maxEntries ^ (maxEntries >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsReplyVer13.java
new file mode 100644
index 0000000..fba991d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableDescStatsReplyVer13 implements OFBsnGentableDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableDescStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnGentableDescStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnGentableDescStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnGentableDescStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnGentableDescStatsReplyVer13 DEFAULT = new OFBsnGentableDescStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableDescStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnGentableDescStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public List<OFBsnGentableDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnGentableDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableDescStatsReply.Builder {
+        final OFBsnGentableDescStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableDescStatsEntry> entries;
+
+        BuilderWithParent(OFBsnGentableDescStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public List<OFBsnGentableDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsReply.Builder setEntries(List<OFBsnGentableDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnGentableDescStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnGentableDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableDescStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public List<OFBsnGentableDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsReply.Builder setEntries(List<OFBsnGentableDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnGentableDescStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnGentableDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableDescStatsReply> {
+        @Override
+        public OFBsnGentableDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            List<OFBsnGentableDescStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnGentableDescStatsEntryVer13.READER);
+
+            OFBsnGentableDescStatsReplyVer13 bsnGentableDescStatsReplyVer13 = new OFBsnGentableDescStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableDescStatsReplyVer13);
+            return bsnGentableDescStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableDescStatsReplyVer13Funnel FUNNEL = new OFBsnGentableDescStatsReplyVer13Funnel();
+    static class OFBsnGentableDescStatsReplyVer13Funnel implements Funnel<OFBsnGentableDescStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableDescStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableDescStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableDescStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableDescStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableDescStatsReplyVer13 other = (OFBsnGentableDescStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsRequestVer13.java
new file mode 100644
index 0000000..385e1ea
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsRequestVer13.java
@@ -0,0 +1,397 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableDescStatsRequestVer13 implements OFBsnGentableDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableDescStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFBsnGentableDescStatsRequestVer13 DEFAULT = new OFBsnGentableDescStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableDescStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+
+
+    public OFBsnGentableDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableDescStatsRequest.Builder {
+        final OFBsnGentableDescStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFBsnGentableDescStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+
+
+        @Override
+        public OFBsnGentableDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFBsnGentableDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+//
+        @Override
+        public OFBsnGentableDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFBsnGentableDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableDescStatsRequest> {
+        @Override
+        public OFBsnGentableDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+
+            OFBsnGentableDescStatsRequestVer13 bsnGentableDescStatsRequestVer13 = new OFBsnGentableDescStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableDescStatsRequestVer13);
+            return bsnGentableDescStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableDescStatsRequestVer13Funnel FUNNEL = new OFBsnGentableDescStatsRequestVer13Funnel();
+    static class OFBsnGentableDescStatsRequestVer13Funnel implements Funnel<OFBsnGentableDescStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableDescStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableDescStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableDescStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableDescStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableDescStatsRequestVer13 other = (OFBsnGentableDescStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryAddVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryAddVer13.java
new file mode 100644
index 0000000..756ebee
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryAddVer13.java
@@ -0,0 +1,543 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableEntryAddVer13 implements OFBsnGentableEntryAdd {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryAddVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 36;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+        private final static List<OFBsnTlv> DEFAULT_KEY = ImmutableList.<OFBsnTlv>of();
+        private final static List<OFBsnTlv> DEFAULT_VALUE = ImmutableList.<OFBsnTlv>of();
+
+    // OF message fields
+    private final long xid;
+    private final GenTableId tableId;
+    private final U128 checksum;
+    private final List<OFBsnTlv> key;
+    private final List<OFBsnTlv> value;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableEntryAddVer13(long xid, GenTableId tableId, U128 checksum, List<OFBsnTlv> key, List<OFBsnTlv> value) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.checksum = checksum;
+        this.key = key;
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2eL;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public List<OFBsnTlv> getValue() {
+        return value;
+    }
+
+
+
+    public OFBsnGentableEntryAdd.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableEntryAdd.Builder {
+        final OFBsnGentableEntryAddVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean keySet;
+        private List<OFBsnTlv> key;
+        private boolean valueSet;
+        private List<OFBsnTlv> value;
+
+        BuilderWithParent(OFBsnGentableEntryAddVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2eL;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setKey(List<OFBsnTlv> key) {
+        this.key = key;
+        this.keySet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setValue(List<OFBsnTlv> value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableEntryAdd build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+                List<OFBsnTlv> key = this.keySet ? this.key : parentMessage.key;
+                if(key == null)
+                    throw new NullPointerException("Property key must not be null");
+                List<OFBsnTlv> value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnGentableEntryAddVer13(
+                    xid,
+                    tableId,
+                    checksum,
+                    key,
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableEntryAdd.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean keySet;
+        private List<OFBsnTlv> key;
+        private boolean valueSet;
+        private List<OFBsnTlv> value;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2eL;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setKey(List<OFBsnTlv> key) {
+        this.key = key;
+        this.keySet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnGentableEntryAdd.Builder setValue(List<OFBsnTlv> value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableEntryAdd build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+            List<OFBsnTlv> key = this.keySet ? this.key : DEFAULT_KEY;
+            if(key == null)
+                throw new NullPointerException("Property key must not be null");
+            List<OFBsnTlv> value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnGentableEntryAddVer13(
+                    xid,
+                    tableId,
+                    checksum,
+                    key,
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableEntryAdd> {
+        @Override
+        public OFBsnGentableEntryAdd readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2eL
+            int subtype = bb.readInt();
+            if(subtype != 0x2e)
+                throw new OFParseError("Wrong subtype: Expected=0x2eL(0x2eL), got="+subtype);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            int keyLength = U16.f(bb.readShort());
+            U128 checksum = U128.read16Bytes(bb);
+            List<OFBsnTlv> key = ChannelUtils.readList(bb, keyLength, OFBsnTlvVer13.READER);
+            List<OFBsnTlv> value = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnTlvVer13.READER);
+
+            OFBsnGentableEntryAddVer13 bsnGentableEntryAddVer13 = new OFBsnGentableEntryAddVer13(
+                    xid,
+                      tableId,
+                      checksum,
+                      key,
+                      value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableEntryAddVer13);
+            return bsnGentableEntryAddVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableEntryAddVer13Funnel FUNNEL = new OFBsnGentableEntryAddVer13Funnel();
+    static class OFBsnGentableEntryAddVer13Funnel implements Funnel<OFBsnGentableEntryAddVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableEntryAddVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2eL
+            sink.putInt(0x2e);
+            message.tableId.putTo(sink);
+            // FIXME: skip funnel of keyLength
+            message.checksum.putTo(sink);
+            FunnelUtils.putList(message.key, sink);
+            FunnelUtils.putList(message.value, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableEntryAddVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableEntryAddVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2eL
+            bb.writeInt(0x2e);
+            message.tableId.write2Bytes(bb);
+            // keyLength is length indicator for key, will be
+            // udpated when key has been written
+            int keyLengthIndex = bb.writerIndex();
+            bb.writeShort(0);
+            message.checksum.write16Bytes(bb);
+            int keyStartIndex = bb.writerIndex();
+            ChannelUtils.writeList(bb, message.key);
+            // update field length member keyLength
+            int keyLength = bb.writerIndex() - keyStartIndex;
+            bb.setShort(keyLengthIndex, keyLength);
+            ChannelUtils.writeList(bb, message.value);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableEntryAddVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("checksum=").append(checksum);
+        b.append(", ");
+        b.append("key=").append(key);
+        b.append(", ");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableEntryAddVer13 other = (OFBsnGentableEntryAddVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        if (key == null) {
+            if (other.key != null)
+                return false;
+        } else if (!key.equals(other.key))
+            return false;
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        result = prime * result + ((key == null) ? 0 : key.hashCode());
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDeleteVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDeleteVer13.java
new file mode 100644
index 0000000..3b9c823
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDeleteVer13.java
@@ -0,0 +1,425 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableEntryDeleteVer13 implements OFBsnGentableEntryDelete {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryDeleteVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 18;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static List<OFBsnTlv> DEFAULT_KEY = ImmutableList.<OFBsnTlv>of();
+
+    // OF message fields
+    private final long xid;
+    private final GenTableId tableId;
+    private final List<OFBsnTlv> key;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableEntryDeleteVer13(long xid, GenTableId tableId, List<OFBsnTlv> key) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.key = key;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2fL;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+
+
+    public OFBsnGentableEntryDelete.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableEntryDelete.Builder {
+        final OFBsnGentableEntryDeleteVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean keySet;
+        private List<OFBsnTlv> key;
+
+        BuilderWithParent(OFBsnGentableEntryDeleteVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2fL;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableEntryDelete.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public OFBsnGentableEntryDelete.Builder setKey(List<OFBsnTlv> key) {
+        this.key = key;
+        this.keySet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableEntryDelete build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                List<OFBsnTlv> key = this.keySet ? this.key : parentMessage.key;
+                if(key == null)
+                    throw new NullPointerException("Property key must not be null");
+
+                //
+                return new OFBsnGentableEntryDeleteVer13(
+                    xid,
+                    tableId,
+                    key
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableEntryDelete.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean keySet;
+        private List<OFBsnTlv> key;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2fL;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableEntryDelete.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public OFBsnGentableEntryDelete.Builder setKey(List<OFBsnTlv> key) {
+        this.key = key;
+        this.keySet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableEntryDelete build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            List<OFBsnTlv> key = this.keySet ? this.key : DEFAULT_KEY;
+            if(key == null)
+                throw new NullPointerException("Property key must not be null");
+
+
+            return new OFBsnGentableEntryDeleteVer13(
+                    xid,
+                    tableId,
+                    key
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableEntryDelete> {
+        @Override
+        public OFBsnGentableEntryDelete readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2fL
+            int subtype = bb.readInt();
+            if(subtype != 0x2f)
+                throw new OFParseError("Wrong subtype: Expected=0x2fL(0x2fL), got="+subtype);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            List<OFBsnTlv> key = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnTlvVer13.READER);
+
+            OFBsnGentableEntryDeleteVer13 bsnGentableEntryDeleteVer13 = new OFBsnGentableEntryDeleteVer13(
+                    xid,
+                      tableId,
+                      key
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableEntryDeleteVer13);
+            return bsnGentableEntryDeleteVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableEntryDeleteVer13Funnel FUNNEL = new OFBsnGentableEntryDeleteVer13Funnel();
+    static class OFBsnGentableEntryDeleteVer13Funnel implements Funnel<OFBsnGentableEntryDeleteVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableEntryDeleteVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2fL
+            sink.putInt(0x2f);
+            message.tableId.putTo(sink);
+            FunnelUtils.putList(message.key, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableEntryDeleteVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableEntryDeleteVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2fL
+            bb.writeInt(0x2f);
+            message.tableId.write2Bytes(bb);
+            ChannelUtils.writeList(bb, message.key);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableEntryDeleteVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("key=").append(key);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableEntryDeleteVer13 other = (OFBsnGentableEntryDeleteVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (key == null) {
+            if (other.key != null)
+                return false;
+        } else if (!key.equals(other.key))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((key == null) ? 0 : key.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsEntryVer13.java
new file mode 100644
index 0000000..5b9c438
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsEntryVer13.java
@@ -0,0 +1,369 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableEntryDescStatsEntryVer13 implements OFBsnGentableEntryDescStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryDescStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 20;
+
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+        private final static List<OFBsnTlv> DEFAULT_KEY = ImmutableList.<OFBsnTlv>of();
+        private final static List<OFBsnTlv> DEFAULT_VALUE = ImmutableList.<OFBsnTlv>of();
+
+    // OF message fields
+    private final U128 checksum;
+    private final List<OFBsnTlv> key;
+    private final List<OFBsnTlv> value;
+//
+    // Immutable default instance
+    final static OFBsnGentableEntryDescStatsEntryVer13 DEFAULT = new OFBsnGentableEntryDescStatsEntryVer13(
+        DEFAULT_CHECKSUM, DEFAULT_KEY, DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableEntryDescStatsEntryVer13(U128 checksum, List<OFBsnTlv> key, List<OFBsnTlv> value) {
+        this.checksum = checksum;
+        this.key = key;
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public List<OFBsnTlv> getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnGentableEntryDescStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableEntryDescStatsEntry.Builder {
+        final OFBsnGentableEntryDescStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean keySet;
+        private List<OFBsnTlv> key;
+        private boolean valueSet;
+        private List<OFBsnTlv> value;
+
+        BuilderWithParent(OFBsnGentableEntryDescStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsEntry.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsEntry.Builder setKey(List<OFBsnTlv> key) {
+        this.key = key;
+        this.keySet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsEntry.Builder setValue(List<OFBsnTlv> value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnGentableEntryDescStatsEntry build() {
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+                List<OFBsnTlv> key = this.keySet ? this.key : parentMessage.key;
+                if(key == null)
+                    throw new NullPointerException("Property key must not be null");
+                List<OFBsnTlv> value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnGentableEntryDescStatsEntryVer13(
+                    checksum,
+                    key,
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableEntryDescStatsEntry.Builder {
+        // OF message fields
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean keySet;
+        private List<OFBsnTlv> key;
+        private boolean valueSet;
+        private List<OFBsnTlv> value;
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsEntry.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsEntry.Builder setKey(List<OFBsnTlv> key) {
+        this.key = key;
+        this.keySet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsEntry.Builder setValue(List<OFBsnTlv> value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnGentableEntryDescStatsEntry build() {
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+            List<OFBsnTlv> key = this.keySet ? this.key : DEFAULT_KEY;
+            if(key == null)
+                throw new NullPointerException("Property key must not be null");
+            List<OFBsnTlv> value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnGentableEntryDescStatsEntryVer13(
+                    checksum,
+                    key,
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableEntryDescStatsEntry> {
+        @Override
+        public OFBsnGentableEntryDescStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int keyLength = U16.f(bb.readShort());
+            U128 checksum = U128.read16Bytes(bb);
+            List<OFBsnTlv> key = ChannelUtils.readList(bb, keyLength, OFBsnTlvVer13.READER);
+            List<OFBsnTlv> value = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnTlvVer13.READER);
+
+            OFBsnGentableEntryDescStatsEntryVer13 bsnGentableEntryDescStatsEntryVer13 = new OFBsnGentableEntryDescStatsEntryVer13(
+                    checksum,
+                      key,
+                      value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableEntryDescStatsEntryVer13);
+            return bsnGentableEntryDescStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableEntryDescStatsEntryVer13Funnel FUNNEL = new OFBsnGentableEntryDescStatsEntryVer13Funnel();
+    static class OFBsnGentableEntryDescStatsEntryVer13Funnel implements Funnel<OFBsnGentableEntryDescStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableEntryDescStatsEntryVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            // FIXME: skip funnel of keyLength
+            message.checksum.putTo(sink);
+            FunnelUtils.putList(message.key, sink);
+            FunnelUtils.putList(message.value, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableEntryDescStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableEntryDescStatsEntryVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // keyLength is length indicator for key, will be
+            // udpated when key has been written
+            int keyLengthIndex = bb.writerIndex();
+            bb.writeShort(0);
+            message.checksum.write16Bytes(bb);
+            int keyStartIndex = bb.writerIndex();
+            ChannelUtils.writeList(bb, message.key);
+            // update field length member keyLength
+            int keyLength = bb.writerIndex() - keyStartIndex;
+            bb.setShort(keyLengthIndex, keyLength);
+            ChannelUtils.writeList(bb, message.value);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableEntryDescStatsEntryVer13(");
+        b.append("checksum=").append(checksum);
+        b.append(", ");
+        b.append("key=").append(key);
+        b.append(", ");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableEntryDescStatsEntryVer13 other = (OFBsnGentableEntryDescStatsEntryVer13) obj;
+
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        if (key == null) {
+            if (other.key != null)
+                return false;
+        } else if (!key.equals(other.key))
+            return false;
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        result = prime * result + ((key == null) ? 0 : key.hashCode());
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsReplyVer13.java
new file mode 100644
index 0000000..1fd1796
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableEntryDescStatsReplyVer13 implements OFBsnGentableEntryDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryDescStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnGentableEntryDescStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnGentableEntryDescStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnGentableEntryDescStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnGentableEntryDescStatsReplyVer13 DEFAULT = new OFBsnGentableEntryDescStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableEntryDescStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnGentableEntryDescStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public List<OFBsnGentableEntryDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnGentableEntryDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableEntryDescStatsReply.Builder {
+        final OFBsnGentableEntryDescStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableEntryDescStatsEntry> entries;
+
+        BuilderWithParent(OFBsnGentableEntryDescStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public List<OFBsnGentableEntryDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsReply.Builder setEntries(List<OFBsnGentableEntryDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableEntryDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnGentableEntryDescStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnGentableEntryDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableEntryDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableEntryDescStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public List<OFBsnGentableEntryDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsReply.Builder setEntries(List<OFBsnGentableEntryDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableEntryDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnGentableEntryDescStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnGentableEntryDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableEntryDescStatsReply> {
+        @Override
+        public OFBsnGentableEntryDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+            List<OFBsnGentableEntryDescStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnGentableEntryDescStatsEntryVer13.READER);
+
+            OFBsnGentableEntryDescStatsReplyVer13 bsnGentableEntryDescStatsReplyVer13 = new OFBsnGentableEntryDescStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableEntryDescStatsReplyVer13);
+            return bsnGentableEntryDescStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableEntryDescStatsReplyVer13Funnel FUNNEL = new OFBsnGentableEntryDescStatsReplyVer13Funnel();
+    static class OFBsnGentableEntryDescStatsReplyVer13Funnel implements Funnel<OFBsnGentableEntryDescStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableEntryDescStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableEntryDescStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableEntryDescStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableEntryDescStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableEntryDescStatsReplyVer13 other = (OFBsnGentableEntryDescStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsRequestVer13.java
new file mode 100644
index 0000000..36d9bd7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsRequestVer13.java
@@ -0,0 +1,560 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableEntryDescStatsRequestVer13 implements OFBsnGentableEntryDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryDescStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 60;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+        private final static U128 DEFAULT_CHECKSUM_MASK = U128.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final GenTableId tableId;
+    private final U128 checksum;
+    private final U128 checksumMask;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableEntryDescStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, GenTableId tableId, U128 checksum, U128 checksumMask) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+        this.checksum = checksum;
+        this.checksumMask = checksumMask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+
+
+    public OFBsnGentableEntryDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableEntryDescStatsRequest.Builder {
+        final OFBsnGentableEntryDescStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean checksumMaskSet;
+        private U128 checksumMask;
+
+        BuilderWithParent(OFBsnGentableEntryDescStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setChecksumMask(U128 checksumMask) {
+        this.checksumMask = checksumMask;
+        this.checksumMaskSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableEntryDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+                U128 checksumMask = this.checksumMaskSet ? this.checksumMask : parentMessage.checksumMask;
+                if(checksumMask == null)
+                    throw new NullPointerException("Property checksumMask must not be null");
+
+                //
+                return new OFBsnGentableEntryDescStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId,
+                    checksum,
+                    checksumMask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableEntryDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean checksumMaskSet;
+        private U128 checksumMask;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+    @Override
+    public OFBsnGentableEntryDescStatsRequest.Builder setChecksumMask(U128 checksumMask) {
+        this.checksumMask = checksumMask;
+        this.checksumMaskSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableEntryDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+            U128 checksumMask = this.checksumMaskSet ? this.checksumMask : DEFAULT_CHECKSUM_MASK;
+            if(checksumMask == null)
+                throw new NullPointerException("Property checksumMask must not be null");
+
+
+            return new OFBsnGentableEntryDescStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId,
+                    checksum,
+                    checksumMask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableEntryDescStatsRequest> {
+        @Override
+        public OFBsnGentableEntryDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 60)
+                throw new OFParseError("Wrong length: Expected=60(60), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            U128 checksum = U128.read16Bytes(bb);
+            U128 checksumMask = U128.read16Bytes(bb);
+
+            OFBsnGentableEntryDescStatsRequestVer13 bsnGentableEntryDescStatsRequestVer13 = new OFBsnGentableEntryDescStatsRequestVer13(
+                    xid,
+                      flags,
+                      tableId,
+                      checksum,
+                      checksumMask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableEntryDescStatsRequestVer13);
+            return bsnGentableEntryDescStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableEntryDescStatsRequestVer13Funnel FUNNEL = new OFBsnGentableEntryDescStatsRequestVer13Funnel();
+    static class OFBsnGentableEntryDescStatsRequestVer13Funnel implements Funnel<OFBsnGentableEntryDescStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableEntryDescStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 60
+            sink.putShort((short) 0x3c);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+            message.tableId.putTo(sink);
+            // skip pad (2 bytes)
+            message.checksum.putTo(sink);
+            message.checksumMask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableEntryDescStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableEntryDescStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 60
+            bb.writeShort((short) 0x3c);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+            message.tableId.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.checksum.write16Bytes(bb);
+            message.checksumMask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableEntryDescStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("checksum=").append(checksum);
+        b.append(", ");
+        b.append("checksumMask=").append(checksumMask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableEntryDescStatsRequestVer13 other = (OFBsnGentableEntryDescStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        if (checksumMask == null) {
+            if (other.checksumMask != null)
+                return false;
+        } else if (!checksumMask.equals(other.checksumMask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        result = prime * result + ((checksumMask == null) ? 0 : checksumMask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsEntryVer13.java
new file mode 100644
index 0000000..8d4183b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsEntryVer13.java
@@ -0,0 +1,315 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableEntryStatsEntryVer13 implements OFBsnGentableEntryStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<OFBsnTlv> DEFAULT_KEY = ImmutableList.<OFBsnTlv>of();
+        private final static List<OFBsnTlv> DEFAULT_STATS = ImmutableList.<OFBsnTlv>of();
+
+    // OF message fields
+    private final List<OFBsnTlv> key;
+    private final List<OFBsnTlv> stats;
+//
+    // Immutable default instance
+    final static OFBsnGentableEntryStatsEntryVer13 DEFAULT = new OFBsnGentableEntryStatsEntryVer13(
+        DEFAULT_KEY, DEFAULT_STATS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableEntryStatsEntryVer13(List<OFBsnTlv> key, List<OFBsnTlv> stats) {
+        this.key = key;
+        this.stats = stats;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public List<OFBsnTlv> getStats() {
+        return stats;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnGentableEntryStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableEntryStatsEntry.Builder {
+        final OFBsnGentableEntryStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean keySet;
+        private List<OFBsnTlv> key;
+        private boolean statsSet;
+        private List<OFBsnTlv> stats;
+
+        BuilderWithParent(OFBsnGentableEntryStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsEntry.Builder setKey(List<OFBsnTlv> key) {
+        this.key = key;
+        this.keySet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getStats() {
+        return stats;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsEntry.Builder setStats(List<OFBsnTlv> stats) {
+        this.stats = stats;
+        this.statsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnGentableEntryStatsEntry build() {
+                List<OFBsnTlv> key = this.keySet ? this.key : parentMessage.key;
+                if(key == null)
+                    throw new NullPointerException("Property key must not be null");
+                List<OFBsnTlv> stats = this.statsSet ? this.stats : parentMessage.stats;
+                if(stats == null)
+                    throw new NullPointerException("Property stats must not be null");
+
+                //
+                return new OFBsnGentableEntryStatsEntryVer13(
+                    key,
+                    stats
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableEntryStatsEntry.Builder {
+        // OF message fields
+        private boolean keySet;
+        private List<OFBsnTlv> key;
+        private boolean statsSet;
+        private List<OFBsnTlv> stats;
+
+    @Override
+    public List<OFBsnTlv> getKey() {
+        return key;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsEntry.Builder setKey(List<OFBsnTlv> key) {
+        this.key = key;
+        this.keySet = true;
+        return this;
+    }
+    @Override
+    public List<OFBsnTlv> getStats() {
+        return stats;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsEntry.Builder setStats(List<OFBsnTlv> stats) {
+        this.stats = stats;
+        this.statsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnGentableEntryStatsEntry build() {
+            List<OFBsnTlv> key = this.keySet ? this.key : DEFAULT_KEY;
+            if(key == null)
+                throw new NullPointerException("Property key must not be null");
+            List<OFBsnTlv> stats = this.statsSet ? this.stats : DEFAULT_STATS;
+            if(stats == null)
+                throw new NullPointerException("Property stats must not be null");
+
+
+            return new OFBsnGentableEntryStatsEntryVer13(
+                    key,
+                    stats
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableEntryStatsEntry> {
+        @Override
+        public OFBsnGentableEntryStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int keyLength = U16.f(bb.readShort());
+            List<OFBsnTlv> key = ChannelUtils.readList(bb, keyLength, OFBsnTlvVer13.READER);
+            List<OFBsnTlv> stats = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnTlvVer13.READER);
+
+            OFBsnGentableEntryStatsEntryVer13 bsnGentableEntryStatsEntryVer13 = new OFBsnGentableEntryStatsEntryVer13(
+                    key,
+                      stats
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableEntryStatsEntryVer13);
+            return bsnGentableEntryStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableEntryStatsEntryVer13Funnel FUNNEL = new OFBsnGentableEntryStatsEntryVer13Funnel();
+    static class OFBsnGentableEntryStatsEntryVer13Funnel implements Funnel<OFBsnGentableEntryStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableEntryStatsEntryVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            // FIXME: skip funnel of keyLength
+            FunnelUtils.putList(message.key, sink);
+            FunnelUtils.putList(message.stats, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableEntryStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableEntryStatsEntryVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // keyLength is length indicator for key, will be
+            // udpated when key has been written
+            int keyLengthIndex = bb.writerIndex();
+            bb.writeShort(0);
+            int keyStartIndex = bb.writerIndex();
+            ChannelUtils.writeList(bb, message.key);
+            // update field length member keyLength
+            int keyLength = bb.writerIndex() - keyStartIndex;
+            bb.setShort(keyLengthIndex, keyLength);
+            ChannelUtils.writeList(bb, message.stats);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableEntryStatsEntryVer13(");
+        b.append("key=").append(key);
+        b.append(", ");
+        b.append("stats=").append(stats);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableEntryStatsEntryVer13 other = (OFBsnGentableEntryStatsEntryVer13) obj;
+
+        if (key == null) {
+            if (other.key != null)
+                return false;
+        } else if (!key.equals(other.key))
+            return false;
+        if (stats == null) {
+            if (other.stats != null)
+                return false;
+        } else if (!stats.equals(other.stats))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((key == null) ? 0 : key.hashCode());
+        result = prime * result + ((stats == null) ? 0 : stats.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsReplyVer13.java
new file mode 100644
index 0000000..eea3a42
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableEntryStatsReplyVer13 implements OFBsnGentableEntryStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnGentableEntryStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnGentableEntryStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnGentableEntryStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnGentableEntryStatsReplyVer13 DEFAULT = new OFBsnGentableEntryStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableEntryStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnGentableEntryStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public List<OFBsnGentableEntryStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnGentableEntryStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableEntryStatsReply.Builder {
+        final OFBsnGentableEntryStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableEntryStatsEntry> entries;
+
+        BuilderWithParent(OFBsnGentableEntryStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public List<OFBsnGentableEntryStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsReply.Builder setEntries(List<OFBsnGentableEntryStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableEntryStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnGentableEntryStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnGentableEntryStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableEntryStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableEntryStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public List<OFBsnGentableEntryStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsReply.Builder setEntries(List<OFBsnGentableEntryStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableEntryStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnGentableEntryStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnGentableEntryStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableEntryStatsReply> {
+        @Override
+        public OFBsnGentableEntryStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3L
+            int subtype = bb.readInt();
+            if(subtype != 0x3)
+                throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got="+subtype);
+            List<OFBsnGentableEntryStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnGentableEntryStatsEntryVer13.READER);
+
+            OFBsnGentableEntryStatsReplyVer13 bsnGentableEntryStatsReplyVer13 = new OFBsnGentableEntryStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableEntryStatsReplyVer13);
+            return bsnGentableEntryStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableEntryStatsReplyVer13Funnel FUNNEL = new OFBsnGentableEntryStatsReplyVer13Funnel();
+    static class OFBsnGentableEntryStatsReplyVer13Funnel implements Funnel<OFBsnGentableEntryStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableEntryStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            sink.putInt(0x3);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableEntryStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableEntryStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            bb.writeInt(0x3);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableEntryStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableEntryStatsReplyVer13 other = (OFBsnGentableEntryStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsRequestVer13.java
new file mode 100644
index 0000000..75961b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsRequestVer13.java
@@ -0,0 +1,560 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableEntryStatsRequestVer13 implements OFBsnGentableEntryStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableEntryStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 60;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+        private final static U128 DEFAULT_CHECKSUM_MASK = U128.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final GenTableId tableId;
+    private final U128 checksum;
+    private final U128 checksumMask;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableEntryStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, GenTableId tableId, U128 checksum, U128 checksumMask) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+        this.checksum = checksum;
+        this.checksumMask = checksumMask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+
+
+    public OFBsnGentableEntryStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableEntryStatsRequest.Builder {
+        final OFBsnGentableEntryStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean checksumMaskSet;
+        private U128 checksumMask;
+
+        BuilderWithParent(OFBsnGentableEntryStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setChecksumMask(U128 checksumMask) {
+        this.checksumMask = checksumMask;
+        this.checksumMaskSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableEntryStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+                U128 checksumMask = this.checksumMaskSet ? this.checksumMask : parentMessage.checksumMask;
+                if(checksumMask == null)
+                    throw new NullPointerException("Property checksumMask must not be null");
+
+                //
+                return new OFBsnGentableEntryStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId,
+                    checksum,
+                    checksumMask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableEntryStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean checksumSet;
+        private U128 checksum;
+        private boolean checksumMaskSet;
+        private U128 checksumMask;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksumMask() {
+        return checksumMask;
+    }
+
+    @Override
+    public OFBsnGentableEntryStatsRequest.Builder setChecksumMask(U128 checksumMask) {
+        this.checksumMask = checksumMask;
+        this.checksumMaskSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableEntryStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+            U128 checksumMask = this.checksumMaskSet ? this.checksumMask : DEFAULT_CHECKSUM_MASK;
+            if(checksumMask == null)
+                throw new NullPointerException("Property checksumMask must not be null");
+
+
+            return new OFBsnGentableEntryStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId,
+                    checksum,
+                    checksumMask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableEntryStatsRequest> {
+        @Override
+        public OFBsnGentableEntryStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 60)
+                throw new OFParseError("Wrong length: Expected=60(60), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3L
+            int subtype = bb.readInt();
+            if(subtype != 0x3)
+                throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got="+subtype);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            U128 checksum = U128.read16Bytes(bb);
+            U128 checksumMask = U128.read16Bytes(bb);
+
+            OFBsnGentableEntryStatsRequestVer13 bsnGentableEntryStatsRequestVer13 = new OFBsnGentableEntryStatsRequestVer13(
+                    xid,
+                      flags,
+                      tableId,
+                      checksum,
+                      checksumMask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableEntryStatsRequestVer13);
+            return bsnGentableEntryStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableEntryStatsRequestVer13Funnel FUNNEL = new OFBsnGentableEntryStatsRequestVer13Funnel();
+    static class OFBsnGentableEntryStatsRequestVer13Funnel implements Funnel<OFBsnGentableEntryStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableEntryStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 60
+            sink.putShort((short) 0x3c);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            sink.putInt(0x3);
+            message.tableId.putTo(sink);
+            // skip pad (2 bytes)
+            message.checksum.putTo(sink);
+            message.checksumMask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableEntryStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableEntryStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 60
+            bb.writeShort((short) 0x3c);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            bb.writeInt(0x3);
+            message.tableId.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.checksum.write16Bytes(bb);
+            message.checksumMask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableEntryStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("checksum=").append(checksum);
+        b.append(", ");
+        b.append("checksumMask=").append(checksumMask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableEntryStatsRequestVer13 other = (OFBsnGentableEntryStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        if (checksumMask == null) {
+            if (other.checksumMask != null)
+                return false;
+        } else if (!checksumMask.equals(other.checksumMask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        result = prime * result + ((checksumMask == null) ? 0 : checksumMask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableSetBucketsSizeVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableSetBucketsSizeVer13.java
new file mode 100644
index 0000000..323e546
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableSetBucketsSizeVer13.java
@@ -0,0 +1,416 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableSetBucketsSizeVer13 implements OFBsnGentableSetBucketsSize {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableSetBucketsSizeVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_BUCKETS_SIZE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final GenTableId tableId;
+    private final long bucketsSize;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableSetBucketsSizeVer13(long xid, GenTableId tableId, long bucketsSize) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.bucketsSize = bucketsSize;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x32L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+
+
+    public OFBsnGentableSetBucketsSize.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableSetBucketsSize.Builder {
+        final OFBsnGentableSetBucketsSizeVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean bucketsSizeSet;
+        private long bucketsSize;
+
+        BuilderWithParent(OFBsnGentableSetBucketsSizeVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableSetBucketsSize.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x32L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableSetBucketsSize.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+    @Override
+    public OFBsnGentableSetBucketsSize.Builder setBucketsSize(long bucketsSize) {
+        this.bucketsSize = bucketsSize;
+        this.bucketsSizeSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableSetBucketsSize build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long bucketsSize = this.bucketsSizeSet ? this.bucketsSize : parentMessage.bucketsSize;
+
+                //
+                return new OFBsnGentableSetBucketsSizeVer13(
+                    xid,
+                    tableId,
+                    bucketsSize
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableSetBucketsSize.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean bucketsSizeSet;
+        private long bucketsSize;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableSetBucketsSize.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x32L;
+    }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableSetBucketsSize.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+    @Override
+    public OFBsnGentableSetBucketsSize.Builder setBucketsSize(long bucketsSize) {
+        this.bucketsSize = bucketsSize;
+        this.bucketsSizeSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableSetBucketsSize build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long bucketsSize = this.bucketsSizeSet ? this.bucketsSize : DEFAULT_BUCKETS_SIZE;
+
+
+            return new OFBsnGentableSetBucketsSizeVer13(
+                    xid,
+                    tableId,
+                    bucketsSize
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableSetBucketsSize> {
+        @Override
+        public OFBsnGentableSetBucketsSize readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x32L
+            int subtype = bb.readInt();
+            if(subtype != 0x32)
+                throw new OFParseError("Wrong subtype: Expected=0x32L(0x32L), got="+subtype);
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long bucketsSize = U32.f(bb.readInt());
+
+            OFBsnGentableSetBucketsSizeVer13 bsnGentableSetBucketsSizeVer13 = new OFBsnGentableSetBucketsSizeVer13(
+                    xid,
+                      tableId,
+                      bucketsSize
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableSetBucketsSizeVer13);
+            return bsnGentableSetBucketsSizeVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableSetBucketsSizeVer13Funnel FUNNEL = new OFBsnGentableSetBucketsSizeVer13Funnel();
+    static class OFBsnGentableSetBucketsSizeVer13Funnel implements Funnel<OFBsnGentableSetBucketsSizeVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableSetBucketsSizeVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x32L
+            sink.putInt(0x32);
+            message.tableId.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.bucketsSize);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableSetBucketsSizeVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableSetBucketsSizeVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x32L
+            bb.writeInt(0x32);
+            message.tableId.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.bucketsSize));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableSetBucketsSizeVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("bucketsSize=").append(bucketsSize);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableSetBucketsSizeVer13 other = (OFBsnGentableSetBucketsSizeVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( bucketsSize != other.bucketsSize)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (bucketsSize ^ (bucketsSize >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsEntryVer13.java
new file mode 100644
index 0000000..8175fa5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsEntryVer13.java
@@ -0,0 +1,331 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableStatsEntryVer13 implements OFBsnGentableStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_ENTRY_COUNT = 0x0L;
+        private final static U128 DEFAULT_CHECKSUM = U128.ZERO;
+
+    // OF message fields
+    private final GenTableId tableId;
+    private final long entryCount;
+    private final U128 checksum;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableStatsEntryVer13(GenTableId tableId, long entryCount, U128 checksum) {
+        this.tableId = tableId;
+        this.entryCount = entryCount;
+        this.checksum = checksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getEntryCount() {
+        return entryCount;
+    }
+
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnGentableStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableStatsEntry.Builder {
+        final OFBsnGentableStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean entryCountSet;
+        private long entryCount;
+        private boolean checksumSet;
+        private U128 checksum;
+
+        BuilderWithParent(OFBsnGentableStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableStatsEntry.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getEntryCount() {
+        return entryCount;
+    }
+
+    @Override
+    public OFBsnGentableStatsEntry.Builder setEntryCount(long entryCount) {
+        this.entryCount = entryCount;
+        this.entryCountSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableStatsEntry.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnGentableStatsEntry build() {
+                GenTableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long entryCount = this.entryCountSet ? this.entryCount : parentMessage.entryCount;
+                U128 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+
+                //
+                return new OFBsnGentableStatsEntryVer13(
+                    tableId,
+                    entryCount,
+                    checksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private GenTableId tableId;
+        private boolean entryCountSet;
+        private long entryCount;
+        private boolean checksumSet;
+        private U128 checksum;
+
+    @Override
+    public GenTableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnGentableStatsEntry.Builder setTableId(GenTableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getEntryCount() {
+        return entryCount;
+    }
+
+    @Override
+    public OFBsnGentableStatsEntry.Builder setEntryCount(long entryCount) {
+        this.entryCount = entryCount;
+        this.entryCountSet = true;
+        return this;
+    }
+    @Override
+    public U128 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnGentableStatsEntry.Builder setChecksum(U128 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnGentableStatsEntry build() {
+            if(!this.tableIdSet)
+                throw new IllegalStateException("Property tableId doesn't have default value -- must be set");
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long entryCount = this.entryCountSet ? this.entryCount : DEFAULT_ENTRY_COUNT;
+            U128 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+
+
+            return new OFBsnGentableStatsEntryVer13(
+                    tableId,
+                    entryCount,
+                    checksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableStatsEntry> {
+        @Override
+        public OFBsnGentableStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            GenTableId tableId = GenTableId.read2Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long entryCount = U32.f(bb.readInt());
+            U128 checksum = U128.read16Bytes(bb);
+
+            OFBsnGentableStatsEntryVer13 bsnGentableStatsEntryVer13 = new OFBsnGentableStatsEntryVer13(
+                    tableId,
+                      entryCount,
+                      checksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableStatsEntryVer13);
+            return bsnGentableStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableStatsEntryVer13Funnel FUNNEL = new OFBsnGentableStatsEntryVer13Funnel();
+    static class OFBsnGentableStatsEntryVer13Funnel implements Funnel<OFBsnGentableStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableStatsEntryVer13 message, PrimitiveSink sink) {
+            message.tableId.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.entryCount);
+            message.checksum.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableStatsEntryVer13 message) {
+            message.tableId.write2Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.entryCount));
+            message.checksum.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableStatsEntryVer13(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("entryCount=").append(entryCount);
+        b.append(", ");
+        b.append("checksum=").append(checksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableStatsEntryVer13 other = (OFBsnGentableStatsEntryVer13) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( entryCount != other.entryCount)
+            return false;
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (entryCount ^ (entryCount >>> 32));
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsReplyVer13.java
new file mode 100644
index 0000000..1b47fbf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableStatsReplyVer13 implements OFBsnGentableStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnGentableStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnGentableStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnGentableStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnGentableStatsReplyVer13 DEFAULT = new OFBsnGentableStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnGentableStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+    @Override
+    public List<OFBsnGentableStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnGentableStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableStatsReply.Builder {
+        final OFBsnGentableStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableStatsEntry> entries;
+
+        BuilderWithParent(OFBsnGentableStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+    @Override
+    public List<OFBsnGentableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableStatsReply.Builder setEntries(List<OFBsnGentableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGentableStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnGentableStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnGentableStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnGentableStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+    @Override
+    public List<OFBsnGentableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnGentableStatsReply.Builder setEntries(List<OFBsnGentableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGentableStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnGentableStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnGentableStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableStatsReply> {
+        @Override
+        public OFBsnGentableStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x7L
+            int subtype = bb.readInt();
+            if(subtype != 0x7)
+                throw new OFParseError("Wrong subtype: Expected=0x7L(0x7L), got="+subtype);
+            List<OFBsnGentableStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnGentableStatsEntryVer13.READER);
+
+            OFBsnGentableStatsReplyVer13 bsnGentableStatsReplyVer13 = new OFBsnGentableStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableStatsReplyVer13);
+            return bsnGentableStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableStatsReplyVer13Funnel FUNNEL = new OFBsnGentableStatsReplyVer13Funnel();
+    static class OFBsnGentableStatsReplyVer13Funnel implements Funnel<OFBsnGentableStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            sink.putInt(0x7);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            bb.writeInt(0x7);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableStatsReplyVer13 other = (OFBsnGentableStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsRequestVer13.java
new file mode 100644
index 0000000..fe5fbd8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableStatsRequestVer13.java
@@ -0,0 +1,397 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGentableStatsRequestVer13 implements OFBsnGentableStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGentableStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFBsnGentableStatsRequestVer13 DEFAULT = new OFBsnGentableStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGentableStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+
+
+    public OFBsnGentableStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGentableStatsRequest.Builder {
+        final OFBsnGentableStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFBsnGentableStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+
+
+        @Override
+        public OFBsnGentableStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFBsnGentableStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGentableStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGentableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnGentableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+//
+        @Override
+        public OFBsnGentableStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFBsnGentableStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGentableStatsRequest> {
+        @Override
+        public OFBsnGentableStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x7L
+            int subtype = bb.readInt();
+            if(subtype != 0x7)
+                throw new OFParseError("Wrong subtype: Expected=0x7L(0x7L), got="+subtype);
+
+            OFBsnGentableStatsRequestVer13 bsnGentableStatsRequestVer13 = new OFBsnGentableStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGentableStatsRequestVer13);
+            return bsnGentableStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGentableStatsRequestVer13Funnel FUNNEL = new OFBsnGentableStatsRequestVer13Funnel();
+    static class OFBsnGentableStatsRequestVer13Funnel implements Funnel<OFBsnGentableStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGentableStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            sink.putInt(0x7);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGentableStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGentableStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            bb.writeInt(0x7);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGentableStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGentableStatsRequestVer13 other = (OFBsnGentableStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetInterfacesReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetInterfacesReplyVer13.java
new file mode 100644
index 0000000..a95ab3a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetInterfacesReplyVer13.java
@@ -0,0 +1,375 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetInterfacesReplyVer13 implements OFBsnGetInterfacesReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetInterfacesReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static List<OFBsnInterface> DEFAULT_INTERFACES = ImmutableList.<OFBsnInterface>of();
+
+    // OF message fields
+    private final long xid;
+    private final List<OFBsnInterface> interfaces;
+//
+    // Immutable default instance
+    final static OFBsnGetInterfacesReplyVer13 DEFAULT = new OFBsnGetInterfacesReplyVer13(
+        DEFAULT_XID, DEFAULT_INTERFACES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetInterfacesReplyVer13(long xid, List<OFBsnInterface> interfaces) {
+        this.xid = xid;
+        this.interfaces = interfaces;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+
+
+    public OFBsnGetInterfacesReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetInterfacesReply.Builder {
+        final OFBsnGetInterfacesReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean interfacesSet;
+        private List<OFBsnInterface> interfaces;
+
+        BuilderWithParent(OFBsnGetInterfacesReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setInterfaces(List<OFBsnInterface> interfaces) {
+        this.interfaces = interfaces;
+        this.interfacesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetInterfacesReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                List<OFBsnInterface> interfaces = this.interfacesSet ? this.interfaces : parentMessage.interfaces;
+                if(interfaces == null)
+                    throw new NullPointerException("Property interfaces must not be null");
+
+                //
+                return new OFBsnGetInterfacesReplyVer13(
+                    xid,
+                    interfaces
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetInterfacesReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean interfacesSet;
+        private List<OFBsnInterface> interfaces;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xaL;
+    }
+
+    @Override
+    public List<OFBsnInterface> getInterfaces() {
+        return interfaces;
+    }
+
+    @Override
+    public OFBsnGetInterfacesReply.Builder setInterfaces(List<OFBsnInterface> interfaces) {
+        this.interfaces = interfaces;
+        this.interfacesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetInterfacesReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            List<OFBsnInterface> interfaces = this.interfacesSet ? this.interfaces : DEFAULT_INTERFACES;
+            if(interfaces == null)
+                throw new NullPointerException("Property interfaces must not be null");
+
+
+            return new OFBsnGetInterfacesReplyVer13(
+                    xid,
+                    interfaces
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetInterfacesReply> {
+        @Override
+        public OFBsnGetInterfacesReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xaL
+            int subtype = bb.readInt();
+            if(subtype != 0xa)
+                throw new OFParseError("Wrong subtype: Expected=0xaL(0xaL), got="+subtype);
+            List<OFBsnInterface> interfaces = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnInterfaceVer13.READER);
+
+            OFBsnGetInterfacesReplyVer13 bsnGetInterfacesReplyVer13 = new OFBsnGetInterfacesReplyVer13(
+                    xid,
+                      interfaces
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetInterfacesReplyVer13);
+            return bsnGetInterfacesReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetInterfacesReplyVer13Funnel FUNNEL = new OFBsnGetInterfacesReplyVer13Funnel();
+    static class OFBsnGetInterfacesReplyVer13Funnel implements Funnel<OFBsnGetInterfacesReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetInterfacesReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            sink.putInt(0xa);
+            FunnelUtils.putList(message.interfaces, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetInterfacesReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetInterfacesReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xaL
+            bb.writeInt(0xa);
+            ChannelUtils.writeList(bb, message.interfaces);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetInterfacesReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("interfaces=").append(interfaces);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetInterfacesReplyVer13 other = (OFBsnGetInterfacesReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (interfaces == null) {
+            if (other.interfaces != null)
+                return false;
+        } else if (!interfaces.equals(other.interfaces))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((interfaces == null) ? 0 : interfaces.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetInterfacesRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetInterfacesRequestVer13.java
new file mode 100644
index 0000000..23ed3fd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetInterfacesRequestVer13.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetInterfacesRequestVer13 implements OFBsnGetInterfacesRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetInterfacesRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnGetInterfacesRequestVer13 DEFAULT = new OFBsnGetInterfacesRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetInterfacesRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+
+
+    public OFBsnGetInterfacesRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetInterfacesRequest.Builder {
+        final OFBsnGetInterfacesRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnGetInterfacesRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+
+
+        @Override
+        public OFBsnGetInterfacesRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnGetInterfacesRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetInterfacesRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetInterfacesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+//
+        @Override
+        public OFBsnGetInterfacesRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnGetInterfacesRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetInterfacesRequest> {
+        @Override
+        public OFBsnGetInterfacesRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x9L
+            int subtype = bb.readInt();
+            if(subtype != 0x9)
+                throw new OFParseError("Wrong subtype: Expected=0x9L(0x9L), got="+subtype);
+
+            OFBsnGetInterfacesRequestVer13 bsnGetInterfacesRequestVer13 = new OFBsnGetInterfacesRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetInterfacesRequestVer13);
+            return bsnGetInterfacesRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetInterfacesRequestVer13Funnel FUNNEL = new OFBsnGetInterfacesRequestVer13Funnel();
+    static class OFBsnGetInterfacesRequestVer13Funnel implements Funnel<OFBsnGetInterfacesRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetInterfacesRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            sink.putInt(0x9);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetInterfacesRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetInterfacesRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            bb.writeInt(0x9);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetInterfacesRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetInterfacesRequestVer13 other = (OFBsnGetInterfacesRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetMirroringReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetMirroringReplyVer13.java
new file mode 100644
index 0000000..5ee53c7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetMirroringReplyVer13.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetMirroringReplyVer13 implements OFBsnGetMirroringReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetMirroringReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnGetMirroringReplyVer13 DEFAULT = new OFBsnGetMirroringReplyVer13(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetMirroringReplyVer13(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnGetMirroringReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetMirroringReply.Builder {
+        final OFBsnGetMirroringReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnGetMirroringReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetMirroringReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnGetMirroringReplyVer13(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetMirroringReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringReply.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetMirroringReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnGetMirroringReplyVer13(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetMirroringReply> {
+        @Override
+        public OFBsnGetMirroringReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x5L
+            int subtype = bb.readInt();
+            if(subtype != 0x5)
+                throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnGetMirroringReplyVer13 bsnGetMirroringReplyVer13 = new OFBsnGetMirroringReplyVer13(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetMirroringReplyVer13);
+            return bsnGetMirroringReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetMirroringReplyVer13Funnel FUNNEL = new OFBsnGetMirroringReplyVer13Funnel();
+    static class OFBsnGetMirroringReplyVer13Funnel implements Funnel<OFBsnGetMirroringReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetMirroringReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            sink.putInt(0x5);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetMirroringReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetMirroringReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            bb.writeInt(0x5);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetMirroringReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetMirroringReplyVer13 other = (OFBsnGetMirroringReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetMirroringRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetMirroringRequestVer13.java
new file mode 100644
index 0000000..c7602c6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetMirroringRequestVer13.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetMirroringRequestVer13 implements OFBsnGetMirroringRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetMirroringRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnGetMirroringRequestVer13 DEFAULT = new OFBsnGetMirroringRequestVer13(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetMirroringRequestVer13(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnGetMirroringRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetMirroringRequest.Builder {
+        final OFBsnGetMirroringRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnGetMirroringRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetMirroringRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnGetMirroringRequestVer13(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetMirroringRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnGetMirroringRequest.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetMirroringRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnGetMirroringRequestVer13(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetMirroringRequest> {
+        @Override
+        public OFBsnGetMirroringRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnGetMirroringRequestVer13 bsnGetMirroringRequestVer13 = new OFBsnGetMirroringRequestVer13(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetMirroringRequestVer13);
+            return bsnGetMirroringRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetMirroringRequestVer13Funnel FUNNEL = new OFBsnGetMirroringRequestVer13Funnel();
+    static class OFBsnGetMirroringRequestVer13Funnel implements Funnel<OFBsnGetMirroringRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetMirroringRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetMirroringRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetMirroringRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetMirroringRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetMirroringRequestVer13 other = (OFBsnGetMirroringRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetSwitchPipelineReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetSwitchPipelineReplyVer13.java
new file mode 100644
index 0000000..f5cf745
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetSwitchPipelineReplyVer13.java
@@ -0,0 +1,368 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetSwitchPipelineReplyVer13 implements OFBsnGetSwitchPipelineReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetSwitchPipelineReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 272;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static String DEFAULT_PIPELINE = "";
+
+    // OF message fields
+    private final long xid;
+    private final String pipeline;
+//
+    // Immutable default instance
+    final static OFBsnGetSwitchPipelineReplyVer13 DEFAULT = new OFBsnGetSwitchPipelineReplyVer13(
+        DEFAULT_XID, DEFAULT_PIPELINE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetSwitchPipelineReplyVer13(long xid, String pipeline) {
+        this.xid = xid;
+        this.pipeline = pipeline;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x34L;
+    }
+
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+
+
+    public OFBsnGetSwitchPipelineReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetSwitchPipelineReply.Builder {
+        final OFBsnGetSwitchPipelineReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean pipelineSet;
+        private String pipeline;
+
+        BuilderWithParent(OFBsnGetSwitchPipelineReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetSwitchPipelineReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x34L;
+    }
+
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+    @Override
+    public OFBsnGetSwitchPipelineReply.Builder setPipeline(String pipeline) {
+        this.pipeline = pipeline;
+        this.pipelineSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnGetSwitchPipelineReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                String pipeline = this.pipelineSet ? this.pipeline : parentMessage.pipeline;
+                if(pipeline == null)
+                    throw new NullPointerException("Property pipeline must not be null");
+
+                //
+                return new OFBsnGetSwitchPipelineReplyVer13(
+                    xid,
+                    pipeline
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetSwitchPipelineReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean pipelineSet;
+        private String pipeline;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetSwitchPipelineReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x34L;
+    }
+
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+    @Override
+    public OFBsnGetSwitchPipelineReply.Builder setPipeline(String pipeline) {
+        this.pipeline = pipeline;
+        this.pipelineSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnGetSwitchPipelineReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            String pipeline = this.pipelineSet ? this.pipeline : DEFAULT_PIPELINE;
+            if(pipeline == null)
+                throw new NullPointerException("Property pipeline must not be null");
+
+
+            return new OFBsnGetSwitchPipelineReplyVer13(
+                    xid,
+                    pipeline
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetSwitchPipelineReply> {
+        @Override
+        public OFBsnGetSwitchPipelineReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 272)
+                throw new OFParseError("Wrong length: Expected=272(272), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x34L
+            int subtype = bb.readInt();
+            if(subtype != 0x34)
+                throw new OFParseError("Wrong subtype: Expected=0x34L(0x34L), got="+subtype);
+            String pipeline = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFBsnGetSwitchPipelineReplyVer13 bsnGetSwitchPipelineReplyVer13 = new OFBsnGetSwitchPipelineReplyVer13(
+                    xid,
+                      pipeline
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetSwitchPipelineReplyVer13);
+            return bsnGetSwitchPipelineReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetSwitchPipelineReplyVer13Funnel FUNNEL = new OFBsnGetSwitchPipelineReplyVer13Funnel();
+    static class OFBsnGetSwitchPipelineReplyVer13Funnel implements Funnel<OFBsnGetSwitchPipelineReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetSwitchPipelineReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 272
+            sink.putShort((short) 0x110);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x34L
+            sink.putInt(0x34);
+            sink.putUnencodedChars(message.pipeline);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetSwitchPipelineReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetSwitchPipelineReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 272
+            bb.writeShort((short) 0x110);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x34L
+            bb.writeInt(0x34);
+            ChannelUtils.writeFixedLengthString(bb, message.pipeline, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetSwitchPipelineReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("pipeline=").append(pipeline);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetSwitchPipelineReplyVer13 other = (OFBsnGetSwitchPipelineReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (pipeline == null) {
+            if (other.pipeline != null)
+                return false;
+        } else if (!pipeline.equals(other.pipeline))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((pipeline == null) ? 0 : pipeline.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetSwitchPipelineRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetSwitchPipelineRequestVer13.java
new file mode 100644
index 0000000..2637262
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGetSwitchPipelineRequestVer13.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnGetSwitchPipelineRequestVer13 implements OFBsnGetSwitchPipelineRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnGetSwitchPipelineRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnGetSwitchPipelineRequestVer13 DEFAULT = new OFBsnGetSwitchPipelineRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnGetSwitchPipelineRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x33L;
+    }
+
+
+
+    public OFBsnGetSwitchPipelineRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnGetSwitchPipelineRequest.Builder {
+        final OFBsnGetSwitchPipelineRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnGetSwitchPipelineRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetSwitchPipelineRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x33L;
+    }
+
+
+
+        @Override
+        public OFBsnGetSwitchPipelineRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnGetSwitchPipelineRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnGetSwitchPipelineRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnGetSwitchPipelineRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x33L;
+    }
+
+//
+        @Override
+        public OFBsnGetSwitchPipelineRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnGetSwitchPipelineRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnGetSwitchPipelineRequest> {
+        @Override
+        public OFBsnGetSwitchPipelineRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x33L
+            int subtype = bb.readInt();
+            if(subtype != 0x33)
+                throw new OFParseError("Wrong subtype: Expected=0x33L(0x33L), got="+subtype);
+
+            OFBsnGetSwitchPipelineRequestVer13 bsnGetSwitchPipelineRequestVer13 = new OFBsnGetSwitchPipelineRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnGetSwitchPipelineRequestVer13);
+            return bsnGetSwitchPipelineRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnGetSwitchPipelineRequestVer13Funnel FUNNEL = new OFBsnGetSwitchPipelineRequestVer13Funnel();
+    static class OFBsnGetSwitchPipelineRequestVer13Funnel implements Funnel<OFBsnGetSwitchPipelineRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnGetSwitchPipelineRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x33L
+            sink.putInt(0x33);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnGetSwitchPipelineRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnGetSwitchPipelineRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x33L
+            bb.writeInt(0x33);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnGetSwitchPipelineRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnGetSwitchPipelineRequestVer13 other = (OFBsnGetSwitchPipelineRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnHeaderVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnHeaderVer13.java
new file mode 100644
index 0000000..5154815
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnHeaderVer13.java
@@ -0,0 +1,214 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFBsnHeaderVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFBsnHeaderVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnHeader> {
+        @Override
+        public OFBsnHeader readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x16:
+                   // discriminator value 0x16L=0x16L for class OFBsnBwClearDataReplyVer13
+                   return OFBsnBwClearDataReplyVer13.READER.readFrom(bb);
+               case 0x15:
+                   // discriminator value 0x15L=0x15L for class OFBsnBwClearDataRequestVer13
+                   return OFBsnBwClearDataRequestVer13.READER.readFrom(bb);
+               case 0x14:
+                   // discriminator value 0x14L=0x14L for class OFBsnBwEnableGetReplyVer13
+                   return OFBsnBwEnableGetReplyVer13.READER.readFrom(bb);
+               case 0x13:
+                   // discriminator value 0x13L=0x13L for class OFBsnBwEnableGetRequestVer13
+                   return OFBsnBwEnableGetRequestVer13.READER.readFrom(bb);
+               case 0x17:
+                   // discriminator value 0x17L=0x17L for class OFBsnBwEnableSetReplyVer13
+                   return OFBsnBwEnableSetReplyVer13.READER.readFrom(bb);
+               case 0x12:
+                   // discriminator value 0x12L=0x12L for class OFBsnBwEnableSetRequestVer13
+                   return OFBsnBwEnableSetRequestVer13.READER.readFrom(bb);
+               case 0xa:
+                   // discriminator value 0xaL=0xaL for class OFBsnGetInterfacesReplyVer13
+                   return OFBsnGetInterfacesReplyVer13.READER.readFrom(bb);
+               case 0x9:
+                   // discriminator value 0x9L=0x9L for class OFBsnGetInterfacesRequestVer13
+                   return OFBsnGetInterfacesRequestVer13.READER.readFrom(bb);
+               case 0x5:
+                   // discriminator value 0x5L=0x5L for class OFBsnGetMirroringReplyVer13
+                   return OFBsnGetMirroringReplyVer13.READER.readFrom(bb);
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFBsnGetMirroringRequestVer13
+                   return OFBsnGetMirroringRequestVer13.READER.readFrom(bb);
+               case 0x22:
+                   // discriminator value 0x22L=0x22L for class OFBsnPduRxReplyVer13
+                   return OFBsnPduRxReplyVer13.READER.readFrom(bb);
+               case 0x21:
+                   // discriminator value 0x21L=0x21L for class OFBsnPduRxRequestVer13
+                   return OFBsnPduRxRequestVer13.READER.readFrom(bb);
+               case 0x23:
+                   // discriminator value 0x23L=0x23L for class OFBsnPduRxTimeoutVer13
+                   return OFBsnPduRxTimeoutVer13.READER.readFrom(bb);
+               case 0x20:
+                   // discriminator value 0x20L=0x20L for class OFBsnPduTxReplyVer13
+                   return OFBsnPduTxReplyVer13.READER.readFrom(bb);
+               case 0x1f:
+                   // discriminator value 0x1fL=0x1fL for class OFBsnPduTxRequestVer13
+                   return OFBsnPduTxRequestVer13.READER.readFrom(bb);
+               case 0x3:
+                   // discriminator value 0x3L=0x3L for class OFBsnSetMirroringVer13
+                   return OFBsnSetMirroringVer13.READER.readFrom(bb);
+               case 0x19:
+                   // discriminator value 0x19L=0x19L for class OFBsnSetPktinSuppressionReplyVer13
+                   return OFBsnSetPktinSuppressionReplyVer13.READER.readFrom(bb);
+               case 0xb:
+                   // discriminator value 0xbL=0xbL for class OFBsnSetPktinSuppressionRequestVer13
+                   return OFBsnSetPktinSuppressionRequestVer13.READER.readFrom(bb);
+               case 0x10:
+                   // discriminator value 0x10L=0x10L for class OFBsnVirtualPortCreateReplyVer13
+                   return OFBsnVirtualPortCreateReplyVer13.READER.readFrom(bb);
+               case 0xf:
+                   // discriminator value 0xfL=0xfL for class OFBsnVirtualPortCreateRequestVer13
+                   return OFBsnVirtualPortCreateRequestVer13.READER.readFrom(bb);
+               case 0x1a:
+                   // discriminator value 0x1aL=0x1aL for class OFBsnVirtualPortRemoveReplyVer13
+                   return OFBsnVirtualPortRemoveReplyVer13.READER.readFrom(bb);
+               case 0x11:
+                   // discriminator value 0x11L=0x11L for class OFBsnVirtualPortRemoveRequestVer13
+                   return OFBsnVirtualPortRemoveRequestVer13.READER.readFrom(bb);
+               case 0x3c:
+                   // discriminator value 0x3cL=0x3cL for class OFBsnArpIdleVer13
+                   return OFBsnArpIdleVer13.READER.readFrom(bb);
+               case 0x39:
+                   // discriminator value 0x39L=0x39L for class OFBsnControllerConnectionsReplyVer13
+                   return OFBsnControllerConnectionsReplyVer13.READER.readFrom(bb);
+               case 0x38:
+                   // discriminator value 0x38L=0x38L for class OFBsnControllerConnectionsRequestVer13
+                   return OFBsnControllerConnectionsRequestVer13.READER.readFrom(bb);
+               case 0x28:
+                   // discriminator value 0x28L=0x28L for class OFBsnFlowIdleVer13
+                   return OFBsnFlowIdleVer13.READER.readFrom(bb);
+               case 0x27:
+                   // discriminator value 0x27L=0x27L for class OFBsnFlowIdleEnableGetReplyVer13
+                   return OFBsnFlowIdleEnableGetReplyVer13.READER.readFrom(bb);
+               case 0x26:
+                   // discriminator value 0x26L=0x26L for class OFBsnFlowIdleEnableGetRequestVer13
+                   return OFBsnFlowIdleEnableGetRequestVer13.READER.readFrom(bb);
+               case 0x25:
+                   // discriminator value 0x25L=0x25L for class OFBsnFlowIdleEnableSetReplyVer13
+                   return OFBsnFlowIdleEnableSetReplyVer13.READER.readFrom(bb);
+               case 0x24:
+                   // discriminator value 0x24L=0x24L for class OFBsnFlowIdleEnableSetRequestVer13
+                   return OFBsnFlowIdleEnableSetRequestVer13.READER.readFrom(bb);
+               case 0x31:
+                   // discriminator value 0x31L=0x31L for class OFBsnGentableClearReplyVer13
+                   return OFBsnGentableClearReplyVer13.READER.readFrom(bb);
+               case 0x30:
+                   // discriminator value 0x30L=0x30L for class OFBsnGentableClearRequestVer13
+                   return OFBsnGentableClearRequestVer13.READER.readFrom(bb);
+               case 0x2e:
+                   // discriminator value 0x2eL=0x2eL for class OFBsnGentableEntryAddVer13
+                   return OFBsnGentableEntryAddVer13.READER.readFrom(bb);
+               case 0x2f:
+                   // discriminator value 0x2fL=0x2fL for class OFBsnGentableEntryDeleteVer13
+                   return OFBsnGentableEntryDeleteVer13.READER.readFrom(bb);
+               case 0x32:
+                   // discriminator value 0x32L=0x32L for class OFBsnGentableSetBucketsSizeVer13
+                   return OFBsnGentableSetBucketsSizeVer13.READER.readFrom(bb);
+               case 0x34:
+                   // discriminator value 0x34L=0x34L for class OFBsnGetSwitchPipelineReplyVer13
+                   return OFBsnGetSwitchPipelineReplyVer13.READER.readFrom(bb);
+               case 0x33:
+                   // discriminator value 0x33L=0x33L for class OFBsnGetSwitchPipelineRequestVer13
+                   return OFBsnGetSwitchPipelineRequestVer13.READER.readFrom(bb);
+               case 0x2b:
+                   // discriminator value 0x2bL=0x2bL for class OFBsnLacpConvergenceNotifVer13
+                   return OFBsnLacpConvergenceNotifVer13.READER.readFrom(bb);
+               case 0x3f:
+                   // discriminator value 0x3fL=0x3fL for class OFBsnLogVer13
+                   return OFBsnLogVer13.READER.readFrom(bb);
+               case 0x37:
+                   // discriminator value 0x37L=0x37L for class OFBsnRoleStatusVer13
+                   return OFBsnRoleStatusVer13.READER.readFrom(bb);
+               case 0x3b:
+                   // discriminator value 0x3bL=0x3bL for class OFBsnSetAuxCxnsReplyVer13
+                   return OFBsnSetAuxCxnsReplyVer13.READER.readFrom(bb);
+               case 0x3a:
+                   // discriminator value 0x3aL=0x3aL for class OFBsnSetAuxCxnsRequestVer13
+                   return OFBsnSetAuxCxnsRequestVer13.READER.readFrom(bb);
+               case 0x2a:
+                   // discriminator value 0x2aL=0x2aL for class OFBsnSetLacpReplyVer13
+                   return OFBsnSetLacpReplyVer13.READER.readFrom(bb);
+               case 0x29:
+                   // discriminator value 0x29L=0x29L for class OFBsnSetLacpRequestVer13
+                   return OFBsnSetLacpRequestVer13.READER.readFrom(bb);
+               case 0x36:
+                   // discriminator value 0x36L=0x36L for class OFBsnSetSwitchPipelineReplyVer13
+                   return OFBsnSetSwitchPipelineReplyVer13.READER.readFrom(bb);
+               case 0x35:
+                   // discriminator value 0x35L=0x35L for class OFBsnSetSwitchPipelineRequestVer13
+                   return OFBsnSetSwitchPipelineRequestVer13.READER.readFrom(bb);
+               case 0x3d:
+                   // discriminator value 0x3dL=0x3dL for class OFBsnTableSetBucketsSizeVer13
+                   return OFBsnTableSetBucketsSizeVer13.READER.readFrom(bb);
+               case 0x2d:
+                   // discriminator value 0x2dL=0x2dL for class OFBsnTimeReplyVer13
+                   return OFBsnTimeReplyVer13.READER.readFrom(bb);
+               case 0x2c:
+                   // discriminator value 0x2cL=0x2cL for class OFBsnTimeRequestVer13
+                   return OFBsnTimeRequestVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnHeaderVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnImageDescStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnImageDescStatsReplyVer13.java
new file mode 100644
index 0000000..d1e1551
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnImageDescStatsReplyVer13.java
@@ -0,0 +1,505 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnImageDescStatsReplyVer13 implements OFBsnImageDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnImageDescStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 536;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static String DEFAULT_IMAGE_CHECKSUM = "";
+        private final static String DEFAULT_STARTUP_CONFIG_CHECKSUM = "";
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final String imageChecksum;
+    private final String startupConfigChecksum;
+//
+    // Immutable default instance
+    final static OFBsnImageDescStatsReplyVer13 DEFAULT = new OFBsnImageDescStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_IMAGE_CHECKSUM, DEFAULT_STARTUP_CONFIG_CHECKSUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnImageDescStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, String imageChecksum, String startupConfigChecksum) {
+        this.xid = xid;
+        this.flags = flags;
+        this.imageChecksum = imageChecksum;
+        this.startupConfigChecksum = startupConfigChecksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+    @Override
+    public String getImageChecksum() {
+        return imageChecksum;
+    }
+
+    @Override
+    public String getStartupConfigChecksum() {
+        return startupConfigChecksum;
+    }
+
+
+
+    public OFBsnImageDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnImageDescStatsReply.Builder {
+        final OFBsnImageDescStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean imageChecksumSet;
+        private String imageChecksum;
+        private boolean startupConfigChecksumSet;
+        private String startupConfigChecksum;
+
+        BuilderWithParent(OFBsnImageDescStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnImageDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnImageDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+    @Override
+    public String getImageChecksum() {
+        return imageChecksum;
+    }
+
+    @Override
+    public OFBsnImageDescStatsReply.Builder setImageChecksum(String imageChecksum) {
+        this.imageChecksum = imageChecksum;
+        this.imageChecksumSet = true;
+        return this;
+    }
+    @Override
+    public String getStartupConfigChecksum() {
+        return startupConfigChecksum;
+    }
+
+    @Override
+    public OFBsnImageDescStatsReply.Builder setStartupConfigChecksum(String startupConfigChecksum) {
+        this.startupConfigChecksum = startupConfigChecksum;
+        this.startupConfigChecksumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnImageDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                String imageChecksum = this.imageChecksumSet ? this.imageChecksum : parentMessage.imageChecksum;
+                if(imageChecksum == null)
+                    throw new NullPointerException("Property imageChecksum must not be null");
+                String startupConfigChecksum = this.startupConfigChecksumSet ? this.startupConfigChecksum : parentMessage.startupConfigChecksum;
+                if(startupConfigChecksum == null)
+                    throw new NullPointerException("Property startupConfigChecksum must not be null");
+
+                //
+                return new OFBsnImageDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    imageChecksum,
+                    startupConfigChecksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnImageDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean imageChecksumSet;
+        private String imageChecksum;
+        private boolean startupConfigChecksumSet;
+        private String startupConfigChecksum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnImageDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnImageDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+    @Override
+    public String getImageChecksum() {
+        return imageChecksum;
+    }
+
+    @Override
+    public OFBsnImageDescStatsReply.Builder setImageChecksum(String imageChecksum) {
+        this.imageChecksum = imageChecksum;
+        this.imageChecksumSet = true;
+        return this;
+    }
+    @Override
+    public String getStartupConfigChecksum() {
+        return startupConfigChecksum;
+    }
+
+    @Override
+    public OFBsnImageDescStatsReply.Builder setStartupConfigChecksum(String startupConfigChecksum) {
+        this.startupConfigChecksum = startupConfigChecksum;
+        this.startupConfigChecksumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnImageDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            String imageChecksum = this.imageChecksumSet ? this.imageChecksum : DEFAULT_IMAGE_CHECKSUM;
+            if(imageChecksum == null)
+                throw new NullPointerException("Property imageChecksum must not be null");
+            String startupConfigChecksum = this.startupConfigChecksumSet ? this.startupConfigChecksum : DEFAULT_STARTUP_CONFIG_CHECKSUM;
+            if(startupConfigChecksum == null)
+                throw new NullPointerException("Property startupConfigChecksum must not be null");
+
+
+            return new OFBsnImageDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    imageChecksum,
+                    startupConfigChecksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnImageDescStatsReply> {
+        @Override
+        public OFBsnImageDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 536)
+                throw new OFParseError("Wrong length: Expected=536(536), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xeL
+            int subtype = bb.readInt();
+            if(subtype != 0xe)
+                throw new OFParseError("Wrong subtype: Expected=0xeL(0xeL), got="+subtype);
+            String imageChecksum = ChannelUtils.readFixedLengthString(bb, 256);
+            String startupConfigChecksum = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFBsnImageDescStatsReplyVer13 bsnImageDescStatsReplyVer13 = new OFBsnImageDescStatsReplyVer13(
+                    xid,
+                      flags,
+                      imageChecksum,
+                      startupConfigChecksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnImageDescStatsReplyVer13);
+            return bsnImageDescStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnImageDescStatsReplyVer13Funnel FUNNEL = new OFBsnImageDescStatsReplyVer13Funnel();
+    static class OFBsnImageDescStatsReplyVer13Funnel implements Funnel<OFBsnImageDescStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnImageDescStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 536
+            sink.putShort((short) 0x218);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xeL
+            sink.putInt(0xe);
+            sink.putUnencodedChars(message.imageChecksum);
+            sink.putUnencodedChars(message.startupConfigChecksum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnImageDescStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnImageDescStatsReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 536
+            bb.writeShort((short) 0x218);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xeL
+            bb.writeInt(0xe);
+            ChannelUtils.writeFixedLengthString(bb, message.imageChecksum, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.startupConfigChecksum, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnImageDescStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("imageChecksum=").append(imageChecksum);
+        b.append(", ");
+        b.append("startupConfigChecksum=").append(startupConfigChecksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnImageDescStatsReplyVer13 other = (OFBsnImageDescStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (imageChecksum == null) {
+            if (other.imageChecksum != null)
+                return false;
+        } else if (!imageChecksum.equals(other.imageChecksum))
+            return false;
+        if (startupConfigChecksum == null) {
+            if (other.startupConfigChecksum != null)
+                return false;
+        } else if (!startupConfigChecksum.equals(other.startupConfigChecksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((imageChecksum == null) ? 0 : imageChecksum.hashCode());
+        result = prime * result + ((startupConfigChecksum == null) ? 0 : startupConfigChecksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnImageDescStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnImageDescStatsRequestVer13.java
new file mode 100644
index 0000000..ee1dc59
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnImageDescStatsRequestVer13.java
@@ -0,0 +1,397 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnImageDescStatsRequestVer13 implements OFBsnImageDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnImageDescStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFBsnImageDescStatsRequestVer13 DEFAULT = new OFBsnImageDescStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnImageDescStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+
+
+    public OFBsnImageDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnImageDescStatsRequest.Builder {
+        final OFBsnImageDescStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFBsnImageDescStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnImageDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnImageDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+
+
+        @Override
+        public OFBsnImageDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFBsnImageDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnImageDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnImageDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnImageDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xeL;
+    }
+
+//
+        @Override
+        public OFBsnImageDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFBsnImageDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnImageDescStatsRequest> {
+        @Override
+        public OFBsnImageDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xeL
+            int subtype = bb.readInt();
+            if(subtype != 0xe)
+                throw new OFParseError("Wrong subtype: Expected=0xeL(0xeL), got="+subtype);
+
+            OFBsnImageDescStatsRequestVer13 bsnImageDescStatsRequestVer13 = new OFBsnImageDescStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnImageDescStatsRequestVer13);
+            return bsnImageDescStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnImageDescStatsRequestVer13Funnel FUNNEL = new OFBsnImageDescStatsRequestVer13Funnel();
+    static class OFBsnImageDescStatsRequestVer13Funnel implements Funnel<OFBsnImageDescStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnImageDescStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xeL
+            sink.putInt(0xe);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnImageDescStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnImageDescStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xeL
+            bb.writeInt(0xe);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnImageDescStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnImageDescStatsRequestVer13 other = (OFBsnImageDescStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnInterfaceVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnInterfaceVer13.java
new file mode 100644
index 0000000..006e83f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnInterfaceVer13.java
@@ -0,0 +1,396 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnInterfaceVer13 implements OFBsnInterface {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnInterfaceVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static String DEFAULT_NAME = "";
+        private final static IPv4Address DEFAULT_IPV4_ADDR = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_IPV4_NETMASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final MacAddress hwAddr;
+    private final String name;
+    private final IPv4Address ipv4Addr;
+    private final IPv4Address ipv4Netmask;
+//
+    // Immutable default instance
+    final static OFBsnInterfaceVer13 DEFAULT = new OFBsnInterfaceVer13(
+        DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_IPV4_ADDR, DEFAULT_IPV4_NETMASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnInterfaceVer13(MacAddress hwAddr, String name, IPv4Address ipv4Addr, IPv4Address ipv4Netmask) {
+        this.hwAddr = hwAddr;
+        this.name = name;
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4Netmask = ipv4Netmask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnInterface.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnInterface.Builder {
+        final OFBsnInterfaceVer13 parentMessage;
+
+        // OF message fields
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+        private boolean ipv4NetmaskSet;
+        private IPv4Address ipv4Netmask;
+
+        BuilderWithParent(OFBsnInterfaceVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) {
+        this.ipv4Netmask = ipv4Netmask;
+        this.ipv4NetmaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnInterface build() {
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : parentMessage.ipv4Addr;
+                if(ipv4Addr == null)
+                    throw new NullPointerException("Property ipv4Addr must not be null");
+                IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : parentMessage.ipv4Netmask;
+                if(ipv4Netmask == null)
+                    throw new NullPointerException("Property ipv4Netmask must not be null");
+
+                //
+                return new OFBsnInterfaceVer13(
+                    hwAddr,
+                    name,
+                    ipv4Addr,
+                    ipv4Netmask
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnInterface.Builder {
+        // OF message fields
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean ipv4AddrSet;
+        private IPv4Address ipv4Addr;
+        private boolean ipv4NetmaskSet;
+        private IPv4Address ipv4Netmask;
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Addr() {
+        return ipv4Addr;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) {
+        this.ipv4Addr = ipv4Addr;
+        this.ipv4AddrSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getIpv4Netmask() {
+        return ipv4Netmask;
+    }
+
+    @Override
+    public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) {
+        this.ipv4Netmask = ipv4Netmask;
+        this.ipv4NetmaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnInterface build() {
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : DEFAULT_IPV4_ADDR;
+            if(ipv4Addr == null)
+                throw new NullPointerException("Property ipv4Addr must not be null");
+            IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : DEFAULT_IPV4_NETMASK;
+            if(ipv4Netmask == null)
+                throw new NullPointerException("Property ipv4Netmask must not be null");
+
+
+            return new OFBsnInterfaceVer13(
+                    hwAddr,
+                    name,
+                    ipv4Addr,
+                    ipv4Netmask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnInterface> {
+        @Override
+        public OFBsnInterface readFrom(ChannelBuffer bb) throws OFParseError {
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            String name = ChannelUtils.readFixedLengthString(bb, 16);
+            IPv4Address ipv4Addr = IPv4Address.read4Bytes(bb);
+            IPv4Address ipv4Netmask = IPv4Address.read4Bytes(bb);
+
+            OFBsnInterfaceVer13 bsnInterfaceVer13 = new OFBsnInterfaceVer13(
+                    hwAddr,
+                      name,
+                      ipv4Addr,
+                      ipv4Netmask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnInterfaceVer13);
+            return bsnInterfaceVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnInterfaceVer13Funnel FUNNEL = new OFBsnInterfaceVer13Funnel();
+    static class OFBsnInterfaceVer13Funnel implements Funnel<OFBsnInterfaceVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnInterfaceVer13 message, PrimitiveSink sink) {
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putUnencodedChars(message.name);
+            message.ipv4Addr.putTo(sink);
+            message.ipv4Netmask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnInterfaceVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnInterfaceVer13 message) {
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 16);
+            message.ipv4Addr.write4Bytes(bb);
+            message.ipv4Netmask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnInterfaceVer13(");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("ipv4Addr=").append(ipv4Addr);
+        b.append(", ");
+        b.append("ipv4Netmask=").append(ipv4Netmask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnInterfaceVer13 other = (OFBsnInterfaceVer13) obj;
+
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (ipv4Addr == null) {
+            if (other.ipv4Addr != null)
+                return false;
+        } else if (!ipv4Addr.equals(other.ipv4Addr))
+            return false;
+        if (ipv4Netmask == null) {
+            if (other.ipv4Netmask != null)
+                return false;
+        } else if (!ipv4Netmask.equals(other.ipv4Netmask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((ipv4Addr == null) ? 0 : ipv4Addr.hashCode());
+        result = prime * result + ((ipv4Netmask == null) ? 0 : ipv4Netmask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpConvergenceNotifVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpConvergenceNotifVer13.java
new file mode 100644
index 0000000..cef593e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpConvergenceNotifVer13.java
@@ -0,0 +1,904 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnLacpConvergenceNotifVer13 implements OFBsnLacpConvergenceNotif {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnLacpConvergenceNotifVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 52;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_CONVERGENCE_STATUS = (short) 0x0;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static int DEFAULT_ACTOR_SYS_PRIORITY = 0x0;
+        private final static MacAddress DEFAULT_ACTOR_SYS_MAC = MacAddress.NONE;
+        private final static int DEFAULT_ACTOR_PORT_PRIORITY = 0x0;
+        private final static int DEFAULT_ACTOR_PORT_NUM = 0x0;
+        private final static int DEFAULT_ACTOR_KEY = 0x0;
+        private final static int DEFAULT_PARTNER_SYS_PRIORITY = 0x0;
+        private final static MacAddress DEFAULT_PARTNER_SYS_MAC = MacAddress.NONE;
+        private final static int DEFAULT_PARTNER_PORT_PRIORITY = 0x0;
+        private final static int DEFAULT_PARTNER_PORT_NUM = 0x0;
+        private final static int DEFAULT_PARTNER_KEY = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short convergenceStatus;
+    private final OFPort portNo;
+    private final int actorSysPriority;
+    private final MacAddress actorSysMac;
+    private final int actorPortPriority;
+    private final int actorPortNum;
+    private final int actorKey;
+    private final int partnerSysPriority;
+    private final MacAddress partnerSysMac;
+    private final int partnerPortPriority;
+    private final int partnerPortNum;
+    private final int partnerKey;
+//
+    // Immutable default instance
+    final static OFBsnLacpConvergenceNotifVer13 DEFAULT = new OFBsnLacpConvergenceNotifVer13(
+        DEFAULT_XID, DEFAULT_CONVERGENCE_STATUS, DEFAULT_PORT_NO, DEFAULT_ACTOR_SYS_PRIORITY, DEFAULT_ACTOR_SYS_MAC, DEFAULT_ACTOR_PORT_PRIORITY, DEFAULT_ACTOR_PORT_NUM, DEFAULT_ACTOR_KEY, DEFAULT_PARTNER_SYS_PRIORITY, DEFAULT_PARTNER_SYS_MAC, DEFAULT_PARTNER_PORT_PRIORITY, DEFAULT_PARTNER_PORT_NUM, DEFAULT_PARTNER_KEY
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnLacpConvergenceNotifVer13(long xid, short convergenceStatus, OFPort portNo, int actorSysPriority, MacAddress actorSysMac, int actorPortPriority, int actorPortNum, int actorKey, int partnerSysPriority, MacAddress partnerSysMac, int partnerPortPriority, int partnerPortNum, int partnerKey) {
+        this.xid = xid;
+        this.convergenceStatus = convergenceStatus;
+        this.portNo = portNo;
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysMac = actorSysMac;
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortNum = actorPortNum;
+        this.actorKey = actorKey;
+        this.partnerSysPriority = partnerSysPriority;
+        this.partnerSysMac = partnerSysMac;
+        this.partnerPortPriority = partnerPortPriority;
+        this.partnerPortNum = partnerPortNum;
+        this.partnerKey = partnerKey;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2bL;
+    }
+
+    @Override
+    public short getConvergenceStatus() {
+        return convergenceStatus;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+    @Override
+    public int getPartnerSysPriority() {
+        return partnerSysPriority;
+    }
+
+    @Override
+    public MacAddress getPartnerSysMac() {
+        return partnerSysMac;
+    }
+
+    @Override
+    public int getPartnerPortPriority() {
+        return partnerPortPriority;
+    }
+
+    @Override
+    public int getPartnerPortNum() {
+        return partnerPortNum;
+    }
+
+    @Override
+    public int getPartnerKey() {
+        return partnerKey;
+    }
+
+
+
+    public OFBsnLacpConvergenceNotif.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnLacpConvergenceNotif.Builder {
+        final OFBsnLacpConvergenceNotifVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean convergenceStatusSet;
+        private short convergenceStatus;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean actorSysPrioritySet;
+        private int actorSysPriority;
+        private boolean actorSysMacSet;
+        private MacAddress actorSysMac;
+        private boolean actorPortPrioritySet;
+        private int actorPortPriority;
+        private boolean actorPortNumSet;
+        private int actorPortNum;
+        private boolean actorKeySet;
+        private int actorKey;
+        private boolean partnerSysPrioritySet;
+        private int partnerSysPriority;
+        private boolean partnerSysMacSet;
+        private MacAddress partnerSysMac;
+        private boolean partnerPortPrioritySet;
+        private int partnerPortPriority;
+        private boolean partnerPortNumSet;
+        private int partnerPortNum;
+        private boolean partnerKeySet;
+        private int partnerKey;
+
+        BuilderWithParent(OFBsnLacpConvergenceNotifVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2bL;
+    }
+
+    @Override
+    public short getConvergenceStatus() {
+        return convergenceStatus;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setConvergenceStatus(short convergenceStatus) {
+        this.convergenceStatus = convergenceStatus;
+        this.convergenceStatusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorSysPriority(int actorSysPriority) {
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorSysMac(MacAddress actorSysMac) {
+        this.actorSysMac = actorSysMac;
+        this.actorSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorPortPriority(int actorPortPriority) {
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorPortNum(int actorPortNum) {
+        this.actorPortNum = actorPortNum;
+        this.actorPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorKey(int actorKey) {
+        this.actorKey = actorKey;
+        this.actorKeySet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerSysPriority() {
+        return partnerSysPriority;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerSysPriority(int partnerSysPriority) {
+        this.partnerSysPriority = partnerSysPriority;
+        this.partnerSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getPartnerSysMac() {
+        return partnerSysMac;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerSysMac(MacAddress partnerSysMac) {
+        this.partnerSysMac = partnerSysMac;
+        this.partnerSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerPortPriority() {
+        return partnerPortPriority;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerPortPriority(int partnerPortPriority) {
+        this.partnerPortPriority = partnerPortPriority;
+        this.partnerPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerPortNum() {
+        return partnerPortNum;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerPortNum(int partnerPortNum) {
+        this.partnerPortNum = partnerPortNum;
+        this.partnerPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerKey() {
+        return partnerKey;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerKey(int partnerKey) {
+        this.partnerKey = partnerKey;
+        this.partnerKeySet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnLacpConvergenceNotif build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short convergenceStatus = this.convergenceStatusSet ? this.convergenceStatus : parentMessage.convergenceStatus;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                int actorSysPriority = this.actorSysPrioritySet ? this.actorSysPriority : parentMessage.actorSysPriority;
+                MacAddress actorSysMac = this.actorSysMacSet ? this.actorSysMac : parentMessage.actorSysMac;
+                if(actorSysMac == null)
+                    throw new NullPointerException("Property actorSysMac must not be null");
+                int actorPortPriority = this.actorPortPrioritySet ? this.actorPortPriority : parentMessage.actorPortPriority;
+                int actorPortNum = this.actorPortNumSet ? this.actorPortNum : parentMessage.actorPortNum;
+                int actorKey = this.actorKeySet ? this.actorKey : parentMessage.actorKey;
+                int partnerSysPriority = this.partnerSysPrioritySet ? this.partnerSysPriority : parentMessage.partnerSysPriority;
+                MacAddress partnerSysMac = this.partnerSysMacSet ? this.partnerSysMac : parentMessage.partnerSysMac;
+                if(partnerSysMac == null)
+                    throw new NullPointerException("Property partnerSysMac must not be null");
+                int partnerPortPriority = this.partnerPortPrioritySet ? this.partnerPortPriority : parentMessage.partnerPortPriority;
+                int partnerPortNum = this.partnerPortNumSet ? this.partnerPortNum : parentMessage.partnerPortNum;
+                int partnerKey = this.partnerKeySet ? this.partnerKey : parentMessage.partnerKey;
+
+                //
+                return new OFBsnLacpConvergenceNotifVer13(
+                    xid,
+                    convergenceStatus,
+                    portNo,
+                    actorSysPriority,
+                    actorSysMac,
+                    actorPortPriority,
+                    actorPortNum,
+                    actorKey,
+                    partnerSysPriority,
+                    partnerSysMac,
+                    partnerPortPriority,
+                    partnerPortNum,
+                    partnerKey
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnLacpConvergenceNotif.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean convergenceStatusSet;
+        private short convergenceStatus;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean actorSysPrioritySet;
+        private int actorSysPriority;
+        private boolean actorSysMacSet;
+        private MacAddress actorSysMac;
+        private boolean actorPortPrioritySet;
+        private int actorPortPriority;
+        private boolean actorPortNumSet;
+        private int actorPortNum;
+        private boolean actorKeySet;
+        private int actorKey;
+        private boolean partnerSysPrioritySet;
+        private int partnerSysPriority;
+        private boolean partnerSysMacSet;
+        private MacAddress partnerSysMac;
+        private boolean partnerPortPrioritySet;
+        private int partnerPortPriority;
+        private boolean partnerPortNumSet;
+        private int partnerPortNum;
+        private boolean partnerKeySet;
+        private int partnerKey;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2bL;
+    }
+
+    @Override
+    public short getConvergenceStatus() {
+        return convergenceStatus;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setConvergenceStatus(short convergenceStatus) {
+        this.convergenceStatus = convergenceStatus;
+        this.convergenceStatusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorSysPriority(int actorSysPriority) {
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorSysMac(MacAddress actorSysMac) {
+        this.actorSysMac = actorSysMac;
+        this.actorSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorPortPriority(int actorPortPriority) {
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorPortNum(int actorPortNum) {
+        this.actorPortNum = actorPortNum;
+        this.actorPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setActorKey(int actorKey) {
+        this.actorKey = actorKey;
+        this.actorKeySet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerSysPriority() {
+        return partnerSysPriority;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerSysPriority(int partnerSysPriority) {
+        this.partnerSysPriority = partnerSysPriority;
+        this.partnerSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getPartnerSysMac() {
+        return partnerSysMac;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerSysMac(MacAddress partnerSysMac) {
+        this.partnerSysMac = partnerSysMac;
+        this.partnerSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerPortPriority() {
+        return partnerPortPriority;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerPortPriority(int partnerPortPriority) {
+        this.partnerPortPriority = partnerPortPriority;
+        this.partnerPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerPortNum() {
+        return partnerPortNum;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerPortNum(int partnerPortNum) {
+        this.partnerPortNum = partnerPortNum;
+        this.partnerPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerKey() {
+        return partnerKey;
+    }
+
+    @Override
+    public OFBsnLacpConvergenceNotif.Builder setPartnerKey(int partnerKey) {
+        this.partnerKey = partnerKey;
+        this.partnerKeySet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnLacpConvergenceNotif build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short convergenceStatus = this.convergenceStatusSet ? this.convergenceStatus : DEFAULT_CONVERGENCE_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            int actorSysPriority = this.actorSysPrioritySet ? this.actorSysPriority : DEFAULT_ACTOR_SYS_PRIORITY;
+            MacAddress actorSysMac = this.actorSysMacSet ? this.actorSysMac : DEFAULT_ACTOR_SYS_MAC;
+            if(actorSysMac == null)
+                throw new NullPointerException("Property actorSysMac must not be null");
+            int actorPortPriority = this.actorPortPrioritySet ? this.actorPortPriority : DEFAULT_ACTOR_PORT_PRIORITY;
+            int actorPortNum = this.actorPortNumSet ? this.actorPortNum : DEFAULT_ACTOR_PORT_NUM;
+            int actorKey = this.actorKeySet ? this.actorKey : DEFAULT_ACTOR_KEY;
+            int partnerSysPriority = this.partnerSysPrioritySet ? this.partnerSysPriority : DEFAULT_PARTNER_SYS_PRIORITY;
+            MacAddress partnerSysMac = this.partnerSysMacSet ? this.partnerSysMac : DEFAULT_PARTNER_SYS_MAC;
+            if(partnerSysMac == null)
+                throw new NullPointerException("Property partnerSysMac must not be null");
+            int partnerPortPriority = this.partnerPortPrioritySet ? this.partnerPortPriority : DEFAULT_PARTNER_PORT_PRIORITY;
+            int partnerPortNum = this.partnerPortNumSet ? this.partnerPortNum : DEFAULT_PARTNER_PORT_NUM;
+            int partnerKey = this.partnerKeySet ? this.partnerKey : DEFAULT_PARTNER_KEY;
+
+
+            return new OFBsnLacpConvergenceNotifVer13(
+                    xid,
+                    convergenceStatus,
+                    portNo,
+                    actorSysPriority,
+                    actorSysMac,
+                    actorPortPriority,
+                    actorPortNum,
+                    actorKey,
+                    partnerSysPriority,
+                    partnerSysMac,
+                    partnerPortPriority,
+                    partnerPortNum,
+                    partnerKey
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnLacpConvergenceNotif> {
+        @Override
+        public OFBsnLacpConvergenceNotif readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 52)
+                throw new OFParseError("Wrong length: Expected=52(52), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2bL
+            int subtype = bb.readInt();
+            if(subtype != 0x2b)
+                throw new OFParseError("Wrong subtype: Expected=0x2bL(0x2bL), got="+subtype);
+            short convergenceStatus = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            int actorSysPriority = U16.f(bb.readShort());
+            MacAddress actorSysMac = MacAddress.read6Bytes(bb);
+            int actorPortPriority = U16.f(bb.readShort());
+            int actorPortNum = U16.f(bb.readShort());
+            int actorKey = U16.f(bb.readShort());
+            int partnerSysPriority = U16.f(bb.readShort());
+            MacAddress partnerSysMac = MacAddress.read6Bytes(bb);
+            int partnerPortPriority = U16.f(bb.readShort());
+            int partnerPortNum = U16.f(bb.readShort());
+            int partnerKey = U16.f(bb.readShort());
+
+            OFBsnLacpConvergenceNotifVer13 bsnLacpConvergenceNotifVer13 = new OFBsnLacpConvergenceNotifVer13(
+                    xid,
+                      convergenceStatus,
+                      portNo,
+                      actorSysPriority,
+                      actorSysMac,
+                      actorPortPriority,
+                      actorPortNum,
+                      actorKey,
+                      partnerSysPriority,
+                      partnerSysMac,
+                      partnerPortPriority,
+                      partnerPortNum,
+                      partnerKey
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnLacpConvergenceNotifVer13);
+            return bsnLacpConvergenceNotifVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnLacpConvergenceNotifVer13Funnel FUNNEL = new OFBsnLacpConvergenceNotifVer13Funnel();
+    static class OFBsnLacpConvergenceNotifVer13Funnel implements Funnel<OFBsnLacpConvergenceNotifVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnLacpConvergenceNotifVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 52
+            sink.putShort((short) 0x34);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2bL
+            sink.putInt(0x2b);
+            sink.putShort(message.convergenceStatus);
+            // skip pad (3 bytes)
+            message.portNo.putTo(sink);
+            sink.putInt(message.actorSysPriority);
+            message.actorSysMac.putTo(sink);
+            sink.putInt(message.actorPortPriority);
+            sink.putInt(message.actorPortNum);
+            sink.putInt(message.actorKey);
+            sink.putInt(message.partnerSysPriority);
+            message.partnerSysMac.putTo(sink);
+            sink.putInt(message.partnerPortPriority);
+            sink.putInt(message.partnerPortNum);
+            sink.putInt(message.partnerKey);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnLacpConvergenceNotifVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnLacpConvergenceNotifVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 52
+            bb.writeShort((short) 0x34);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2bL
+            bb.writeInt(0x2b);
+            bb.writeByte(U8.t(message.convergenceStatus));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            message.portNo.write4Bytes(bb);
+            bb.writeShort(U16.t(message.actorSysPriority));
+            message.actorSysMac.write6Bytes(bb);
+            bb.writeShort(U16.t(message.actorPortPriority));
+            bb.writeShort(U16.t(message.actorPortNum));
+            bb.writeShort(U16.t(message.actorKey));
+            bb.writeShort(U16.t(message.partnerSysPriority));
+            message.partnerSysMac.write6Bytes(bb);
+            bb.writeShort(U16.t(message.partnerPortPriority));
+            bb.writeShort(U16.t(message.partnerPortNum));
+            bb.writeShort(U16.t(message.partnerKey));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnLacpConvergenceNotifVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("convergenceStatus=").append(convergenceStatus);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("actorSysPriority=").append(actorSysPriority);
+        b.append(", ");
+        b.append("actorSysMac=").append(actorSysMac);
+        b.append(", ");
+        b.append("actorPortPriority=").append(actorPortPriority);
+        b.append(", ");
+        b.append("actorPortNum=").append(actorPortNum);
+        b.append(", ");
+        b.append("actorKey=").append(actorKey);
+        b.append(", ");
+        b.append("partnerSysPriority=").append(partnerSysPriority);
+        b.append(", ");
+        b.append("partnerSysMac=").append(partnerSysMac);
+        b.append(", ");
+        b.append("partnerPortPriority=").append(partnerPortPriority);
+        b.append(", ");
+        b.append("partnerPortNum=").append(partnerPortNum);
+        b.append(", ");
+        b.append("partnerKey=").append(partnerKey);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnLacpConvergenceNotifVer13 other = (OFBsnLacpConvergenceNotifVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( convergenceStatus != other.convergenceStatus)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( actorSysPriority != other.actorSysPriority)
+            return false;
+        if (actorSysMac == null) {
+            if (other.actorSysMac != null)
+                return false;
+        } else if (!actorSysMac.equals(other.actorSysMac))
+            return false;
+        if( actorPortPriority != other.actorPortPriority)
+            return false;
+        if( actorPortNum != other.actorPortNum)
+            return false;
+        if( actorKey != other.actorKey)
+            return false;
+        if( partnerSysPriority != other.partnerSysPriority)
+            return false;
+        if (partnerSysMac == null) {
+            if (other.partnerSysMac != null)
+                return false;
+        } else if (!partnerSysMac.equals(other.partnerSysMac))
+            return false;
+        if( partnerPortPriority != other.partnerPortPriority)
+            return false;
+        if( partnerPortNum != other.partnerPortNum)
+            return false;
+        if( partnerKey != other.partnerKey)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + convergenceStatus;
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + actorSysPriority;
+        result = prime * result + ((actorSysMac == null) ? 0 : actorSysMac.hashCode());
+        result = prime * result + actorPortPriority;
+        result = prime * result + actorPortNum;
+        result = prime * result + actorKey;
+        result = prime * result + partnerSysPriority;
+        result = prime * result + ((partnerSysMac == null) ? 0 : partnerSysMac.hashCode());
+        result = prime * result + partnerPortPriority;
+        result = prime * result + partnerPortNum;
+        result = prime * result + partnerKey;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpConvergenceStatusTSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpConvergenceStatusTSerializerVer13.java
new file mode 100644
index 0000000..e60dc25
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpConvergenceStatusTSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnLacpConvergenceStatusT;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnLacpConvergenceStatusTSerializerVer13 {
+
+    public final static byte SUCCESS_VAL = (byte) 0x0;
+    public final static byte TIMEDOUT_VAL = (byte) 0x1;
+    public final static byte OUT_OF_SYNC_VAL = (byte) 0x2;
+
+    public static OFBsnLacpConvergenceStatusT readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnLacpConvergenceStatusT e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnLacpConvergenceStatusT e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnLacpConvergenceStatusT ofWireValue(byte val) {
+        switch(val) {
+            case SUCCESS_VAL:
+                return OFBsnLacpConvergenceStatusT.SUCCESS;
+            case TIMEDOUT_VAL:
+                return OFBsnLacpConvergenceStatusT.TIMEDOUT;
+            case OUT_OF_SYNC_VAL:
+                return OFBsnLacpConvergenceStatusT.OUT_OF_SYNC;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnLacpConvergenceStatusT in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnLacpConvergenceStatusT e) {
+        switch(e) {
+            case SUCCESS:
+                return SUCCESS_VAL;
+            case TIMEDOUT:
+                return TIMEDOUT_VAL;
+            case OUT_OF_SYNC:
+                return OUT_OF_SYNC_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnLacpConvergenceStatusT in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsEntryVer13.java
new file mode 100644
index 0000000..6d0ac70
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsEntryVer13.java
@@ -0,0 +1,770 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnLacpStatsEntryVer13 implements OFBsnLacpStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnLacpStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 36;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static int DEFAULT_ACTOR_SYS_PRIORITY = 0x0;
+        private final static MacAddress DEFAULT_ACTOR_SYS_MAC = MacAddress.NONE;
+        private final static int DEFAULT_ACTOR_PORT_PRIORITY = 0x0;
+        private final static int DEFAULT_ACTOR_PORT_NUM = 0x0;
+        private final static int DEFAULT_ACTOR_KEY = 0x0;
+        private final static short DEFAULT_CONVERGENCE_STATUS = (short) 0x0;
+        private final static int DEFAULT_PARTNER_SYS_PRIORITY = 0x0;
+        private final static MacAddress DEFAULT_PARTNER_SYS_MAC = MacAddress.NONE;
+        private final static int DEFAULT_PARTNER_PORT_PRIORITY = 0x0;
+        private final static int DEFAULT_PARTNER_PORT_NUM = 0x0;
+        private final static int DEFAULT_PARTNER_KEY = 0x0;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final int actorSysPriority;
+    private final MacAddress actorSysMac;
+    private final int actorPortPriority;
+    private final int actorPortNum;
+    private final int actorKey;
+    private final short convergenceStatus;
+    private final int partnerSysPriority;
+    private final MacAddress partnerSysMac;
+    private final int partnerPortPriority;
+    private final int partnerPortNum;
+    private final int partnerKey;
+//
+    // Immutable default instance
+    final static OFBsnLacpStatsEntryVer13 DEFAULT = new OFBsnLacpStatsEntryVer13(
+        DEFAULT_PORT_NO, DEFAULT_ACTOR_SYS_PRIORITY, DEFAULT_ACTOR_SYS_MAC, DEFAULT_ACTOR_PORT_PRIORITY, DEFAULT_ACTOR_PORT_NUM, DEFAULT_ACTOR_KEY, DEFAULT_CONVERGENCE_STATUS, DEFAULT_PARTNER_SYS_PRIORITY, DEFAULT_PARTNER_SYS_MAC, DEFAULT_PARTNER_PORT_PRIORITY, DEFAULT_PARTNER_PORT_NUM, DEFAULT_PARTNER_KEY
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnLacpStatsEntryVer13(OFPort portNo, int actorSysPriority, MacAddress actorSysMac, int actorPortPriority, int actorPortNum, int actorKey, short convergenceStatus, int partnerSysPriority, MacAddress partnerSysMac, int partnerPortPriority, int partnerPortNum, int partnerKey) {
+        this.portNo = portNo;
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysMac = actorSysMac;
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortNum = actorPortNum;
+        this.actorKey = actorKey;
+        this.convergenceStatus = convergenceStatus;
+        this.partnerSysPriority = partnerSysPriority;
+        this.partnerSysMac = partnerSysMac;
+        this.partnerPortPriority = partnerPortPriority;
+        this.partnerPortNum = partnerPortNum;
+        this.partnerKey = partnerKey;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+    @Override
+    public short getConvergenceStatus() {
+        return convergenceStatus;
+    }
+
+    @Override
+    public int getPartnerSysPriority() {
+        return partnerSysPriority;
+    }
+
+    @Override
+    public MacAddress getPartnerSysMac() {
+        return partnerSysMac;
+    }
+
+    @Override
+    public int getPartnerPortPriority() {
+        return partnerPortPriority;
+    }
+
+    @Override
+    public int getPartnerPortNum() {
+        return partnerPortNum;
+    }
+
+    @Override
+    public int getPartnerKey() {
+        return partnerKey;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnLacpStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnLacpStatsEntry.Builder {
+        final OFBsnLacpStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean actorSysPrioritySet;
+        private int actorSysPriority;
+        private boolean actorSysMacSet;
+        private MacAddress actorSysMac;
+        private boolean actorPortPrioritySet;
+        private int actorPortPriority;
+        private boolean actorPortNumSet;
+        private int actorPortNum;
+        private boolean actorKeySet;
+        private int actorKey;
+        private boolean convergenceStatusSet;
+        private short convergenceStatus;
+        private boolean partnerSysPrioritySet;
+        private int partnerSysPriority;
+        private boolean partnerSysMacSet;
+        private MacAddress partnerSysMac;
+        private boolean partnerPortPrioritySet;
+        private int partnerPortPriority;
+        private boolean partnerPortNumSet;
+        private int partnerPortNum;
+        private boolean partnerKeySet;
+        private int partnerKey;
+
+        BuilderWithParent(OFBsnLacpStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorSysPriority(int actorSysPriority) {
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorSysMac(MacAddress actorSysMac) {
+        this.actorSysMac = actorSysMac;
+        this.actorSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorPortPriority(int actorPortPriority) {
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorPortNum(int actorPortNum) {
+        this.actorPortNum = actorPortNum;
+        this.actorPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorKey(int actorKey) {
+        this.actorKey = actorKey;
+        this.actorKeySet = true;
+        return this;
+    }
+    @Override
+    public short getConvergenceStatus() {
+        return convergenceStatus;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setConvergenceStatus(short convergenceStatus) {
+        this.convergenceStatus = convergenceStatus;
+        this.convergenceStatusSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerSysPriority() {
+        return partnerSysPriority;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerSysPriority(int partnerSysPriority) {
+        this.partnerSysPriority = partnerSysPriority;
+        this.partnerSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getPartnerSysMac() {
+        return partnerSysMac;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerSysMac(MacAddress partnerSysMac) {
+        this.partnerSysMac = partnerSysMac;
+        this.partnerSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerPortPriority() {
+        return partnerPortPriority;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerPortPriority(int partnerPortPriority) {
+        this.partnerPortPriority = partnerPortPriority;
+        this.partnerPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerPortNum() {
+        return partnerPortNum;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerPortNum(int partnerPortNum) {
+        this.partnerPortNum = partnerPortNum;
+        this.partnerPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerKey() {
+        return partnerKey;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerKey(int partnerKey) {
+        this.partnerKey = partnerKey;
+        this.partnerKeySet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnLacpStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                int actorSysPriority = this.actorSysPrioritySet ? this.actorSysPriority : parentMessage.actorSysPriority;
+                MacAddress actorSysMac = this.actorSysMacSet ? this.actorSysMac : parentMessage.actorSysMac;
+                if(actorSysMac == null)
+                    throw new NullPointerException("Property actorSysMac must not be null");
+                int actorPortPriority = this.actorPortPrioritySet ? this.actorPortPriority : parentMessage.actorPortPriority;
+                int actorPortNum = this.actorPortNumSet ? this.actorPortNum : parentMessage.actorPortNum;
+                int actorKey = this.actorKeySet ? this.actorKey : parentMessage.actorKey;
+                short convergenceStatus = this.convergenceStatusSet ? this.convergenceStatus : parentMessage.convergenceStatus;
+                int partnerSysPriority = this.partnerSysPrioritySet ? this.partnerSysPriority : parentMessage.partnerSysPriority;
+                MacAddress partnerSysMac = this.partnerSysMacSet ? this.partnerSysMac : parentMessage.partnerSysMac;
+                if(partnerSysMac == null)
+                    throw new NullPointerException("Property partnerSysMac must not be null");
+                int partnerPortPriority = this.partnerPortPrioritySet ? this.partnerPortPriority : parentMessage.partnerPortPriority;
+                int partnerPortNum = this.partnerPortNumSet ? this.partnerPortNum : parentMessage.partnerPortNum;
+                int partnerKey = this.partnerKeySet ? this.partnerKey : parentMessage.partnerKey;
+
+                //
+                return new OFBsnLacpStatsEntryVer13(
+                    portNo,
+                    actorSysPriority,
+                    actorSysMac,
+                    actorPortPriority,
+                    actorPortNum,
+                    actorKey,
+                    convergenceStatus,
+                    partnerSysPriority,
+                    partnerSysMac,
+                    partnerPortPriority,
+                    partnerPortNum,
+                    partnerKey
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnLacpStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean actorSysPrioritySet;
+        private int actorSysPriority;
+        private boolean actorSysMacSet;
+        private MacAddress actorSysMac;
+        private boolean actorPortPrioritySet;
+        private int actorPortPriority;
+        private boolean actorPortNumSet;
+        private int actorPortNum;
+        private boolean actorKeySet;
+        private int actorKey;
+        private boolean convergenceStatusSet;
+        private short convergenceStatus;
+        private boolean partnerSysPrioritySet;
+        private int partnerSysPriority;
+        private boolean partnerSysMacSet;
+        private MacAddress partnerSysMac;
+        private boolean partnerPortPrioritySet;
+        private int partnerPortPriority;
+        private boolean partnerPortNumSet;
+        private int partnerPortNum;
+        private boolean partnerKeySet;
+        private int partnerKey;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorSysPriority(int actorSysPriority) {
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorSysMac(MacAddress actorSysMac) {
+        this.actorSysMac = actorSysMac;
+        this.actorSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorPortPriority(int actorPortPriority) {
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorPortNum(int actorPortNum) {
+        this.actorPortNum = actorPortNum;
+        this.actorPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setActorKey(int actorKey) {
+        this.actorKey = actorKey;
+        this.actorKeySet = true;
+        return this;
+    }
+    @Override
+    public short getConvergenceStatus() {
+        return convergenceStatus;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setConvergenceStatus(short convergenceStatus) {
+        this.convergenceStatus = convergenceStatus;
+        this.convergenceStatusSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerSysPriority() {
+        return partnerSysPriority;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerSysPriority(int partnerSysPriority) {
+        this.partnerSysPriority = partnerSysPriority;
+        this.partnerSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getPartnerSysMac() {
+        return partnerSysMac;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerSysMac(MacAddress partnerSysMac) {
+        this.partnerSysMac = partnerSysMac;
+        this.partnerSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerPortPriority() {
+        return partnerPortPriority;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerPortPriority(int partnerPortPriority) {
+        this.partnerPortPriority = partnerPortPriority;
+        this.partnerPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerPortNum() {
+        return partnerPortNum;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerPortNum(int partnerPortNum) {
+        this.partnerPortNum = partnerPortNum;
+        this.partnerPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getPartnerKey() {
+        return partnerKey;
+    }
+
+    @Override
+    public OFBsnLacpStatsEntry.Builder setPartnerKey(int partnerKey) {
+        this.partnerKey = partnerKey;
+        this.partnerKeySet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnLacpStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            int actorSysPriority = this.actorSysPrioritySet ? this.actorSysPriority : DEFAULT_ACTOR_SYS_PRIORITY;
+            MacAddress actorSysMac = this.actorSysMacSet ? this.actorSysMac : DEFAULT_ACTOR_SYS_MAC;
+            if(actorSysMac == null)
+                throw new NullPointerException("Property actorSysMac must not be null");
+            int actorPortPriority = this.actorPortPrioritySet ? this.actorPortPriority : DEFAULT_ACTOR_PORT_PRIORITY;
+            int actorPortNum = this.actorPortNumSet ? this.actorPortNum : DEFAULT_ACTOR_PORT_NUM;
+            int actorKey = this.actorKeySet ? this.actorKey : DEFAULT_ACTOR_KEY;
+            short convergenceStatus = this.convergenceStatusSet ? this.convergenceStatus : DEFAULT_CONVERGENCE_STATUS;
+            int partnerSysPriority = this.partnerSysPrioritySet ? this.partnerSysPriority : DEFAULT_PARTNER_SYS_PRIORITY;
+            MacAddress partnerSysMac = this.partnerSysMacSet ? this.partnerSysMac : DEFAULT_PARTNER_SYS_MAC;
+            if(partnerSysMac == null)
+                throw new NullPointerException("Property partnerSysMac must not be null");
+            int partnerPortPriority = this.partnerPortPrioritySet ? this.partnerPortPriority : DEFAULT_PARTNER_PORT_PRIORITY;
+            int partnerPortNum = this.partnerPortNumSet ? this.partnerPortNum : DEFAULT_PARTNER_PORT_NUM;
+            int partnerKey = this.partnerKeySet ? this.partnerKey : DEFAULT_PARTNER_KEY;
+
+
+            return new OFBsnLacpStatsEntryVer13(
+                    portNo,
+                    actorSysPriority,
+                    actorSysMac,
+                    actorPortPriority,
+                    actorPortNum,
+                    actorKey,
+                    convergenceStatus,
+                    partnerSysPriority,
+                    partnerSysMac,
+                    partnerPortPriority,
+                    partnerPortNum,
+                    partnerKey
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnLacpStatsEntry> {
+        @Override
+        public OFBsnLacpStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            int actorSysPriority = U16.f(bb.readShort());
+            MacAddress actorSysMac = MacAddress.read6Bytes(bb);
+            int actorPortPriority = U16.f(bb.readShort());
+            int actorPortNum = U16.f(bb.readShort());
+            int actorKey = U16.f(bb.readShort());
+            short convergenceStatus = U8.f(bb.readByte());
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int partnerSysPriority = U16.f(bb.readShort());
+            MacAddress partnerSysMac = MacAddress.read6Bytes(bb);
+            int partnerPortPriority = U16.f(bb.readShort());
+            int partnerPortNum = U16.f(bb.readShort());
+            int partnerKey = U16.f(bb.readShort());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFBsnLacpStatsEntryVer13 bsnLacpStatsEntryVer13 = new OFBsnLacpStatsEntryVer13(
+                    portNo,
+                      actorSysPriority,
+                      actorSysMac,
+                      actorPortPriority,
+                      actorPortNum,
+                      actorKey,
+                      convergenceStatus,
+                      partnerSysPriority,
+                      partnerSysMac,
+                      partnerPortPriority,
+                      partnerPortNum,
+                      partnerKey
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnLacpStatsEntryVer13);
+            return bsnLacpStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnLacpStatsEntryVer13Funnel FUNNEL = new OFBsnLacpStatsEntryVer13Funnel();
+    static class OFBsnLacpStatsEntryVer13Funnel implements Funnel<OFBsnLacpStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnLacpStatsEntryVer13 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            sink.putInt(message.actorSysPriority);
+            message.actorSysMac.putTo(sink);
+            sink.putInt(message.actorPortPriority);
+            sink.putInt(message.actorPortNum);
+            sink.putInt(message.actorKey);
+            sink.putShort(message.convergenceStatus);
+            // skip pad (1 bytes)
+            sink.putInt(message.partnerSysPriority);
+            message.partnerSysMac.putTo(sink);
+            sink.putInt(message.partnerPortPriority);
+            sink.putInt(message.partnerPortNum);
+            sink.putInt(message.partnerKey);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnLacpStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnLacpStatsEntryVer13 message) {
+            message.portNo.write4Bytes(bb);
+            bb.writeShort(U16.t(message.actorSysPriority));
+            message.actorSysMac.write6Bytes(bb);
+            bb.writeShort(U16.t(message.actorPortPriority));
+            bb.writeShort(U16.t(message.actorPortNum));
+            bb.writeShort(U16.t(message.actorKey));
+            bb.writeByte(U8.t(message.convergenceStatus));
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.partnerSysPriority));
+            message.partnerSysMac.write6Bytes(bb);
+            bb.writeShort(U16.t(message.partnerPortPriority));
+            bb.writeShort(U16.t(message.partnerPortNum));
+            bb.writeShort(U16.t(message.partnerKey));
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnLacpStatsEntryVer13(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("actorSysPriority=").append(actorSysPriority);
+        b.append(", ");
+        b.append("actorSysMac=").append(actorSysMac);
+        b.append(", ");
+        b.append("actorPortPriority=").append(actorPortPriority);
+        b.append(", ");
+        b.append("actorPortNum=").append(actorPortNum);
+        b.append(", ");
+        b.append("actorKey=").append(actorKey);
+        b.append(", ");
+        b.append("convergenceStatus=").append(convergenceStatus);
+        b.append(", ");
+        b.append("partnerSysPriority=").append(partnerSysPriority);
+        b.append(", ");
+        b.append("partnerSysMac=").append(partnerSysMac);
+        b.append(", ");
+        b.append("partnerPortPriority=").append(partnerPortPriority);
+        b.append(", ");
+        b.append("partnerPortNum=").append(partnerPortNum);
+        b.append(", ");
+        b.append("partnerKey=").append(partnerKey);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnLacpStatsEntryVer13 other = (OFBsnLacpStatsEntryVer13) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( actorSysPriority != other.actorSysPriority)
+            return false;
+        if (actorSysMac == null) {
+            if (other.actorSysMac != null)
+                return false;
+        } else if (!actorSysMac.equals(other.actorSysMac))
+            return false;
+        if( actorPortPriority != other.actorPortPriority)
+            return false;
+        if( actorPortNum != other.actorPortNum)
+            return false;
+        if( actorKey != other.actorKey)
+            return false;
+        if( convergenceStatus != other.convergenceStatus)
+            return false;
+        if( partnerSysPriority != other.partnerSysPriority)
+            return false;
+        if (partnerSysMac == null) {
+            if (other.partnerSysMac != null)
+                return false;
+        } else if (!partnerSysMac.equals(other.partnerSysMac))
+            return false;
+        if( partnerPortPriority != other.partnerPortPriority)
+            return false;
+        if( partnerPortNum != other.partnerPortNum)
+            return false;
+        if( partnerKey != other.partnerKey)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + actorSysPriority;
+        result = prime * result + ((actorSysMac == null) ? 0 : actorSysMac.hashCode());
+        result = prime * result + actorPortPriority;
+        result = prime * result + actorPortNum;
+        result = prime * result + actorKey;
+        result = prime * result + convergenceStatus;
+        result = prime * result + partnerSysPriority;
+        result = prime * result + ((partnerSysMac == null) ? 0 : partnerSysMac.hashCode());
+        result = prime * result + partnerPortPriority;
+        result = prime * result + partnerPortNum;
+        result = prime * result + partnerKey;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsReplyVer13.java
new file mode 100644
index 0000000..4662c39
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnLacpStatsReplyVer13 implements OFBsnLacpStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnLacpStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnLacpStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnLacpStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnLacpStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnLacpStatsReplyVer13 DEFAULT = new OFBsnLacpStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnLacpStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnLacpStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public List<OFBsnLacpStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnLacpStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnLacpStatsReply.Builder {
+        final OFBsnLacpStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnLacpStatsEntry> entries;
+
+        BuilderWithParent(OFBsnLacpStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnLacpStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnLacpStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public List<OFBsnLacpStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnLacpStatsReply.Builder setEntries(List<OFBsnLacpStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnLacpStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnLacpStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnLacpStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnLacpStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnLacpStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnLacpStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnLacpStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public List<OFBsnLacpStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnLacpStatsReply.Builder setEntries(List<OFBsnLacpStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnLacpStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnLacpStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnLacpStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnLacpStatsReply> {
+        @Override
+        public OFBsnLacpStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+            List<OFBsnLacpStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnLacpStatsEntryVer13.READER);
+
+            OFBsnLacpStatsReplyVer13 bsnLacpStatsReplyVer13 = new OFBsnLacpStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnLacpStatsReplyVer13);
+            return bsnLacpStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnLacpStatsReplyVer13Funnel FUNNEL = new OFBsnLacpStatsReplyVer13Funnel();
+    static class OFBsnLacpStatsReplyVer13Funnel implements Funnel<OFBsnLacpStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnLacpStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnLacpStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnLacpStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnLacpStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnLacpStatsReplyVer13 other = (OFBsnLacpStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsRequestVer13.java
new file mode 100644
index 0000000..4995613
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsRequestVer13.java
@@ -0,0 +1,397 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnLacpStatsRequestVer13 implements OFBsnLacpStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnLacpStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFBsnLacpStatsRequestVer13 DEFAULT = new OFBsnLacpStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnLacpStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+
+
+    public OFBsnLacpStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnLacpStatsRequest.Builder {
+        final OFBsnLacpStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFBsnLacpStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnLacpStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnLacpStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+
+
+        @Override
+        public OFBsnLacpStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFBsnLacpStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnLacpStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnLacpStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnLacpStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+//
+        @Override
+        public OFBsnLacpStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFBsnLacpStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnLacpStatsRequest> {
+        @Override
+        public OFBsnLacpStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+
+            OFBsnLacpStatsRequestVer13 bsnLacpStatsRequestVer13 = new OFBsnLacpStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnLacpStatsRequestVer13);
+            return bsnLacpStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnLacpStatsRequestVer13Funnel FUNNEL = new OFBsnLacpStatsRequestVer13Funnel();
+    static class OFBsnLacpStatsRequestVer13Funnel implements Funnel<OFBsnLacpStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnLacpStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnLacpStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnLacpStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnLacpStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnLacpStatsRequestVer13 other = (OFBsnLacpStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLogVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLogVer13.java
new file mode 100644
index 0000000..7c2c1a2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLogVer13.java
@@ -0,0 +1,423 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnLogVer13 implements OFBsnLog {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnLogVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 17;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static String DEFAULT_DATA = "";
+
+    // OF message fields
+    private final long xid;
+    private final OFBsnLoglevel loglevel;
+    private final String data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnLogVer13(long xid, OFBsnLoglevel loglevel, String data) {
+        this.xid = xid;
+        this.loglevel = loglevel;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3fL;
+    }
+
+    @Override
+    public OFBsnLoglevel getLoglevel() {
+        return loglevel;
+    }
+
+    @Override
+    public String getData() {
+        return data;
+    }
+
+
+
+    public OFBsnLog.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnLog.Builder {
+        final OFBsnLogVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean loglevelSet;
+        private OFBsnLoglevel loglevel;
+        private boolean dataSet;
+        private String data;
+
+        BuilderWithParent(OFBsnLogVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnLog.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3fL;
+    }
+
+    @Override
+    public OFBsnLoglevel getLoglevel() {
+        return loglevel;
+    }
+
+    @Override
+    public OFBsnLog.Builder setLoglevel(OFBsnLoglevel loglevel) {
+        this.loglevel = loglevel;
+        this.loglevelSet = true;
+        return this;
+    }
+    @Override
+    public String getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnLog.Builder setData(String data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnLog build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBsnLoglevel loglevel = this.loglevelSet ? this.loglevel : parentMessage.loglevel;
+                if(loglevel == null)
+                    throw new NullPointerException("Property loglevel must not be null");
+                String data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnLogVer13(
+                    xid,
+                    loglevel,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnLog.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean loglevelSet;
+        private OFBsnLoglevel loglevel;
+        private boolean dataSet;
+        private String data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnLog.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3fL;
+    }
+
+    @Override
+    public OFBsnLoglevel getLoglevel() {
+        return loglevel;
+    }
+
+    @Override
+    public OFBsnLog.Builder setLoglevel(OFBsnLoglevel loglevel) {
+        this.loglevel = loglevel;
+        this.loglevelSet = true;
+        return this;
+    }
+    @Override
+    public String getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnLog.Builder setData(String data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnLog build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.loglevelSet)
+                throw new IllegalStateException("Property loglevel doesn't have default value -- must be set");
+            if(loglevel == null)
+                throw new NullPointerException("Property loglevel must not be null");
+            String data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnLogVer13(
+                    xid,
+                    loglevel,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnLog> {
+        @Override
+        public OFBsnLog readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3fL
+            int subtype = bb.readInt();
+            if(subtype != 0x3f)
+                throw new OFParseError("Wrong subtype: Expected=0x3fL(0x3fL), got="+subtype);
+            OFBsnLoglevel loglevel = OFBsnLoglevelSerializerVer13.readFrom(bb);
+            String data = ChannelUtils.readFixedLengthString(bb, length - (bb.readerIndex() - start));
+
+            OFBsnLogVer13 bsnLogVer13 = new OFBsnLogVer13(
+                    xid,
+                      loglevel,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnLogVer13);
+            return bsnLogVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnLogVer13Funnel FUNNEL = new OFBsnLogVer13Funnel();
+    static class OFBsnLogVer13Funnel implements Funnel<OFBsnLogVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnLogVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3fL
+            sink.putInt(0x3f);
+            OFBsnLoglevelSerializerVer13.putTo(message.loglevel, sink);
+            sink.putUnencodedChars(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnLogVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnLogVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3fL
+            bb.writeInt(0x3f);
+            OFBsnLoglevelSerializerVer13.writeTo(bb, message.loglevel);
+            ChannelUtils.writeFixedLengthString(bb, message.data, message.data.length());
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnLogVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("loglevel=").append(loglevel);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnLogVer13 other = (OFBsnLogVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (loglevel == null) {
+            if (other.loglevel != null)
+                return false;
+        } else if (!loglevel.equals(other.loglevel))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((loglevel == null) ? 0 : loglevel.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLoglevelSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLoglevelSerializerVer13.java
new file mode 100644
index 0000000..2f26b4c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLoglevelSerializerVer13.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnLoglevel;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnLoglevelSerializerVer13 {
+
+    public final static byte BSN_LOGLEVEL_MSG_VAL = (byte) 0x0;
+    public final static byte BSN_LOGLEVEL_ERROR_VAL = (byte) 0x1;
+    public final static byte BSN_LOGLEVEL_WARN_VAL = (byte) 0x2;
+    public final static byte BSN_LOGLEVEL_INFO_VAL = (byte) 0x3;
+    public final static byte BSN_LOGLEVEL_VERBOSE_VAL = (byte) 0x4;
+    public final static byte BSN_LOGLEVEL_TRACE_VAL = (byte) 0x5;
+
+    public static OFBsnLoglevel readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnLoglevel e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnLoglevel e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnLoglevel ofWireValue(byte val) {
+        switch(val) {
+            case BSN_LOGLEVEL_MSG_VAL:
+                return OFBsnLoglevel.BSN_LOGLEVEL_MSG;
+            case BSN_LOGLEVEL_ERROR_VAL:
+                return OFBsnLoglevel.BSN_LOGLEVEL_ERROR;
+            case BSN_LOGLEVEL_WARN_VAL:
+                return OFBsnLoglevel.BSN_LOGLEVEL_WARN;
+            case BSN_LOGLEVEL_INFO_VAL:
+                return OFBsnLoglevel.BSN_LOGLEVEL_INFO;
+            case BSN_LOGLEVEL_VERBOSE_VAL:
+                return OFBsnLoglevel.BSN_LOGLEVEL_VERBOSE;
+            case BSN_LOGLEVEL_TRACE_VAL:
+                return OFBsnLoglevel.BSN_LOGLEVEL_TRACE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnLoglevel in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnLoglevel e) {
+        switch(e) {
+            case BSN_LOGLEVEL_MSG:
+                return BSN_LOGLEVEL_MSG_VAL;
+            case BSN_LOGLEVEL_ERROR:
+                return BSN_LOGLEVEL_ERROR_VAL;
+            case BSN_LOGLEVEL_WARN:
+                return BSN_LOGLEVEL_WARN_VAL;
+            case BSN_LOGLEVEL_INFO:
+                return BSN_LOGLEVEL_INFO_VAL;
+            case BSN_LOGLEVEL_VERBOSE:
+                return BSN_LOGLEVEL_VERBOSE_VAL;
+            case BSN_LOGLEVEL_TRACE:
+                return BSN_LOGLEVEL_TRACE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnLoglevel in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxReplyVer13.java
new file mode 100644
index 0000000..42f8184
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxReplyVer13.java
@@ -0,0 +1,462 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduRxReplyVer13 implements OFBsnPduRxReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 25;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduRxReplyVer13 DEFAULT = new OFBsnPduRxReplyVer13(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxReplyVer13(long xid, long status, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduRxReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxReply.Builder {
+        final OFBsnPduRxReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduRxReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduRxReplyVer13(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x22L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduRxReplyVer13(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxReply> {
+        @Override
+        public OFBsnPduRxReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 25)
+                throw new OFParseError("Wrong length: Expected=25(25), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x22L
+            int subtype = bb.readInt();
+            if(subtype != 0x22)
+                throw new OFParseError("Wrong subtype: Expected=0x22L(0x22L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduRxReplyVer13 bsnPduRxReplyVer13 = new OFBsnPduRxReplyVer13(
+                    xid,
+                      status,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxReplyVer13);
+            return bsnPduRxReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxReplyVer13Funnel FUNNEL = new OFBsnPduRxReplyVer13Funnel();
+    static class OFBsnPduRxReplyVer13Funnel implements Funnel<OFBsnPduRxReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 25
+            sink.putShort((short) 0x19);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x22L
+            sink.putInt(0x22);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 25
+            bb.writeShort((short) 0x19);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x22L
+            bb.writeInt(0x22);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxReplyVer13 other = (OFBsnPduRxReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxRequestVer13.java
new file mode 100644
index 0000000..cf6463e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxRequestVer13.java
@@ -0,0 +1,524 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnPduRxRequestVer13 implements OFBsnPduRxRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_TIMEOUT_MS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long timeoutMs;
+    private final OFPort portNo;
+    private final short slotNum;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnPduRxRequestVer13 DEFAULT = new OFBsnPduRxRequestVer13(
+        DEFAULT_XID, DEFAULT_TIMEOUT_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxRequestVer13(long xid, long timeoutMs, OFPort portNo, short slotNum, byte[] data) {
+        this.xid = xid;
+        this.timeoutMs = timeoutMs;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnPduRxRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxRequest.Builder {
+        final OFBsnPduRxRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeoutMsSet;
+        private long timeoutMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnPduRxRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setTimeoutMs(long timeoutMs) {
+        this.timeoutMs = timeoutMs;
+        this.timeoutMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long timeoutMs = this.timeoutMsSet ? this.timeoutMs : parentMessage.timeoutMs;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnPduRxRequestVer13(
+                    xid,
+                    timeoutMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeoutMsSet;
+        private long timeoutMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x21L;
+    }
+
+    @Override
+    public long getTimeoutMs() {
+        return timeoutMs;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setTimeoutMs(long timeoutMs) {
+        this.timeoutMs = timeoutMs;
+        this.timeoutMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduRxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long timeoutMs = this.timeoutMsSet ? this.timeoutMs : DEFAULT_TIMEOUT_MS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnPduRxRequestVer13(
+                    xid,
+                    timeoutMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxRequest> {
+        @Override
+        public OFBsnPduRxRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x21L
+            int subtype = bb.readInt();
+            if(subtype != 0x21)
+                throw new OFParseError("Wrong subtype: Expected=0x21L(0x21L), got="+subtype);
+            long timeoutMs = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnPduRxRequestVer13 bsnPduRxRequestVer13 = new OFBsnPduRxRequestVer13(
+                    xid,
+                      timeoutMs,
+                      portNo,
+                      slotNum,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxRequestVer13);
+            return bsnPduRxRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxRequestVer13Funnel FUNNEL = new OFBsnPduRxRequestVer13Funnel();
+    static class OFBsnPduRxRequestVer13Funnel implements Funnel<OFBsnPduRxRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x21L
+            sink.putInt(0x21);
+            sink.putLong(message.timeoutMs);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+            // skip pad (3 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxRequestVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x21L
+            bb.writeInt(0x21);
+            bb.writeInt(U32.t(message.timeoutMs));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("timeoutMs=").append(timeoutMs);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxRequestVer13 other = (OFBsnPduRxRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( timeoutMs != other.timeoutMs)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (timeoutMs ^ (timeoutMs >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxTimeoutVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxTimeoutVer13.java
new file mode 100644
index 0000000..061f8b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduRxTimeoutVer13.java
@@ -0,0 +1,415 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduRxTimeoutVer13 implements OFBsnPduRxTimeout {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduRxTimeoutVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 21;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduRxTimeoutVer13 DEFAULT = new OFBsnPduRxTimeoutVer13(
+        DEFAULT_XID, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduRxTimeoutVer13(long xid, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduRxTimeout.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduRxTimeout.Builder {
+        final OFBsnPduRxTimeoutVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduRxTimeoutVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduRxTimeout build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduRxTimeoutVer13(
+                    xid,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduRxTimeout.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x23L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduRxTimeout.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduRxTimeout build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduRxTimeoutVer13(
+                    xid,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduRxTimeout> {
+        @Override
+        public OFBsnPduRxTimeout readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 21)
+                throw new OFParseError("Wrong length: Expected=21(21), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x23L
+            int subtype = bb.readInt();
+            if(subtype != 0x23)
+                throw new OFParseError("Wrong subtype: Expected=0x23L(0x23L), got="+subtype);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduRxTimeoutVer13 bsnPduRxTimeoutVer13 = new OFBsnPduRxTimeoutVer13(
+                    xid,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduRxTimeoutVer13);
+            return bsnPduRxTimeoutVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduRxTimeoutVer13Funnel FUNNEL = new OFBsnPduRxTimeoutVer13Funnel();
+    static class OFBsnPduRxTimeoutVer13Funnel implements Funnel<OFBsnPduRxTimeoutVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduRxTimeoutVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 21
+            sink.putShort((short) 0x15);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x23L
+            sink.putInt(0x23);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduRxTimeoutVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduRxTimeoutVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 21
+            bb.writeShort((short) 0x15);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x23L
+            bb.writeInt(0x23);
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduRxTimeoutVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduRxTimeoutVer13 other = (OFBsnPduRxTimeoutVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduSlotNumTSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduSlotNumTSerializerVer13.java
new file mode 100644
index 0000000..2bd51e2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduSlotNumTSerializerVer13.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnPduSlotNumT;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnPduSlotNumTSerializerVer13 {
+
+    public final static byte PDU_SLOT_NUM_ANY_VAL = (byte) 0xff;
+
+    public static OFBsnPduSlotNumT readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnPduSlotNumT e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnPduSlotNumT e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnPduSlotNumT ofWireValue(byte val) {
+        switch(val) {
+            case PDU_SLOT_NUM_ANY_VAL:
+                return OFBsnPduSlotNumT.PDU_SLOT_NUM_ANY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnPduSlotNumT in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnPduSlotNumT e) {
+        switch(e) {
+            case PDU_SLOT_NUM_ANY:
+                return PDU_SLOT_NUM_ANY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnPduSlotNumT in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduTxReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduTxReplyVer13.java
new file mode 100644
index 0000000..2c8c0ca
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduTxReplyVer13.java
@@ -0,0 +1,462 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPduTxReplyVer13 implements OFBsnPduTxReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 25;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+    private final short slotNum;
+//
+    // Immutable default instance
+    final static OFBsnPduTxReplyVer13 DEFAULT = new OFBsnPduTxReplyVer13(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduTxReplyVer13(long xid, long status, OFPort portNo, short slotNum) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+
+
+    public OFBsnPduTxReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduTxReply.Builder {
+        final OFBsnPduTxReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+        BuilderWithParent(OFBsnPduTxReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduTxReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+
+                //
+                return new OFBsnPduTxReplyVer13(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduTxReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x20L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxReply.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduTxReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+
+
+            return new OFBsnPduTxReplyVer13(
+                    xid,
+                    status,
+                    portNo,
+                    slotNum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduTxReply> {
+        @Override
+        public OFBsnPduTxReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 25)
+                throw new OFParseError("Wrong length: Expected=25(25), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x20L
+            int subtype = bb.readInt();
+            if(subtype != 0x20)
+                throw new OFParseError("Wrong subtype: Expected=0x20L(0x20L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+
+            OFBsnPduTxReplyVer13 bsnPduTxReplyVer13 = new OFBsnPduTxReplyVer13(
+                    xid,
+                      status,
+                      portNo,
+                      slotNum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduTxReplyVer13);
+            return bsnPduTxReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduTxReplyVer13Funnel FUNNEL = new OFBsnPduTxReplyVer13Funnel();
+    static class OFBsnPduTxReplyVer13Funnel implements Funnel<OFBsnPduTxReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduTxReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 25
+            sink.putShort((short) 0x19);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x20L
+            sink.putInt(0x20);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduTxReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduTxReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 25
+            bb.writeShort((short) 0x19);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x20L
+            bb.writeInt(0x20);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduTxReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduTxReplyVer13 other = (OFBsnPduTxReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduTxRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduTxRequestVer13.java
new file mode 100644
index 0000000..eb252c8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPduTxRequestVer13.java
@@ -0,0 +1,524 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnPduTxRequestVer13 implements OFBsnPduTxRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPduTxRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_TX_INTERVAL_MS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static short DEFAULT_SLOT_NUM = (short) 0x0;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final long txIntervalMs;
+    private final OFPort portNo;
+    private final short slotNum;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFBsnPduTxRequestVer13 DEFAULT = new OFBsnPduTxRequestVer13(
+        DEFAULT_XID, DEFAULT_TX_INTERVAL_MS, DEFAULT_PORT_NO, DEFAULT_SLOT_NUM, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPduTxRequestVer13(long xid, long txIntervalMs, OFPort portNo, short slotNum, byte[] data) {
+        this.xid = xid;
+        this.txIntervalMs = txIntervalMs;
+        this.portNo = portNo;
+        this.slotNum = slotNum;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFBsnPduTxRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPduTxRequest.Builder {
+        final OFBsnPduTxRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean txIntervalMsSet;
+        private long txIntervalMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFBsnPduTxRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) {
+        this.txIntervalMs = txIntervalMs;
+        this.txIntervalMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPduTxRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : parentMessage.txIntervalMs;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                short slotNum = this.slotNumSet ? this.slotNum : parentMessage.slotNum;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFBsnPduTxRequestVer13(
+                    xid,
+                    txIntervalMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPduTxRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean txIntervalMsSet;
+        private long txIntervalMs;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean slotNumSet;
+        private short slotNum;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1fL;
+    }
+
+    @Override
+    public long getTxIntervalMs() {
+        return txIntervalMs;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setTxIntervalMs(long txIntervalMs) {
+        this.txIntervalMs = txIntervalMs;
+        this.txIntervalMsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public short getSlotNum() {
+        return slotNum;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setSlotNum(short slotNum) {
+        this.slotNum = slotNum;
+        this.slotNumSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFBsnPduTxRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPduTxRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long txIntervalMs = this.txIntervalMsSet ? this.txIntervalMs : DEFAULT_TX_INTERVAL_MS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            short slotNum = this.slotNumSet ? this.slotNum : DEFAULT_SLOT_NUM;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFBsnPduTxRequestVer13(
+                    xid,
+                    txIntervalMs,
+                    portNo,
+                    slotNum,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPduTxRequest> {
+        @Override
+        public OFBsnPduTxRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1fL
+            int subtype = bb.readInt();
+            if(subtype != 0x1f)
+                throw new OFParseError("Wrong subtype: Expected=0x1fL(0x1fL), got="+subtype);
+            long txIntervalMs = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            short slotNum = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnPduTxRequestVer13 bsnPduTxRequestVer13 = new OFBsnPduTxRequestVer13(
+                    xid,
+                      txIntervalMs,
+                      portNo,
+                      slotNum,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPduTxRequestVer13);
+            return bsnPduTxRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPduTxRequestVer13Funnel FUNNEL = new OFBsnPduTxRequestVer13Funnel();
+    static class OFBsnPduTxRequestVer13Funnel implements Funnel<OFBsnPduTxRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPduTxRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1fL
+            sink.putInt(0x1f);
+            sink.putLong(message.txIntervalMs);
+            message.portNo.putTo(sink);
+            sink.putShort(message.slotNum);
+            // skip pad (3 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPduTxRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPduTxRequestVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1fL
+            bb.writeInt(0x1f);
+            bb.writeInt(U32.t(message.txIntervalMs));
+            message.portNo.write4Bytes(bb);
+            bb.writeByte(U8.t(message.slotNum));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPduTxRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("txIntervalMs=").append(txIntervalMs);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("slotNum=").append(slotNum);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPduTxRequestVer13 other = (OFBsnPduTxRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( txIntervalMs != other.txIntervalMs)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( slotNum != other.slotNum)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (txIntervalMs ^ (txIntervalMs >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + slotNum;
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPktinFlagSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPktinFlagSerializerVer13.java
new file mode 100644
index 0000000..9c43fd4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPktinFlagSerializerVer13.java
@@ -0,0 +1,138 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnPktinFlag;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFBsnPktinFlagSerializerVer13 {
+
+    public final static long BSN_PKTIN_FLAG_PDU_VAL = 0x1L;
+    public final static long BSN_PKTIN_FLAG_NEW_HOST_VAL = 0x2L;
+    public final static long BSN_PKTIN_FLAG_STATION_MOVE_VAL = 0x4L;
+    public final static long BSN_PKTIN_FLAG_ARP_VAL = 0x8L;
+    public final static long BSN_PKTIN_FLAG_DHCP_VAL = 0x10L;
+    public final static long BSN_PKTIN_FLAG_L2_CPU_VAL = 0x20L;
+    public final static long BSN_PKTIN_FLAG_DEBUG_VAL = 0x40L;
+    public final static long BSN_PKTIN_FLAG_TTL_EXPIRED_VAL = 0x80L;
+    public final static long BSN_PKTIN_FLAG_L3_MISS_VAL = 0x100L;
+    public final static long BSN_PKTIN_FLAG_L3_CPU_VAL = 0x200L;
+    public final static long BSN_PKTIN_FLAG_INGRESS_ACL_VAL = 0x400L;
+
+    public static Set<OFBsnPktinFlag> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readLong());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFBsnPktinFlag> set) {
+        bb.writeLong(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFBsnPktinFlag> set, PrimitiveSink sink) {
+        sink.putLong(toWireValue(set));
+    }
+
+
+    public static Set<OFBsnPktinFlag> ofWireValue(long val) {
+        EnumSet<OFBsnPktinFlag> set = EnumSet.noneOf(OFBsnPktinFlag.class);
+
+        if((val & BSN_PKTIN_FLAG_PDU_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_PDU);
+        if((val & BSN_PKTIN_FLAG_NEW_HOST_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_NEW_HOST);
+        if((val & BSN_PKTIN_FLAG_STATION_MOVE_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_STATION_MOVE);
+        if((val & BSN_PKTIN_FLAG_ARP_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_ARP);
+        if((val & BSN_PKTIN_FLAG_DHCP_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_DHCP);
+        if((val & BSN_PKTIN_FLAG_L2_CPU_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_L2_CPU);
+        if((val & BSN_PKTIN_FLAG_DEBUG_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_DEBUG);
+        if((val & BSN_PKTIN_FLAG_TTL_EXPIRED_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_TTL_EXPIRED);
+        if((val & BSN_PKTIN_FLAG_L3_MISS_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_L3_MISS);
+        if((val & BSN_PKTIN_FLAG_L3_CPU_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_L3_CPU);
+        if((val & BSN_PKTIN_FLAG_INGRESS_ACL_VAL) != 0)
+            set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_INGRESS_ACL);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static long toWireValue(Set<OFBsnPktinFlag> set) {
+        long wireValue = 0;
+
+        for(OFBsnPktinFlag e: set) {
+            switch(e) {
+                case BSN_PKTIN_FLAG_PDU:
+                    wireValue |= BSN_PKTIN_FLAG_PDU_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_NEW_HOST:
+                    wireValue |= BSN_PKTIN_FLAG_NEW_HOST_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_STATION_MOVE:
+                    wireValue |= BSN_PKTIN_FLAG_STATION_MOVE_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_ARP:
+                    wireValue |= BSN_PKTIN_FLAG_ARP_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_DHCP:
+                    wireValue |= BSN_PKTIN_FLAG_DHCP_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_L2_CPU:
+                    wireValue |= BSN_PKTIN_FLAG_L2_CPU_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_DEBUG:
+                    wireValue |= BSN_PKTIN_FLAG_DEBUG_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_TTL_EXPIRED:
+                    wireValue |= BSN_PKTIN_FLAG_TTL_EXPIRED_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_L3_MISS:
+                    wireValue |= BSN_PKTIN_FLAG_L3_MISS_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_L3_CPU:
+                    wireValue |= BSN_PKTIN_FLAG_L3_CPU_VAL;
+                    break;
+                case BSN_PKTIN_FLAG_INGRESS_ACL:
+                    wireValue |= BSN_PKTIN_FLAG_INGRESS_ACL_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFBsnPktinFlag in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterSerializerVer13.java
new file mode 100644
index 0000000..0c5c819
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterSerializerVer13.java
@@ -0,0 +1,199 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnPortCounter;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnPortCounterSerializerVer13 {
+
+    public final static byte BSN_PORT_COUNTER_RX_BYTES_VAL = (byte) 0x0;
+    public final static byte BSN_PORT_COUNTER_RX_PACKETS_UNICAST_VAL = (byte) 0x1;
+    public final static byte BSN_PORT_COUNTER_RX_PACKETS_BROADCAST_VAL = (byte) 0x2;
+    public final static byte BSN_PORT_COUNTER_RX_PACKETS_MULTICAST_VAL = (byte) 0x3;
+    public final static byte BSN_PORT_COUNTER_RX_DROPPED_VAL = (byte) 0x4;
+    public final static byte BSN_PORT_COUNTER_RX_ERRORS_VAL = (byte) 0x5;
+    public final static byte BSN_PORT_COUNTER_TX_BYTES_VAL = (byte) 0x6;
+    public final static byte BSN_PORT_COUNTER_TX_PACKETS_UNICAST_VAL = (byte) 0x7;
+    public final static byte BSN_PORT_COUNTER_TX_PACKETS_BROADCAST_VAL = (byte) 0x8;
+    public final static byte BSN_PORT_COUNTER_TX_PACKETS_MULTICAST_VAL = (byte) 0x9;
+    public final static byte BSN_PORT_COUNTER_TX_DROPPED_VAL = (byte) 0xa;
+    public final static byte BSN_PORT_COUNTER_TX_ERRORS_VAL = (byte) 0xb;
+    public final static byte BSN_PORT_COUNTER_RX_RUNTS_VAL = (byte) 0xc;
+    public final static byte BSN_PORT_COUNTER_RX_GIANTS_VAL = (byte) 0xd;
+    public final static byte BSN_PORT_COUNTER_RX_CRC_ERRORS_VAL = (byte) 0xe;
+    public final static byte BSN_PORT_COUNTER_RX_ALIGNMENT_ERRORS_VAL = (byte) 0xf;
+    public final static byte BSN_PORT_COUNTER_RX_SYMBOL_ERRORS_VAL = (byte) 0x10;
+    public final static byte BSN_PORT_COUNTER_RX_PAUSE_INPUT_VAL = (byte) 0x11;
+    public final static byte BSN_PORT_COUNTER_TX_COLLISIONS_VAL = (byte) 0x12;
+    public final static byte BSN_PORT_COUNTER_TX_LATE_COLLISIONS_VAL = (byte) 0x13;
+    public final static byte BSN_PORT_COUNTER_TX_DEFERRED_VAL = (byte) 0x14;
+    public final static byte BSN_PORT_COUNTER_TX_PAUSE_OUTPUT_VAL = (byte) 0x15;
+    public final static byte BSN_PORT_COUNTER_RX_PACKETS_VAL = (byte) 0x16;
+    public final static byte BSN_PORT_COUNTER_TX_PACKETS_VAL = (byte) 0x17;
+    public final static byte BSN_PORT_COUNTER_RX_LENGTH_ERRORS_VAL = (byte) 0x18;
+    public final static byte BSN_PORT_COUNTER_RX_OVERFLOW_ERRORS_VAL = (byte) 0x19;
+    public final static byte BSN_PORT_COUNTER_TX_CARRIER_ERRORS_VAL = (byte) 0x1a;
+
+    public static OFBsnPortCounter readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnPortCounter e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnPortCounter e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnPortCounter ofWireValue(byte val) {
+        switch(val) {
+            case BSN_PORT_COUNTER_RX_BYTES_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_BYTES;
+            case BSN_PORT_COUNTER_RX_PACKETS_UNICAST_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_PACKETS_UNICAST;
+            case BSN_PORT_COUNTER_RX_PACKETS_BROADCAST_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_PACKETS_BROADCAST;
+            case BSN_PORT_COUNTER_RX_PACKETS_MULTICAST_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_PACKETS_MULTICAST;
+            case BSN_PORT_COUNTER_RX_DROPPED_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_DROPPED;
+            case BSN_PORT_COUNTER_RX_ERRORS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_ERRORS;
+            case BSN_PORT_COUNTER_TX_BYTES_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_BYTES;
+            case BSN_PORT_COUNTER_TX_PACKETS_UNICAST_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_PACKETS_UNICAST;
+            case BSN_PORT_COUNTER_TX_PACKETS_BROADCAST_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_PACKETS_BROADCAST;
+            case BSN_PORT_COUNTER_TX_PACKETS_MULTICAST_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_PACKETS_MULTICAST;
+            case BSN_PORT_COUNTER_TX_DROPPED_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_DROPPED;
+            case BSN_PORT_COUNTER_TX_ERRORS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_ERRORS;
+            case BSN_PORT_COUNTER_RX_RUNTS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_RUNTS;
+            case BSN_PORT_COUNTER_RX_GIANTS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_GIANTS;
+            case BSN_PORT_COUNTER_RX_CRC_ERRORS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_CRC_ERRORS;
+            case BSN_PORT_COUNTER_RX_ALIGNMENT_ERRORS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_ALIGNMENT_ERRORS;
+            case BSN_PORT_COUNTER_RX_SYMBOL_ERRORS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_SYMBOL_ERRORS;
+            case BSN_PORT_COUNTER_RX_PAUSE_INPUT_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_PAUSE_INPUT;
+            case BSN_PORT_COUNTER_TX_COLLISIONS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_COLLISIONS;
+            case BSN_PORT_COUNTER_TX_LATE_COLLISIONS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_LATE_COLLISIONS;
+            case BSN_PORT_COUNTER_TX_DEFERRED_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_DEFERRED;
+            case BSN_PORT_COUNTER_TX_PAUSE_OUTPUT_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_PAUSE_OUTPUT;
+            case BSN_PORT_COUNTER_RX_PACKETS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_PACKETS;
+            case BSN_PORT_COUNTER_TX_PACKETS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_PACKETS;
+            case BSN_PORT_COUNTER_RX_LENGTH_ERRORS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_LENGTH_ERRORS;
+            case BSN_PORT_COUNTER_RX_OVERFLOW_ERRORS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_RX_OVERFLOW_ERRORS;
+            case BSN_PORT_COUNTER_TX_CARRIER_ERRORS_VAL:
+                return OFBsnPortCounter.BSN_PORT_COUNTER_TX_CARRIER_ERRORS;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnPortCounter in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnPortCounter e) {
+        switch(e) {
+            case BSN_PORT_COUNTER_RX_BYTES:
+                return BSN_PORT_COUNTER_RX_BYTES_VAL;
+            case BSN_PORT_COUNTER_RX_PACKETS_UNICAST:
+                return BSN_PORT_COUNTER_RX_PACKETS_UNICAST_VAL;
+            case BSN_PORT_COUNTER_RX_PACKETS_BROADCAST:
+                return BSN_PORT_COUNTER_RX_PACKETS_BROADCAST_VAL;
+            case BSN_PORT_COUNTER_RX_PACKETS_MULTICAST:
+                return BSN_PORT_COUNTER_RX_PACKETS_MULTICAST_VAL;
+            case BSN_PORT_COUNTER_RX_DROPPED:
+                return BSN_PORT_COUNTER_RX_DROPPED_VAL;
+            case BSN_PORT_COUNTER_RX_ERRORS:
+                return BSN_PORT_COUNTER_RX_ERRORS_VAL;
+            case BSN_PORT_COUNTER_TX_BYTES:
+                return BSN_PORT_COUNTER_TX_BYTES_VAL;
+            case BSN_PORT_COUNTER_TX_PACKETS_UNICAST:
+                return BSN_PORT_COUNTER_TX_PACKETS_UNICAST_VAL;
+            case BSN_PORT_COUNTER_TX_PACKETS_BROADCAST:
+                return BSN_PORT_COUNTER_TX_PACKETS_BROADCAST_VAL;
+            case BSN_PORT_COUNTER_TX_PACKETS_MULTICAST:
+                return BSN_PORT_COUNTER_TX_PACKETS_MULTICAST_VAL;
+            case BSN_PORT_COUNTER_TX_DROPPED:
+                return BSN_PORT_COUNTER_TX_DROPPED_VAL;
+            case BSN_PORT_COUNTER_TX_ERRORS:
+                return BSN_PORT_COUNTER_TX_ERRORS_VAL;
+            case BSN_PORT_COUNTER_RX_RUNTS:
+                return BSN_PORT_COUNTER_RX_RUNTS_VAL;
+            case BSN_PORT_COUNTER_RX_GIANTS:
+                return BSN_PORT_COUNTER_RX_GIANTS_VAL;
+            case BSN_PORT_COUNTER_RX_CRC_ERRORS:
+                return BSN_PORT_COUNTER_RX_CRC_ERRORS_VAL;
+            case BSN_PORT_COUNTER_RX_ALIGNMENT_ERRORS:
+                return BSN_PORT_COUNTER_RX_ALIGNMENT_ERRORS_VAL;
+            case BSN_PORT_COUNTER_RX_SYMBOL_ERRORS:
+                return BSN_PORT_COUNTER_RX_SYMBOL_ERRORS_VAL;
+            case BSN_PORT_COUNTER_RX_PAUSE_INPUT:
+                return BSN_PORT_COUNTER_RX_PAUSE_INPUT_VAL;
+            case BSN_PORT_COUNTER_TX_COLLISIONS:
+                return BSN_PORT_COUNTER_TX_COLLISIONS_VAL;
+            case BSN_PORT_COUNTER_TX_LATE_COLLISIONS:
+                return BSN_PORT_COUNTER_TX_LATE_COLLISIONS_VAL;
+            case BSN_PORT_COUNTER_TX_DEFERRED:
+                return BSN_PORT_COUNTER_TX_DEFERRED_VAL;
+            case BSN_PORT_COUNTER_TX_PAUSE_OUTPUT:
+                return BSN_PORT_COUNTER_TX_PAUSE_OUTPUT_VAL;
+            case BSN_PORT_COUNTER_RX_PACKETS:
+                return BSN_PORT_COUNTER_RX_PACKETS_VAL;
+            case BSN_PORT_COUNTER_TX_PACKETS:
+                return BSN_PORT_COUNTER_TX_PACKETS_VAL;
+            case BSN_PORT_COUNTER_RX_LENGTH_ERRORS:
+                return BSN_PORT_COUNTER_RX_LENGTH_ERRORS_VAL;
+            case BSN_PORT_COUNTER_RX_OVERFLOW_ERRORS:
+                return BSN_PORT_COUNTER_RX_OVERFLOW_ERRORS_VAL;
+            case BSN_PORT_COUNTER_TX_CARRIER_ERRORS:
+                return BSN_PORT_COUNTER_TX_CARRIER_ERRORS_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnPortCounter in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsEntryVer13.java
new file mode 100644
index 0000000..abddc03
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsEntryVer13.java
@@ -0,0 +1,310 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPortCounterStatsEntryVer13 implements OFBsnPortCounterStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPortCounterStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static List<U64> DEFAULT_VALUES = ImmutableList.<U64>of();
+
+    // OF message fields
+    private final OFPort portNo;
+    private final List<U64> values;
+//
+    // Immutable default instance
+    final static OFBsnPortCounterStatsEntryVer13 DEFAULT = new OFBsnPortCounterStatsEntryVer13(
+        DEFAULT_PORT_NO, DEFAULT_VALUES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPortCounterStatsEntryVer13(OFPort portNo, List<U64> values) {
+        this.portNo = portNo;
+        this.values = values;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnPortCounterStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPortCounterStatsEntry.Builder {
+        final OFBsnPortCounterStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean valuesSet;
+        private List<U64> values;
+
+        BuilderWithParent(OFBsnPortCounterStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsEntry.Builder setValues(List<U64> values) {
+        this.values = values;
+        this.valuesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnPortCounterStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                List<U64> values = this.valuesSet ? this.values : parentMessage.values;
+                if(values == null)
+                    throw new NullPointerException("Property values must not be null");
+
+                //
+                return new OFBsnPortCounterStatsEntryVer13(
+                    portNo,
+                    values
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPortCounterStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean valuesSet;
+        private List<U64> values;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsEntry.Builder setValues(List<U64> values) {
+        this.values = values;
+        this.valuesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnPortCounterStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            List<U64> values = this.valuesSet ? this.values : DEFAULT_VALUES;
+            if(values == null)
+                throw new NullPointerException("Property values must not be null");
+
+
+            return new OFBsnPortCounterStatsEntryVer13(
+                    portNo,
+                    values
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPortCounterStatsEntry> {
+        @Override
+        public OFBsnPortCounterStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            List<U64> values = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U64.READER);
+
+            OFBsnPortCounterStatsEntryVer13 bsnPortCounterStatsEntryVer13 = new OFBsnPortCounterStatsEntryVer13(
+                    portNo,
+                      values
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPortCounterStatsEntryVer13);
+            return bsnPortCounterStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPortCounterStatsEntryVer13Funnel FUNNEL = new OFBsnPortCounterStatsEntryVer13Funnel();
+    static class OFBsnPortCounterStatsEntryVer13Funnel implements Funnel<OFBsnPortCounterStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPortCounterStatsEntryVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            // skip pad (2 bytes)
+            message.portNo.putTo(sink);
+            FunnelUtils.putList(message.values, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPortCounterStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPortCounterStatsEntryVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.portNo.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.values);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPortCounterStatsEntryVer13(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("values=").append(values);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPortCounterStatsEntryVer13 other = (OFBsnPortCounterStatsEntryVer13) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (values == null) {
+            if (other.values != null)
+                return false;
+        } else if (!values.equals(other.values))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((values == null) ? 0 : values.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsReplyVer13.java
new file mode 100644
index 0000000..6039442
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPortCounterStatsReplyVer13 implements OFBsnPortCounterStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPortCounterStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnPortCounterStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnPortCounterStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnPortCounterStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnPortCounterStatsReplyVer13 DEFAULT = new OFBsnPortCounterStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPortCounterStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnPortCounterStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public List<OFBsnPortCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnPortCounterStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPortCounterStatsReply.Builder {
+        final OFBsnPortCounterStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnPortCounterStatsEntry> entries;
+
+        BuilderWithParent(OFBsnPortCounterStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public List<OFBsnPortCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsReply.Builder setEntries(List<OFBsnPortCounterStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPortCounterStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnPortCounterStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnPortCounterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPortCounterStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnPortCounterStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public List<OFBsnPortCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsReply.Builder setEntries(List<OFBsnPortCounterStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPortCounterStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnPortCounterStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnPortCounterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPortCounterStatsReply> {
+        @Override
+        public OFBsnPortCounterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x8L
+            int subtype = bb.readInt();
+            if(subtype != 0x8)
+                throw new OFParseError("Wrong subtype: Expected=0x8L(0x8L), got="+subtype);
+            List<OFBsnPortCounterStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnPortCounterStatsEntryVer13.READER);
+
+            OFBsnPortCounterStatsReplyVer13 bsnPortCounterStatsReplyVer13 = new OFBsnPortCounterStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPortCounterStatsReplyVer13);
+            return bsnPortCounterStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPortCounterStatsReplyVer13Funnel FUNNEL = new OFBsnPortCounterStatsReplyVer13Funnel();
+    static class OFBsnPortCounterStatsReplyVer13Funnel implements Funnel<OFBsnPortCounterStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPortCounterStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            sink.putInt(0x8);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPortCounterStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPortCounterStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            bb.writeInt(0x8);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPortCounterStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPortCounterStatsReplyVer13 other = (OFBsnPortCounterStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsRequestVer13.java
new file mode 100644
index 0000000..0098b40
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsRequestVer13.java
@@ -0,0 +1,451 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnPortCounterStatsRequestVer13 implements OFBsnPortCounterStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnPortCounterStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+//
+    // Immutable default instance
+    final static OFBsnPortCounterStatsRequestVer13 DEFAULT = new OFBsnPortCounterStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnPortCounterStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+
+
+    public OFBsnPortCounterStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnPortCounterStatsRequest.Builder {
+        final OFBsnPortCounterStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+        BuilderWithParent(OFBsnPortCounterStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnPortCounterStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+
+                //
+                return new OFBsnPortCounterStatsRequestVer13(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnPortCounterStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnPortCounterStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnPortCounterStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+
+
+            return new OFBsnPortCounterStatsRequestVer13(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnPortCounterStatsRequest> {
+        @Override
+        public OFBsnPortCounterStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 28)
+                throw new OFParseError("Wrong length: Expected=28(28), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x8L
+            int subtype = bb.readInt();
+            if(subtype != 0x8)
+                throw new OFParseError("Wrong subtype: Expected=0x8L(0x8L), got="+subtype);
+            OFPort portNo = OFPort.read4Bytes(bb);
+
+            OFBsnPortCounterStatsRequestVer13 bsnPortCounterStatsRequestVer13 = new OFBsnPortCounterStatsRequestVer13(
+                    xid,
+                      flags,
+                      portNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnPortCounterStatsRequestVer13);
+            return bsnPortCounterStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnPortCounterStatsRequestVer13Funnel FUNNEL = new OFBsnPortCounterStatsRequestVer13Funnel();
+    static class OFBsnPortCounterStatsRequestVer13Funnel implements Funnel<OFBsnPortCounterStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnPortCounterStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 28
+            sink.putShort((short) 0x1c);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            sink.putInt(0x8);
+            message.portNo.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnPortCounterStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnPortCounterStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 28
+            bb.writeShort((short) 0x1c);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            bb.writeInt(0x8);
+            message.portNo.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnPortCounterStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnPortCounterStatsRequestVer13 other = (OFBsnPortCounterStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnRoleStatusVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnRoleStatusVer13.java
new file mode 100644
index 0000000..00db5b9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnRoleStatusVer13.java
@@ -0,0 +1,477 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnRoleStatusVer13 implements OFBsnRoleStatus {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnRoleStatusVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_GENERATION_ID = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final OFControllerRole role;
+    private final OFBsnControllerRoleReason reason;
+    private final U64 generationId;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnRoleStatusVer13(long xid, OFControllerRole role, OFBsnControllerRoleReason reason, U64 generationId) {
+        this.xid = xid;
+        this.role = role;
+        this.reason = reason;
+        this.generationId = generationId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x37L;
+    }
+
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFBsnControllerRoleReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+
+
+    public OFBsnRoleStatus.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnRoleStatus.Builder {
+        final OFBsnRoleStatusVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean reasonSet;
+        private OFBsnControllerRoleReason reason;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+        BuilderWithParent(OFBsnRoleStatusVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnRoleStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x37L;
+    }
+
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFBsnRoleStatus.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public OFBsnControllerRoleReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFBsnRoleStatus.Builder setReason(OFBsnControllerRoleReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFBsnRoleStatus.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnRoleStatus build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFControllerRole role = this.roleSet ? this.role : parentMessage.role;
+                if(role == null)
+                    throw new NullPointerException("Property role must not be null");
+                OFBsnControllerRoleReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                U64 generationId = this.generationIdSet ? this.generationId : parentMessage.generationId;
+                if(generationId == null)
+                    throw new NullPointerException("Property generationId must not be null");
+
+                //
+                return new OFBsnRoleStatusVer13(
+                    xid,
+                    role,
+                    reason,
+                    generationId
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnRoleStatus.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean reasonSet;
+        private OFBsnControllerRoleReason reason;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnRoleStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x37L;
+    }
+
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFBsnRoleStatus.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public OFBsnControllerRoleReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFBsnRoleStatus.Builder setReason(OFBsnControllerRoleReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFBsnRoleStatus.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnRoleStatus build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.roleSet)
+                throw new IllegalStateException("Property role doesn't have default value -- must be set");
+            if(role == null)
+                throw new NullPointerException("Property role must not be null");
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            U64 generationId = this.generationIdSet ? this.generationId : DEFAULT_GENERATION_ID;
+            if(generationId == null)
+                throw new NullPointerException("Property generationId must not be null");
+
+
+            return new OFBsnRoleStatusVer13(
+                    xid,
+                    role,
+                    reason,
+                    generationId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnRoleStatus> {
+        @Override
+        public OFBsnRoleStatus readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x37L
+            int subtype = bb.readInt();
+            if(subtype != 0x37)
+                throw new OFParseError("Wrong subtype: Expected=0x37L(0x37L), got="+subtype);
+            OFControllerRole role = OFControllerRoleSerializerVer13.readFrom(bb);
+            OFBsnControllerRoleReason reason = OFBsnControllerRoleReasonSerializerVer13.readFrom(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            U64 generationId = U64.ofRaw(bb.readLong());
+
+            OFBsnRoleStatusVer13 bsnRoleStatusVer13 = new OFBsnRoleStatusVer13(
+                    xid,
+                      role,
+                      reason,
+                      generationId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnRoleStatusVer13);
+            return bsnRoleStatusVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnRoleStatusVer13Funnel FUNNEL = new OFBsnRoleStatusVer13Funnel();
+    static class OFBsnRoleStatusVer13Funnel implements Funnel<OFBsnRoleStatusVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnRoleStatusVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x37L
+            sink.putInt(0x37);
+            OFControllerRoleSerializerVer13.putTo(message.role, sink);
+            OFBsnControllerRoleReasonSerializerVer13.putTo(message.reason, sink);
+            // skip pad (3 bytes)
+            message.generationId.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnRoleStatusVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnRoleStatusVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x37L
+            bb.writeInt(0x37);
+            OFControllerRoleSerializerVer13.writeTo(bb, message.role);
+            OFBsnControllerRoleReasonSerializerVer13.writeTo(bb, message.reason);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeLong(message.generationId.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnRoleStatusVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("role=").append(role);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("generationId=").append(generationId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnRoleStatusVer13 other = (OFBsnRoleStatusVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (role == null) {
+            if (other.role != null)
+                return false;
+        } else if (!role.equals(other.role))
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (generationId == null) {
+            if (other.generationId != null)
+                return false;
+        } else if (!generationId.equals(other.generationId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((role == null) ? 0 : role.hashCode());
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + ((generationId == null) ? 0 : generationId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsReplyVer13.java
new file mode 100644
index 0000000..836536e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsReplyVer13.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetAuxCxnsReplyVer13 implements OFBsnSetAuxCxnsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetAuxCxnsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_NUM_AUX = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long numAux;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnSetAuxCxnsReplyVer13 DEFAULT = new OFBsnSetAuxCxnsReplyVer13(
+        DEFAULT_XID, DEFAULT_NUM_AUX, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetAuxCxnsReplyVer13(long xid, long numAux, long status) {
+        this.xid = xid;
+        this.numAux = numAux;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3bL;
+    }
+
+    @Override
+    public long getNumAux() {
+        return numAux;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnSetAuxCxnsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetAuxCxnsReply.Builder {
+        final OFBsnSetAuxCxnsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean numAuxSet;
+        private long numAux;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnSetAuxCxnsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3bL;
+    }
+
+    @Override
+    public long getNumAux() {
+        return numAux;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsReply.Builder setNumAux(long numAux) {
+        this.numAux = numAux;
+        this.numAuxSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetAuxCxnsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long numAux = this.numAuxSet ? this.numAux : parentMessage.numAux;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnSetAuxCxnsReplyVer13(
+                    xid,
+                    numAux,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetAuxCxnsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean numAuxSet;
+        private long numAux;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3bL;
+    }
+
+    @Override
+    public long getNumAux() {
+        return numAux;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsReply.Builder setNumAux(long numAux) {
+        this.numAux = numAux;
+        this.numAuxSet = true;
+        return this;
+    }
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetAuxCxnsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long numAux = this.numAuxSet ? this.numAux : DEFAULT_NUM_AUX;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnSetAuxCxnsReplyVer13(
+                    xid,
+                    numAux,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetAuxCxnsReply> {
+        @Override
+        public OFBsnSetAuxCxnsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3bL
+            int subtype = bb.readInt();
+            if(subtype != 0x3b)
+                throw new OFParseError("Wrong subtype: Expected=0x3bL(0x3bL), got="+subtype);
+            long numAux = U32.f(bb.readInt());
+            long status = U32.f(bb.readInt());
+
+            OFBsnSetAuxCxnsReplyVer13 bsnSetAuxCxnsReplyVer13 = new OFBsnSetAuxCxnsReplyVer13(
+                    xid,
+                      numAux,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetAuxCxnsReplyVer13);
+            return bsnSetAuxCxnsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetAuxCxnsReplyVer13Funnel FUNNEL = new OFBsnSetAuxCxnsReplyVer13Funnel();
+    static class OFBsnSetAuxCxnsReplyVer13Funnel implements Funnel<OFBsnSetAuxCxnsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetAuxCxnsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3bL
+            sink.putInt(0x3b);
+            sink.putLong(message.numAux);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetAuxCxnsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetAuxCxnsReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3bL
+            bb.writeInt(0x3b);
+            bb.writeInt(U32.t(message.numAux));
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetAuxCxnsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("numAux=").append(numAux);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetAuxCxnsReplyVer13 other = (OFBsnSetAuxCxnsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( numAux != other.numAux)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (numAux ^ (numAux >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsRequestVer13.java
new file mode 100644
index 0000000..f96b27e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsRequestVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetAuxCxnsRequestVer13 implements OFBsnSetAuxCxnsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetAuxCxnsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_NUM_AUX = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long numAux;
+//
+    // Immutable default instance
+    final static OFBsnSetAuxCxnsRequestVer13 DEFAULT = new OFBsnSetAuxCxnsRequestVer13(
+        DEFAULT_XID, DEFAULT_NUM_AUX
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetAuxCxnsRequestVer13(long xid, long numAux) {
+        this.xid = xid;
+        this.numAux = numAux;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3aL;
+    }
+
+    @Override
+    public long getNumAux() {
+        return numAux;
+    }
+
+
+
+    public OFBsnSetAuxCxnsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetAuxCxnsRequest.Builder {
+        final OFBsnSetAuxCxnsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean numAuxSet;
+        private long numAux;
+
+        BuilderWithParent(OFBsnSetAuxCxnsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3aL;
+    }
+
+    @Override
+    public long getNumAux() {
+        return numAux;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsRequest.Builder setNumAux(long numAux) {
+        this.numAux = numAux;
+        this.numAuxSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetAuxCxnsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long numAux = this.numAuxSet ? this.numAux : parentMessage.numAux;
+
+                //
+                return new OFBsnSetAuxCxnsRequestVer13(
+                    xid,
+                    numAux
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetAuxCxnsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean numAuxSet;
+        private long numAux;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3aL;
+    }
+
+    @Override
+    public long getNumAux() {
+        return numAux;
+    }
+
+    @Override
+    public OFBsnSetAuxCxnsRequest.Builder setNumAux(long numAux) {
+        this.numAux = numAux;
+        this.numAuxSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetAuxCxnsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long numAux = this.numAuxSet ? this.numAux : DEFAULT_NUM_AUX;
+
+
+            return new OFBsnSetAuxCxnsRequestVer13(
+                    xid,
+                    numAux
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetAuxCxnsRequest> {
+        @Override
+        public OFBsnSetAuxCxnsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3aL
+            int subtype = bb.readInt();
+            if(subtype != 0x3a)
+                throw new OFParseError("Wrong subtype: Expected=0x3aL(0x3aL), got="+subtype);
+            long numAux = U32.f(bb.readInt());
+
+            OFBsnSetAuxCxnsRequestVer13 bsnSetAuxCxnsRequestVer13 = new OFBsnSetAuxCxnsRequestVer13(
+                    xid,
+                      numAux
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetAuxCxnsRequestVer13);
+            return bsnSetAuxCxnsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetAuxCxnsRequestVer13Funnel FUNNEL = new OFBsnSetAuxCxnsRequestVer13Funnel();
+    static class OFBsnSetAuxCxnsRequestVer13Funnel implements Funnel<OFBsnSetAuxCxnsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetAuxCxnsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3aL
+            sink.putInt(0x3a);
+            sink.putLong(message.numAux);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetAuxCxnsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetAuxCxnsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3aL
+            bb.writeInt(0x3a);
+            bb.writeInt(U32.t(message.numAux));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetAuxCxnsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("numAux=").append(numAux);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetAuxCxnsRequestVer13 other = (OFBsnSetAuxCxnsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( numAux != other.numAux)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (numAux ^ (numAux >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetLacpReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetLacpReplyVer13.java
new file mode 100644
index 0000000..fe19e6f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetLacpReplyVer13.java
@@ -0,0 +1,415 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetLacpReplyVer13 implements OFBsnSetLacpReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetLacpReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final OFPort portNo;
+//
+    // Immutable default instance
+    final static OFBsnSetLacpReplyVer13 DEFAULT = new OFBsnSetLacpReplyVer13(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_PORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetLacpReplyVer13(long xid, long status, OFPort portNo) {
+        this.xid = xid;
+        this.status = status;
+        this.portNo = portNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+
+
+    public OFBsnSetLacpReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetLacpReply.Builder {
+        final OFBsnSetLacpReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+        BuilderWithParent(OFBsnSetLacpReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetLacpReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetLacpReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnSetLacpReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetLacpReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+
+                //
+                return new OFBsnSetLacpReplyVer13(
+                    xid,
+                    status,
+                    portNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetLacpReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetLacpReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetLacpReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnSetLacpReply.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetLacpReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+
+
+            return new OFBsnSetLacpReplyVer13(
+                    xid,
+                    status,
+                    portNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetLacpReply> {
+        @Override
+        public OFBsnSetLacpReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2aL
+            int subtype = bb.readInt();
+            if(subtype != 0x2a)
+                throw new OFParseError("Wrong subtype: Expected=0x2aL(0x2aL), got="+subtype);
+            long status = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+
+            OFBsnSetLacpReplyVer13 bsnSetLacpReplyVer13 = new OFBsnSetLacpReplyVer13(
+                    xid,
+                      status,
+                      portNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetLacpReplyVer13);
+            return bsnSetLacpReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetLacpReplyVer13Funnel FUNNEL = new OFBsnSetLacpReplyVer13Funnel();
+    static class OFBsnSetLacpReplyVer13Funnel implements Funnel<OFBsnSetLacpReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetLacpReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2aL
+            sink.putInt(0x2a);
+            sink.putLong(message.status);
+            message.portNo.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetLacpReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetLacpReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2aL
+            bb.writeInt(0x2a);
+            bb.writeInt(U32.t(message.status));
+            message.portNo.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetLacpReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetLacpReplyVer13 other = (OFBsnSetLacpReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetLacpRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetLacpRequestVer13.java
new file mode 100644
index 0000000..6dc30f3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetLacpRequestVer13.java
@@ -0,0 +1,662 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetLacpRequestVer13 implements OFBsnSetLacpRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetLacpRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 38;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_ENABLED = (short) 0x0;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static int DEFAULT_ACTOR_SYS_PRIORITY = 0x0;
+        private final static MacAddress DEFAULT_ACTOR_SYS_MAC = MacAddress.NONE;
+        private final static int DEFAULT_ACTOR_PORT_PRIORITY = 0x0;
+        private final static int DEFAULT_ACTOR_PORT_NUM = 0x0;
+        private final static int DEFAULT_ACTOR_KEY = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short enabled;
+    private final OFPort portNo;
+    private final int actorSysPriority;
+    private final MacAddress actorSysMac;
+    private final int actorPortPriority;
+    private final int actorPortNum;
+    private final int actorKey;
+//
+    // Immutable default instance
+    final static OFBsnSetLacpRequestVer13 DEFAULT = new OFBsnSetLacpRequestVer13(
+        DEFAULT_XID, DEFAULT_ENABLED, DEFAULT_PORT_NO, DEFAULT_ACTOR_SYS_PRIORITY, DEFAULT_ACTOR_SYS_MAC, DEFAULT_ACTOR_PORT_PRIORITY, DEFAULT_ACTOR_PORT_NUM, DEFAULT_ACTOR_KEY
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetLacpRequestVer13(long xid, short enabled, OFPort portNo, int actorSysPriority, MacAddress actorSysMac, int actorPortPriority, int actorPortNum, int actorKey) {
+        this.xid = xid;
+        this.enabled = enabled;
+        this.portNo = portNo;
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysMac = actorSysMac;
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortNum = actorPortNum;
+        this.actorKey = actorKey;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x29L;
+    }
+
+    @Override
+    public short getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+
+
+    public OFBsnSetLacpRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetLacpRequest.Builder {
+        final OFBsnSetLacpRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private short enabled;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean actorSysPrioritySet;
+        private int actorSysPriority;
+        private boolean actorSysMacSet;
+        private MacAddress actorSysMac;
+        private boolean actorPortPrioritySet;
+        private int actorPortPriority;
+        private boolean actorPortNumSet;
+        private int actorPortNum;
+        private boolean actorKeySet;
+        private int actorKey;
+
+        BuilderWithParent(OFBsnSetLacpRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x29L;
+    }
+
+    @Override
+    public short getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setEnabled(short enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorSysPriority(int actorSysPriority) {
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorSysMac(MacAddress actorSysMac) {
+        this.actorSysMac = actorSysMac;
+        this.actorSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorPortPriority(int actorPortPriority) {
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorPortNum(int actorPortNum) {
+        this.actorPortNum = actorPortNum;
+        this.actorPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorKey(int actorKey) {
+        this.actorKey = actorKey;
+        this.actorKeySet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetLacpRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                int actorSysPriority = this.actorSysPrioritySet ? this.actorSysPriority : parentMessage.actorSysPriority;
+                MacAddress actorSysMac = this.actorSysMacSet ? this.actorSysMac : parentMessage.actorSysMac;
+                if(actorSysMac == null)
+                    throw new NullPointerException("Property actorSysMac must not be null");
+                int actorPortPriority = this.actorPortPrioritySet ? this.actorPortPriority : parentMessage.actorPortPriority;
+                int actorPortNum = this.actorPortNumSet ? this.actorPortNum : parentMessage.actorPortNum;
+                int actorKey = this.actorKeySet ? this.actorKey : parentMessage.actorKey;
+
+                //
+                return new OFBsnSetLacpRequestVer13(
+                    xid,
+                    enabled,
+                    portNo,
+                    actorSysPriority,
+                    actorSysMac,
+                    actorPortPriority,
+                    actorPortNum,
+                    actorKey
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetLacpRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private short enabled;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean actorSysPrioritySet;
+        private int actorSysPriority;
+        private boolean actorSysMacSet;
+        private MacAddress actorSysMac;
+        private boolean actorPortPrioritySet;
+        private int actorPortPriority;
+        private boolean actorPortNumSet;
+        private int actorPortNum;
+        private boolean actorKeySet;
+        private int actorKey;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x29L;
+    }
+
+    @Override
+    public short getEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setEnabled(short enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getActorSysPriority() {
+        return actorSysPriority;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorSysPriority(int actorSysPriority) {
+        this.actorSysPriority = actorSysPriority;
+        this.actorSysPrioritySet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getActorSysMac() {
+        return actorSysMac;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorSysMac(MacAddress actorSysMac) {
+        this.actorSysMac = actorSysMac;
+        this.actorSysMacSet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortPriority() {
+        return actorPortPriority;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorPortPriority(int actorPortPriority) {
+        this.actorPortPriority = actorPortPriority;
+        this.actorPortPrioritySet = true;
+        return this;
+    }
+    @Override
+    public int getActorPortNum() {
+        return actorPortNum;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorPortNum(int actorPortNum) {
+        this.actorPortNum = actorPortNum;
+        this.actorPortNumSet = true;
+        return this;
+    }
+    @Override
+    public int getActorKey() {
+        return actorKey;
+    }
+
+    @Override
+    public OFBsnSetLacpRequest.Builder setActorKey(int actorKey) {
+        this.actorKey = actorKey;
+        this.actorKeySet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetLacpRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            int actorSysPriority = this.actorSysPrioritySet ? this.actorSysPriority : DEFAULT_ACTOR_SYS_PRIORITY;
+            MacAddress actorSysMac = this.actorSysMacSet ? this.actorSysMac : DEFAULT_ACTOR_SYS_MAC;
+            if(actorSysMac == null)
+                throw new NullPointerException("Property actorSysMac must not be null");
+            int actorPortPriority = this.actorPortPrioritySet ? this.actorPortPriority : DEFAULT_ACTOR_PORT_PRIORITY;
+            int actorPortNum = this.actorPortNumSet ? this.actorPortNum : DEFAULT_ACTOR_PORT_NUM;
+            int actorKey = this.actorKeySet ? this.actorKey : DEFAULT_ACTOR_KEY;
+
+
+            return new OFBsnSetLacpRequestVer13(
+                    xid,
+                    enabled,
+                    portNo,
+                    actorSysPriority,
+                    actorSysMac,
+                    actorPortPriority,
+                    actorPortNum,
+                    actorKey
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetLacpRequest> {
+        @Override
+        public OFBsnSetLacpRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 38)
+                throw new OFParseError("Wrong length: Expected=38(38), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x29L
+            int subtype = bb.readInt();
+            if(subtype != 0x29)
+                throw new OFParseError("Wrong subtype: Expected=0x29L(0x29L), got="+subtype);
+            short enabled = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            int actorSysPriority = U16.f(bb.readShort());
+            MacAddress actorSysMac = MacAddress.read6Bytes(bb);
+            int actorPortPriority = U16.f(bb.readShort());
+            int actorPortNum = U16.f(bb.readShort());
+            int actorKey = U16.f(bb.readShort());
+
+            OFBsnSetLacpRequestVer13 bsnSetLacpRequestVer13 = new OFBsnSetLacpRequestVer13(
+                    xid,
+                      enabled,
+                      portNo,
+                      actorSysPriority,
+                      actorSysMac,
+                      actorPortPriority,
+                      actorPortNum,
+                      actorKey
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetLacpRequestVer13);
+            return bsnSetLacpRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetLacpRequestVer13Funnel FUNNEL = new OFBsnSetLacpRequestVer13Funnel();
+    static class OFBsnSetLacpRequestVer13Funnel implements Funnel<OFBsnSetLacpRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetLacpRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 38
+            sink.putShort((short) 0x26);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x29L
+            sink.putInt(0x29);
+            sink.putShort(message.enabled);
+            // skip pad (3 bytes)
+            message.portNo.putTo(sink);
+            sink.putInt(message.actorSysPriority);
+            message.actorSysMac.putTo(sink);
+            sink.putInt(message.actorPortPriority);
+            sink.putInt(message.actorPortNum);
+            sink.putInt(message.actorKey);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetLacpRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetLacpRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 38
+            bb.writeShort((short) 0x26);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x29L
+            bb.writeInt(0x29);
+            bb.writeByte(U8.t(message.enabled));
+            // pad: 3 bytes
+            bb.writeZero(3);
+            message.portNo.write4Bytes(bb);
+            bb.writeShort(U16.t(message.actorSysPriority));
+            message.actorSysMac.write6Bytes(bb);
+            bb.writeShort(U16.t(message.actorPortPriority));
+            bb.writeShort(U16.t(message.actorPortNum));
+            bb.writeShort(U16.t(message.actorKey));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetLacpRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("actorSysPriority=").append(actorSysPriority);
+        b.append(", ");
+        b.append("actorSysMac=").append(actorSysMac);
+        b.append(", ");
+        b.append("actorPortPriority=").append(actorPortPriority);
+        b.append(", ");
+        b.append("actorPortNum=").append(actorPortNum);
+        b.append(", ");
+        b.append("actorKey=").append(actorKey);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetLacpRequestVer13 other = (OFBsnSetLacpRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( actorSysPriority != other.actorSysPriority)
+            return false;
+        if (actorSysMac == null) {
+            if (other.actorSysMac != null)
+                return false;
+        } else if (!actorSysMac.equals(other.actorSysMac))
+            return false;
+        if( actorPortPriority != other.actorPortPriority)
+            return false;
+        if( actorPortNum != other.actorPortNum)
+            return false;
+        if( actorKey != other.actorKey)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + enabled;
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + actorSysPriority;
+        result = prime * result + ((actorSysMac == null) ? 0 : actorSysMac.hashCode());
+        result = prime * result + actorPortPriority;
+        result = prime * result + actorPortNum;
+        result = prime * result + actorKey;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetMirroringVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetMirroringVer13.java
new file mode 100644
index 0000000..bf447a9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetMirroringVer13.java
@@ -0,0 +1,366 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetMirroringVer13 implements OFBsnSetMirroring {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetMirroringVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static short DEFAULT_REPORT_MIRROR_PORTS = (short) 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final short reportMirrorPorts;
+//
+    // Immutable default instance
+    final static OFBsnSetMirroringVer13 DEFAULT = new OFBsnSetMirroringVer13(
+        DEFAULT_XID, DEFAULT_REPORT_MIRROR_PORTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetMirroringVer13(long xid, short reportMirrorPorts) {
+        this.xid = xid;
+        this.reportMirrorPorts = reportMirrorPorts;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+
+
+    public OFBsnSetMirroring.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetMirroring.Builder {
+        final OFBsnSetMirroringVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+        BuilderWithParent(OFBsnSetMirroringVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetMirroring build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : parentMessage.reportMirrorPorts;
+
+                //
+                return new OFBsnSetMirroringVer13(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetMirroring.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reportMirrorPortsSet;
+        private short reportMirrorPorts;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public short getReportMirrorPorts() {
+        return reportMirrorPorts;
+    }
+
+    @Override
+    public OFBsnSetMirroring.Builder setReportMirrorPorts(short reportMirrorPorts) {
+        this.reportMirrorPorts = reportMirrorPorts;
+        this.reportMirrorPortsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetMirroring build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            short reportMirrorPorts = this.reportMirrorPortsSet ? this.reportMirrorPorts : DEFAULT_REPORT_MIRROR_PORTS;
+
+
+            return new OFBsnSetMirroringVer13(
+                    xid,
+                    reportMirrorPorts
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetMirroring> {
+        @Override
+        public OFBsnSetMirroring readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3L
+            int subtype = bb.readInt();
+            if(subtype != 0x3)
+                throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got="+subtype);
+            short reportMirrorPorts = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFBsnSetMirroringVer13 bsnSetMirroringVer13 = new OFBsnSetMirroringVer13(
+                    xid,
+                      reportMirrorPorts
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetMirroringVer13);
+            return bsnSetMirroringVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetMirroringVer13Funnel FUNNEL = new OFBsnSetMirroringVer13Funnel();
+    static class OFBsnSetMirroringVer13Funnel implements Funnel<OFBsnSetMirroringVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetMirroringVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            sink.putInt(0x3);
+            sink.putShort(message.reportMirrorPorts);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetMirroringVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetMirroringVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            bb.writeInt(0x3);
+            bb.writeByte(U8.t(message.reportMirrorPorts));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetMirroringVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reportMirrorPorts=").append(reportMirrorPorts);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetMirroringVer13 other = (OFBsnSetMirroringVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( reportMirrorPorts != other.reportMirrorPorts)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + reportMirrorPorts;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetPktinSuppressionReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetPktinSuppressionReplyVer13.java
new file mode 100644
index 0000000..2ff9aeb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetPktinSuppressionReplyVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetPktinSuppressionReplyVer13 implements OFBsnSetPktinSuppressionReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetPktinSuppressionReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnSetPktinSuppressionReplyVer13 DEFAULT = new OFBsnSetPktinSuppressionReplyVer13(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetPktinSuppressionReplyVer13(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnSetPktinSuppressionReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetPktinSuppressionReply.Builder {
+        final OFBsnSetPktinSuppressionReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnSetPktinSuppressionReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetPktinSuppressionReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnSetPktinSuppressionReplyVer13(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetPktinSuppressionReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x19L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetPktinSuppressionReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnSetPktinSuppressionReplyVer13(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetPktinSuppressionReply> {
+        @Override
+        public OFBsnSetPktinSuppressionReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x19L
+            int subtype = bb.readInt();
+            if(subtype != 0x19)
+                throw new OFParseError("Wrong subtype: Expected=0x19L(0x19L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnSetPktinSuppressionReplyVer13 bsnSetPktinSuppressionReplyVer13 = new OFBsnSetPktinSuppressionReplyVer13(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetPktinSuppressionReplyVer13);
+            return bsnSetPktinSuppressionReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetPktinSuppressionReplyVer13Funnel FUNNEL = new OFBsnSetPktinSuppressionReplyVer13Funnel();
+    static class OFBsnSetPktinSuppressionReplyVer13Funnel implements Funnel<OFBsnSetPktinSuppressionReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetPktinSuppressionReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x19L
+            sink.putInt(0x19);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetPktinSuppressionReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetPktinSuppressionReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x19L
+            bb.writeInt(0x19);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetPktinSuppressionReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetPktinSuppressionReplyVer13 other = (OFBsnSetPktinSuppressionReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetPktinSuppressionRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetPktinSuppressionRequestVer13.java
new file mode 100644
index 0000000..84ab62f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetPktinSuppressionRequestVer13.java
@@ -0,0 +1,561 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetPktinSuppressionRequestVer13 implements OFBsnSetPktinSuppressionRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetPktinSuppressionRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static boolean DEFAULT_ENABLED = false;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final boolean enabled;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final U64 cookie;
+//
+    // Immutable default instance
+    final static OFBsnSetPktinSuppressionRequestVer13 DEFAULT = new OFBsnSetPktinSuppressionRequestVer13(
+        DEFAULT_XID, DEFAULT_ENABLED, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_COOKIE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetPktinSuppressionRequestVer13(long xid, boolean enabled, int idleTimeout, int hardTimeout, int priority, U64 cookie) {
+        this.xid = xid;
+        this.enabled = enabled;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.cookie = cookie;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+
+
+    public OFBsnSetPktinSuppressionRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetPktinSuppressionRequest.Builder {
+        final OFBsnSetPktinSuppressionRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private boolean enabled;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean cookieSet;
+        private U64 cookie;
+
+        BuilderWithParent(OFBsnSetPktinSuppressionRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setEnabled(boolean enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetPktinSuppressionRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                boolean enabled = this.enabledSet ? this.enabled : parentMessage.enabled;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+
+                //
+                return new OFBsnSetPktinSuppressionRequestVer13(
+                    xid,
+                    enabled,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    cookie
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetPktinSuppressionRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean enabledSet;
+        private boolean enabled;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean cookieSet;
+        private U64 cookie;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setEnabled(boolean enabled) {
+        this.enabled = enabled;
+        this.enabledSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFBsnSetPktinSuppressionRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetPktinSuppressionRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            boolean enabled = this.enabledSet ? this.enabled : DEFAULT_ENABLED;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+
+
+            return new OFBsnSetPktinSuppressionRequestVer13(
+                    xid,
+                    enabled,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    cookie
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetPktinSuppressionRequest> {
+        @Override
+        public OFBsnSetPktinSuppressionRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xbL
+            int subtype = bb.readInt();
+            if(subtype != 0xb)
+                throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got="+subtype);
+            boolean enabled = (bb.readByte() != 0);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            U64 cookie = U64.ofRaw(bb.readLong());
+
+            OFBsnSetPktinSuppressionRequestVer13 bsnSetPktinSuppressionRequestVer13 = new OFBsnSetPktinSuppressionRequestVer13(
+                    xid,
+                      enabled,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      cookie
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetPktinSuppressionRequestVer13);
+            return bsnSetPktinSuppressionRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetPktinSuppressionRequestVer13Funnel FUNNEL = new OFBsnSetPktinSuppressionRequestVer13Funnel();
+    static class OFBsnSetPktinSuppressionRequestVer13Funnel implements Funnel<OFBsnSetPktinSuppressionRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetPktinSuppressionRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            sink.putInt(0xb);
+            sink.putBoolean(message.enabled);
+            // skip pad (1 bytes)
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.cookie.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetPktinSuppressionRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetPktinSuppressionRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            bb.writeInt(0xb);
+            bb.writeByte(message.enabled ? 1 : 0);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeLong(message.cookie.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetPktinSuppressionRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("enabled=").append(enabled);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetPktinSuppressionRequestVer13 other = (OFBsnSetPktinSuppressionRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( enabled != other.enabled)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + (enabled ? 1231 : 1237);
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetSwitchPipelineReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetSwitchPipelineReplyVer13.java
new file mode 100644
index 0000000..c8eb9e0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetSwitchPipelineReplyVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetSwitchPipelineReplyVer13 implements OFBsnSetSwitchPipelineReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetSwitchPipelineReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnSetSwitchPipelineReplyVer13 DEFAULT = new OFBsnSetSwitchPipelineReplyVer13(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetSwitchPipelineReplyVer13(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x36L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnSetSwitchPipelineReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetSwitchPipelineReply.Builder {
+        final OFBsnSetSwitchPipelineReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnSetSwitchPipelineReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetSwitchPipelineReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x36L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetSwitchPipelineReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetSwitchPipelineReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnSetSwitchPipelineReplyVer13(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetSwitchPipelineReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetSwitchPipelineReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x36L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnSetSwitchPipelineReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetSwitchPipelineReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnSetSwitchPipelineReplyVer13(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetSwitchPipelineReply> {
+        @Override
+        public OFBsnSetSwitchPipelineReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x36L
+            int subtype = bb.readInt();
+            if(subtype != 0x36)
+                throw new OFParseError("Wrong subtype: Expected=0x36L(0x36L), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnSetSwitchPipelineReplyVer13 bsnSetSwitchPipelineReplyVer13 = new OFBsnSetSwitchPipelineReplyVer13(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetSwitchPipelineReplyVer13);
+            return bsnSetSwitchPipelineReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetSwitchPipelineReplyVer13Funnel FUNNEL = new OFBsnSetSwitchPipelineReplyVer13Funnel();
+    static class OFBsnSetSwitchPipelineReplyVer13Funnel implements Funnel<OFBsnSetSwitchPipelineReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetSwitchPipelineReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x36L
+            sink.putInt(0x36);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetSwitchPipelineReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetSwitchPipelineReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x36L
+            bb.writeInt(0x36);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetSwitchPipelineReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetSwitchPipelineReplyVer13 other = (OFBsnSetSwitchPipelineReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetSwitchPipelineRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetSwitchPipelineRequestVer13.java
new file mode 100644
index 0000000..a5aa2a6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetSwitchPipelineRequestVer13.java
@@ -0,0 +1,368 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSetSwitchPipelineRequestVer13 implements OFBsnSetSwitchPipelineRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSetSwitchPipelineRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 272;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static String DEFAULT_PIPELINE = "";
+
+    // OF message fields
+    private final long xid;
+    private final String pipeline;
+//
+    // Immutable default instance
+    final static OFBsnSetSwitchPipelineRequestVer13 DEFAULT = new OFBsnSetSwitchPipelineRequestVer13(
+        DEFAULT_XID, DEFAULT_PIPELINE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSetSwitchPipelineRequestVer13(long xid, String pipeline) {
+        this.xid = xid;
+        this.pipeline = pipeline;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x35L;
+    }
+
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+
+
+    public OFBsnSetSwitchPipelineRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSetSwitchPipelineRequest.Builder {
+        final OFBsnSetSwitchPipelineRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean pipelineSet;
+        private String pipeline;
+
+        BuilderWithParent(OFBsnSetSwitchPipelineRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetSwitchPipelineRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x35L;
+    }
+
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+    @Override
+    public OFBsnSetSwitchPipelineRequest.Builder setPipeline(String pipeline) {
+        this.pipeline = pipeline;
+        this.pipelineSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSetSwitchPipelineRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                String pipeline = this.pipelineSet ? this.pipeline : parentMessage.pipeline;
+                if(pipeline == null)
+                    throw new NullPointerException("Property pipeline must not be null");
+
+                //
+                return new OFBsnSetSwitchPipelineRequestVer13(
+                    xid,
+                    pipeline
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSetSwitchPipelineRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean pipelineSet;
+        private String pipeline;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSetSwitchPipelineRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x35L;
+    }
+
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+    @Override
+    public OFBsnSetSwitchPipelineRequest.Builder setPipeline(String pipeline) {
+        this.pipeline = pipeline;
+        this.pipelineSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSetSwitchPipelineRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            String pipeline = this.pipelineSet ? this.pipeline : DEFAULT_PIPELINE;
+            if(pipeline == null)
+                throw new NullPointerException("Property pipeline must not be null");
+
+
+            return new OFBsnSetSwitchPipelineRequestVer13(
+                    xid,
+                    pipeline
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSetSwitchPipelineRequest> {
+        @Override
+        public OFBsnSetSwitchPipelineRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 272)
+                throw new OFParseError("Wrong length: Expected=272(272), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x35L
+            int subtype = bb.readInt();
+            if(subtype != 0x35)
+                throw new OFParseError("Wrong subtype: Expected=0x35L(0x35L), got="+subtype);
+            String pipeline = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFBsnSetSwitchPipelineRequestVer13 bsnSetSwitchPipelineRequestVer13 = new OFBsnSetSwitchPipelineRequestVer13(
+                    xid,
+                      pipeline
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSetSwitchPipelineRequestVer13);
+            return bsnSetSwitchPipelineRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSetSwitchPipelineRequestVer13Funnel FUNNEL = new OFBsnSetSwitchPipelineRequestVer13Funnel();
+    static class OFBsnSetSwitchPipelineRequestVer13Funnel implements Funnel<OFBsnSetSwitchPipelineRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSetSwitchPipelineRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 272
+            sink.putShort((short) 0x110);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x35L
+            sink.putInt(0x35);
+            sink.putUnencodedChars(message.pipeline);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSetSwitchPipelineRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSetSwitchPipelineRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 272
+            bb.writeShort((short) 0x110);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x35L
+            bb.writeInt(0x35);
+            ChannelUtils.writeFixedLengthString(bb, message.pipeline, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSetSwitchPipelineRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("pipeline=").append(pipeline);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSetSwitchPipelineRequestVer13 other = (OFBsnSetSwitchPipelineRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (pipeline == null) {
+            if (other.pipeline != null)
+                return false;
+        } else if (!pipeline.equals(other.pipeline))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((pipeline == null) ? 0 : pipeline.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnStatsReplyVer13.java
new file mode 100644
index 0000000..b6151d4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnStatsReplyVer13.java
@@ -0,0 +1,118 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnStatsReplyVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFBsnStatsReplyVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnStatsReply> {
+        @Override
+        public OFBsnStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0xd:
+                   // discriminator value 0xdL=0xdL for class OFBsnDebugCounterDescStatsReplyVer13
+                   return OFBsnDebugCounterDescStatsReplyVer13.READER.readFrom(bb);
+               case 0xc:
+                   // discriminator value 0xcL=0xcL for class OFBsnDebugCounterStatsReplyVer13
+                   return OFBsnDebugCounterStatsReplyVer13.READER.readFrom(bb);
+               case 0xa:
+                   // discriminator value 0xaL=0xaL for class OFBsnFlowChecksumBucketStatsReplyVer13
+                   return OFBsnFlowChecksumBucketStatsReplyVer13.READER.readFrom(bb);
+               case 0x5:
+                   // discriminator value 0x5L=0x5L for class OFBsnGentableBucketStatsReplyVer13
+                   return OFBsnGentableBucketStatsReplyVer13.READER.readFrom(bb);
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFBsnGentableDescStatsReplyVer13
+                   return OFBsnGentableDescStatsReplyVer13.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFBsnGentableEntryDescStatsReplyVer13
+                   return OFBsnGentableEntryDescStatsReplyVer13.READER.readFrom(bb);
+               case 0x3:
+                   // discriminator value 0x3L=0x3L for class OFBsnGentableEntryStatsReplyVer13
+                   return OFBsnGentableEntryStatsReplyVer13.READER.readFrom(bb);
+               case 0x7:
+                   // discriminator value 0x7L=0x7L for class OFBsnGentableStatsReplyVer13
+                   return OFBsnGentableStatsReplyVer13.READER.readFrom(bb);
+               case 0xe:
+                   // discriminator value 0xeL=0xeL for class OFBsnImageDescStatsReplyVer13
+                   return OFBsnImageDescStatsReplyVer13.READER.readFrom(bb);
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFBsnLacpStatsReplyVer13
+                   return OFBsnLacpStatsReplyVer13.READER.readFrom(bb);
+               case 0x8:
+                   // discriminator value 0x8L=0x8L for class OFBsnPortCounterStatsReplyVer13
+                   return OFBsnPortCounterStatsReplyVer13.READER.readFrom(bb);
+               case 0x6:
+                   // discriminator value 0x6L=0x6L for class OFBsnSwitchPipelineStatsReplyVer13
+                   return OFBsnSwitchPipelineStatsReplyVer13.READER.readFrom(bb);
+               case 0xb:
+                   // discriminator value 0xbL=0xbL for class OFBsnTableChecksumStatsReplyVer13
+                   return OFBsnTableChecksumStatsReplyVer13.READER.readFrom(bb);
+               case 0x9:
+                   // discriminator value 0x9L=0x9L for class OFBsnVlanCounterStatsReplyVer13
+                   return OFBsnVlanCounterStatsReplyVer13.READER.readFrom(bb);
+               case 0xf:
+                   // discriminator value 0xfL=0xfL for class OFBsnVrfCounterStatsReplyVer13
+                   return OFBsnVrfCounterStatsReplyVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnStatsReplyVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnStatsRequestVer13.java
new file mode 100644
index 0000000..47aad4c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnStatsRequestVer13.java
@@ -0,0 +1,118 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnStatsRequestVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFBsnStatsRequestVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnStatsRequest<?>> {
+        @Override
+        public OFBsnStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0xd:
+                   // discriminator value 0xdL=0xdL for class OFBsnDebugCounterDescStatsRequestVer13
+                   return OFBsnDebugCounterDescStatsRequestVer13.READER.readFrom(bb);
+               case 0xc:
+                   // discriminator value 0xcL=0xcL for class OFBsnDebugCounterStatsRequestVer13
+                   return OFBsnDebugCounterStatsRequestVer13.READER.readFrom(bb);
+               case 0xa:
+                   // discriminator value 0xaL=0xaL for class OFBsnFlowChecksumBucketStatsRequestVer13
+                   return OFBsnFlowChecksumBucketStatsRequestVer13.READER.readFrom(bb);
+               case 0x5:
+                   // discriminator value 0x5L=0x5L for class OFBsnGentableBucketStatsRequestVer13
+                   return OFBsnGentableBucketStatsRequestVer13.READER.readFrom(bb);
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFBsnGentableDescStatsRequestVer13
+                   return OFBsnGentableDescStatsRequestVer13.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFBsnGentableEntryDescStatsRequestVer13
+                   return OFBsnGentableEntryDescStatsRequestVer13.READER.readFrom(bb);
+               case 0x3:
+                   // discriminator value 0x3L=0x3L for class OFBsnGentableEntryStatsRequestVer13
+                   return OFBsnGentableEntryStatsRequestVer13.READER.readFrom(bb);
+               case 0x7:
+                   // discriminator value 0x7L=0x7L for class OFBsnGentableStatsRequestVer13
+                   return OFBsnGentableStatsRequestVer13.READER.readFrom(bb);
+               case 0xe:
+                   // discriminator value 0xeL=0xeL for class OFBsnImageDescStatsRequestVer13
+                   return OFBsnImageDescStatsRequestVer13.READER.readFrom(bb);
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFBsnLacpStatsRequestVer13
+                   return OFBsnLacpStatsRequestVer13.READER.readFrom(bb);
+               case 0x8:
+                   // discriminator value 0x8L=0x8L for class OFBsnPortCounterStatsRequestVer13
+                   return OFBsnPortCounterStatsRequestVer13.READER.readFrom(bb);
+               case 0x6:
+                   // discriminator value 0x6L=0x6L for class OFBsnSwitchPipelineStatsRequestVer13
+                   return OFBsnSwitchPipelineStatsRequestVer13.READER.readFrom(bb);
+               case 0xb:
+                   // discriminator value 0xbL=0xbL for class OFBsnTableChecksumStatsRequestVer13
+                   return OFBsnTableChecksumStatsRequestVer13.READER.readFrom(bb);
+               case 0x9:
+                   // discriminator value 0x9L=0x9L for class OFBsnVlanCounterStatsRequestVer13
+                   return OFBsnVlanCounterStatsRequestVer13.READER.readFrom(bb);
+               case 0xf:
+                   // discriminator value 0xfL=0xfL for class OFBsnVrfCounterStatsRequestVer13
+                   return OFBsnVrfCounterStatsRequestVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFBsnStatsRequestVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsEntryVer13.java
new file mode 100644
index 0000000..753708b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsEntryVer13.java
@@ -0,0 +1,229 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSwitchPipelineStatsEntryVer13 implements OFBsnSwitchPipelineStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSwitchPipelineStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 256;
+
+        private final static String DEFAULT_PIPELINE = "";
+
+    // OF message fields
+    private final String pipeline;
+//
+    // Immutable default instance
+    final static OFBsnSwitchPipelineStatsEntryVer13 DEFAULT = new OFBsnSwitchPipelineStatsEntryVer13(
+        DEFAULT_PIPELINE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSwitchPipelineStatsEntryVer13(String pipeline) {
+        this.pipeline = pipeline;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnSwitchPipelineStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSwitchPipelineStatsEntry.Builder {
+        final OFBsnSwitchPipelineStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean pipelineSet;
+        private String pipeline;
+
+        BuilderWithParent(OFBsnSwitchPipelineStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsEntry.Builder setPipeline(String pipeline) {
+        this.pipeline = pipeline;
+        this.pipelineSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnSwitchPipelineStatsEntry build() {
+                String pipeline = this.pipelineSet ? this.pipeline : parentMessage.pipeline;
+                if(pipeline == null)
+                    throw new NullPointerException("Property pipeline must not be null");
+
+                //
+                return new OFBsnSwitchPipelineStatsEntryVer13(
+                    pipeline
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSwitchPipelineStatsEntry.Builder {
+        // OF message fields
+        private boolean pipelineSet;
+        private String pipeline;
+
+    @Override
+    public String getPipeline() {
+        return pipeline;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsEntry.Builder setPipeline(String pipeline) {
+        this.pipeline = pipeline;
+        this.pipelineSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnSwitchPipelineStatsEntry build() {
+            String pipeline = this.pipelineSet ? this.pipeline : DEFAULT_PIPELINE;
+            if(pipeline == null)
+                throw new NullPointerException("Property pipeline must not be null");
+
+
+            return new OFBsnSwitchPipelineStatsEntryVer13(
+                    pipeline
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSwitchPipelineStatsEntry> {
+        @Override
+        public OFBsnSwitchPipelineStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            String pipeline = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFBsnSwitchPipelineStatsEntryVer13 bsnSwitchPipelineStatsEntryVer13 = new OFBsnSwitchPipelineStatsEntryVer13(
+                    pipeline
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSwitchPipelineStatsEntryVer13);
+            return bsnSwitchPipelineStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSwitchPipelineStatsEntryVer13Funnel FUNNEL = new OFBsnSwitchPipelineStatsEntryVer13Funnel();
+    static class OFBsnSwitchPipelineStatsEntryVer13Funnel implements Funnel<OFBsnSwitchPipelineStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSwitchPipelineStatsEntryVer13 message, PrimitiveSink sink) {
+            sink.putUnencodedChars(message.pipeline);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSwitchPipelineStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSwitchPipelineStatsEntryVer13 message) {
+            ChannelUtils.writeFixedLengthString(bb, message.pipeline, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSwitchPipelineStatsEntryVer13(");
+        b.append("pipeline=").append(pipeline);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSwitchPipelineStatsEntryVer13 other = (OFBsnSwitchPipelineStatsEntryVer13) obj;
+
+        if (pipeline == null) {
+            if (other.pipeline != null)
+                return false;
+        } else if (!pipeline.equals(other.pipeline))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((pipeline == null) ? 0 : pipeline.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsReplyVer13.java
new file mode 100644
index 0000000..1d852d5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSwitchPipelineStatsReplyVer13 implements OFBsnSwitchPipelineStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSwitchPipelineStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnSwitchPipelineStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnSwitchPipelineStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnSwitchPipelineStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnSwitchPipelineStatsReplyVer13 DEFAULT = new OFBsnSwitchPipelineStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSwitchPipelineStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnSwitchPipelineStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+    @Override
+    public List<OFBsnSwitchPipelineStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnSwitchPipelineStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSwitchPipelineStatsReply.Builder {
+        final OFBsnSwitchPipelineStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnSwitchPipelineStatsEntry> entries;
+
+        BuilderWithParent(OFBsnSwitchPipelineStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+    @Override
+    public List<OFBsnSwitchPipelineStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsReply.Builder setEntries(List<OFBsnSwitchPipelineStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnSwitchPipelineStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnSwitchPipelineStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnSwitchPipelineStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSwitchPipelineStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnSwitchPipelineStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+    @Override
+    public List<OFBsnSwitchPipelineStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsReply.Builder setEntries(List<OFBsnSwitchPipelineStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnSwitchPipelineStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnSwitchPipelineStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnSwitchPipelineStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSwitchPipelineStatsReply> {
+        @Override
+        public OFBsnSwitchPipelineStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x6L
+            int subtype = bb.readInt();
+            if(subtype != 0x6)
+                throw new OFParseError("Wrong subtype: Expected=0x6L(0x6L), got="+subtype);
+            List<OFBsnSwitchPipelineStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnSwitchPipelineStatsEntryVer13.READER);
+
+            OFBsnSwitchPipelineStatsReplyVer13 bsnSwitchPipelineStatsReplyVer13 = new OFBsnSwitchPipelineStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSwitchPipelineStatsReplyVer13);
+            return bsnSwitchPipelineStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSwitchPipelineStatsReplyVer13Funnel FUNNEL = new OFBsnSwitchPipelineStatsReplyVer13Funnel();
+    static class OFBsnSwitchPipelineStatsReplyVer13Funnel implements Funnel<OFBsnSwitchPipelineStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSwitchPipelineStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            sink.putInt(0x6);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSwitchPipelineStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSwitchPipelineStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            bb.writeInt(0x6);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSwitchPipelineStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSwitchPipelineStatsReplyVer13 other = (OFBsnSwitchPipelineStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsRequestVer13.java
new file mode 100644
index 0000000..f84e7c0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSwitchPipelineStatsRequestVer13.java
@@ -0,0 +1,397 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnSwitchPipelineStatsRequestVer13 implements OFBsnSwitchPipelineStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnSwitchPipelineStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFBsnSwitchPipelineStatsRequestVer13 DEFAULT = new OFBsnSwitchPipelineStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnSwitchPipelineStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+
+
+    public OFBsnSwitchPipelineStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnSwitchPipelineStatsRequest.Builder {
+        final OFBsnSwitchPipelineStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFBsnSwitchPipelineStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+
+
+        @Override
+        public OFBsnSwitchPipelineStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFBsnSwitchPipelineStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnSwitchPipelineStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnSwitchPipelineStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+//
+        @Override
+        public OFBsnSwitchPipelineStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFBsnSwitchPipelineStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnSwitchPipelineStatsRequest> {
+        @Override
+        public OFBsnSwitchPipelineStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x6L
+            int subtype = bb.readInt();
+            if(subtype != 0x6)
+                throw new OFParseError("Wrong subtype: Expected=0x6L(0x6L), got="+subtype);
+
+            OFBsnSwitchPipelineStatsRequestVer13 bsnSwitchPipelineStatsRequestVer13 = new OFBsnSwitchPipelineStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnSwitchPipelineStatsRequestVer13);
+            return bsnSwitchPipelineStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnSwitchPipelineStatsRequestVer13Funnel FUNNEL = new OFBsnSwitchPipelineStatsRequestVer13Funnel();
+    static class OFBsnSwitchPipelineStatsRequestVer13Funnel implements Funnel<OFBsnSwitchPipelineStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnSwitchPipelineStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            sink.putInt(0x6);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnSwitchPipelineStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnSwitchPipelineStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            bb.writeInt(0x6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnSwitchPipelineStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnSwitchPipelineStatsRequestVer13 other = (OFBsnSwitchPipelineStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsEntryVer13.java
new file mode 100644
index 0000000..275cf10
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsEntryVer13.java
@@ -0,0 +1,283 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTableChecksumStatsEntryVer13 implements OFBsnTableChecksumStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTableChecksumStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 9;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static U64 DEFAULT_CHECKSUM = U64.ZERO;
+
+    // OF message fields
+    private final TableId tableId;
+    private final U64 checksum;
+//
+    // Immutable default instance
+    final static OFBsnTableChecksumStatsEntryVer13 DEFAULT = new OFBsnTableChecksumStatsEntryVer13(
+        DEFAULT_TABLE_ID, DEFAULT_CHECKSUM
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTableChecksumStatsEntryVer13(TableId tableId, U64 checksum) {
+        this.tableId = tableId;
+        this.checksum = checksum;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public U64 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTableChecksumStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTableChecksumStatsEntry.Builder {
+        final OFBsnTableChecksumStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean checksumSet;
+        private U64 checksum;
+
+        BuilderWithParent(OFBsnTableChecksumStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsEntry.Builder setChecksum(U64 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTableChecksumStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                U64 checksum = this.checksumSet ? this.checksum : parentMessage.checksum;
+                if(checksum == null)
+                    throw new NullPointerException("Property checksum must not be null");
+
+                //
+                return new OFBsnTableChecksumStatsEntryVer13(
+                    tableId,
+                    checksum
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTableChecksumStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean checksumSet;
+        private U64 checksum;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getChecksum() {
+        return checksum;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsEntry.Builder setChecksum(U64 checksum) {
+        this.checksum = checksum;
+        this.checksumSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTableChecksumStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            U64 checksum = this.checksumSet ? this.checksum : DEFAULT_CHECKSUM;
+            if(checksum == null)
+                throw new NullPointerException("Property checksum must not be null");
+
+
+            return new OFBsnTableChecksumStatsEntryVer13(
+                    tableId,
+                    checksum
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTableChecksumStatsEntry> {
+        @Override
+        public OFBsnTableChecksumStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            TableId tableId = TableId.readByte(bb);
+            U64 checksum = U64.ofRaw(bb.readLong());
+
+            OFBsnTableChecksumStatsEntryVer13 bsnTableChecksumStatsEntryVer13 = new OFBsnTableChecksumStatsEntryVer13(
+                    tableId,
+                      checksum
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTableChecksumStatsEntryVer13);
+            return bsnTableChecksumStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTableChecksumStatsEntryVer13Funnel FUNNEL = new OFBsnTableChecksumStatsEntryVer13Funnel();
+    static class OFBsnTableChecksumStatsEntryVer13Funnel implements Funnel<OFBsnTableChecksumStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTableChecksumStatsEntryVer13 message, PrimitiveSink sink) {
+            message.tableId.putTo(sink);
+            message.checksum.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTableChecksumStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTableChecksumStatsEntryVer13 message) {
+            message.tableId.writeByte(bb);
+            bb.writeLong(message.checksum.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTableChecksumStatsEntryVer13(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("checksum=").append(checksum);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTableChecksumStatsEntryVer13 other = (OFBsnTableChecksumStatsEntryVer13) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (checksum == null) {
+            if (other.checksum != null)
+                return false;
+        } else if (!checksum.equals(other.checksum))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((checksum == null) ? 0 : checksum.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsReplyVer13.java
new file mode 100644
index 0000000..4fd5c00
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTableChecksumStatsReplyVer13 implements OFBsnTableChecksumStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTableChecksumStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnTableChecksumStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnTableChecksumStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnTableChecksumStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnTableChecksumStatsReplyVer13 DEFAULT = new OFBsnTableChecksumStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTableChecksumStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnTableChecksumStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public List<OFBsnTableChecksumStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnTableChecksumStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTableChecksumStatsReply.Builder {
+        final OFBsnTableChecksumStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnTableChecksumStatsEntry> entries;
+
+        BuilderWithParent(OFBsnTableChecksumStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public List<OFBsnTableChecksumStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsReply.Builder setEntries(List<OFBsnTableChecksumStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnTableChecksumStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnTableChecksumStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnTableChecksumStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTableChecksumStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnTableChecksumStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+    @Override
+    public List<OFBsnTableChecksumStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsReply.Builder setEntries(List<OFBsnTableChecksumStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnTableChecksumStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnTableChecksumStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnTableChecksumStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTableChecksumStatsReply> {
+        @Override
+        public OFBsnTableChecksumStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xbL
+            int subtype = bb.readInt();
+            if(subtype != 0xb)
+                throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got="+subtype);
+            List<OFBsnTableChecksumStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnTableChecksumStatsEntryVer13.READER);
+
+            OFBsnTableChecksumStatsReplyVer13 bsnTableChecksumStatsReplyVer13 = new OFBsnTableChecksumStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTableChecksumStatsReplyVer13);
+            return bsnTableChecksumStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTableChecksumStatsReplyVer13Funnel FUNNEL = new OFBsnTableChecksumStatsReplyVer13Funnel();
+    static class OFBsnTableChecksumStatsReplyVer13Funnel implements Funnel<OFBsnTableChecksumStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTableChecksumStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            sink.putInt(0xb);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTableChecksumStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTableChecksumStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            bb.writeInt(0xb);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTableChecksumStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTableChecksumStatsReplyVer13 other = (OFBsnTableChecksumStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsRequestVer13.java
new file mode 100644
index 0000000..57c88c8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableChecksumStatsRequestVer13.java
@@ -0,0 +1,397 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTableChecksumStatsRequestVer13 implements OFBsnTableChecksumStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTableChecksumStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFBsnTableChecksumStatsRequestVer13 DEFAULT = new OFBsnTableChecksumStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTableChecksumStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+
+
+    public OFBsnTableChecksumStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTableChecksumStatsRequest.Builder {
+        final OFBsnTableChecksumStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFBsnTableChecksumStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+
+
+        @Override
+        public OFBsnTableChecksumStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFBsnTableChecksumStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTableChecksumStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnTableChecksumStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xbL;
+    }
+
+//
+        @Override
+        public OFBsnTableChecksumStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFBsnTableChecksumStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTableChecksumStatsRequest> {
+        @Override
+        public OFBsnTableChecksumStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xbL
+            int subtype = bb.readInt();
+            if(subtype != 0xb)
+                throw new OFParseError("Wrong subtype: Expected=0xbL(0xbL), got="+subtype);
+
+            OFBsnTableChecksumStatsRequestVer13 bsnTableChecksumStatsRequestVer13 = new OFBsnTableChecksumStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTableChecksumStatsRequestVer13);
+            return bsnTableChecksumStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTableChecksumStatsRequestVer13Funnel FUNNEL = new OFBsnTableChecksumStatsRequestVer13Funnel();
+    static class OFBsnTableChecksumStatsRequestVer13Funnel implements Funnel<OFBsnTableChecksumStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTableChecksumStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            sink.putInt(0xb);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTableChecksumStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTableChecksumStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xbL
+            bb.writeInt(0xb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTableChecksumStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTableChecksumStatsRequestVer13 other = (OFBsnTableChecksumStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableSetBucketsSizeVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableSetBucketsSizeVer13.java
new file mode 100644
index 0000000..b14a473
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTableSetBucketsSizeVer13.java
@@ -0,0 +1,425 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTableSetBucketsSizeVer13 implements OFBsnTableSetBucketsSize {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTableSetBucketsSizeVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_BUCKETS_SIZE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final TableId tableId;
+    private final long bucketsSize;
+//
+    // Immutable default instance
+    final static OFBsnTableSetBucketsSizeVer13 DEFAULT = new OFBsnTableSetBucketsSizeVer13(
+        DEFAULT_XID, DEFAULT_TABLE_ID, DEFAULT_BUCKETS_SIZE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTableSetBucketsSizeVer13(long xid, TableId tableId, long bucketsSize) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.bucketsSize = bucketsSize;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3dL;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+
+
+    public OFBsnTableSetBucketsSize.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTableSetBucketsSize.Builder {
+        final OFBsnTableSetBucketsSizeVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean bucketsSizeSet;
+        private long bucketsSize;
+
+        BuilderWithParent(OFBsnTableSetBucketsSizeVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTableSetBucketsSize.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3dL;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnTableSetBucketsSize.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+    @Override
+    public OFBsnTableSetBucketsSize.Builder setBucketsSize(long bucketsSize) {
+        this.bucketsSize = bucketsSize;
+        this.bucketsSizeSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnTableSetBucketsSize build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long bucketsSize = this.bucketsSizeSet ? this.bucketsSize : parentMessage.bucketsSize;
+
+                //
+                return new OFBsnTableSetBucketsSizeVer13(
+                    xid,
+                    tableId,
+                    bucketsSize
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTableSetBucketsSize.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean bucketsSizeSet;
+        private long bucketsSize;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTableSetBucketsSize.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3dL;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFBsnTableSetBucketsSize.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getBucketsSize() {
+        return bucketsSize;
+    }
+
+    @Override
+    public OFBsnTableSetBucketsSize.Builder setBucketsSize(long bucketsSize) {
+        this.bucketsSize = bucketsSize;
+        this.bucketsSizeSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnTableSetBucketsSize build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long bucketsSize = this.bucketsSizeSet ? this.bucketsSize : DEFAULT_BUCKETS_SIZE;
+
+
+            return new OFBsnTableSetBucketsSizeVer13(
+                    xid,
+                    tableId,
+                    bucketsSize
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTableSetBucketsSize> {
+        @Override
+        public OFBsnTableSetBucketsSize readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3dL
+            int subtype = bb.readInt();
+            if(subtype != 0x3d)
+                throw new OFParseError("Wrong subtype: Expected=0x3dL(0x3dL), got="+subtype);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long bucketsSize = U32.f(bb.readInt());
+
+            OFBsnTableSetBucketsSizeVer13 bsnTableSetBucketsSizeVer13 = new OFBsnTableSetBucketsSizeVer13(
+                    xid,
+                      tableId,
+                      bucketsSize
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTableSetBucketsSizeVer13);
+            return bsnTableSetBucketsSizeVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTableSetBucketsSizeVer13Funnel FUNNEL = new OFBsnTableSetBucketsSizeVer13Funnel();
+    static class OFBsnTableSetBucketsSizeVer13Funnel implements Funnel<OFBsnTableSetBucketsSizeVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTableSetBucketsSizeVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3dL
+            sink.putInt(0x3d);
+            // skip pad (1 bytes)
+            message.tableId.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.bucketsSize);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTableSetBucketsSizeVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTableSetBucketsSizeVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3dL
+            bb.writeInt(0x3d);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.tableId.writeByte(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.bucketsSize));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTableSetBucketsSizeVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("bucketsSize=").append(bucketsSize);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTableSetBucketsSizeVer13 other = (OFBsnTableSetBucketsSizeVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( bucketsSize != other.bucketsSize)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (bucketsSize ^ (bucketsSize >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTcpFlagSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTcpFlagSerializerVer13.java
new file mode 100644
index 0000000..2b222b1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTcpFlagSerializerVer13.java
@@ -0,0 +1,126 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnTcpFlag;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFBsnTcpFlagSerializerVer13 {
+
+    public final static short BSN_TCP_FLAG_FIN_VAL = (short) 0x1;
+    public final static short BSN_TCP_FLAG_SYN_VAL = (short) 0x2;
+    public final static short BSN_TCP_FLAG_RST_VAL = (short) 0x4;
+    public final static short BSN_TCP_FLAG_PSH_VAL = (short) 0x8;
+    public final static short BSN_TCP_FLAG_ACK_VAL = (short) 0x10;
+    public final static short BSN_TCP_FLAG_URG_VAL = (short) 0x20;
+    public final static short BSN_TCP_FLAG_ECE_VAL = (short) 0x40;
+    public final static short BSN_TCP_FLAG_CWR_VAL = (short) 0x80;
+    public final static short BSN_TCP_FLAG_NS_VAL = (short) 0x100;
+
+    public static Set<OFBsnTcpFlag> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFBsnTcpFlag> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFBsnTcpFlag> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFBsnTcpFlag> ofWireValue(short val) {
+        EnumSet<OFBsnTcpFlag> set = EnumSet.noneOf(OFBsnTcpFlag.class);
+
+        if((val & BSN_TCP_FLAG_FIN_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_FIN);
+        if((val & BSN_TCP_FLAG_SYN_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_SYN);
+        if((val & BSN_TCP_FLAG_RST_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_RST);
+        if((val & BSN_TCP_FLAG_PSH_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_PSH);
+        if((val & BSN_TCP_FLAG_ACK_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_ACK);
+        if((val & BSN_TCP_FLAG_URG_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_URG);
+        if((val & BSN_TCP_FLAG_ECE_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_ECE);
+        if((val & BSN_TCP_FLAG_CWR_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_CWR);
+        if((val & BSN_TCP_FLAG_NS_VAL) != 0)
+            set.add(OFBsnTcpFlag.BSN_TCP_FLAG_NS);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFBsnTcpFlag> set) {
+        short wireValue = 0;
+
+        for(OFBsnTcpFlag e: set) {
+            switch(e) {
+                case BSN_TCP_FLAG_FIN:
+                    wireValue |= BSN_TCP_FLAG_FIN_VAL;
+                    break;
+                case BSN_TCP_FLAG_SYN:
+                    wireValue |= BSN_TCP_FLAG_SYN_VAL;
+                    break;
+                case BSN_TCP_FLAG_RST:
+                    wireValue |= BSN_TCP_FLAG_RST_VAL;
+                    break;
+                case BSN_TCP_FLAG_PSH:
+                    wireValue |= BSN_TCP_FLAG_PSH_VAL;
+                    break;
+                case BSN_TCP_FLAG_ACK:
+                    wireValue |= BSN_TCP_FLAG_ACK_VAL;
+                    break;
+                case BSN_TCP_FLAG_URG:
+                    wireValue |= BSN_TCP_FLAG_URG_VAL;
+                    break;
+                case BSN_TCP_FLAG_ECE:
+                    wireValue |= BSN_TCP_FLAG_ECE_VAL;
+                    break;
+                case BSN_TCP_FLAG_CWR:
+                    wireValue |= BSN_TCP_FLAG_CWR_VAL;
+                    break;
+                case BSN_TCP_FLAG_NS:
+                    wireValue |= BSN_TCP_FLAG_NS_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFBsnTcpFlag in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTimeReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTimeReplyVer13.java
new file mode 100644
index 0000000..4a7f57b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTimeReplyVer13.java
@@ -0,0 +1,368 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTimeReplyVer13 implements OFBsnTimeReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTimeReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_TIME_MS = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final U64 timeMs;
+//
+    // Immutable default instance
+    final static OFBsnTimeReplyVer13 DEFAULT = new OFBsnTimeReplyVer13(
+        DEFAULT_XID, DEFAULT_TIME_MS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTimeReplyVer13(long xid, U64 timeMs) {
+        this.xid = xid;
+        this.timeMs = timeMs;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2dL;
+    }
+
+    @Override
+    public U64 getTimeMs() {
+        return timeMs;
+    }
+
+
+
+    public OFBsnTimeReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTimeReply.Builder {
+        final OFBsnTimeReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeMsSet;
+        private U64 timeMs;
+
+        BuilderWithParent(OFBsnTimeReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTimeReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2dL;
+    }
+
+    @Override
+    public U64 getTimeMs() {
+        return timeMs;
+    }
+
+    @Override
+    public OFBsnTimeReply.Builder setTimeMs(U64 timeMs) {
+        this.timeMs = timeMs;
+        this.timeMsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnTimeReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 timeMs = this.timeMsSet ? this.timeMs : parentMessage.timeMs;
+                if(timeMs == null)
+                    throw new NullPointerException("Property timeMs must not be null");
+
+                //
+                return new OFBsnTimeReplyVer13(
+                    xid,
+                    timeMs
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTimeReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean timeMsSet;
+        private U64 timeMs;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTimeReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2dL;
+    }
+
+    @Override
+    public U64 getTimeMs() {
+        return timeMs;
+    }
+
+    @Override
+    public OFBsnTimeReply.Builder setTimeMs(U64 timeMs) {
+        this.timeMs = timeMs;
+        this.timeMsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnTimeReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 timeMs = this.timeMsSet ? this.timeMs : DEFAULT_TIME_MS;
+            if(timeMs == null)
+                throw new NullPointerException("Property timeMs must not be null");
+
+
+            return new OFBsnTimeReplyVer13(
+                    xid,
+                    timeMs
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTimeReply> {
+        @Override
+        public OFBsnTimeReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2dL
+            int subtype = bb.readInt();
+            if(subtype != 0x2d)
+                throw new OFParseError("Wrong subtype: Expected=0x2dL(0x2dL), got="+subtype);
+            U64 timeMs = U64.ofRaw(bb.readLong());
+
+            OFBsnTimeReplyVer13 bsnTimeReplyVer13 = new OFBsnTimeReplyVer13(
+                    xid,
+                      timeMs
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTimeReplyVer13);
+            return bsnTimeReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTimeReplyVer13Funnel FUNNEL = new OFBsnTimeReplyVer13Funnel();
+    static class OFBsnTimeReplyVer13Funnel implements Funnel<OFBsnTimeReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTimeReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2dL
+            sink.putInt(0x2d);
+            message.timeMs.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTimeReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTimeReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2dL
+            bb.writeInt(0x2d);
+            bb.writeLong(message.timeMs.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTimeReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("timeMs=").append(timeMs);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTimeReplyVer13 other = (OFBsnTimeReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (timeMs == null) {
+            if (other.timeMs != null)
+                return false;
+        } else if (!timeMs.equals(other.timeMs))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((timeMs == null) ? 0 : timeMs.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTimeRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTimeRequestVer13.java
new file mode 100644
index 0000000..eae56b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTimeRequestVer13.java
@@ -0,0 +1,314 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTimeRequestVer13 implements OFBsnTimeRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTimeRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFBsnTimeRequestVer13 DEFAULT = new OFBsnTimeRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTimeRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2cL;
+    }
+
+
+
+    public OFBsnTimeRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTimeRequest.Builder {
+        final OFBsnTimeRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFBsnTimeRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTimeRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2cL;
+    }
+
+
+
+        @Override
+        public OFBsnTimeRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFBsnTimeRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTimeRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnTimeRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2cL;
+    }
+
+//
+        @Override
+        public OFBsnTimeRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFBsnTimeRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTimeRequest> {
+        @Override
+        public OFBsnTimeRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2cL
+            int subtype = bb.readInt();
+            if(subtype != 0x2c)
+                throw new OFParseError("Wrong subtype: Expected=0x2cL(0x2cL), got="+subtype);
+
+            OFBsnTimeRequestVer13 bsnTimeRequestVer13 = new OFBsnTimeRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTimeRequestVer13);
+            return bsnTimeRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTimeRequestVer13Funnel FUNNEL = new OFBsnTimeRequestVer13Funnel();
+    static class OFBsnTimeRequestVer13Funnel implements Funnel<OFBsnTimeRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTimeRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2cL
+            sink.putInt(0x2c);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTimeRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTimeRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2cL
+            bb.writeInt(0x2c);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTimeRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTimeRequestVer13 other = (OFBsnTimeRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvBroadcastQueryTimeoutVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvBroadcastQueryTimeoutVer13.java
new file mode 100644
index 0000000..ba18e22
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvBroadcastQueryTimeoutVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvBroadcastQueryTimeoutVer13 implements OFBsnTlvBroadcastQueryTimeout {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvBroadcastQueryTimeoutVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_VALUE = 0x0L;
+
+    // OF message fields
+    private final long value;
+//
+    // Immutable default instance
+    final static OFBsnTlvBroadcastQueryTimeoutVer13 DEFAULT = new OFBsnTlvBroadcastQueryTimeoutVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvBroadcastQueryTimeoutVer13(long value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xa;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvBroadcastQueryTimeout.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvBroadcastQueryTimeout.Builder {
+        final OFBsnTlvBroadcastQueryTimeoutVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+        BuilderWithParent(OFBsnTlvBroadcastQueryTimeoutVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xa;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvBroadcastQueryTimeout.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvBroadcastQueryTimeout build() {
+                long value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvBroadcastQueryTimeoutVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvBroadcastQueryTimeout.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+    @Override
+    public int getType() {
+        return 0xa;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvBroadcastQueryTimeout.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvBroadcastQueryTimeout build() {
+            long value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvBroadcastQueryTimeoutVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvBroadcastQueryTimeout> {
+        @Override
+        public OFBsnTlvBroadcastQueryTimeout readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xa
+            short type = bb.readShort();
+            if(type != (short) 0xa)
+                throw new OFParseError("Wrong type: Expected=0xa(0xa), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long value = U32.f(bb.readInt());
+
+            OFBsnTlvBroadcastQueryTimeoutVer13 bsnTlvBroadcastQueryTimeoutVer13 = new OFBsnTlvBroadcastQueryTimeoutVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvBroadcastQueryTimeoutVer13);
+            return bsnTlvBroadcastQueryTimeoutVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvBroadcastQueryTimeoutVer13Funnel FUNNEL = new OFBsnTlvBroadcastQueryTimeoutVer13Funnel();
+    static class OFBsnTlvBroadcastQueryTimeoutVer13Funnel implements Funnel<OFBsnTlvBroadcastQueryTimeoutVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvBroadcastQueryTimeoutVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xa
+            sink.putShort((short) 0xa);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvBroadcastQueryTimeoutVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvBroadcastQueryTimeoutVer13 message) {
+            // fixed value property type = 0xa
+            bb.writeShort((short) 0xa);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvBroadcastQueryTimeoutVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvBroadcastQueryTimeoutVer13 other = (OFBsnTlvBroadcastQueryTimeoutVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (value ^ (value >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvCircuitIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvCircuitIdVer13.java
new file mode 100644
index 0000000..73a3fb4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvCircuitIdVer13.java
@@ -0,0 +1,270 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFBsnTlvCircuitIdVer13 implements OFBsnTlvCircuitId {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvCircuitIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static byte[] DEFAULT_VALUE = new byte[0];
+
+    // OF message fields
+    private final byte[] value;
+//
+    // Immutable default instance
+    final static OFBsnTlvCircuitIdVer13 DEFAULT = new OFBsnTlvCircuitIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvCircuitIdVer13(byte[] value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xe;
+    }
+
+    @Override
+    public byte[] getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvCircuitId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvCircuitId.Builder {
+        final OFBsnTlvCircuitIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private byte[] value;
+
+        BuilderWithParent(OFBsnTlvCircuitIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xe;
+    }
+
+    @Override
+    public byte[] getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvCircuitId.Builder setValue(byte[] value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvCircuitId build() {
+                byte[] value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvCircuitIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvCircuitId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private byte[] value;
+
+    @Override
+    public int getType() {
+        return 0xe;
+    }
+
+    @Override
+    public byte[] getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvCircuitId.Builder setValue(byte[] value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvCircuitId build() {
+            byte[] value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvCircuitIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvCircuitId> {
+        @Override
+        public OFBsnTlvCircuitId readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xe
+            short type = bb.readShort();
+            if(type != (short) 0xe)
+                throw new OFParseError("Wrong type: Expected=0xe(0xe), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            byte[] value = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFBsnTlvCircuitIdVer13 bsnTlvCircuitIdVer13 = new OFBsnTlvCircuitIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvCircuitIdVer13);
+            return bsnTlvCircuitIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvCircuitIdVer13Funnel FUNNEL = new OFBsnTlvCircuitIdVer13Funnel();
+    static class OFBsnTlvCircuitIdVer13Funnel implements Funnel<OFBsnTlvCircuitIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvCircuitIdVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xe
+            sink.putShort((short) 0xe);
+            // FIXME: skip funnel of length
+            sink.putBytes(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvCircuitIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvCircuitIdVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0xe
+            bb.writeShort((short) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeBytes(message.value);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvCircuitIdVer13(");
+        b.append("value=").append(Arrays.toString(value));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvCircuitIdVer13 other = (OFBsnTlvCircuitIdVer13) obj;
+
+        if (!Arrays.equals(value, other.value))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + Arrays.hashCode(value);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvCrcEnabledVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvCrcEnabledVer13.java
new file mode 100644
index 0000000..357fd67
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvCrcEnabledVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvCrcEnabledVer13 implements OFBsnTlvCrcEnabled {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvCrcEnabledVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static short DEFAULT_VALUE = (short) 0x0;
+
+    // OF message fields
+    private final short value;
+//
+    // Immutable default instance
+    final static OFBsnTlvCrcEnabledVer13 DEFAULT = new OFBsnTlvCrcEnabledVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvCrcEnabledVer13(short value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x16;
+    }
+
+    @Override
+    public short getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvCrcEnabled.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvCrcEnabled.Builder {
+        final OFBsnTlvCrcEnabledVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private short value;
+
+        BuilderWithParent(OFBsnTlvCrcEnabledVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x16;
+    }
+
+    @Override
+    public short getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvCrcEnabled.Builder setValue(short value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvCrcEnabled build() {
+                short value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvCrcEnabledVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvCrcEnabled.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private short value;
+
+    @Override
+    public int getType() {
+        return 0x16;
+    }
+
+    @Override
+    public short getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvCrcEnabled.Builder setValue(short value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvCrcEnabled build() {
+            short value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvCrcEnabledVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvCrcEnabled> {
+        @Override
+        public OFBsnTlvCrcEnabled readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x16
+            short type = bb.readShort();
+            if(type != (short) 0x16)
+                throw new OFParseError("Wrong type: Expected=0x16(0x16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 5)
+                throw new OFParseError("Wrong length: Expected=5(5), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            short value = U8.f(bb.readByte());
+
+            OFBsnTlvCrcEnabledVer13 bsnTlvCrcEnabledVer13 = new OFBsnTlvCrcEnabledVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvCrcEnabledVer13);
+            return bsnTlvCrcEnabledVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvCrcEnabledVer13Funnel FUNNEL = new OFBsnTlvCrcEnabledVer13Funnel();
+    static class OFBsnTlvCrcEnabledVer13Funnel implements Funnel<OFBsnTlvCrcEnabledVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvCrcEnabledVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x16
+            sink.putShort((short) 0x16);
+            // fixed value property length = 5
+            sink.putShort((short) 0x5);
+            sink.putShort(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvCrcEnabledVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvCrcEnabledVer13 message) {
+            // fixed value property type = 0x16
+            bb.writeShort((short) 0x16);
+            // fixed value property length = 5
+            bb.writeShort((short) 0x5);
+            bb.writeByte(U8.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvCrcEnabledVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvCrcEnabledVer13 other = (OFBsnTlvCrcEnabledVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + value;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleNotificationVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleNotificationVer13.java
new file mode 100644
index 0000000..75ce07f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleNotificationVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvIdleNotificationVer13 implements OFBsnTlvIdleNotification {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvIdleNotificationVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFBsnTlvIdleNotificationVer13 DEFAULT = new OFBsnTlvIdleNotificationVer13(
+
+    );
+
+    final static OFBsnTlvIdleNotificationVer13 INSTANCE = new OFBsnTlvIdleNotificationVer13();
+    // private empty constructor - use shared instance!
+    private OFBsnTlvIdleNotificationVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x7;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFBsnTlvIdleNotification.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFBsnTlvIdleNotificationVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvIdleNotification> {
+        @Override
+        public OFBsnTlvIdleNotification readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x7
+            short type = bb.readShort();
+            if(type != (short) 0x7)
+                throw new OFParseError("Wrong type: Expected=0x7(0x7), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvIdleNotificationVer13Funnel FUNNEL = new OFBsnTlvIdleNotificationVer13Funnel();
+    static class OFBsnTlvIdleNotificationVer13Funnel implements Funnel<OFBsnTlvIdleNotificationVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvIdleNotificationVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x7
+            sink.putShort((short) 0x7);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvIdleNotificationVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvIdleNotificationVer13 message) {
+            // fixed value property type = 0x7
+            bb.writeShort((short) 0x7);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvIdleNotificationVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleTimeVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleTimeVer13.java
new file mode 100644
index 0000000..11b4312
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleTimeVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvIdleTimeVer13 implements OFBsnTlvIdleTime {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvIdleTimeVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFBsnTlvIdleTimeVer13 DEFAULT = new OFBsnTlvIdleTimeVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvIdleTimeVer13(U64 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x5;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvIdleTime.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvIdleTime.Builder {
+        final OFBsnTlvIdleTimeVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFBsnTlvIdleTimeVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x5;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvIdleTime.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvIdleTime build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvIdleTimeVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvIdleTime.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public int getType() {
+        return 0x5;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvIdleTime.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvIdleTime build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvIdleTimeVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvIdleTime> {
+        @Override
+        public OFBsnTlvIdleTime readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x5
+            short type = bb.readShort();
+            if(type != (short) 0x5)
+                throw new OFParseError("Wrong type: Expected=0x5(0x5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFBsnTlvIdleTimeVer13 bsnTlvIdleTimeVer13 = new OFBsnTlvIdleTimeVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvIdleTimeVer13);
+            return bsnTlvIdleTimeVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvIdleTimeVer13Funnel FUNNEL = new OFBsnTlvIdleTimeVer13Funnel();
+    static class OFBsnTlvIdleTimeVer13Funnel implements Funnel<OFBsnTlvIdleTimeVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvIdleTimeVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x5
+            sink.putShort((short) 0x5);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvIdleTimeVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvIdleTimeVer13 message) {
+            // fixed value property type = 0x5
+            bb.writeShort((short) 0x5);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvIdleTimeVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvIdleTimeVer13 other = (OFBsnTlvIdleTimeVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleTimeoutVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleTimeoutVer13.java
new file mode 100644
index 0000000..c958c11
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIdleTimeoutVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvIdleTimeoutVer13 implements OFBsnTlvIdleTimeout {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvIdleTimeoutVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_VALUE = 0x0L;
+
+    // OF message fields
+    private final long value;
+//
+    // Immutable default instance
+    final static OFBsnTlvIdleTimeoutVer13 DEFAULT = new OFBsnTlvIdleTimeoutVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvIdleTimeoutVer13(long value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x8;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvIdleTimeout.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvIdleTimeout.Builder {
+        final OFBsnTlvIdleTimeoutVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+        BuilderWithParent(OFBsnTlvIdleTimeoutVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x8;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvIdleTimeout.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvIdleTimeout build() {
+                long value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvIdleTimeoutVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvIdleTimeout.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+    @Override
+    public int getType() {
+        return 0x8;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvIdleTimeout.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvIdleTimeout build() {
+            long value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvIdleTimeoutVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvIdleTimeout> {
+        @Override
+        public OFBsnTlvIdleTimeout readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x8
+            short type = bb.readShort();
+            if(type != (short) 0x8)
+                throw new OFParseError("Wrong type: Expected=0x8(0x8), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long value = U32.f(bb.readInt());
+
+            OFBsnTlvIdleTimeoutVer13 bsnTlvIdleTimeoutVer13 = new OFBsnTlvIdleTimeoutVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvIdleTimeoutVer13);
+            return bsnTlvIdleTimeoutVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvIdleTimeoutVer13Funnel FUNNEL = new OFBsnTlvIdleTimeoutVer13Funnel();
+    static class OFBsnTlvIdleTimeoutVer13Funnel implements Funnel<OFBsnTlvIdleTimeoutVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvIdleTimeoutVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x8
+            sink.putShort((short) 0x8);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvIdleTimeoutVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvIdleTimeoutVer13 message) {
+            // fixed value property type = 0x8
+            bb.writeShort((short) 0x8);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvIdleTimeoutVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvIdleTimeoutVer13 other = (OFBsnTlvIdleTimeoutVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (value ^ (value >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIpv4Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIpv4Ver13.java
new file mode 100644
index 0000000..4deb9e0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvIpv4Ver13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvIpv4Ver13 implements OFBsnTlvIpv4 {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvIpv4Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFBsnTlvIpv4Ver13 DEFAULT = new OFBsnTlvIpv4Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvIpv4Ver13(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x4;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvIpv4.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvIpv4.Builder {
+        final OFBsnTlvIpv4Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFBsnTlvIpv4Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x4;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvIpv4.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvIpv4 build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvIpv4Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvIpv4.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public int getType() {
+        return 0x4;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvIpv4.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvIpv4 build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvIpv4Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvIpv4> {
+        @Override
+        public OFBsnTlvIpv4 readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x4
+            short type = bb.readShort();
+            if(type != (short) 0x4)
+                throw new OFParseError("Wrong type: Expected=0x4(0x4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFBsnTlvIpv4Ver13 bsnTlvIpv4Ver13 = new OFBsnTlvIpv4Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvIpv4Ver13);
+            return bsnTlvIpv4Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvIpv4Ver13Funnel FUNNEL = new OFBsnTlvIpv4Ver13Funnel();
+    static class OFBsnTlvIpv4Ver13Funnel implements Funnel<OFBsnTlvIpv4Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvIpv4Ver13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x4
+            sink.putShort((short) 0x4);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvIpv4Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvIpv4Ver13 message) {
+            // fixed value property type = 0x4
+            bb.writeShort((short) 0x4);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvIpv4Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvIpv4Ver13 other = (OFBsnTlvIpv4Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvMacVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvMacVer13.java
new file mode 100644
index 0000000..3c383ab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvMacVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvMacVer13 implements OFBsnTlvMac {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvMacVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFBsnTlvMacVer13 DEFAULT = new OFBsnTlvMacVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvMacVer13(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvMac.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvMac.Builder {
+        final OFBsnTlvMacVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFBsnTlvMacVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvMac.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvMac build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvMacVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvMac.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvMac.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvMac build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvMacVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvMac> {
+        @Override
+        public OFBsnTlvMac readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 10)
+                throw new OFParseError("Wrong length: Expected=10(10), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFBsnTlvMacVer13 bsnTlvMacVer13 = new OFBsnTlvMacVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvMacVer13);
+            return bsnTlvMacVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvMacVer13Funnel FUNNEL = new OFBsnTlvMacVer13Funnel();
+    static class OFBsnTlvMacVer13Funnel implements Funnel<OFBsnTlvMacVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvMacVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 10
+            sink.putShort((short) 0xa);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvMacVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvMacVer13 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 10
+            bb.writeShort((short) 0xa);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvMacVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvMacVer13 other = (OFBsnTlvMacVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvMissPacketsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvMissPacketsVer13.java
new file mode 100644
index 0000000..e014663
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvMissPacketsVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvMissPacketsVer13 implements OFBsnTlvMissPackets {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvMissPacketsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFBsnTlvMissPacketsVer13 DEFAULT = new OFBsnTlvMissPacketsVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvMissPacketsVer13(U64 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xd;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvMissPackets.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvMissPackets.Builder {
+        final OFBsnTlvMissPacketsVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFBsnTlvMissPacketsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xd;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvMissPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvMissPackets build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvMissPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvMissPackets.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public int getType() {
+        return 0xd;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvMissPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvMissPackets build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvMissPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvMissPackets> {
+        @Override
+        public OFBsnTlvMissPackets readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xd
+            short type = bb.readShort();
+            if(type != (short) 0xd)
+                throw new OFParseError("Wrong type: Expected=0xd(0xd), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFBsnTlvMissPacketsVer13 bsnTlvMissPacketsVer13 = new OFBsnTlvMissPacketsVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvMissPacketsVer13);
+            return bsnTlvMissPacketsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvMissPacketsVer13Funnel FUNNEL = new OFBsnTlvMissPacketsVer13Funnel();
+    static class OFBsnTlvMissPacketsVer13Funnel implements Funnel<OFBsnTlvMissPacketsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvMissPacketsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xd
+            sink.putShort((short) 0xd);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvMissPacketsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvMissPacketsVer13 message) {
+            // fixed value property type = 0xd
+            bb.writeShort((short) 0xd);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvMissPacketsVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvMissPacketsVer13 other = (OFBsnTlvMissPacketsVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvPortVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvPortVer13.java
new file mode 100644
index 0000000..76cb109
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvPortVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvPortVer13 implements OFBsnTlvPort {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvPortVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+//
+    // Immutable default instance
+    final static OFBsnTlvPortVer13 DEFAULT = new OFBsnTlvPortVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvPortVer13(OFPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvPort.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvPort.Builder {
+        final OFBsnTlvPortVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+        BuilderWithParent(OFBsnTlvPortVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvPort build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvPortVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvPort.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvPort build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvPortVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvPort> {
+        @Override
+        public OFBsnTlvPort readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=0x0(0x0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFPort value = OFPort.read4Bytes(bb);
+
+            OFBsnTlvPortVer13 bsnTlvPortVer13 = new OFBsnTlvPortVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvPortVer13);
+            return bsnTlvPortVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvPortVer13Funnel FUNNEL = new OFBsnTlvPortVer13Funnel();
+    static class OFBsnTlvPortVer13Funnel implements Funnel<OFBsnTlvPortVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvPortVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvPortVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvPortVer13 message) {
+            // fixed value property type = 0x0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvPortVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvPortVer13 other = (OFBsnTlvPortVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvQueueIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvQueueIdVer13.java
new file mode 100644
index 0000000..c398747
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvQueueIdVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvQueueIdVer13 implements OFBsnTlvQueueId {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvQueueIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_VALUE = 0x0L;
+
+    // OF message fields
+    private final long value;
+//
+    // Immutable default instance
+    final static OFBsnTlvQueueIdVer13 DEFAULT = new OFBsnTlvQueueIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvQueueIdVer13(long value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x14;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvQueueId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvQueueId.Builder {
+        final OFBsnTlvQueueIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+        BuilderWithParent(OFBsnTlvQueueIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x14;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvQueueId.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvQueueId build() {
+                long value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvQueueIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvQueueId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+    @Override
+    public int getType() {
+        return 0x14;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvQueueId.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvQueueId build() {
+            long value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvQueueIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvQueueId> {
+        @Override
+        public OFBsnTlvQueueId readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x14
+            short type = bb.readShort();
+            if(type != (short) 0x14)
+                throw new OFParseError("Wrong type: Expected=0x14(0x14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long value = U32.f(bb.readInt());
+
+            OFBsnTlvQueueIdVer13 bsnTlvQueueIdVer13 = new OFBsnTlvQueueIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvQueueIdVer13);
+            return bsnTlvQueueIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvQueueIdVer13Funnel FUNNEL = new OFBsnTlvQueueIdVer13Funnel();
+    static class OFBsnTlvQueueIdVer13Funnel implements Funnel<OFBsnTlvQueueIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvQueueIdVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x14
+            sink.putShort((short) 0x14);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvQueueIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvQueueIdVer13 message) {
+            // fixed value property type = 0x14
+            bb.writeShort((short) 0x14);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvQueueIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvQueueIdVer13 other = (OFBsnTlvQueueIdVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (value ^ (value >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvQueueWeightVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvQueueWeightVer13.java
new file mode 100644
index 0000000..8661e1d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvQueueWeightVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvQueueWeightVer13 implements OFBsnTlvQueueWeight {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvQueueWeightVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_VALUE = 0x0L;
+
+    // OF message fields
+    private final long value;
+//
+    // Immutable default instance
+    final static OFBsnTlvQueueWeightVer13 DEFAULT = new OFBsnTlvQueueWeightVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvQueueWeightVer13(long value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x15;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvQueueWeight.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvQueueWeight.Builder {
+        final OFBsnTlvQueueWeightVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+        BuilderWithParent(OFBsnTlvQueueWeightVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x15;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvQueueWeight.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvQueueWeight build() {
+                long value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvQueueWeightVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvQueueWeight.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+    @Override
+    public int getType() {
+        return 0x15;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvQueueWeight.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvQueueWeight build() {
+            long value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvQueueWeightVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvQueueWeight> {
+        @Override
+        public OFBsnTlvQueueWeight readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x15
+            short type = bb.readShort();
+            if(type != (short) 0x15)
+                throw new OFParseError("Wrong type: Expected=0x15(0x15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long value = U32.f(bb.readInt());
+
+            OFBsnTlvQueueWeightVer13 bsnTlvQueueWeightVer13 = new OFBsnTlvQueueWeightVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvQueueWeightVer13);
+            return bsnTlvQueueWeightVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvQueueWeightVer13Funnel FUNNEL = new OFBsnTlvQueueWeightVer13Funnel();
+    static class OFBsnTlvQueueWeightVer13Funnel implements Funnel<OFBsnTlvQueueWeightVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvQueueWeightVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x15
+            sink.putShort((short) 0x15);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvQueueWeightVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvQueueWeightVer13 message) {
+            // fixed value property type = 0x15
+            bb.writeShort((short) 0x15);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvQueueWeightVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvQueueWeightVer13 other = (OFBsnTlvQueueWeightVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (value ^ (value >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvReplyPacketsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvReplyPacketsVer13.java
new file mode 100644
index 0000000..dabb3f1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvReplyPacketsVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvReplyPacketsVer13 implements OFBsnTlvReplyPackets {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvReplyPacketsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFBsnTlvReplyPacketsVer13 DEFAULT = new OFBsnTlvReplyPacketsVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvReplyPacketsVer13(U64 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xc;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvReplyPackets.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvReplyPackets.Builder {
+        final OFBsnTlvReplyPacketsVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFBsnTlvReplyPacketsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xc;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvReplyPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvReplyPackets build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvReplyPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvReplyPackets.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public int getType() {
+        return 0xc;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvReplyPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvReplyPackets build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvReplyPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvReplyPackets> {
+        @Override
+        public OFBsnTlvReplyPackets readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xc
+            short type = bb.readShort();
+            if(type != (short) 0xc)
+                throw new OFParseError("Wrong type: Expected=0xc(0xc), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFBsnTlvReplyPacketsVer13 bsnTlvReplyPacketsVer13 = new OFBsnTlvReplyPacketsVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvReplyPacketsVer13);
+            return bsnTlvReplyPacketsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvReplyPacketsVer13Funnel FUNNEL = new OFBsnTlvReplyPacketsVer13Funnel();
+    static class OFBsnTlvReplyPacketsVer13Funnel implements Funnel<OFBsnTlvReplyPacketsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvReplyPacketsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xc
+            sink.putShort((short) 0xc);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvReplyPacketsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvReplyPacketsVer13 message) {
+            // fixed value property type = 0xc
+            bb.writeShort((short) 0xc);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvReplyPacketsVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvReplyPacketsVer13 other = (OFBsnTlvReplyPacketsVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvRequestPacketsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvRequestPacketsVer13.java
new file mode 100644
index 0000000..40f2709
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvRequestPacketsVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvRequestPacketsVer13 implements OFBsnTlvRequestPackets {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvRequestPacketsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFBsnTlvRequestPacketsVer13 DEFAULT = new OFBsnTlvRequestPacketsVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvRequestPacketsVer13(U64 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xb;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvRequestPackets.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvRequestPackets.Builder {
+        final OFBsnTlvRequestPacketsVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFBsnTlvRequestPacketsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xb;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvRequestPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvRequestPackets build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvRequestPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvRequestPackets.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public int getType() {
+        return 0xb;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvRequestPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvRequestPackets build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvRequestPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvRequestPackets> {
+        @Override
+        public OFBsnTlvRequestPackets readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xb
+            short type = bb.readShort();
+            if(type != (short) 0xb)
+                throw new OFParseError("Wrong type: Expected=0xb(0xb), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFBsnTlvRequestPacketsVer13 bsnTlvRequestPacketsVer13 = new OFBsnTlvRequestPacketsVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvRequestPacketsVer13);
+            return bsnTlvRequestPacketsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvRequestPacketsVer13Funnel FUNNEL = new OFBsnTlvRequestPacketsVer13Funnel();
+    static class OFBsnTlvRequestPacketsVer13Funnel implements Funnel<OFBsnTlvRequestPacketsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvRequestPacketsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xb
+            sink.putShort((short) 0xb);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvRequestPacketsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvRequestPacketsVer13 message) {
+            // fixed value property type = 0xb
+            bb.writeShort((short) 0xb);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvRequestPacketsVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvRequestPacketsVer13 other = (OFBsnTlvRequestPacketsVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvRxPacketsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvRxPacketsVer13.java
new file mode 100644
index 0000000..c8d4998
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvRxPacketsVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvRxPacketsVer13 implements OFBsnTlvRxPackets {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvRxPacketsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFBsnTlvRxPacketsVer13 DEFAULT = new OFBsnTlvRxPacketsVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvRxPacketsVer13(U64 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvRxPackets.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvRxPackets.Builder {
+        final OFBsnTlvRxPacketsVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFBsnTlvRxPacketsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvRxPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvRxPackets build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvRxPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvRxPackets.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvRxPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvRxPackets build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvRxPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvRxPackets> {
+        @Override
+        public OFBsnTlvRxPackets readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=0x2(0x2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFBsnTlvRxPacketsVer13 bsnTlvRxPacketsVer13 = new OFBsnTlvRxPacketsVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvRxPacketsVer13);
+            return bsnTlvRxPacketsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvRxPacketsVer13Funnel FUNNEL = new OFBsnTlvRxPacketsVer13Funnel();
+    static class OFBsnTlvRxPacketsVer13Funnel implements Funnel<OFBsnTlvRxPacketsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvRxPacketsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvRxPacketsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvRxPacketsVer13 message) {
+            // fixed value property type = 0x2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvRxPacketsVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvRxPacketsVer13 other = (OFBsnTlvRxPacketsVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvTxPacketsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvTxPacketsVer13.java
new file mode 100644
index 0000000..8f687aa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvTxPacketsVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvTxPacketsVer13 implements OFBsnTlvTxPackets {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvTxPacketsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFBsnTlvTxPacketsVer13 DEFAULT = new OFBsnTlvTxPacketsVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvTxPacketsVer13(U64 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x3;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvTxPackets.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvTxPackets.Builder {
+        final OFBsnTlvTxPacketsVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFBsnTlvTxPacketsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x3;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvTxPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvTxPackets build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvTxPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvTxPackets.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public int getType() {
+        return 0x3;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvTxPackets.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvTxPackets build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvTxPacketsVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvTxPackets> {
+        @Override
+        public OFBsnTlvTxPackets readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x3
+            short type = bb.readShort();
+            if(type != (short) 0x3)
+                throw new OFParseError("Wrong type: Expected=0x3(0x3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFBsnTlvTxPacketsVer13 bsnTlvTxPacketsVer13 = new OFBsnTlvTxPacketsVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvTxPacketsVer13);
+            return bsnTlvTxPacketsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvTxPacketsVer13Funnel FUNNEL = new OFBsnTlvTxPacketsVer13Funnel();
+    static class OFBsnTlvTxPacketsVer13Funnel implements Funnel<OFBsnTlvTxPacketsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvTxPacketsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x3
+            sink.putShort((short) 0x3);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvTxPacketsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvTxPacketsVer13 message) {
+            // fixed value property type = 0x3
+            bb.writeShort((short) 0x3);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvTxPacketsVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvTxPacketsVer13 other = (OFBsnTlvTxPacketsVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfAnchorVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfAnchorVer13.java
new file mode 100644
index 0000000..358310e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfAnchorVer13.java
@@ -0,0 +1,263 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvUdfAnchorVer13 implements OFBsnTlvUdfAnchor {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvUdfAnchorVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+
+    // OF message fields
+    private final OFBsnUdfAnchor value;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvUdfAnchorVer13(OFBsnUdfAnchor value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x10;
+    }
+
+    @Override
+    public OFBsnUdfAnchor getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvUdfAnchor.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvUdfAnchor.Builder {
+        final OFBsnTlvUdfAnchorVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBsnUdfAnchor value;
+
+        BuilderWithParent(OFBsnTlvUdfAnchorVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x10;
+    }
+
+    @Override
+    public OFBsnUdfAnchor getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUdfAnchor.Builder setValue(OFBsnUdfAnchor value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvUdfAnchor build() {
+                OFBsnUdfAnchor value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvUdfAnchorVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvUdfAnchor.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBsnUdfAnchor value;
+
+    @Override
+    public int getType() {
+        return 0x10;
+    }
+
+    @Override
+    public OFBsnUdfAnchor getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUdfAnchor.Builder setValue(OFBsnUdfAnchor value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvUdfAnchor build() {
+            if(!this.valueSet)
+                throw new IllegalStateException("Property value doesn't have default value -- must be set");
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvUdfAnchorVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvUdfAnchor> {
+        @Override
+        public OFBsnTlvUdfAnchor readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x10
+            short type = bb.readShort();
+            if(type != (short) 0x10)
+                throw new OFParseError("Wrong type: Expected=0x10(0x10), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 6)
+                throw new OFParseError("Wrong length: Expected=6(6), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFBsnUdfAnchor value = OFBsnUdfAnchorSerializerVer13.readFrom(bb);
+
+            OFBsnTlvUdfAnchorVer13 bsnTlvUdfAnchorVer13 = new OFBsnTlvUdfAnchorVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvUdfAnchorVer13);
+            return bsnTlvUdfAnchorVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvUdfAnchorVer13Funnel FUNNEL = new OFBsnTlvUdfAnchorVer13Funnel();
+    static class OFBsnTlvUdfAnchorVer13Funnel implements Funnel<OFBsnTlvUdfAnchorVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvUdfAnchorVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x10
+            sink.putShort((short) 0x10);
+            // fixed value property length = 6
+            sink.putShort((short) 0x6);
+            OFBsnUdfAnchorSerializerVer13.putTo(message.value, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvUdfAnchorVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvUdfAnchorVer13 message) {
+            // fixed value property type = 0x10
+            bb.writeShort((short) 0x10);
+            // fixed value property length = 6
+            bb.writeShort((short) 0x6);
+            OFBsnUdfAnchorSerializerVer13.writeTo(bb, message.value);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvUdfAnchorVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvUdfAnchorVer13 other = (OFBsnTlvUdfAnchorVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfIdVer13.java
new file mode 100644
index 0000000..3c3ac1e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfIdVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvUdfIdVer13 implements OFBsnTlvUdfId {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvUdfIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static int DEFAULT_VALUE = 0x0;
+
+    // OF message fields
+    private final int value;
+//
+    // Immutable default instance
+    final static OFBsnTlvUdfIdVer13 DEFAULT = new OFBsnTlvUdfIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvUdfIdVer13(int value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xf;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvUdfId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvUdfId.Builder {
+        final OFBsnTlvUdfIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private int value;
+
+        BuilderWithParent(OFBsnTlvUdfIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xf;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUdfId.Builder setValue(int value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvUdfId build() {
+                int value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvUdfIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvUdfId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private int value;
+
+    @Override
+    public int getType() {
+        return 0xf;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUdfId.Builder setValue(int value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvUdfId build() {
+            int value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvUdfIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvUdfId> {
+        @Override
+        public OFBsnTlvUdfId readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xf
+            short type = bb.readShort();
+            if(type != (short) 0xf)
+                throw new OFParseError("Wrong type: Expected=0xf(0xf), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 6)
+                throw new OFParseError("Wrong length: Expected=6(6), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int value = U16.f(bb.readShort());
+
+            OFBsnTlvUdfIdVer13 bsnTlvUdfIdVer13 = new OFBsnTlvUdfIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvUdfIdVer13);
+            return bsnTlvUdfIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvUdfIdVer13Funnel FUNNEL = new OFBsnTlvUdfIdVer13Funnel();
+    static class OFBsnTlvUdfIdVer13Funnel implements Funnel<OFBsnTlvUdfIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvUdfIdVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xf
+            sink.putShort((short) 0xf);
+            // fixed value property length = 6
+            sink.putShort((short) 0x6);
+            sink.putInt(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvUdfIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvUdfIdVer13 message) {
+            // fixed value property type = 0xf
+            bb.writeShort((short) 0xf);
+            // fixed value property length = 6
+            bb.writeShort((short) 0x6);
+            bb.writeShort(U16.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvUdfIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvUdfIdVer13 other = (OFBsnTlvUdfIdVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + value;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfLengthVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfLengthVer13.java
new file mode 100644
index 0000000..8da277a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfLengthVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvUdfLengthVer13 implements OFBsnTlvUdfLength {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvUdfLengthVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static int DEFAULT_VALUE = 0x0;
+
+    // OF message fields
+    private final int value;
+//
+    // Immutable default instance
+    final static OFBsnTlvUdfLengthVer13 DEFAULT = new OFBsnTlvUdfLengthVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvUdfLengthVer13(int value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x12;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvUdfLength.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvUdfLength.Builder {
+        final OFBsnTlvUdfLengthVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private int value;
+
+        BuilderWithParent(OFBsnTlvUdfLengthVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x12;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUdfLength.Builder setValue(int value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvUdfLength build() {
+                int value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvUdfLengthVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvUdfLength.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private int value;
+
+    @Override
+    public int getType() {
+        return 0x12;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUdfLength.Builder setValue(int value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvUdfLength build() {
+            int value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvUdfLengthVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvUdfLength> {
+        @Override
+        public OFBsnTlvUdfLength readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x12
+            short type = bb.readShort();
+            if(type != (short) 0x12)
+                throw new OFParseError("Wrong type: Expected=0x12(0x12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 6)
+                throw new OFParseError("Wrong length: Expected=6(6), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int value = U16.f(bb.readShort());
+
+            OFBsnTlvUdfLengthVer13 bsnTlvUdfLengthVer13 = new OFBsnTlvUdfLengthVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvUdfLengthVer13);
+            return bsnTlvUdfLengthVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvUdfLengthVer13Funnel FUNNEL = new OFBsnTlvUdfLengthVer13Funnel();
+    static class OFBsnTlvUdfLengthVer13Funnel implements Funnel<OFBsnTlvUdfLengthVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvUdfLengthVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x12
+            sink.putShort((short) 0x12);
+            // fixed value property length = 6
+            sink.putShort((short) 0x6);
+            sink.putInt(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvUdfLengthVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvUdfLengthVer13 message) {
+            // fixed value property type = 0x12
+            bb.writeShort((short) 0x12);
+            // fixed value property length = 6
+            bb.writeShort((short) 0x6);
+            bb.writeShort(U16.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvUdfLengthVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvUdfLengthVer13 other = (OFBsnTlvUdfLengthVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + value;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfOffsetVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfOffsetVer13.java
new file mode 100644
index 0000000..bc13ef9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUdfOffsetVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvUdfOffsetVer13 implements OFBsnTlvUdfOffset {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvUdfOffsetVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static int DEFAULT_VALUE = 0x0;
+
+    // OF message fields
+    private final int value;
+//
+    // Immutable default instance
+    final static OFBsnTlvUdfOffsetVer13 DEFAULT = new OFBsnTlvUdfOffsetVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvUdfOffsetVer13(int value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x11;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvUdfOffset.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvUdfOffset.Builder {
+        final OFBsnTlvUdfOffsetVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private int value;
+
+        BuilderWithParent(OFBsnTlvUdfOffsetVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x11;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUdfOffset.Builder setValue(int value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvUdfOffset build() {
+                int value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvUdfOffsetVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvUdfOffset.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private int value;
+
+    @Override
+    public int getType() {
+        return 0x11;
+    }
+
+    @Override
+    public int getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUdfOffset.Builder setValue(int value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvUdfOffset build() {
+            int value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvUdfOffsetVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvUdfOffset> {
+        @Override
+        public OFBsnTlvUdfOffset readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x11
+            short type = bb.readShort();
+            if(type != (short) 0x11)
+                throw new OFParseError("Wrong type: Expected=0x11(0x11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 6)
+                throw new OFParseError("Wrong length: Expected=6(6), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int value = U16.f(bb.readShort());
+
+            OFBsnTlvUdfOffsetVer13 bsnTlvUdfOffsetVer13 = new OFBsnTlvUdfOffsetVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvUdfOffsetVer13);
+            return bsnTlvUdfOffsetVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvUdfOffsetVer13Funnel FUNNEL = new OFBsnTlvUdfOffsetVer13Funnel();
+    static class OFBsnTlvUdfOffsetVer13Funnel implements Funnel<OFBsnTlvUdfOffsetVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvUdfOffsetVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x11
+            sink.putShort((short) 0x11);
+            // fixed value property length = 6
+            sink.putShort((short) 0x6);
+            sink.putInt(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvUdfOffsetVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvUdfOffsetVer13 message) {
+            // fixed value property type = 0x11
+            bb.writeShort((short) 0x11);
+            // fixed value property length = 6
+            bb.writeShort((short) 0x6);
+            bb.writeShort(U16.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvUdfOffsetVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvUdfOffsetVer13 other = (OFBsnTlvUdfOffsetVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + value;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUnicastQueryTimeoutVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUnicastQueryTimeoutVer13.java
new file mode 100644
index 0000000..a769b25
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvUnicastQueryTimeoutVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvUnicastQueryTimeoutVer13 implements OFBsnTlvUnicastQueryTimeout {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvUnicastQueryTimeoutVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_VALUE = 0x0L;
+
+    // OF message fields
+    private final long value;
+//
+    // Immutable default instance
+    final static OFBsnTlvUnicastQueryTimeoutVer13 DEFAULT = new OFBsnTlvUnicastQueryTimeoutVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvUnicastQueryTimeoutVer13(long value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x9;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvUnicastQueryTimeout.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvUnicastQueryTimeout.Builder {
+        final OFBsnTlvUnicastQueryTimeoutVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+        BuilderWithParent(OFBsnTlvUnicastQueryTimeoutVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x9;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUnicastQueryTimeout.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvUnicastQueryTimeout build() {
+                long value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvUnicastQueryTimeoutVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvUnicastQueryTimeout.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+    @Override
+    public int getType() {
+        return 0x9;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvUnicastQueryTimeout.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvUnicastQueryTimeout build() {
+            long value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvUnicastQueryTimeoutVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvUnicastQueryTimeout> {
+        @Override
+        public OFBsnTlvUnicastQueryTimeout readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x9
+            short type = bb.readShort();
+            if(type != (short) 0x9)
+                throw new OFParseError("Wrong type: Expected=0x9(0x9), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long value = U32.f(bb.readInt());
+
+            OFBsnTlvUnicastQueryTimeoutVer13 bsnTlvUnicastQueryTimeoutVer13 = new OFBsnTlvUnicastQueryTimeoutVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvUnicastQueryTimeoutVer13);
+            return bsnTlvUnicastQueryTimeoutVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvUnicastQueryTimeoutVer13Funnel FUNNEL = new OFBsnTlvUnicastQueryTimeoutVer13Funnel();
+    static class OFBsnTlvUnicastQueryTimeoutVer13Funnel implements Funnel<OFBsnTlvUnicastQueryTimeoutVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvUnicastQueryTimeoutVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x9
+            sink.putShort((short) 0x9);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvUnicastQueryTimeoutVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvUnicastQueryTimeoutVer13 message) {
+            // fixed value property type = 0x9
+            bb.writeShort((short) 0x9);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvUnicastQueryTimeoutVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvUnicastQueryTimeoutVer13 other = (OFBsnTlvUnicastQueryTimeoutVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (value ^ (value >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVer13.java
new file mode 100644
index 0000000..0601c93
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVer13.java
@@ -0,0 +1,119 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnTlvVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFBsnTlvVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnTlv> {
+        @Override
+        public OFBsnTlv readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0xa:
+                   // discriminator value 0xa=0xa for class OFBsnTlvBroadcastQueryTimeoutVer13
+                   return OFBsnTlvBroadcastQueryTimeoutVer13.READER.readFrom(bb);
+               case (short) 0xe:
+                   // discriminator value 0xe=0xe for class OFBsnTlvCircuitIdVer13
+                   return OFBsnTlvCircuitIdVer13.READER.readFrom(bb);
+               case (short) 0x16:
+                   // discriminator value 0x16=0x16 for class OFBsnTlvCrcEnabledVer13
+                   return OFBsnTlvCrcEnabledVer13.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value 0x7=0x7 for class OFBsnTlvIdleNotificationVer13
+                   return OFBsnTlvIdleNotificationVer13.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value 0x5=0x5 for class OFBsnTlvIdleTimeVer13
+                   return OFBsnTlvIdleTimeVer13.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value 0x8=0x8 for class OFBsnTlvIdleTimeoutVer13
+                   return OFBsnTlvIdleTimeoutVer13.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value 0x4=0x4 for class OFBsnTlvIpv4Ver13
+                   return OFBsnTlvIpv4Ver13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFBsnTlvMacVer13
+                   return OFBsnTlvMacVer13.READER.readFrom(bb);
+               case (short) 0xd:
+                   // discriminator value 0xd=0xd for class OFBsnTlvMissPacketsVer13
+                   return OFBsnTlvMissPacketsVer13.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value 0x0=0x0 for class OFBsnTlvPortVer13
+                   return OFBsnTlvPortVer13.READER.readFrom(bb);
+               case (short) 0x14:
+                   // discriminator value 0x14=0x14 for class OFBsnTlvQueueIdVer13
+                   return OFBsnTlvQueueIdVer13.READER.readFrom(bb);
+               case (short) 0x15:
+                   // discriminator value 0x15=0x15 for class OFBsnTlvQueueWeightVer13
+                   return OFBsnTlvQueueWeightVer13.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value 0xc=0xc for class OFBsnTlvReplyPacketsVer13
+                   return OFBsnTlvReplyPacketsVer13.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value 0xb=0xb for class OFBsnTlvRequestPacketsVer13
+                   return OFBsnTlvRequestPacketsVer13.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value 0x2=0x2 for class OFBsnTlvRxPacketsVer13
+                   return OFBsnTlvRxPacketsVer13.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value 0x3=0x3 for class OFBsnTlvTxPacketsVer13
+                   return OFBsnTlvTxPacketsVer13.READER.readFrom(bb);
+               case (short) 0x10:
+                   // discriminator value 0x10=0x10 for class OFBsnTlvUdfAnchorVer13
+                   return OFBsnTlvUdfAnchorVer13.READER.readFrom(bb);
+               case (short) 0xf:
+                   // discriminator value 0xf=0xf for class OFBsnTlvUdfIdVer13
+                   return OFBsnTlvUdfIdVer13.READER.readFrom(bb);
+               case (short) 0x12:
+                   // discriminator value 0x12=0x12 for class OFBsnTlvUdfLengthVer13
+                   return OFBsnTlvUdfLengthVer13.READER.readFrom(bb);
+               case (short) 0x11:
+                   // discriminator value 0x11=0x11 for class OFBsnTlvUdfOffsetVer13
+                   return OFBsnTlvUdfOffsetVer13.READER.readFrom(bb);
+               case (short) 0x9:
+                   // discriminator value 0x9=0x9 for class OFBsnTlvUnicastQueryTimeoutVer13
+                   return OFBsnTlvUnicastQueryTimeoutVer13.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value 0x6=0x6 for class OFBsnTlvVlanVidVer13
+                   return OFBsnTlvVlanVidVer13.READER.readFrom(bb);
+               case (short) 0x13:
+                   // discriminator value 0x13=0x13 for class OFBsnTlvVrfVer13
+                   return OFBsnTlvVrfVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFBsnTlvVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVlanVidVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVlanVidVer13.java
new file mode 100644
index 0000000..1c58c00
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVlanVidVer13.java
@@ -0,0 +1,267 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvVlanVidVer13 implements OFBsnTlvVlanVid {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvVlanVidVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static VlanVid DEFAULT_VALUE = VlanVid.ZERO;
+
+    // OF message fields
+    private final VlanVid value;
+//
+    // Immutable default instance
+    final static OFBsnTlvVlanVidVer13 DEFAULT = new OFBsnTlvVlanVidVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvVlanVidVer13(VlanVid value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x6;
+    }
+
+    @Override
+    public VlanVid getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvVlanVid.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvVlanVid.Builder {
+        final OFBsnTlvVlanVidVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VlanVid value;
+
+        BuilderWithParent(OFBsnTlvVlanVidVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x6;
+    }
+
+    @Override
+    public VlanVid getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvVlanVid.Builder setValue(VlanVid value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvVlanVid build() {
+                VlanVid value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFBsnTlvVlanVidVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvVlanVid.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VlanVid value;
+
+    @Override
+    public int getType() {
+        return 0x6;
+    }
+
+    @Override
+    public VlanVid getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvVlanVid.Builder setValue(VlanVid value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvVlanVid build() {
+            VlanVid value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFBsnTlvVlanVidVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvVlanVid> {
+        @Override
+        public OFBsnTlvVlanVid readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x6
+            short type = bb.readShort();
+            if(type != (short) 0x6)
+                throw new OFParseError("Wrong type: Expected=0x6(0x6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 6)
+                throw new OFParseError("Wrong length: Expected=6(6), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            VlanVid value = VlanVid.read2Bytes(bb);
+
+            OFBsnTlvVlanVidVer13 bsnTlvVlanVidVer13 = new OFBsnTlvVlanVidVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvVlanVidVer13);
+            return bsnTlvVlanVidVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvVlanVidVer13Funnel FUNNEL = new OFBsnTlvVlanVidVer13Funnel();
+    static class OFBsnTlvVlanVidVer13Funnel implements Funnel<OFBsnTlvVlanVidVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvVlanVidVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x6
+            sink.putShort((short) 0x6);
+            // fixed value property length = 6
+            sink.putShort((short) 0x6);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvVlanVidVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvVlanVidVer13 message) {
+            // fixed value property type = 0x6
+            bb.writeShort((short) 0x6);
+            // fixed value property length = 6
+            bb.writeShort((short) 0x6);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvVlanVidVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvVlanVidVer13 other = (OFBsnTlvVlanVidVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVrfVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVrfVer13.java
new file mode 100644
index 0000000..a8b6988
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvVrfVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnTlvVrfVer13 implements OFBsnTlvVrf {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvVrfVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_VALUE = 0x0L;
+
+    // OF message fields
+    private final long value;
+//
+    // Immutable default instance
+    final static OFBsnTlvVrfVer13 DEFAULT = new OFBsnTlvVrfVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnTlvVrfVer13(long value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x13;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnTlvVrf.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnTlvVrf.Builder {
+        final OFBsnTlvVrfVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+        BuilderWithParent(OFBsnTlvVrfVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x13;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvVrf.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnTlvVrf build() {
+                long value = this.valueSet ? this.value : parentMessage.value;
+
+                //
+                return new OFBsnTlvVrfVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnTlvVrf.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private long value;
+
+    @Override
+    public int getType() {
+        return 0x13;
+    }
+
+    @Override
+    public long getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBsnTlvVrf.Builder setValue(long value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnTlvVrf build() {
+            long value = this.valueSet ? this.value : DEFAULT_VALUE;
+
+
+            return new OFBsnTlvVrfVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnTlvVrf> {
+        @Override
+        public OFBsnTlvVrf readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x13
+            short type = bb.readShort();
+            if(type != (short) 0x13)
+                throw new OFParseError("Wrong type: Expected=0x13(0x13), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long value = U32.f(bb.readInt());
+
+            OFBsnTlvVrfVer13 bsnTlvVrfVer13 = new OFBsnTlvVrfVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnTlvVrfVer13);
+            return bsnTlvVrfVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnTlvVrfVer13Funnel FUNNEL = new OFBsnTlvVrfVer13Funnel();
+    static class OFBsnTlvVrfVer13Funnel implements Funnel<OFBsnTlvVrfVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnTlvVrfVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x13
+            sink.putShort((short) 0x13);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.value);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnTlvVrfVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnTlvVrfVer13 message) {
+            // fixed value property type = 0x13
+            bb.writeShort((short) 0x13);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.value));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnTlvVrfVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnTlvVrfVer13 other = (OFBsnTlvVrfVer13) obj;
+
+        if( value != other.value)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (value ^ (value >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvsVer13.java
new file mode 100644
index 0000000..10b01bc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvsVer13.java
@@ -0,0 +1,244 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFBsnTlvsVer13 implements OFBsnTlvs {
+    public final static OFBsnTlvsVer13 INSTANCE = new OFBsnTlvsVer13();
+
+
+
+
+    public OFBsnTlvBroadcastQueryTimeout.Builder buildBroadcastQueryTimeout() {
+        return new OFBsnTlvBroadcastQueryTimeoutVer13.Builder();
+    }
+    public OFBsnTlvBroadcastQueryTimeout broadcastQueryTimeout(long value) {
+        return new OFBsnTlvBroadcastQueryTimeoutVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvCircuitId.Builder buildCircuitId() {
+        return new OFBsnTlvCircuitIdVer13.Builder();
+    }
+    public OFBsnTlvCircuitId circuitId(byte[] value) {
+        return new OFBsnTlvCircuitIdVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvCrcEnabled.Builder buildCrcEnabled() {
+        return new OFBsnTlvCrcEnabledVer13.Builder();
+    }
+    public OFBsnTlvCrcEnabled crcEnabled(short value) {
+        return new OFBsnTlvCrcEnabledVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvIdleNotification idleNotification() {
+        return OFBsnTlvIdleNotificationVer13.INSTANCE;
+    }
+
+    public OFBsnTlvIdleTime.Builder buildIdleTime() {
+        return new OFBsnTlvIdleTimeVer13.Builder();
+    }
+    public OFBsnTlvIdleTime idleTime(U64 value) {
+        return new OFBsnTlvIdleTimeVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvIdleTimeout.Builder buildIdleTimeout() {
+        return new OFBsnTlvIdleTimeoutVer13.Builder();
+    }
+    public OFBsnTlvIdleTimeout idleTimeout(long value) {
+        return new OFBsnTlvIdleTimeoutVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvIpv4.Builder buildIpv4() {
+        return new OFBsnTlvIpv4Ver13.Builder();
+    }
+    public OFBsnTlvIpv4 ipv4(IPv4Address value) {
+        return new OFBsnTlvIpv4Ver13(
+                value
+                    );
+    }
+
+    public OFBsnTlvMac.Builder buildMac() {
+        return new OFBsnTlvMacVer13.Builder();
+    }
+    public OFBsnTlvMac mac(MacAddress value) {
+        return new OFBsnTlvMacVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvMissPackets.Builder buildMissPackets() {
+        return new OFBsnTlvMissPacketsVer13.Builder();
+    }
+    public OFBsnTlvMissPackets missPackets(U64 value) {
+        return new OFBsnTlvMissPacketsVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvPort.Builder buildPort() {
+        return new OFBsnTlvPortVer13.Builder();
+    }
+    public OFBsnTlvPort port(OFPort value) {
+        return new OFBsnTlvPortVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvQueueId.Builder buildQueueId() {
+        return new OFBsnTlvQueueIdVer13.Builder();
+    }
+    public OFBsnTlvQueueId queueId(long value) {
+        return new OFBsnTlvQueueIdVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvQueueWeight.Builder buildQueueWeight() {
+        return new OFBsnTlvQueueWeightVer13.Builder();
+    }
+    public OFBsnTlvQueueWeight queueWeight(long value) {
+        return new OFBsnTlvQueueWeightVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvReplyPackets.Builder buildReplyPackets() {
+        return new OFBsnTlvReplyPacketsVer13.Builder();
+    }
+    public OFBsnTlvReplyPackets replyPackets(U64 value) {
+        return new OFBsnTlvReplyPacketsVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvRequestPackets.Builder buildRequestPackets() {
+        return new OFBsnTlvRequestPacketsVer13.Builder();
+    }
+    public OFBsnTlvRequestPackets requestPackets(U64 value) {
+        return new OFBsnTlvRequestPacketsVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvRxPackets.Builder buildRxPackets() {
+        return new OFBsnTlvRxPacketsVer13.Builder();
+    }
+    public OFBsnTlvRxPackets rxPackets(U64 value) {
+        return new OFBsnTlvRxPacketsVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvTxPackets.Builder buildTxPackets() {
+        return new OFBsnTlvTxPacketsVer13.Builder();
+    }
+    public OFBsnTlvTxPackets txPackets(U64 value) {
+        return new OFBsnTlvTxPacketsVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvUdfAnchor.Builder buildUdfAnchor() {
+        return new OFBsnTlvUdfAnchorVer13.Builder();
+    }
+    public OFBsnTlvUdfAnchor udfAnchor(OFBsnUdfAnchor value) {
+        return new OFBsnTlvUdfAnchorVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvUdfId.Builder buildUdfId() {
+        return new OFBsnTlvUdfIdVer13.Builder();
+    }
+    public OFBsnTlvUdfId udfId(int value) {
+        return new OFBsnTlvUdfIdVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvUdfLength.Builder buildUdfLength() {
+        return new OFBsnTlvUdfLengthVer13.Builder();
+    }
+    public OFBsnTlvUdfLength udfLength(int value) {
+        return new OFBsnTlvUdfLengthVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvUdfOffset.Builder buildUdfOffset() {
+        return new OFBsnTlvUdfOffsetVer13.Builder();
+    }
+    public OFBsnTlvUdfOffset udfOffset(int value) {
+        return new OFBsnTlvUdfOffsetVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvUnicastQueryTimeout.Builder buildUnicastQueryTimeout() {
+        return new OFBsnTlvUnicastQueryTimeoutVer13.Builder();
+    }
+    public OFBsnTlvUnicastQueryTimeout unicastQueryTimeout(long value) {
+        return new OFBsnTlvUnicastQueryTimeoutVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvVlanVid.Builder buildVlanVid() {
+        return new OFBsnTlvVlanVidVer13.Builder();
+    }
+    public OFBsnTlvVlanVid vlanVid(VlanVid value) {
+        return new OFBsnTlvVlanVidVer13(
+                value
+                    );
+    }
+
+    public OFBsnTlvVrf.Builder buildVrf() {
+        return new OFBsnTlvVrfVer13.Builder();
+    }
+    public OFBsnTlvVrf vrf(long value) {
+        return new OFBsnTlvVrfVer13(
+                value
+                    );
+    }
+
+    public OFMessageReader<OFBsnTlv> getReader() {
+        return OFBsnTlvVer13.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnUdfAnchorSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnUdfAnchorSerializerVer13.java
new file mode 100644
index 0000000..646a16c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnUdfAnchorSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnUdfAnchor;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnUdfAnchorSerializerVer13 {
+
+    public final static short BSN_UDF_ANCHOR_PACKET_START_VAL = (short) 0x0;
+    public final static short BSN_UDF_ANCHOR_L3_HEADER_START_VAL = (short) 0x1;
+    public final static short BSN_UDF_ANCHOR_L4_HEADER_START_VAL = (short) 0x2;
+
+    public static OFBsnUdfAnchor readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnUdfAnchor e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnUdfAnchor e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnUdfAnchor ofWireValue(short val) {
+        switch(val) {
+            case BSN_UDF_ANCHOR_PACKET_START_VAL:
+                return OFBsnUdfAnchor.BSN_UDF_ANCHOR_PACKET_START;
+            case BSN_UDF_ANCHOR_L3_HEADER_START_VAL:
+                return OFBsnUdfAnchor.BSN_UDF_ANCHOR_L3_HEADER_START;
+            case BSN_UDF_ANCHOR_L4_HEADER_START_VAL:
+                return OFBsnUdfAnchor.BSN_UDF_ANCHOR_L4_HEADER_START;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnUdfAnchor in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnUdfAnchor e) {
+        switch(e) {
+            case BSN_UDF_ANCHOR_PACKET_START:
+                return BSN_UDF_ANCHOR_PACKET_START_VAL;
+            case BSN_UDF_ANCHOR_L3_HEADER_START:
+                return BSN_UDF_ANCHOR_L3_HEADER_START_VAL;
+            case BSN_UDF_ANCHOR_L4_HEADER_START:
+                return BSN_UDF_ANCHOR_L4_HEADER_START_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnUdfAnchor in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateReplyVer13.java
new file mode 100644
index 0000000..63cb3fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateReplyVer13.java
@@ -0,0 +1,408 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortCreateReplyVer13 implements OFBsnVirtualPortCreateReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortCreateReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+        private final static long DEFAULT_VPORT_NO = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+    private final long vportNo;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortCreateReplyVer13 DEFAULT = new OFBsnVirtualPortCreateReplyVer13(
+        DEFAULT_XID, DEFAULT_STATUS, DEFAULT_VPORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortCreateReplyVer13(long xid, long status, long vportNo) {
+        this.xid = xid;
+        this.status = status;
+        this.vportNo = vportNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+
+
+    public OFBsnVirtualPortCreateReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortCreateReply.Builder {
+        final OFBsnVirtualPortCreateReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean vportNoSet;
+        private long vportNo;
+
+        BuilderWithParent(OFBsnVirtualPortCreateReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortCreateReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+                long vportNo = this.vportNoSet ? this.vportNo : parentMessage.vportNo;
+
+                //
+                return new OFBsnVirtualPortCreateReplyVer13(
+                    xid,
+                    status,
+                    vportNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortCreateReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+        private boolean vportNoSet;
+        private long vportNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x10L;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateReply.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortCreateReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+            long vportNo = this.vportNoSet ? this.vportNo : DEFAULT_VPORT_NO;
+
+
+            return new OFBsnVirtualPortCreateReplyVer13(
+                    xid,
+                    status,
+                    vportNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortCreateReply> {
+        @Override
+        public OFBsnVirtualPortCreateReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x10L
+            int subtype = bb.readInt();
+            if(subtype != 0x10)
+                throw new OFParseError("Wrong subtype: Expected=0x10L(0x10L), got="+subtype);
+            long status = U32.f(bb.readInt());
+            long vportNo = U32.f(bb.readInt());
+
+            OFBsnVirtualPortCreateReplyVer13 bsnVirtualPortCreateReplyVer13 = new OFBsnVirtualPortCreateReplyVer13(
+                    xid,
+                      status,
+                      vportNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortCreateReplyVer13);
+            return bsnVirtualPortCreateReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortCreateReplyVer13Funnel FUNNEL = new OFBsnVirtualPortCreateReplyVer13Funnel();
+    static class OFBsnVirtualPortCreateReplyVer13Funnel implements Funnel<OFBsnVirtualPortCreateReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortCreateReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x10L
+            sink.putInt(0x10);
+            sink.putLong(message.status);
+            sink.putLong(message.vportNo);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortCreateReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortCreateReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x10L
+            bb.writeInt(0x10);
+            bb.writeInt(U32.t(message.status));
+            bb.writeInt(U32.t(message.vportNo));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortCreateReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(", ");
+        b.append("vportNo=").append(vportNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortCreateReplyVer13 other = (OFBsnVirtualPortCreateReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        if( vportNo != other.vportNo)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        result = prime *  (int) (vportNo ^ (vportNo >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13.java
new file mode 100644
index 0000000..6700e71
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13.java
@@ -0,0 +1,369 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortCreateRequestVer13 implements OFBsnVirtualPortCreateRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortCreateRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFBsnVport vport;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortCreateRequestVer13(long xid, OFBsnVport vport) {
+        this.xid = xid;
+        this.vport = vport;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+
+
+    public OFBsnVirtualPortCreateRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortCreateRequest.Builder {
+        final OFBsnVirtualPortCreateRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportSet;
+        private OFBsnVport vport;
+
+        BuilderWithParent(OFBsnVirtualPortCreateRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setVport(OFBsnVport vport) {
+        this.vport = vport;
+        this.vportSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortCreateRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBsnVport vport = this.vportSet ? this.vport : parentMessage.vport;
+                if(vport == null)
+                    throw new NullPointerException("Property vport must not be null");
+
+                //
+                return new OFBsnVirtualPortCreateRequestVer13(
+                    xid,
+                    vport
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortCreateRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportSet;
+        private OFBsnVport vport;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public OFBsnVport getVport() {
+        return vport;
+    }
+
+    @Override
+    public OFBsnVirtualPortCreateRequest.Builder setVport(OFBsnVport vport) {
+        this.vport = vport;
+        this.vportSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortCreateRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.vportSet)
+                throw new IllegalStateException("Property vport doesn't have default value -- must be set");
+            if(vport == null)
+                throw new NullPointerException("Property vport must not be null");
+
+
+            return new OFBsnVirtualPortCreateRequestVer13(
+                    xid,
+                    vport
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortCreateRequest> {
+        @Override
+        public OFBsnVirtualPortCreateRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xfL
+            int subtype = bb.readInt();
+            if(subtype != 0xf)
+                throw new OFParseError("Wrong subtype: Expected=0xfL(0xfL), got="+subtype);
+            OFBsnVport vport = OFBsnVportVer13.READER.readFrom(bb);
+
+            OFBsnVirtualPortCreateRequestVer13 bsnVirtualPortCreateRequestVer13 = new OFBsnVirtualPortCreateRequestVer13(
+                    xid,
+                      vport
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortCreateRequestVer13);
+            return bsnVirtualPortCreateRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortCreateRequestVer13Funnel FUNNEL = new OFBsnVirtualPortCreateRequestVer13Funnel();
+    static class OFBsnVirtualPortCreateRequestVer13Funnel implements Funnel<OFBsnVirtualPortCreateRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortCreateRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            sink.putInt(0xf);
+            message.vport.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortCreateRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortCreateRequestVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            bb.writeInt(0xf);
+            message.vport.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortCreateRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vport=").append(vport);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortCreateRequestVer13 other = (OFBsnVirtualPortCreateRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (vport == null) {
+            if (other.vport != null)
+                return false;
+        } else if (!vport.equals(other.vport))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((vport == null) ? 0 : vport.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortRemoveReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortRemoveReplyVer13.java
new file mode 100644
index 0000000..4cf13ca
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortRemoveReplyVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortRemoveReplyVer13 implements OFBsnVirtualPortRemoveReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortRemoveReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_STATUS = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long status;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortRemoveReplyVer13 DEFAULT = new OFBsnVirtualPortRemoveReplyVer13(
+        DEFAULT_XID, DEFAULT_STATUS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortRemoveReplyVer13(long xid, long status) {
+        this.xid = xid;
+        this.status = status;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+
+
+    public OFBsnVirtualPortRemoveReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortRemoveReply.Builder {
+        final OFBsnVirtualPortRemoveReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+        BuilderWithParent(OFBsnVirtualPortRemoveReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortRemoveReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long status = this.statusSet ? this.status : parentMessage.status;
+
+                //
+                return new OFBsnVirtualPortRemoveReplyVer13(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortRemoveReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean statusSet;
+        private long status;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1aL;
+    }
+
+    @Override
+    public long getStatus() {
+        return status;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveReply.Builder setStatus(long status) {
+        this.status = status;
+        this.statusSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortRemoveReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long status = this.statusSet ? this.status : DEFAULT_STATUS;
+
+
+            return new OFBsnVirtualPortRemoveReplyVer13(
+                    xid,
+                    status
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortRemoveReply> {
+        @Override
+        public OFBsnVirtualPortRemoveReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1aL
+            int subtype = bb.readInt();
+            if(subtype != 0x1a)
+                throw new OFParseError("Wrong subtype: Expected=0x1aL(0x1aL), got="+subtype);
+            long status = U32.f(bb.readInt());
+
+            OFBsnVirtualPortRemoveReplyVer13 bsnVirtualPortRemoveReplyVer13 = new OFBsnVirtualPortRemoveReplyVer13(
+                    xid,
+                      status
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortRemoveReplyVer13);
+            return bsnVirtualPortRemoveReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortRemoveReplyVer13Funnel FUNNEL = new OFBsnVirtualPortRemoveReplyVer13Funnel();
+    static class OFBsnVirtualPortRemoveReplyVer13Funnel implements Funnel<OFBsnVirtualPortRemoveReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortRemoveReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1aL
+            sink.putInt(0x1a);
+            sink.putLong(message.status);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortRemoveReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortRemoveReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1aL
+            bb.writeInt(0x1a);
+            bb.writeInt(U32.t(message.status));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortRemoveReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("status=").append(status);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortRemoveReplyVer13 other = (OFBsnVirtualPortRemoveReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( status != other.status)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (status ^ (status >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortRemoveRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortRemoveRequestVer13.java
new file mode 100644
index 0000000..503d758
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortRemoveRequestVer13.java
@@ -0,0 +1,361 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVirtualPortRemoveRequestVer13 implements OFBsnVirtualPortRemoveRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVirtualPortRemoveRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static long DEFAULT_VPORT_NO = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final long vportNo;
+//
+    // Immutable default instance
+    final static OFBsnVirtualPortRemoveRequestVer13 DEFAULT = new OFBsnVirtualPortRemoveRequestVer13(
+        DEFAULT_XID, DEFAULT_VPORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVirtualPortRemoveRequestVer13(long xid, long vportNo) {
+        this.xid = xid;
+        this.vportNo = vportNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+
+
+    public OFBsnVirtualPortRemoveRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVirtualPortRemoveRequest.Builder {
+        final OFBsnVirtualPortRemoveRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportNoSet;
+        private long vportNo;
+
+        BuilderWithParent(OFBsnVirtualPortRemoveRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVirtualPortRemoveRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                long vportNo = this.vportNoSet ? this.vportNo : parentMessage.vportNo;
+
+                //
+                return new OFBsnVirtualPortRemoveRequestVer13(
+                    xid,
+                    vportNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVirtualPortRemoveRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean vportNoSet;
+        private long vportNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x11L;
+    }
+
+    @Override
+    public long getVportNo() {
+        return vportNo;
+    }
+
+    @Override
+    public OFBsnVirtualPortRemoveRequest.Builder setVportNo(long vportNo) {
+        this.vportNo = vportNo;
+        this.vportNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVirtualPortRemoveRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            long vportNo = this.vportNoSet ? this.vportNo : DEFAULT_VPORT_NO;
+
+
+            return new OFBsnVirtualPortRemoveRequestVer13(
+                    xid,
+                    vportNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVirtualPortRemoveRequest> {
+        @Override
+        public OFBsnVirtualPortRemoveRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 20)
+                throw new OFParseError("Wrong length: Expected=20(20), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x11L
+            int subtype = bb.readInt();
+            if(subtype != 0x11)
+                throw new OFParseError("Wrong subtype: Expected=0x11L(0x11L), got="+subtype);
+            long vportNo = U32.f(bb.readInt());
+
+            OFBsnVirtualPortRemoveRequestVer13 bsnVirtualPortRemoveRequestVer13 = new OFBsnVirtualPortRemoveRequestVer13(
+                    xid,
+                      vportNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVirtualPortRemoveRequestVer13);
+            return bsnVirtualPortRemoveRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVirtualPortRemoveRequestVer13Funnel FUNNEL = new OFBsnVirtualPortRemoveRequestVer13Funnel();
+    static class OFBsnVirtualPortRemoveRequestVer13Funnel implements Funnel<OFBsnVirtualPortRemoveRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVirtualPortRemoveRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property length = 20
+            sink.putShort((short) 0x14);
+            sink.putLong(message.xid);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x11L
+            sink.putInt(0x11);
+            sink.putLong(message.vportNo);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVirtualPortRemoveRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVirtualPortRemoveRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property length = 20
+            bb.writeShort((short) 0x14);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x11L
+            bb.writeInt(0x11);
+            bb.writeInt(U32.t(message.vportNo));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVirtualPortRemoveRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("vportNo=").append(vportNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVirtualPortRemoveRequestVer13 other = (OFBsnVirtualPortRemoveRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( vportNo != other.vportNo)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime *  (int) (vportNo ^ (vportNo >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterConstantsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterConstantsSerializerVer13.java
new file mode 100644
index 0000000..d793b0f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterConstantsSerializerVer13.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVlanCounterConstants;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVlanCounterConstantsSerializerVer13 {
+
+    public final static short BSN_VLAN_ALL_VAL = (short) 0xffff;
+
+    public static OFBsnVlanCounterConstants readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(U8.f(bb.readByte()));
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVlanCounterConstants e) {
+        bb.writeByte(U8.t(toWireValue(e)));
+    }
+
+    public static void putTo(OFBsnVlanCounterConstants e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVlanCounterConstants ofWireValue(short val) {
+        switch(val) {
+            case BSN_VLAN_ALL_VAL:
+                return OFBsnVlanCounterConstants.BSN_VLAN_ALL;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVlanCounterConstants in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVlanCounterConstants e) {
+        switch(e) {
+            case BSN_VLAN_ALL:
+                return BSN_VLAN_ALL_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVlanCounterConstants in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsEntryVer13.java
new file mode 100644
index 0000000..1adf599
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsEntryVer13.java
@@ -0,0 +1,303 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVlanCounterStatsEntryVer13 implements OFBsnVlanCounterStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVlanCounterStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static int DEFAULT_VLAN_VID = 0x0;
+        private final static List<U64> DEFAULT_VALUES = ImmutableList.<U64>of();
+
+    // OF message fields
+    private final int vlanVid;
+    private final List<U64> values;
+//
+    // Immutable default instance
+    final static OFBsnVlanCounterStatsEntryVer13 DEFAULT = new OFBsnVlanCounterStatsEntryVer13(
+        DEFAULT_VLAN_VID, DEFAULT_VALUES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVlanCounterStatsEntryVer13(int vlanVid, List<U64> values) {
+        this.vlanVid = vlanVid;
+        this.values = values;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnVlanCounterStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVlanCounterStatsEntry.Builder {
+        final OFBsnVlanCounterStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean vlanVidSet;
+        private int vlanVid;
+        private boolean valuesSet;
+        private List<U64> values;
+
+        BuilderWithParent(OFBsnVlanCounterStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsEntry.Builder setVlanVid(int vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsEntry.Builder setValues(List<U64> values) {
+        this.values = values;
+        this.valuesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnVlanCounterStatsEntry build() {
+                int vlanVid = this.vlanVidSet ? this.vlanVid : parentMessage.vlanVid;
+                List<U64> values = this.valuesSet ? this.values : parentMessage.values;
+                if(values == null)
+                    throw new NullPointerException("Property values must not be null");
+
+                //
+                return new OFBsnVlanCounterStatsEntryVer13(
+                    vlanVid,
+                    values
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVlanCounterStatsEntry.Builder {
+        // OF message fields
+        private boolean vlanVidSet;
+        private int vlanVid;
+        private boolean valuesSet;
+        private List<U64> values;
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsEntry.Builder setVlanVid(int vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsEntry.Builder setValues(List<U64> values) {
+        this.values = values;
+        this.valuesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnVlanCounterStatsEntry build() {
+            int vlanVid = this.vlanVidSet ? this.vlanVid : DEFAULT_VLAN_VID;
+            List<U64> values = this.valuesSet ? this.values : DEFAULT_VALUES;
+            if(values == null)
+                throw new NullPointerException("Property values must not be null");
+
+
+            return new OFBsnVlanCounterStatsEntryVer13(
+                    vlanVid,
+                    values
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVlanCounterStatsEntry> {
+        @Override
+        public OFBsnVlanCounterStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int vlanVid = U16.f(bb.readShort());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<U64> values = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U64.READER);
+
+            OFBsnVlanCounterStatsEntryVer13 bsnVlanCounterStatsEntryVer13 = new OFBsnVlanCounterStatsEntryVer13(
+                    vlanVid,
+                      values
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVlanCounterStatsEntryVer13);
+            return bsnVlanCounterStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVlanCounterStatsEntryVer13Funnel FUNNEL = new OFBsnVlanCounterStatsEntryVer13Funnel();
+    static class OFBsnVlanCounterStatsEntryVer13Funnel implements Funnel<OFBsnVlanCounterStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVlanCounterStatsEntryVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            sink.putInt(message.vlanVid);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.values, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVlanCounterStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVlanCounterStatsEntryVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeShort(U16.t(message.vlanVid));
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.values);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVlanCounterStatsEntryVer13(");
+        b.append("vlanVid=").append(vlanVid);
+        b.append(", ");
+        b.append("values=").append(values);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVlanCounterStatsEntryVer13 other = (OFBsnVlanCounterStatsEntryVer13) obj;
+
+        if( vlanVid != other.vlanVid)
+            return false;
+        if (values == null) {
+            if (other.values != null)
+                return false;
+        } else if (!values.equals(other.values))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + vlanVid;
+        result = prime * result + ((values == null) ? 0 : values.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsReplyVer13.java
new file mode 100644
index 0000000..e09f083
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVlanCounterStatsReplyVer13 implements OFBsnVlanCounterStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVlanCounterStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnVlanCounterStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnVlanCounterStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnVlanCounterStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnVlanCounterStatsReplyVer13 DEFAULT = new OFBsnVlanCounterStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVlanCounterStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnVlanCounterStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+    @Override
+    public List<OFBsnVlanCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnVlanCounterStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVlanCounterStatsReply.Builder {
+        final OFBsnVlanCounterStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnVlanCounterStatsEntry> entries;
+
+        BuilderWithParent(OFBsnVlanCounterStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+    @Override
+    public List<OFBsnVlanCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsReply.Builder setEntries(List<OFBsnVlanCounterStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVlanCounterStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnVlanCounterStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnVlanCounterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVlanCounterStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnVlanCounterStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+    @Override
+    public List<OFBsnVlanCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsReply.Builder setEntries(List<OFBsnVlanCounterStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVlanCounterStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnVlanCounterStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnVlanCounterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVlanCounterStatsReply> {
+        @Override
+        public OFBsnVlanCounterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x9L
+            int subtype = bb.readInt();
+            if(subtype != 0x9)
+                throw new OFParseError("Wrong subtype: Expected=0x9L(0x9L), got="+subtype);
+            List<OFBsnVlanCounterStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnVlanCounterStatsEntryVer13.READER);
+
+            OFBsnVlanCounterStatsReplyVer13 bsnVlanCounterStatsReplyVer13 = new OFBsnVlanCounterStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVlanCounterStatsReplyVer13);
+            return bsnVlanCounterStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVlanCounterStatsReplyVer13Funnel FUNNEL = new OFBsnVlanCounterStatsReplyVer13Funnel();
+    static class OFBsnVlanCounterStatsReplyVer13Funnel implements Funnel<OFBsnVlanCounterStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVlanCounterStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            sink.putInt(0x9);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVlanCounterStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVlanCounterStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            bb.writeInt(0x9);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVlanCounterStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVlanCounterStatsReplyVer13 other = (OFBsnVlanCounterStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsRequestVer13.java
new file mode 100644
index 0000000..228e70b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterStatsRequestVer13.java
@@ -0,0 +1,444 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVlanCounterStatsRequestVer13 implements OFBsnVlanCounterStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVlanCounterStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 26;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static int DEFAULT_VLAN_VID = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final int vlanVid;
+//
+    // Immutable default instance
+    final static OFBsnVlanCounterStatsRequestVer13 DEFAULT = new OFBsnVlanCounterStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_VLAN_VID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVlanCounterStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, int vlanVid) {
+        this.xid = xid;
+        this.flags = flags;
+        this.vlanVid = vlanVid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+
+
+    public OFBsnVlanCounterStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVlanCounterStatsRequest.Builder {
+        final OFBsnVlanCounterStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean vlanVidSet;
+        private int vlanVid;
+
+        BuilderWithParent(OFBsnVlanCounterStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsRequest.Builder setVlanVid(int vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVlanCounterStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int vlanVid = this.vlanVidSet ? this.vlanVid : parentMessage.vlanVid;
+
+                //
+                return new OFBsnVlanCounterStatsRequestVer13(
+                    xid,
+                    flags,
+                    vlanVid
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVlanCounterStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean vlanVidSet;
+        private int vlanVid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+    @Override
+    public int getVlanVid() {
+        return vlanVid;
+    }
+
+    @Override
+    public OFBsnVlanCounterStatsRequest.Builder setVlanVid(int vlanVid) {
+        this.vlanVid = vlanVid;
+        this.vlanVidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVlanCounterStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int vlanVid = this.vlanVidSet ? this.vlanVid : DEFAULT_VLAN_VID;
+
+
+            return new OFBsnVlanCounterStatsRequestVer13(
+                    xid,
+                    flags,
+                    vlanVid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVlanCounterStatsRequest> {
+        @Override
+        public OFBsnVlanCounterStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 26)
+                throw new OFParseError("Wrong length: Expected=26(26), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x9L
+            int subtype = bb.readInt();
+            if(subtype != 0x9)
+                throw new OFParseError("Wrong subtype: Expected=0x9L(0x9L), got="+subtype);
+            int vlanVid = U16.f(bb.readShort());
+
+            OFBsnVlanCounterStatsRequestVer13 bsnVlanCounterStatsRequestVer13 = new OFBsnVlanCounterStatsRequestVer13(
+                    xid,
+                      flags,
+                      vlanVid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVlanCounterStatsRequestVer13);
+            return bsnVlanCounterStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVlanCounterStatsRequestVer13Funnel FUNNEL = new OFBsnVlanCounterStatsRequestVer13Funnel();
+    static class OFBsnVlanCounterStatsRequestVer13Funnel implements Funnel<OFBsnVlanCounterStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVlanCounterStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 26
+            sink.putShort((short) 0x1a);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            sink.putInt(0x9);
+            sink.putInt(message.vlanVid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVlanCounterStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVlanCounterStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 26
+            bb.writeShort((short) 0x1a);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            bb.writeInt(0x9);
+            bb.writeShort(U16.t(message.vlanVid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVlanCounterStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("vlanVid=").append(vlanVid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVlanCounterStatsRequestVer13 other = (OFBsnVlanCounterStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( vlanVid != other.vlanVid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + vlanVid;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterTSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterTSerializerVer13.java
new file mode 100644
index 0000000..81063c7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVlanCounterTSerializerVer13.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVlanCounterT;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVlanCounterTSerializerVer13 {
+
+    public final static byte BSN_VLAN_COUNTER_RX_BYTES_VAL = (byte) 0x0;
+    public final static byte BSN_VLAN_COUNTER_RX_PACKETS_VAL = (byte) 0x1;
+    public final static byte BSN_VLAN_COUNTER_TX_BYTES_VAL = (byte) 0x2;
+    public final static byte BSN_VLAN_COUNTER_TX_PACKETS_VAL = (byte) 0x3;
+
+    public static OFBsnVlanCounterT readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVlanCounterT e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnVlanCounterT e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnVlanCounterT ofWireValue(byte val) {
+        switch(val) {
+            case BSN_VLAN_COUNTER_RX_BYTES_VAL:
+                return OFBsnVlanCounterT.BSN_VLAN_COUNTER_RX_BYTES;
+            case BSN_VLAN_COUNTER_RX_PACKETS_VAL:
+                return OFBsnVlanCounterT.BSN_VLAN_COUNTER_RX_PACKETS;
+            case BSN_VLAN_COUNTER_TX_BYTES_VAL:
+                return OFBsnVlanCounterT.BSN_VLAN_COUNTER_TX_BYTES;
+            case BSN_VLAN_COUNTER_TX_PACKETS_VAL:
+                return OFBsnVlanCounterT.BSN_VLAN_COUNTER_TX_PACKETS;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVlanCounterT in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnVlanCounterT e) {
+        switch(e) {
+            case BSN_VLAN_COUNTER_RX_BYTES:
+                return BSN_VLAN_COUNTER_RX_BYTES_VAL;
+            case BSN_VLAN_COUNTER_RX_PACKETS:
+                return BSN_VLAN_COUNTER_RX_PACKETS_VAL;
+            case BSN_VLAN_COUNTER_TX_BYTES:
+                return BSN_VLAN_COUNTER_TX_BYTES_VAL;
+            case BSN_VLAN_COUNTER_TX_PACKETS:
+                return BSN_VLAN_COUNTER_TX_PACKETS_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVlanCounterT in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportL2GreFlagsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportL2GreFlagsSerializerVer13.java
new file mode 100644
index 0000000..0e4330b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportL2GreFlagsSerializerVer13.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportL2GreFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFBsnVportL2GreFlagsSerializerVer13 {
+
+    public final static int BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL = 0x1;
+    public final static int BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL = 0x2;
+    public final static int BSN_VPORT_L2GRE_DSCP_COPY_VAL = 0x4;
+    public final static int BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL = 0x8;
+    public final static int BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL = 0x10;
+
+    public static Set<OFBsnVportL2GreFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFBsnVportL2GreFlags> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFBsnVportL2GreFlags> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFBsnVportL2GreFlags> ofWireValue(int val) {
+        EnumSet<OFBsnVportL2GreFlags> set = EnumSet.noneOf(OFBsnVportL2GreFlags.class);
+
+        if((val & BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID);
+        if((val & BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN);
+        if((val & BSN_VPORT_L2GRE_DSCP_COPY_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_COPY);
+        if((val & BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID);
+        if((val & BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL) != 0)
+            set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFBsnVportL2GreFlags> set) {
+        int wireValue = 0;
+
+        for(OFBsnVportL2GreFlags e: set) {
+            switch(e) {
+                case BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_DSCP_ASSIGN:
+                    wireValue |= BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_DSCP_COPY:
+                    wireValue |= BSN_VPORT_L2GRE_DSCP_COPY_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_LOOPBACK_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL;
+                    break;
+                case BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID:
+                    wireValue |= BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFBsnVportL2GreFlags in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportL2GreVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportL2GreVer13.java
new file mode 100644
index 0000000..f420bdc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportL2GreVer13.java
@@ -0,0 +1,839 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVportL2GreVer13 implements OFBsnVportL2Gre {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVportL2GreVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 64;
+
+        private final static Set<OFBsnVportL2GreFlags> DEFAULT_FLAGS = ImmutableSet.<OFBsnVportL2GreFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static OFPort DEFAULT_LOOPBACK_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_LOCAL_MAC = MacAddress.NONE;
+        private final static MacAddress DEFAULT_NH_MAC = MacAddress.NONE;
+        private final static IPv4Address DEFAULT_SRC_IP = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_DST_IP = IPv4Address.NONE;
+        private final static short DEFAULT_DSCP = (short) 0x0;
+        private final static short DEFAULT_TTL = (short) 0x0;
+        private final static long DEFAULT_VPN = 0x0L;
+        private final static long DEFAULT_RATE_LIMIT = 0x0L;
+        private final static String DEFAULT_IF_NAME = "";
+
+    // OF message fields
+    private final Set<OFBsnVportL2GreFlags> flags;
+    private final OFPort portNo;
+    private final OFPort loopbackPortNo;
+    private final MacAddress localMac;
+    private final MacAddress nhMac;
+    private final IPv4Address srcIp;
+    private final IPv4Address dstIp;
+    private final short dscp;
+    private final short ttl;
+    private final long vpn;
+    private final long rateLimit;
+    private final String ifName;
+//
+    // Immutable default instance
+    final static OFBsnVportL2GreVer13 DEFAULT = new OFBsnVportL2GreVer13(
+        DEFAULT_FLAGS, DEFAULT_PORT_NO, DEFAULT_LOOPBACK_PORT_NO, DEFAULT_LOCAL_MAC, DEFAULT_NH_MAC, DEFAULT_SRC_IP, DEFAULT_DST_IP, DEFAULT_DSCP, DEFAULT_TTL, DEFAULT_VPN, DEFAULT_RATE_LIMIT, DEFAULT_IF_NAME
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVportL2GreVer13(Set<OFBsnVportL2GreFlags> flags, OFPort portNo, OFPort loopbackPortNo, MacAddress localMac, MacAddress nhMac, IPv4Address srcIp, IPv4Address dstIp, short dscp, short ttl, long vpn, long rateLimit, String ifName) {
+        this.flags = flags;
+        this.portNo = portNo;
+        this.loopbackPortNo = loopbackPortNo;
+        this.localMac = localMac;
+        this.nhMac = nhMac;
+        this.srcIp = srcIp;
+        this.dstIp = dstIp;
+        this.dscp = dscp;
+        this.ttl = ttl;
+        this.vpn = vpn;
+        this.rateLimit = rateLimit;
+        this.ifName = ifName;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnVportL2Gre.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVportL2Gre.Builder {
+        final OFBsnVportL2GreVer13 parentMessage;
+
+        // OF message fields
+        private boolean flagsSet;
+        private Set<OFBsnVportL2GreFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean loopbackPortNoSet;
+        private OFPort loopbackPortNo;
+        private boolean localMacSet;
+        private MacAddress localMac;
+        private boolean nhMacSet;
+        private MacAddress nhMac;
+        private boolean srcIpSet;
+        private IPv4Address srcIp;
+        private boolean dstIpSet;
+        private IPv4Address dstIp;
+        private boolean dscpSet;
+        private short dscp;
+        private boolean ttlSet;
+        private short ttl;
+        private boolean vpnSet;
+        private long vpn;
+        private boolean rateLimitSet;
+        private long rateLimit;
+        private boolean ifNameSet;
+        private String ifName;
+
+        BuilderWithParent(OFBsnVportL2GreVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setFlags(Set<OFBsnVportL2GreFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLoopbackPortNo(OFPort loopbackPortNo) {
+        this.loopbackPortNo = loopbackPortNo;
+        this.loopbackPortNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLocalMac(MacAddress localMac) {
+        this.localMac = localMac;
+        this.localMacSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setNhMac(MacAddress nhMac) {
+        this.nhMac = nhMac;
+        this.nhMacSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setSrcIp(IPv4Address srcIp) {
+        this.srcIp = srcIp;
+        this.srcIpSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDstIp(IPv4Address dstIp) {
+        this.dstIp = dstIp;
+        this.dstIpSet = true;
+        return this;
+    }
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDscp(short dscp) {
+        this.dscp = dscp;
+        this.dscpSet = true;
+        return this;
+    }
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setTtl(short ttl) {
+        this.ttl = ttl;
+        this.ttlSet = true;
+        return this;
+    }
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setVpn(long vpn) {
+        this.vpn = vpn;
+        this.vpnSet = true;
+        return this;
+    }
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setRateLimit(long rateLimit) {
+        this.rateLimit = rateLimit;
+        this.rateLimitSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnVportL2Gre build() {
+                Set<OFBsnVportL2GreFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                OFPort loopbackPortNo = this.loopbackPortNoSet ? this.loopbackPortNo : parentMessage.loopbackPortNo;
+                if(loopbackPortNo == null)
+                    throw new NullPointerException("Property loopbackPortNo must not be null");
+                MacAddress localMac = this.localMacSet ? this.localMac : parentMessage.localMac;
+                if(localMac == null)
+                    throw new NullPointerException("Property localMac must not be null");
+                MacAddress nhMac = this.nhMacSet ? this.nhMac : parentMessage.nhMac;
+                if(nhMac == null)
+                    throw new NullPointerException("Property nhMac must not be null");
+                IPv4Address srcIp = this.srcIpSet ? this.srcIp : parentMessage.srcIp;
+                if(srcIp == null)
+                    throw new NullPointerException("Property srcIp must not be null");
+                IPv4Address dstIp = this.dstIpSet ? this.dstIp : parentMessage.dstIp;
+                if(dstIp == null)
+                    throw new NullPointerException("Property dstIp must not be null");
+                short dscp = this.dscpSet ? this.dscp : parentMessage.dscp;
+                short ttl = this.ttlSet ? this.ttl : parentMessage.ttl;
+                long vpn = this.vpnSet ? this.vpn : parentMessage.vpn;
+                long rateLimit = this.rateLimitSet ? this.rateLimit : parentMessage.rateLimit;
+                String ifName = this.ifNameSet ? this.ifName : parentMessage.ifName;
+                if(ifName == null)
+                    throw new NullPointerException("Property ifName must not be null");
+
+                //
+                return new OFBsnVportL2GreVer13(
+                    flags,
+                    portNo,
+                    loopbackPortNo,
+                    localMac,
+                    nhMac,
+                    srcIp,
+                    dstIp,
+                    dscp,
+                    ttl,
+                    vpn,
+                    rateLimit,
+                    ifName
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVportL2Gre.Builder {
+        // OF message fields
+        private boolean flagsSet;
+        private Set<OFBsnVportL2GreFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean loopbackPortNoSet;
+        private OFPort loopbackPortNo;
+        private boolean localMacSet;
+        private MacAddress localMac;
+        private boolean nhMacSet;
+        private MacAddress nhMac;
+        private boolean srcIpSet;
+        private IPv4Address srcIp;
+        private boolean dstIpSet;
+        private IPv4Address dstIp;
+        private boolean dscpSet;
+        private short dscp;
+        private boolean ttlSet;
+        private short ttl;
+        private boolean vpnSet;
+        private long vpn;
+        private boolean rateLimitSet;
+        private long rateLimit;
+        private boolean ifNameSet;
+        private String ifName;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public Set<OFBsnVportL2GreFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setFlags(Set<OFBsnVportL2GreFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getLoopbackPortNo() {
+        return loopbackPortNo;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLoopbackPortNo(OFPort loopbackPortNo) {
+        this.loopbackPortNo = loopbackPortNo;
+        this.loopbackPortNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getLocalMac() {
+        return localMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setLocalMac(MacAddress localMac) {
+        this.localMac = localMac;
+        this.localMacSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getNhMac() {
+        return nhMac;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setNhMac(MacAddress nhMac) {
+        this.nhMac = nhMac;
+        this.nhMacSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getSrcIp() {
+        return srcIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setSrcIp(IPv4Address srcIp) {
+        this.srcIp = srcIp;
+        this.srcIpSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getDstIp() {
+        return dstIp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDstIp(IPv4Address dstIp) {
+        this.dstIp = dstIp;
+        this.dstIpSet = true;
+        return this;
+    }
+    @Override
+    public short getDscp() {
+        return dscp;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setDscp(short dscp) {
+        this.dscp = dscp;
+        this.dscpSet = true;
+        return this;
+    }
+    @Override
+    public short getTtl() {
+        return ttl;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setTtl(short ttl) {
+        this.ttl = ttl;
+        this.ttlSet = true;
+        return this;
+    }
+    @Override
+    public long getVpn() {
+        return vpn;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setVpn(long vpn) {
+        this.vpn = vpn;
+        this.vpnSet = true;
+        return this;
+    }
+    @Override
+    public long getRateLimit() {
+        return rateLimit;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setRateLimit(long rateLimit) {
+        this.rateLimit = rateLimit;
+        this.rateLimitSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportL2Gre.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnVportL2Gre build() {
+            Set<OFBsnVportL2GreFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            OFPort loopbackPortNo = this.loopbackPortNoSet ? this.loopbackPortNo : DEFAULT_LOOPBACK_PORT_NO;
+            if(loopbackPortNo == null)
+                throw new NullPointerException("Property loopbackPortNo must not be null");
+            MacAddress localMac = this.localMacSet ? this.localMac : DEFAULT_LOCAL_MAC;
+            if(localMac == null)
+                throw new NullPointerException("Property localMac must not be null");
+            MacAddress nhMac = this.nhMacSet ? this.nhMac : DEFAULT_NH_MAC;
+            if(nhMac == null)
+                throw new NullPointerException("Property nhMac must not be null");
+            IPv4Address srcIp = this.srcIpSet ? this.srcIp : DEFAULT_SRC_IP;
+            if(srcIp == null)
+                throw new NullPointerException("Property srcIp must not be null");
+            IPv4Address dstIp = this.dstIpSet ? this.dstIp : DEFAULT_DST_IP;
+            if(dstIp == null)
+                throw new NullPointerException("Property dstIp must not be null");
+            short dscp = this.dscpSet ? this.dscp : DEFAULT_DSCP;
+            short ttl = this.ttlSet ? this.ttl : DEFAULT_TTL;
+            long vpn = this.vpnSet ? this.vpn : DEFAULT_VPN;
+            long rateLimit = this.rateLimitSet ? this.rateLimit : DEFAULT_RATE_LIMIT;
+            String ifName = this.ifNameSet ? this.ifName : DEFAULT_IF_NAME;
+            if(ifName == null)
+                throw new NullPointerException("Property ifName must not be null");
+
+
+            return new OFBsnVportL2GreVer13(
+                    flags,
+                    portNo,
+                    loopbackPortNo,
+                    localMac,
+                    nhMac,
+                    srcIp,
+                    dstIp,
+                    dscp,
+                    ttl,
+                    vpn,
+                    rateLimit,
+                    ifName
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVportL2Gre> {
+        @Override
+        public OFBsnVportL2Gre readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 64)
+                throw new OFParseError("Wrong length: Expected=64(64), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            Set<OFBsnVportL2GreFlags> flags = OFBsnVportL2GreFlagsSerializerVer13.readFrom(bb);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            OFPort loopbackPortNo = OFPort.read4Bytes(bb);
+            MacAddress localMac = MacAddress.read6Bytes(bb);
+            MacAddress nhMac = MacAddress.read6Bytes(bb);
+            IPv4Address srcIp = IPv4Address.read4Bytes(bb);
+            IPv4Address dstIp = IPv4Address.read4Bytes(bb);
+            short dscp = U8.f(bb.readByte());
+            short ttl = U8.f(bb.readByte());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long vpn = U32.f(bb.readInt());
+            long rateLimit = U32.f(bb.readInt());
+            String ifName = ChannelUtils.readFixedLengthString(bb, 16);
+
+            OFBsnVportL2GreVer13 bsnVportL2GreVer13 = new OFBsnVportL2GreVer13(
+                    flags,
+                      portNo,
+                      loopbackPortNo,
+                      localMac,
+                      nhMac,
+                      srcIp,
+                      dstIp,
+                      dscp,
+                      ttl,
+                      vpn,
+                      rateLimit,
+                      ifName
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVportL2GreVer13);
+            return bsnVportL2GreVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVportL2GreVer13Funnel FUNNEL = new OFBsnVportL2GreVer13Funnel();
+    static class OFBsnVportL2GreVer13Funnel implements Funnel<OFBsnVportL2GreVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVportL2GreVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 64
+            sink.putShort((short) 0x40);
+            OFBsnVportL2GreFlagsSerializerVer13.putTo(message.flags, sink);
+            message.portNo.putTo(sink);
+            message.loopbackPortNo.putTo(sink);
+            message.localMac.putTo(sink);
+            message.nhMac.putTo(sink);
+            message.srcIp.putTo(sink);
+            message.dstIp.putTo(sink);
+            sink.putShort(message.dscp);
+            sink.putShort(message.ttl);
+            // skip pad (2 bytes)
+            sink.putLong(message.vpn);
+            sink.putLong(message.rateLimit);
+            sink.putUnencodedChars(message.ifName);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVportL2GreVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVportL2GreVer13 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 64
+            bb.writeShort((short) 0x40);
+            OFBsnVportL2GreFlagsSerializerVer13.writeTo(bb, message.flags);
+            message.portNo.write4Bytes(bb);
+            message.loopbackPortNo.write4Bytes(bb);
+            message.localMac.write6Bytes(bb);
+            message.nhMac.write6Bytes(bb);
+            message.srcIp.write4Bytes(bb);
+            message.dstIp.write4Bytes(bb);
+            bb.writeByte(U8.t(message.dscp));
+            bb.writeByte(U8.t(message.ttl));
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.vpn));
+            bb.writeInt(U32.t(message.rateLimit));
+            ChannelUtils.writeFixedLengthString(bb, message.ifName, 16);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVportL2GreVer13(");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("loopbackPortNo=").append(loopbackPortNo);
+        b.append(", ");
+        b.append("localMac=").append(localMac);
+        b.append(", ");
+        b.append("nhMac=").append(nhMac);
+        b.append(", ");
+        b.append("srcIp=").append(srcIp);
+        b.append(", ");
+        b.append("dstIp=").append(dstIp);
+        b.append(", ");
+        b.append("dscp=").append(dscp);
+        b.append(", ");
+        b.append("ttl=").append(ttl);
+        b.append(", ");
+        b.append("vpn=").append(vpn);
+        b.append(", ");
+        b.append("rateLimit=").append(rateLimit);
+        b.append(", ");
+        b.append("ifName=").append(ifName);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVportL2GreVer13 other = (OFBsnVportL2GreVer13) obj;
+
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (loopbackPortNo == null) {
+            if (other.loopbackPortNo != null)
+                return false;
+        } else if (!loopbackPortNo.equals(other.loopbackPortNo))
+            return false;
+        if (localMac == null) {
+            if (other.localMac != null)
+                return false;
+        } else if (!localMac.equals(other.localMac))
+            return false;
+        if (nhMac == null) {
+            if (other.nhMac != null)
+                return false;
+        } else if (!nhMac.equals(other.nhMac))
+            return false;
+        if (srcIp == null) {
+            if (other.srcIp != null)
+                return false;
+        } else if (!srcIp.equals(other.srcIp))
+            return false;
+        if (dstIp == null) {
+            if (other.dstIp != null)
+                return false;
+        } else if (!dstIp.equals(other.dstIp))
+            return false;
+        if( dscp != other.dscp)
+            return false;
+        if( ttl != other.ttl)
+            return false;
+        if( vpn != other.vpn)
+            return false;
+        if( rateLimit != other.rateLimit)
+            return false;
+        if (ifName == null) {
+            if (other.ifName != null)
+                return false;
+        } else if (!ifName.equals(other.ifName))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((loopbackPortNo == null) ? 0 : loopbackPortNo.hashCode());
+        result = prime * result + ((localMac == null) ? 0 : localMac.hashCode());
+        result = prime * result + ((nhMac == null) ? 0 : nhMac.hashCode());
+        result = prime * result + ((srcIp == null) ? 0 : srcIp.hashCode());
+        result = prime * result + ((dstIp == null) ? 0 : dstIp.hashCode());
+        result = prime * result + dscp;
+        result = prime * result + ttl;
+        result = prime *  (int) (vpn ^ (vpn >>> 32));
+        result = prime *  (int) (rateLimit ^ (rateLimit >>> 32));
+        result = prime * result + ((ifName == null) ? 0 : ifName.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportQInQUntaggedSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportQInQUntaggedSerializerVer13.java
new file mode 100644
index 0000000..da359ae
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportQInQUntaggedSerializerVer13.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportQInQUntagged;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVportQInQUntaggedSerializerVer13 {
+
+    public final static short BSN_VPORT_Q_IN_Q_UNTAGGED_VAL = (short) 0xffff;
+
+    public static OFBsnVportQInQUntagged readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVportQInQUntagged e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnVportQInQUntagged e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVportQInQUntagged ofWireValue(short val) {
+        switch(val) {
+            case BSN_VPORT_Q_IN_Q_UNTAGGED_VAL:
+                return OFBsnVportQInQUntagged.BSN_VPORT_Q_IN_Q_UNTAGGED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVportQInQUntagged in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVportQInQUntagged e) {
+        switch(e) {
+            case BSN_VPORT_Q_IN_Q_UNTAGGED:
+                return BSN_VPORT_Q_IN_Q_UNTAGGED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVportQInQUntagged in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportQInQVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportQInQVer13.java
new file mode 100644
index 0000000..1aed0b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportQInQVer13.java
@@ -0,0 +1,502 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVportQInQVer13 implements OFBsnVportQInQ {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVportQInQVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_PORT_NO = 0x0L;
+        private final static int DEFAULT_INGRESS_TPID = 0x0;
+        private final static int DEFAULT_INGRESS_VLAN_ID = 0x0;
+        private final static int DEFAULT_EGRESS_TPID = 0x0;
+        private final static int DEFAULT_EGRESS_VLAN_ID = 0x0;
+        private final static String DEFAULT_IF_NAME = "";
+
+    // OF message fields
+    private final long portNo;
+    private final int ingressTpid;
+    private final int ingressVlanId;
+    private final int egressTpid;
+    private final int egressVlanId;
+    private final String ifName;
+//
+    // Immutable default instance
+    final static OFBsnVportQInQVer13 DEFAULT = new OFBsnVportQInQVer13(
+        DEFAULT_PORT_NO, DEFAULT_INGRESS_TPID, DEFAULT_INGRESS_VLAN_ID, DEFAULT_EGRESS_TPID, DEFAULT_EGRESS_VLAN_ID, DEFAULT_IF_NAME
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVportQInQVer13(long portNo, int ingressTpid, int ingressVlanId, int egressTpid, int egressVlanId, String ifName) {
+        this.portNo = portNo;
+        this.ingressTpid = ingressTpid;
+        this.ingressVlanId = ingressVlanId;
+        this.egressTpid = egressTpid;
+        this.egressVlanId = egressVlanId;
+        this.ifName = ifName;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnVportQInQ.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVportQInQ.Builder {
+        final OFBsnVportQInQVer13 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private long portNo;
+        private boolean ingressTpidSet;
+        private int ingressTpid;
+        private boolean ingressVlanIdSet;
+        private int ingressVlanId;
+        private boolean egressTpidSet;
+        private int egressTpid;
+        private boolean egressVlanIdSet;
+        private int egressVlanId;
+        private boolean ifNameSet;
+        private String ifName;
+
+        BuilderWithParent(OFBsnVportQInQVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setPortNo(long portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressTpid(int ingressTpid) {
+        this.ingressTpid = ingressTpid;
+        this.ingressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressVlanId(int ingressVlanId) {
+        this.ingressVlanId = ingressVlanId;
+        this.ingressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressTpid(int egressTpid) {
+        this.egressTpid = egressTpid;
+        this.egressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressVlanId(int egressVlanId) {
+        this.egressVlanId = egressVlanId;
+        this.egressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnVportQInQ build() {
+                long portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                int ingressTpid = this.ingressTpidSet ? this.ingressTpid : parentMessage.ingressTpid;
+                int ingressVlanId = this.ingressVlanIdSet ? this.ingressVlanId : parentMessage.ingressVlanId;
+                int egressTpid = this.egressTpidSet ? this.egressTpid : parentMessage.egressTpid;
+                int egressVlanId = this.egressVlanIdSet ? this.egressVlanId : parentMessage.egressVlanId;
+                String ifName = this.ifNameSet ? this.ifName : parentMessage.ifName;
+                if(ifName == null)
+                    throw new NullPointerException("Property ifName must not be null");
+
+                //
+                return new OFBsnVportQInQVer13(
+                    portNo,
+                    ingressTpid,
+                    ingressVlanId,
+                    egressTpid,
+                    egressVlanId,
+                    ifName
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVportQInQ.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private long portNo;
+        private boolean ingressTpidSet;
+        private int ingressTpid;
+        private boolean ingressVlanIdSet;
+        private int ingressVlanId;
+        private boolean egressTpidSet;
+        private int egressTpid;
+        private boolean egressVlanIdSet;
+        private int egressVlanId;
+        private boolean ifNameSet;
+        private String ifName;
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public long getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setPortNo(long portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressTpid() {
+        return ingressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressTpid(int ingressTpid) {
+        this.ingressTpid = ingressTpid;
+        this.ingressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getIngressVlanId() {
+        return ingressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIngressVlanId(int ingressVlanId) {
+        this.ingressVlanId = ingressVlanId;
+        this.ingressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressTpid() {
+        return egressTpid;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressTpid(int egressTpid) {
+        this.egressTpid = egressTpid;
+        this.egressTpidSet = true;
+        return this;
+    }
+    @Override
+    public int getEgressVlanId() {
+        return egressVlanId;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setEgressVlanId(int egressVlanId) {
+        this.egressVlanId = egressVlanId;
+        this.egressVlanIdSet = true;
+        return this;
+    }
+    @Override
+    public String getIfName() {
+        return ifName;
+    }
+
+    @Override
+    public OFBsnVportQInQ.Builder setIfName(String ifName) {
+        this.ifName = ifName;
+        this.ifNameSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnVportQInQ build() {
+            long portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            int ingressTpid = this.ingressTpidSet ? this.ingressTpid : DEFAULT_INGRESS_TPID;
+            int ingressVlanId = this.ingressVlanIdSet ? this.ingressVlanId : DEFAULT_INGRESS_VLAN_ID;
+            int egressTpid = this.egressTpidSet ? this.egressTpid : DEFAULT_EGRESS_TPID;
+            int egressVlanId = this.egressVlanIdSet ? this.egressVlanId : DEFAULT_EGRESS_VLAN_ID;
+            String ifName = this.ifNameSet ? this.ifName : DEFAULT_IF_NAME;
+            if(ifName == null)
+                throw new NullPointerException("Property ifName must not be null");
+
+
+            return new OFBsnVportQInQVer13(
+                    portNo,
+                    ingressTpid,
+                    ingressVlanId,
+                    egressTpid,
+                    egressVlanId,
+                    ifName
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVportQInQ> {
+        @Override
+        public OFBsnVportQInQ readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=0x0(0x0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long portNo = U32.f(bb.readInt());
+            int ingressTpid = U16.f(bb.readShort());
+            int ingressVlanId = U16.f(bb.readShort());
+            int egressTpid = U16.f(bb.readShort());
+            int egressVlanId = U16.f(bb.readShort());
+            String ifName = ChannelUtils.readFixedLengthString(bb, 16);
+
+            OFBsnVportQInQVer13 bsnVportQInQVer13 = new OFBsnVportQInQVer13(
+                    portNo,
+                      ingressTpid,
+                      ingressVlanId,
+                      egressTpid,
+                      egressVlanId,
+                      ifName
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVportQInQVer13);
+            return bsnVportQInQVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVportQInQVer13Funnel FUNNEL = new OFBsnVportQInQVer13Funnel();
+    static class OFBsnVportQInQVer13Funnel implements Funnel<OFBsnVportQInQVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVportQInQVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x0
+            sink.putShort((short) 0x0);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.portNo);
+            sink.putInt(message.ingressTpid);
+            sink.putInt(message.ingressVlanId);
+            sink.putInt(message.egressTpid);
+            sink.putInt(message.egressVlanId);
+            sink.putUnencodedChars(message.ifName);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVportQInQVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVportQInQVer13 message) {
+            // fixed value property type = 0x0
+            bb.writeShort((short) 0x0);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.portNo));
+            bb.writeShort(U16.t(message.ingressTpid));
+            bb.writeShort(U16.t(message.ingressVlanId));
+            bb.writeShort(U16.t(message.egressTpid));
+            bb.writeShort(U16.t(message.egressVlanId));
+            ChannelUtils.writeFixedLengthString(bb, message.ifName, 16);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVportQInQVer13(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("ingressTpid=").append(ingressTpid);
+        b.append(", ");
+        b.append("ingressVlanId=").append(ingressVlanId);
+        b.append(", ");
+        b.append("egressTpid=").append(egressTpid);
+        b.append(", ");
+        b.append("egressVlanId=").append(egressVlanId);
+        b.append(", ");
+        b.append("ifName=").append(ifName);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVportQInQVer13 other = (OFBsnVportQInQVer13) obj;
+
+        if( portNo != other.portNo)
+            return false;
+        if( ingressTpid != other.ingressTpid)
+            return false;
+        if( ingressVlanId != other.ingressVlanId)
+            return false;
+        if( egressTpid != other.egressTpid)
+            return false;
+        if( egressVlanId != other.egressVlanId)
+            return false;
+        if (ifName == null) {
+            if (other.ifName != null)
+                return false;
+        } else if (!ifName.equals(other.ifName))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (portNo ^ (portNo >>> 32));
+        result = prime * result + ingressTpid;
+        result = prime * result + ingressVlanId;
+        result = prime * result + egressTpid;
+        result = prime * result + egressVlanId;
+        result = prime * result + ((ifName == null) ? 0 : ifName.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportStatusSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportStatusSerializerVer13.java
new file mode 100644
index 0000000..ad668bf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportStatusSerializerVer13.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVportStatus;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVportStatusSerializerVer13 {
+
+    public final static short BSN_VPORT_STATUS_OK_VAL = (short) 0x0;
+    public final static short BSN_VPORT_STATUS_FAILED_VAL = (short) 0x1;
+
+    public static OFBsnVportStatus readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(U8.f(bb.readByte()));
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVportStatus e) {
+        bb.writeByte(U8.t(toWireValue(e)));
+    }
+
+    public static void putTo(OFBsnVportStatus e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFBsnVportStatus ofWireValue(short val) {
+        switch(val) {
+            case BSN_VPORT_STATUS_OK_VAL:
+                return OFBsnVportStatus.BSN_VPORT_STATUS_OK;
+            case BSN_VPORT_STATUS_FAILED_VAL:
+                return OFBsnVportStatus.BSN_VPORT_STATUS_FAILED;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVportStatus in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFBsnVportStatus e) {
+        switch(e) {
+            case BSN_VPORT_STATUS_OK:
+                return BSN_VPORT_STATUS_OK_VAL;
+            case BSN_VPORT_STATUS_FAILED:
+                return BSN_VPORT_STATUS_FAILED_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVportStatus in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportVer13.java
new file mode 100644
index 0000000..686cbeb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVportVer13.java
@@ -0,0 +1,56 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFBsnVportVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFBsnVportVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFBsnVport> {
+        @Override
+        public OFBsnVport readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFBsnVportL2GreVer13
+                   return OFBsnVportL2GreVer13.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value 0x0=0x0 for class OFBsnVportQInQVer13
+                   return OFBsnVportQInQVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFBsnVportVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterConstantsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterConstantsSerializerVer13.java
new file mode 100644
index 0000000..a8a3ffb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterConstantsSerializerVer13.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVrfCounterConstants;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVrfCounterConstantsSerializerVer13 {
+
+    public final static int BSN_VRF_ALL_VAL = (int) 0xffffffff;
+
+    public static OFBsnVrfCounterConstants readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVrfCounterConstants e) {
+        bb.writeInt(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnVrfCounterConstants e, PrimitiveSink sink) {
+        sink.putInt(toWireValue(e));
+    }
+
+    public static OFBsnVrfCounterConstants ofWireValue(int val) {
+        switch(val) {
+            case BSN_VRF_ALL_VAL:
+                return OFBsnVrfCounterConstants.BSN_VRF_ALL;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVrfCounterConstants in version 1.3: " + val);
+        }
+    }
+
+
+    public static int toWireValue(OFBsnVrfCounterConstants e) {
+        switch(e) {
+            case BSN_VRF_ALL:
+                return BSN_VRF_ALL_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVrfCounterConstants in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsEntryVer13.java
new file mode 100644
index 0000000..9c337b2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsEntryVer13.java
@@ -0,0 +1,303 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVrfCounterStatsEntryVer13 implements OFBsnVrfCounterStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVrfCounterStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_VRF = 0x0L;
+        private final static List<U64> DEFAULT_VALUES = ImmutableList.<U64>of();
+
+    // OF message fields
+    private final long vrf;
+    private final List<U64> values;
+//
+    // Immutable default instance
+    final static OFBsnVrfCounterStatsEntryVer13 DEFAULT = new OFBsnVrfCounterStatsEntryVer13(
+        DEFAULT_VRF, DEFAULT_VALUES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVrfCounterStatsEntryVer13(long vrf, List<U64> values) {
+        this.vrf = vrf;
+        this.values = values;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getVrf() {
+        return vrf;
+    }
+
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBsnVrfCounterStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVrfCounterStatsEntry.Builder {
+        final OFBsnVrfCounterStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean vrfSet;
+        private long vrf;
+        private boolean valuesSet;
+        private List<U64> values;
+
+        BuilderWithParent(OFBsnVrfCounterStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getVrf() {
+        return vrf;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsEntry.Builder setVrf(long vrf) {
+        this.vrf = vrf;
+        this.vrfSet = true;
+        return this;
+    }
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsEntry.Builder setValues(List<U64> values) {
+        this.values = values;
+        this.valuesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBsnVrfCounterStatsEntry build() {
+                long vrf = this.vrfSet ? this.vrf : parentMessage.vrf;
+                List<U64> values = this.valuesSet ? this.values : parentMessage.values;
+                if(values == null)
+                    throw new NullPointerException("Property values must not be null");
+
+                //
+                return new OFBsnVrfCounterStatsEntryVer13(
+                    vrf,
+                    values
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVrfCounterStatsEntry.Builder {
+        // OF message fields
+        private boolean vrfSet;
+        private long vrf;
+        private boolean valuesSet;
+        private List<U64> values;
+
+    @Override
+    public long getVrf() {
+        return vrf;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsEntry.Builder setVrf(long vrf) {
+        this.vrf = vrf;
+        this.vrfSet = true;
+        return this;
+    }
+    @Override
+    public List<U64> getValues() {
+        return values;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsEntry.Builder setValues(List<U64> values) {
+        this.values = values;
+        this.valuesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBsnVrfCounterStatsEntry build() {
+            long vrf = this.vrfSet ? this.vrf : DEFAULT_VRF;
+            List<U64> values = this.valuesSet ? this.values : DEFAULT_VALUES;
+            if(values == null)
+                throw new NullPointerException("Property values must not be null");
+
+
+            return new OFBsnVrfCounterStatsEntryVer13(
+                    vrf,
+                    values
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVrfCounterStatsEntry> {
+        @Override
+        public OFBsnVrfCounterStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long vrf = U32.f(bb.readInt());
+            List<U64> values = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U64.READER);
+
+            OFBsnVrfCounterStatsEntryVer13 bsnVrfCounterStatsEntryVer13 = new OFBsnVrfCounterStatsEntryVer13(
+                    vrf,
+                      values
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVrfCounterStatsEntryVer13);
+            return bsnVrfCounterStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVrfCounterStatsEntryVer13Funnel FUNNEL = new OFBsnVrfCounterStatsEntryVer13Funnel();
+    static class OFBsnVrfCounterStatsEntryVer13Funnel implements Funnel<OFBsnVrfCounterStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVrfCounterStatsEntryVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            // skip pad (2 bytes)
+            sink.putLong(message.vrf);
+            FunnelUtils.putList(message.values, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVrfCounterStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVrfCounterStatsEntryVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.vrf));
+            ChannelUtils.writeList(bb, message.values);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVrfCounterStatsEntryVer13(");
+        b.append("vrf=").append(vrf);
+        b.append(", ");
+        b.append("values=").append(values);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVrfCounterStatsEntryVer13 other = (OFBsnVrfCounterStatsEntryVer13) obj;
+
+        if( vrf != other.vrf)
+            return false;
+        if (values == null) {
+            if (other.values != null)
+                return false;
+        } else if (!values.equals(other.values))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (vrf ^ (vrf >>> 32));
+        result = prime * result + ((values == null) ? 0 : values.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsReplyVer13.java
new file mode 100644
index 0000000..05378ac
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsReplyVer13.java
@@ -0,0 +1,458 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVrfCounterStatsReplyVer13 implements OFBsnVrfCounterStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVrfCounterStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFBsnVrfCounterStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFBsnVrfCounterStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFBsnVrfCounterStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFBsnVrfCounterStatsReplyVer13 DEFAULT = new OFBsnVrfCounterStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVrfCounterStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFBsnVrfCounterStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public List<OFBsnVrfCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFBsnVrfCounterStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVrfCounterStatsReply.Builder {
+        final OFBsnVrfCounterStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnVrfCounterStatsEntry> entries;
+
+        BuilderWithParent(OFBsnVrfCounterStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public List<OFBsnVrfCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsReply.Builder setEntries(List<OFBsnVrfCounterStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVrfCounterStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFBsnVrfCounterStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFBsnVrfCounterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVrfCounterStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFBsnVrfCounterStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public List<OFBsnVrfCounterStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsReply.Builder setEntries(List<OFBsnVrfCounterStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVrfCounterStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFBsnVrfCounterStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFBsnVrfCounterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVrfCounterStatsReply> {
+        @Override
+        public OFBsnVrfCounterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xfL
+            int subtype = bb.readInt();
+            if(subtype != 0xf)
+                throw new OFParseError("Wrong subtype: Expected=0xfL(0xfL), got="+subtype);
+            List<OFBsnVrfCounterStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBsnVrfCounterStatsEntryVer13.READER);
+
+            OFBsnVrfCounterStatsReplyVer13 bsnVrfCounterStatsReplyVer13 = new OFBsnVrfCounterStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVrfCounterStatsReplyVer13);
+            return bsnVrfCounterStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVrfCounterStatsReplyVer13Funnel FUNNEL = new OFBsnVrfCounterStatsReplyVer13Funnel();
+    static class OFBsnVrfCounterStatsReplyVer13Funnel implements Funnel<OFBsnVrfCounterStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVrfCounterStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            sink.putInt(0xf);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVrfCounterStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVrfCounterStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            bb.writeInt(0xf);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVrfCounterStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVrfCounterStatsReplyVer13 other = (OFBsnVrfCounterStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsRequestVer13.java
new file mode 100644
index 0000000..a39cf1c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterStatsRequestVer13.java
@@ -0,0 +1,444 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBsnVrfCounterStatsRequestVer13 implements OFBsnVrfCounterStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFBsnVrfCounterStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 28;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static long DEFAULT_VRF = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final long vrf;
+//
+    // Immutable default instance
+    final static OFBsnVrfCounterStatsRequestVer13 DEFAULT = new OFBsnVrfCounterStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_VRF
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBsnVrfCounterStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, long vrf) {
+        this.xid = xid;
+        this.flags = flags;
+        this.vrf = vrf;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public long getVrf() {
+        return vrf;
+    }
+
+
+
+    public OFBsnVrfCounterStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBsnVrfCounterStatsRequest.Builder {
+        final OFBsnVrfCounterStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean vrfSet;
+        private long vrf;
+
+        BuilderWithParent(OFBsnVrfCounterStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public long getVrf() {
+        return vrf;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsRequest.Builder setVrf(long vrf) {
+        this.vrf = vrf;
+        this.vrfSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFBsnVrfCounterStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                long vrf = this.vrfSet ? this.vrf : parentMessage.vrf;
+
+                //
+                return new OFBsnVrfCounterStatsRequestVer13(
+                    xid,
+                    flags,
+                    vrf
+                );
+        }
+
+    }
+
+    static class Builder implements OFBsnVrfCounterStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean vrfSet;
+        private long vrf;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.EXPERIMENTER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0xfL;
+    }
+
+    @Override
+    public long getVrf() {
+        return vrf;
+    }
+
+    @Override
+    public OFBsnVrfCounterStatsRequest.Builder setVrf(long vrf) {
+        this.vrf = vrf;
+        this.vrfSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFBsnVrfCounterStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            long vrf = this.vrfSet ? this.vrf : DEFAULT_VRF;
+
+
+            return new OFBsnVrfCounterStatsRequestVer13(
+                    xid,
+                    flags,
+                    vrf
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBsnVrfCounterStatsRequest> {
+        @Override
+        public OFBsnVrfCounterStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 28)
+                throw new OFParseError("Wrong length: Expected=28(28), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0xfL
+            int subtype = bb.readInt();
+            if(subtype != 0xf)
+                throw new OFParseError("Wrong subtype: Expected=0xfL(0xfL), got="+subtype);
+            long vrf = U32.f(bb.readInt());
+
+            OFBsnVrfCounterStatsRequestVer13 bsnVrfCounterStatsRequestVer13 = new OFBsnVrfCounterStatsRequestVer13(
+                    xid,
+                      flags,
+                      vrf
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bsnVrfCounterStatsRequestVer13);
+            return bsnVrfCounterStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBsnVrfCounterStatsRequestVer13Funnel FUNNEL = new OFBsnVrfCounterStatsRequestVer13Funnel();
+    static class OFBsnVrfCounterStatsRequestVer13Funnel implements Funnel<OFBsnVrfCounterStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBsnVrfCounterStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 28
+            sink.putShort((short) 0x1c);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 65535
+            sink.putShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            sink.putInt(0xf);
+            sink.putLong(message.vrf);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBsnVrfCounterStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBsnVrfCounterStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 28
+            bb.writeShort((short) 0x1c);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 65535
+            bb.writeShort((short) 0xffff);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0xfL
+            bb.writeInt(0xf);
+            bb.writeInt(U32.t(message.vrf));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBsnVrfCounterStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("vrf=").append(vrf);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBsnVrfCounterStatsRequestVer13 other = (OFBsnVrfCounterStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( vrf != other.vrf)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime *  (int) (vrf ^ (vrf >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterTSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterTSerializerVer13.java
new file mode 100644
index 0000000..aa4c3b1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVrfCounterTSerializerVer13.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFBsnVrfCounterT;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFBsnVrfCounterTSerializerVer13 {
+
+    public final static byte BSN_VRF_COUNTER_BYTES_VAL = (byte) 0x0;
+    public final static byte BSN_VRF_COUNTER_PACKETS_VAL = (byte) 0x1;
+
+    public static OFBsnVrfCounterT readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFBsnVrfCounterT e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFBsnVrfCounterT e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFBsnVrfCounterT ofWireValue(byte val) {
+        switch(val) {
+            case BSN_VRF_COUNTER_BYTES_VAL:
+                return OFBsnVrfCounterT.BSN_VRF_COUNTER_BYTES;
+            case BSN_VRF_COUNTER_PACKETS_VAL:
+                return OFBsnVrfCounterT.BSN_VRF_COUNTER_PACKETS;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFBsnVrfCounterT in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFBsnVrfCounterT e) {
+        switch(e) {
+            case BSN_VRF_COUNTER_BYTES:
+                return BSN_VRF_COUNTER_BYTES_VAL;
+            case BSN_VRF_COUNTER_PACKETS:
+                return BSN_VRF_COUNTER_PACKETS_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFBsnVrfCounterT in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBucketCounterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBucketCounterVer13.java
new file mode 100644
index 0000000..4affdbd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBucketCounterVer13.java
@@ -0,0 +1,283 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBucketCounterVer13 implements OFBucketCounter {
+    private static final Logger logger = LoggerFactory.getLogger(OFBucketCounterVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final U64 packetCount;
+    private final U64 byteCount;
+//
+    // Immutable default instance
+    final static OFBucketCounterVer13 DEFAULT = new OFBucketCounterVer13(
+        DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBucketCounterVer13(U64 packetCount, U64 byteCount) {
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBucketCounter.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBucketCounter.Builder {
+        final OFBucketCounterVer13 parentMessage;
+
+        // OF message fields
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+
+        BuilderWithParent(OFBucketCounterVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBucketCounter build() {
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+
+                //
+                return new OFBucketCounterVer13(
+                    packetCount,
+                    byteCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFBucketCounter.Builder {
+        // OF message fields
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFBucketCounter.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBucketCounter build() {
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+
+
+            return new OFBucketCounterVer13(
+                    packetCount,
+                    byteCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBucketCounter> {
+        @Override
+        public OFBucketCounter readFrom(ChannelBuffer bb) throws OFParseError {
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+
+            OFBucketCounterVer13 bucketCounterVer13 = new OFBucketCounterVer13(
+                    packetCount,
+                      byteCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bucketCounterVer13);
+            return bucketCounterVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBucketCounterVer13Funnel FUNNEL = new OFBucketCounterVer13Funnel();
+    static class OFBucketCounterVer13Funnel implements Funnel<OFBucketCounterVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBucketCounterVer13 message, PrimitiveSink sink) {
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBucketCounterVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBucketCounterVer13 message) {
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBucketCounterVer13(");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBucketCounterVer13 other = (OFBucketCounterVer13) obj;
+
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBucketVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBucketVer13.java
new file mode 100644
index 0000000..be6456c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFBucketVer13.java
@@ -0,0 +1,411 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFBucketVer13 implements OFBucket {
+    private static final Logger logger = LoggerFactory.getLogger(OFBucketVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static int DEFAULT_WEIGHT = 0x0;
+        private final static OFPort DEFAULT_WATCH_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_WATCH_GROUP = OFGroup.ALL;
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final int weight;
+    private final OFPort watchPort;
+    private final OFGroup watchGroup;
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFBucketVer13 DEFAULT = new OFBucketVer13(
+        DEFAULT_WEIGHT, DEFAULT_WATCH_PORT, DEFAULT_WATCH_GROUP, DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFBucketVer13(int weight, OFPort watchPort, OFGroup watchGroup, List<OFAction> actions) {
+        this.weight = weight;
+        this.watchPort = watchPort;
+        this.watchGroup = watchGroup;
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFBucket.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFBucket.Builder {
+        final OFBucketVer13 parentMessage;
+
+        // OF message fields
+        private boolean weightSet;
+        private int weight;
+        private boolean watchPortSet;
+        private OFPort watchPort;
+        private boolean watchGroupSet;
+        private OFGroup watchGroup;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFBucketVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFBucket.Builder setWeight(int weight) {
+        this.weight = weight;
+        this.weightSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchPort(OFPort watchPort) {
+        this.watchPort = watchPort;
+        this.watchPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchGroup(OFGroup watchGroup) {
+        this.watchGroup = watchGroup;
+        this.watchGroupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFBucket.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFBucket build() {
+                int weight = this.weightSet ? this.weight : parentMessage.weight;
+                OFPort watchPort = this.watchPortSet ? this.watchPort : parentMessage.watchPort;
+                if(watchPort == null)
+                    throw new NullPointerException("Property watchPort must not be null");
+                OFGroup watchGroup = this.watchGroupSet ? this.watchGroup : parentMessage.watchGroup;
+                if(watchGroup == null)
+                    throw new NullPointerException("Property watchGroup must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFBucketVer13(
+                    weight,
+                    watchPort,
+                    watchGroup,
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFBucket.Builder {
+        // OF message fields
+        private boolean weightSet;
+        private int weight;
+        private boolean watchPortSet;
+        private OFPort watchPort;
+        private boolean watchGroupSet;
+        private OFGroup watchGroup;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public int getWeight() {
+        return weight;
+    }
+
+    @Override
+    public OFBucket.Builder setWeight(int weight) {
+        this.weight = weight;
+        this.weightSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getWatchPort() {
+        return watchPort;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchPort(OFPort watchPort) {
+        this.watchPort = watchPort;
+        this.watchPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getWatchGroup() {
+        return watchGroup;
+    }
+
+    @Override
+    public OFBucket.Builder setWatchGroup(OFGroup watchGroup) {
+        this.watchGroup = watchGroup;
+        this.watchGroupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFBucket.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFBucket build() {
+            int weight = this.weightSet ? this.weight : DEFAULT_WEIGHT;
+            OFPort watchPort = this.watchPortSet ? this.watchPort : DEFAULT_WATCH_PORT;
+            if(watchPort == null)
+                throw new NullPointerException("Property watchPort must not be null");
+            OFGroup watchGroup = this.watchGroupSet ? this.watchGroup : DEFAULT_WATCH_GROUP;
+            if(watchGroup == null)
+                throw new NullPointerException("Property watchGroup must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFBucketVer13(
+                    weight,
+                    watchPort,
+                    watchGroup,
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFBucket> {
+        @Override
+        public OFBucket readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int weight = U16.f(bb.readShort());
+            OFPort watchPort = OFPort.read4Bytes(bb);
+            OFGroup watchGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer13.READER);
+
+            OFBucketVer13 bucketVer13 = new OFBucketVer13(
+                    weight,
+                      watchPort,
+                      watchGroup,
+                      actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", bucketVer13);
+            return bucketVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFBucketVer13Funnel FUNNEL = new OFBucketVer13Funnel();
+    static class OFBucketVer13Funnel implements Funnel<OFBucketVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFBucketVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            sink.putInt(message.weight);
+            message.watchPort.putTo(sink);
+            message.watchGroup.putTo(sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFBucketVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFBucketVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeShort(U16.t(message.weight));
+            message.watchPort.write4Bytes(bb);
+            message.watchGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFBucketVer13(");
+        b.append("weight=").append(weight);
+        b.append(", ");
+        b.append("watchPort=").append(watchPort);
+        b.append(", ");
+        b.append("watchGroup=").append(watchGroup);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFBucketVer13 other = (OFBucketVer13) obj;
+
+        if( weight != other.weight)
+            return false;
+        if (watchPort == null) {
+            if (other.watchPort != null)
+                return false;
+        } else if (!watchPort.equals(other.watchPort))
+            return false;
+        if (watchGroup == null) {
+            if (other.watchGroup != null)
+                return false;
+        } else if (!watchGroup.equals(other.watchGroup))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + weight;
+        result = prime * result + ((watchPort == null) ? 0 : watchPort.hashCode());
+        result = prime * result + ((watchGroup == null) ? 0 : watchGroup.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFCapabilitiesSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFCapabilitiesSerializerVer13.java
new file mode 100644
index 0000000..e536496
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFCapabilitiesSerializerVer13.java
@@ -0,0 +1,114 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFCapabilities;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFCapabilitiesSerializerVer13 {
+
+    public final static int FLOW_STATS_VAL = 0x1;
+    public final static int TABLE_STATS_VAL = 0x2;
+    public final static int PORT_STATS_VAL = 0x4;
+    public final static int IP_REASM_VAL = 0x20;
+    public final static int QUEUE_STATS_VAL = 0x40;
+    public final static int GROUP_STATS_VAL = 0x8;
+    public final static int PORT_BLOCKED_VAL = 0x100;
+
+    public static Set<OFCapabilities> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFCapabilities> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFCapabilities> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFCapabilities> ofWireValue(int val) {
+        EnumSet<OFCapabilities> set = EnumSet.noneOf(OFCapabilities.class);
+
+        if((val & FLOW_STATS_VAL) != 0)
+            set.add(OFCapabilities.FLOW_STATS);
+        if((val & TABLE_STATS_VAL) != 0)
+            set.add(OFCapabilities.TABLE_STATS);
+        if((val & PORT_STATS_VAL) != 0)
+            set.add(OFCapabilities.PORT_STATS);
+        if((val & IP_REASM_VAL) != 0)
+            set.add(OFCapabilities.IP_REASM);
+        if((val & QUEUE_STATS_VAL) != 0)
+            set.add(OFCapabilities.QUEUE_STATS);
+        if((val & GROUP_STATS_VAL) != 0)
+            set.add(OFCapabilities.GROUP_STATS);
+        if((val & PORT_BLOCKED_VAL) != 0)
+            set.add(OFCapabilities.PORT_BLOCKED);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFCapabilities> set) {
+        int wireValue = 0;
+
+        for(OFCapabilities e: set) {
+            switch(e) {
+                case FLOW_STATS:
+                    wireValue |= FLOW_STATS_VAL;
+                    break;
+                case TABLE_STATS:
+                    wireValue |= TABLE_STATS_VAL;
+                    break;
+                case PORT_STATS:
+                    wireValue |= PORT_STATS_VAL;
+                    break;
+                case IP_REASM:
+                    wireValue |= IP_REASM_VAL;
+                    break;
+                case QUEUE_STATS:
+                    wireValue |= QUEUE_STATS_VAL;
+                    break;
+                case GROUP_STATS:
+                    wireValue |= GROUP_STATS_VAL;
+                    break;
+                case PORT_BLOCKED:
+                    wireValue |= PORT_BLOCKED_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFCapabilities in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFConfigFlagsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFConfigFlagsSerializerVer13.java
new file mode 100644
index 0000000..a1f3eb9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFConfigFlagsSerializerVer13.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFConfigFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFConfigFlagsSerializerVer13 {
+
+    public final static short FRAG_NORMAL_VAL = (short) 0x0;
+    public final static short FRAG_DROP_VAL = (short) 0x1;
+    public final static short FRAG_REASM_VAL = (short) 0x2;
+    public final static short FRAG_MASK_VAL = (short) 0x3;
+
+    public static Set<OFConfigFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFConfigFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFConfigFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFConfigFlags> ofWireValue(short val) {
+        EnumSet<OFConfigFlags> set = EnumSet.noneOf(OFConfigFlags.class);
+
+        if((val & FRAG_MASK_VAL) == FRAG_NORMAL_VAL)
+            set.add(OFConfigFlags.FRAG_NORMAL);
+        else if((val & FRAG_MASK_VAL) == FRAG_DROP_VAL)
+            set.add(OFConfigFlags.FRAG_DROP);
+        else if((val & FRAG_MASK_VAL) == FRAG_REASM_VAL)
+            set.add(OFConfigFlags.FRAG_REASM);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFConfigFlags> set) {
+        short wireValue = 0;
+
+        for(OFConfigFlags e: set) {
+            switch(e) {
+                case FRAG_NORMAL:
+                    wireValue |= FRAG_NORMAL_VAL;
+                    break;
+                case FRAG_DROP:
+                    wireValue |= FRAG_DROP_VAL;
+                    break;
+                case FRAG_REASM:
+                    wireValue |= FRAG_REASM_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFConfigFlags in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFControllerMaxLenSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFControllerMaxLenSerializerVer13.java
new file mode 100644
index 0000000..cb90254
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFControllerMaxLenSerializerVer13.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFControllerMaxLen;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFControllerMaxLenSerializerVer13 {
+
+    public final static short MAX_VAL = (short) 0xffe5;
+    public final static short NO_BUFFER_VAL = (short) 0xffff;
+
+    public static OFControllerMaxLen readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFControllerMaxLen e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFControllerMaxLen e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFControllerMaxLen ofWireValue(short val) {
+        switch(val) {
+            case MAX_VAL:
+                return OFControllerMaxLen.MAX;
+            case NO_BUFFER_VAL:
+                return OFControllerMaxLen.NO_BUFFER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFControllerMaxLen in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFControllerMaxLen e) {
+        switch(e) {
+            case MAX:
+                return MAX_VAL;
+            case NO_BUFFER:
+                return NO_BUFFER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFControllerMaxLen in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFControllerRoleSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFControllerRoleSerializerVer13.java
new file mode 100644
index 0000000..6090527
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFControllerRoleSerializerVer13.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFControllerRole;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFControllerRoleSerializerVer13 {
+
+    public final static int ROLE_NOCHANGE_VAL = 0x0;
+    public final static int ROLE_EQUAL_VAL = 0x1;
+    public final static int ROLE_MASTER_VAL = 0x2;
+    public final static int ROLE_SLAVE_VAL = 0x3;
+
+    public static OFControllerRole readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFControllerRole e) {
+        bb.writeInt(toWireValue(e));
+    }
+
+    public static void putTo(OFControllerRole e, PrimitiveSink sink) {
+        sink.putInt(toWireValue(e));
+    }
+
+    public static OFControllerRole ofWireValue(int val) {
+        switch(val) {
+            case ROLE_NOCHANGE_VAL:
+                return OFControllerRole.ROLE_NOCHANGE;
+            case ROLE_EQUAL_VAL:
+                return OFControllerRole.ROLE_EQUAL;
+            case ROLE_MASTER_VAL:
+                return OFControllerRole.ROLE_MASTER;
+            case ROLE_SLAVE_VAL:
+                return OFControllerRole.ROLE_SLAVE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFControllerRole in version 1.3: " + val);
+        }
+    }
+
+
+    public static int toWireValue(OFControllerRole e) {
+        switch(e) {
+            case ROLE_NOCHANGE:
+                return ROLE_NOCHANGE_VAL;
+            case ROLE_EQUAL:
+                return ROLE_EQUAL_VAL;
+            case ROLE_MASTER:
+                return ROLE_MASTER_VAL;
+            case ROLE_SLAVE:
+                return ROLE_SLAVE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFControllerRole in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFDescStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFDescStatsReplyVer13.java
new file mode 100644
index 0000000..4343d37
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFDescStatsReplyVer13.java
@@ -0,0 +1,621 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFDescStatsReplyVer13 implements OFDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFDescStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 1072;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static String DEFAULT_MFR_DESC = "";
+        private final static String DEFAULT_HW_DESC = "";
+        private final static String DEFAULT_SW_DESC = "";
+        private final static String DEFAULT_SERIAL_NUM = "";
+        private final static String DEFAULT_DP_DESC = "";
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final String mfrDesc;
+    private final String hwDesc;
+    private final String swDesc;
+    private final String serialNum;
+    private final String dpDesc;
+//
+    // Immutable default instance
+    final static OFDescStatsReplyVer13 DEFAULT = new OFDescStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MFR_DESC, DEFAULT_HW_DESC, DEFAULT_SW_DESC, DEFAULT_SERIAL_NUM, DEFAULT_DP_DESC
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFDescStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, String mfrDesc, String hwDesc, String swDesc, String serialNum, String dpDesc) {
+        this.xid = xid;
+        this.flags = flags;
+        this.mfrDesc = mfrDesc;
+        this.hwDesc = hwDesc;
+        this.swDesc = swDesc;
+        this.serialNum = serialNum;
+        this.dpDesc = dpDesc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+
+
+    public OFDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFDescStatsReply.Builder {
+        final OFDescStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean mfrDescSet;
+        private String mfrDesc;
+        private boolean hwDescSet;
+        private String hwDesc;
+        private boolean swDescSet;
+        private String swDesc;
+        private boolean serialNumSet;
+        private String serialNum;
+        private boolean dpDescSet;
+        private String dpDesc;
+
+        BuilderWithParent(OFDescStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
+        this.mfrDesc = mfrDesc;
+        this.mfrDescSet = true;
+        return this;
+    }
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
+        this.hwDesc = hwDesc;
+        this.hwDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSwDesc(String swDesc) {
+        this.swDesc = swDesc;
+        this.swDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSerialNum(String serialNum) {
+        this.serialNum = serialNum;
+        this.serialNumSet = true;
+        return this;
+    }
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
+        this.dpDesc = dpDesc;
+        this.dpDescSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                String mfrDesc = this.mfrDescSet ? this.mfrDesc : parentMessage.mfrDesc;
+                if(mfrDesc == null)
+                    throw new NullPointerException("Property mfrDesc must not be null");
+                String hwDesc = this.hwDescSet ? this.hwDesc : parentMessage.hwDesc;
+                if(hwDesc == null)
+                    throw new NullPointerException("Property hwDesc must not be null");
+                String swDesc = this.swDescSet ? this.swDesc : parentMessage.swDesc;
+                if(swDesc == null)
+                    throw new NullPointerException("Property swDesc must not be null");
+                String serialNum = this.serialNumSet ? this.serialNum : parentMessage.serialNum;
+                if(serialNum == null)
+                    throw new NullPointerException("Property serialNum must not be null");
+                String dpDesc = this.dpDescSet ? this.dpDesc : parentMessage.dpDesc;
+                if(dpDesc == null)
+                    throw new NullPointerException("Property dpDesc must not be null");
+
+                //
+                return new OFDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    mfrDesc,
+                    hwDesc,
+                    swDesc,
+                    serialNum,
+                    dpDesc
+                );
+        }
+
+    }
+
+    static class Builder implements OFDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean mfrDescSet;
+        private String mfrDesc;
+        private boolean hwDescSet;
+        private String hwDesc;
+        private boolean swDescSet;
+        private String swDesc;
+        private boolean serialNumSet;
+        private String serialNum;
+        private boolean dpDescSet;
+        private String dpDesc;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public String getMfrDesc() {
+        return mfrDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
+        this.mfrDesc = mfrDesc;
+        this.mfrDescSet = true;
+        return this;
+    }
+    @Override
+    public String getHwDesc() {
+        return hwDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
+        this.hwDesc = hwDesc;
+        this.hwDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSwDesc() {
+        return swDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSwDesc(String swDesc) {
+        this.swDesc = swDesc;
+        this.swDescSet = true;
+        return this;
+    }
+    @Override
+    public String getSerialNum() {
+        return serialNum;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setSerialNum(String serialNum) {
+        this.serialNum = serialNum;
+        this.serialNumSet = true;
+        return this;
+    }
+    @Override
+    public String getDpDesc() {
+        return dpDesc;
+    }
+
+    @Override
+    public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
+        this.dpDesc = dpDesc;
+        this.dpDescSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            String mfrDesc = this.mfrDescSet ? this.mfrDesc : DEFAULT_MFR_DESC;
+            if(mfrDesc == null)
+                throw new NullPointerException("Property mfrDesc must not be null");
+            String hwDesc = this.hwDescSet ? this.hwDesc : DEFAULT_HW_DESC;
+            if(hwDesc == null)
+                throw new NullPointerException("Property hwDesc must not be null");
+            String swDesc = this.swDescSet ? this.swDesc : DEFAULT_SW_DESC;
+            if(swDesc == null)
+                throw new NullPointerException("Property swDesc must not be null");
+            String serialNum = this.serialNumSet ? this.serialNum : DEFAULT_SERIAL_NUM;
+            if(serialNum == null)
+                throw new NullPointerException("Property serialNum must not be null");
+            String dpDesc = this.dpDescSet ? this.dpDesc : DEFAULT_DP_DESC;
+            if(dpDesc == null)
+                throw new NullPointerException("Property dpDesc must not be null");
+
+
+            return new OFDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    mfrDesc,
+                    hwDesc,
+                    swDesc,
+                    serialNum,
+                    dpDesc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFDescStatsReply> {
+        @Override
+        public OFDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 1072)
+                throw new OFParseError("Wrong length: Expected=1072(1072), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 0
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x0)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            String mfrDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String hwDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String swDesc = ChannelUtils.readFixedLengthString(bb, 256);
+            String serialNum = ChannelUtils.readFixedLengthString(bb, 32);
+            String dpDesc = ChannelUtils.readFixedLengthString(bb, 256);
+
+            OFDescStatsReplyVer13 descStatsReplyVer13 = new OFDescStatsReplyVer13(
+                    xid,
+                      flags,
+                      mfrDesc,
+                      hwDesc,
+                      swDesc,
+                      serialNum,
+                      dpDesc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", descStatsReplyVer13);
+            return descStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFDescStatsReplyVer13Funnel FUNNEL = new OFDescStatsReplyVer13Funnel();
+    static class OFDescStatsReplyVer13Funnel implements Funnel<OFDescStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFDescStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 1072
+            sink.putShort((short) 0x430);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 0
+            sink.putShort((short) 0x0);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            sink.putUnencodedChars(message.mfrDesc);
+            sink.putUnencodedChars(message.hwDesc);
+            sink.putUnencodedChars(message.swDesc);
+            sink.putUnencodedChars(message.serialNum);
+            sink.putUnencodedChars(message.dpDesc);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFDescStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFDescStatsReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 1072
+            bb.writeShort((short) 0x430);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 0
+            bb.writeShort((short) 0x0);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeFixedLengthString(bb, message.mfrDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.hwDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.swDesc, 256);
+            ChannelUtils.writeFixedLengthString(bb, message.serialNum, 32);
+            ChannelUtils.writeFixedLengthString(bb, message.dpDesc, 256);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFDescStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("mfrDesc=").append(mfrDesc);
+        b.append(", ");
+        b.append("hwDesc=").append(hwDesc);
+        b.append(", ");
+        b.append("swDesc=").append(swDesc);
+        b.append(", ");
+        b.append("serialNum=").append(serialNum);
+        b.append(", ");
+        b.append("dpDesc=").append(dpDesc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFDescStatsReplyVer13 other = (OFDescStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (mfrDesc == null) {
+            if (other.mfrDesc != null)
+                return false;
+        } else if (!mfrDesc.equals(other.mfrDesc))
+            return false;
+        if (hwDesc == null) {
+            if (other.hwDesc != null)
+                return false;
+        } else if (!hwDesc.equals(other.hwDesc))
+            return false;
+        if (swDesc == null) {
+            if (other.swDesc != null)
+                return false;
+        } else if (!swDesc.equals(other.swDesc))
+            return false;
+        if (serialNum == null) {
+            if (other.serialNum != null)
+                return false;
+        } else if (!serialNum.equals(other.serialNum))
+            return false;
+        if (dpDesc == null) {
+            if (other.dpDesc != null)
+                return false;
+        } else if (!dpDesc.equals(other.dpDesc))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((mfrDesc == null) ? 0 : mfrDesc.hashCode());
+        result = prime * result + ((hwDesc == null) ? 0 : hwDesc.hashCode());
+        result = prime * result + ((swDesc == null) ? 0 : swDesc.hashCode());
+        result = prime * result + ((serialNum == null) ? 0 : serialNum.hashCode());
+        result = prime * result + ((dpDesc == null) ? 0 : dpDesc.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFDescStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFDescStatsRequestVer13.java
new file mode 100644
index 0000000..687cb8b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFDescStatsRequestVer13.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFDescStatsRequestVer13 implements OFDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFDescStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFDescStatsRequestVer13 DEFAULT = new OFDescStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFDescStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFDescStatsRequest.Builder {
+        final OFDescStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFDescStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFDescStatsRequest> {
+        @Override
+        public OFDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 0
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x0)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFDescStatsRequestVer13 descStatsRequestVer13 = new OFDescStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", descStatsRequestVer13);
+            return descStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFDescStatsRequestVer13Funnel FUNNEL = new OFDescStatsRequestVer13Funnel();
+    static class OFDescStatsRequestVer13Funnel implements Funnel<OFDescStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFDescStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 0
+            sink.putShort((short) 0x0);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFDescStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFDescStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 0
+            bb.writeShort((short) 0x0);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFDescStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFDescStatsRequestVer13 other = (OFDescStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoReplyVer13.java
new file mode 100644
index 0000000..76d065c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoReplyVer13.java
@@ -0,0 +1,325 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFEchoReplyVer13 implements OFEchoReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFEchoReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFEchoReplyVer13 DEFAULT = new OFEchoReplyVer13(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFEchoReplyVer13(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFEchoReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFEchoReply.Builder {
+        final OFEchoReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFEchoReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoReply.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFEchoReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFEchoReplyVer13(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFEchoReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoReply.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFEchoReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFEchoReplyVer13(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFEchoReply> {
+        @Override
+        public OFEchoReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 3
+            byte type = bb.readByte();
+            if(type != (byte) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFType.ECHO_REPLY(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFEchoReplyVer13 echoReplyVer13 = new OFEchoReplyVer13(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", echoReplyVer13);
+            return echoReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFEchoReplyVer13Funnel FUNNEL = new OFEchoReplyVer13Funnel();
+    static class OFEchoReplyVer13Funnel implements Funnel<OFEchoReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFEchoReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 3
+            sink.putByte((byte) 0x3);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFEchoReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFEchoReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 3
+            bb.writeByte((byte) 0x3);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFEchoReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFEchoReplyVer13 other = (OFEchoReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoRequestVer13.java
new file mode 100644
index 0000000..19e2679
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoRequestVer13.java
@@ -0,0 +1,325 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFEchoRequestVer13 implements OFEchoRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFEchoRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFEchoRequestVer13 DEFAULT = new OFEchoRequestVer13(
+        DEFAULT_XID, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFEchoRequestVer13(long xid, byte[] data) {
+        this.xid = xid;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFEchoRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFEchoRequest.Builder {
+        final OFEchoRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFEchoRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFEchoRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFEchoRequestVer13(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFEchoRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ECHO_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFEchoRequest.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFEchoRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFEchoRequestVer13(
+                    xid,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFEchoRequest> {
+        @Override
+        public OFEchoRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 2
+            byte type = bb.readByte();
+            if(type != (byte) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFType.ECHO_REQUEST(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFEchoRequestVer13 echoRequestVer13 = new OFEchoRequestVer13(
+                    xid,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", echoRequestVer13);
+            return echoRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFEchoRequestVer13Funnel FUNNEL = new OFEchoRequestVer13Funnel();
+    static class OFEchoRequestVer13Funnel implements Funnel<OFEchoRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFEchoRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 2
+            sink.putByte((byte) 0x2);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFEchoRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFEchoRequestVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 2
+            bb.writeByte((byte) 0x2);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFEchoRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFEchoRequestVer13 other = (OFEchoRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorMsgVer13.java
new file mode 100644
index 0000000..665ecf4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorMsgVer13.java
@@ -0,0 +1,107 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFErrorMsgVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 10;
+
+
+    public final static OFErrorMsgVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFErrorMsg> {
+        @Override
+        public OFErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short errType = bb.readShort();
+            bb.readerIndex(start);
+            switch(errType) {
+               case (short) 0x2:
+                   // discriminator value OFErrorType.BAD_ACTION=2 for class OFBadActionErrorMsgVer13
+                   return OFBadActionErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFErrorType.BAD_REQUEST=1 for class OFBadRequestErrorMsgVer13
+                   return OFBadRequestErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFErrorType.FLOW_MOD_FAILED=5 for class OFFlowModFailedErrorMsgVer13
+                   return OFFlowModFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFErrorType.HELLO_FAILED=0 for class OFHelloFailedErrorMsgVer13
+                   return OFHelloFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFErrorType.PORT_MOD_FAILED=7 for class OFPortModFailedErrorMsgVer13
+                   return OFPortModFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x9:
+                   // discriminator value OFErrorType.QUEUE_OP_FAILED=9 for class OFQueueOpFailedErrorMsgVer13
+                   return OFQueueOpFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFErrorType.BAD_INSTRUCTION=3 for class OFBadInstructionErrorMsgVer13
+                   return OFBadInstructionErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFErrorType.BAD_MATCH=4 for class OFBadMatchErrorMsgVer13
+                   return OFBadMatchErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFErrorType.GROUP_MOD_FAILED=6 for class OFGroupModFailedErrorMsgVer13
+                   return OFGroupModFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0xa:
+                   // discriminator value OFErrorType.SWITCH_CONFIG_FAILED=10 for class OFSwitchConfigFailedErrorMsgVer13
+                   return OFSwitchConfigFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFErrorType.TABLE_MOD_FAILED=8 for class OFTableModFailedErrorMsgVer13
+                   return OFTableModFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFErrorType.EXPERIMENTER=65535 for class OFExperimenterErrorMsgVer13
+                   return OFExperimenterErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFErrorType.ROLE_REQUEST_FAILED=11 for class OFRoleRequestFailedErrorMsgVer13
+                   return OFRoleRequestFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value OFErrorType.METER_MOD_FAILED=12 for class OFMeterModFailedErrorMsgVer13
+                   return OFMeterModFailedErrorMsgVer13.READER.readFrom(bb);
+               case (short) 0xd:
+                   // discriminator value OFErrorType.TABLE_FEATURES_FAILED=13 for class OFTableFeaturesFailedErrorMsgVer13
+                   return OFTableFeaturesFailedErrorMsgVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator errType of class OFErrorMsgVer13: " + errType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorMsgsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorMsgsVer13.java
new file mode 100644
index 0000000..120b829
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorMsgsVer13.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFErrorMsgsVer13 implements OFErrorMsgs {
+    public final static OFErrorMsgsVer13 INSTANCE = new OFErrorMsgsVer13();
+
+    private final XidGenerator xidGenerator = XidGenerators.global();
+
+
+
+    public OFBadActionErrorMsg.Builder buildBadActionErrorMsg() {
+        return new OFBadActionErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBadRequestErrorMsg.Builder buildBadRequestErrorMsg() {
+        return new OFBadRequestErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModFailedErrorMsg.Builder buildFlowModFailedErrorMsg() {
+        return new OFFlowModFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFHelloFailedErrorMsg.Builder buildHelloFailedErrorMsg() {
+        return new OFHelloFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFPortModFailedErrorMsg.Builder buildPortModFailedErrorMsg() {
+        return new OFPortModFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFQueueOpFailedErrorMsg.Builder buildQueueOpFailedErrorMsg() {
+        return new OFQueueOpFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBadInstructionErrorMsg.Builder buildBadInstructionErrorMsg() {
+        return new OFBadInstructionErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBadMatchErrorMsg.Builder buildBadMatchErrorMsg() {
+        return new OFBadMatchErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGroupModFailedErrorMsg.Builder buildGroupModFailedErrorMsg() {
+        return new OFGroupModFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFSwitchConfigFailedErrorMsg.Builder buildSwitchConfigFailedErrorMsg() {
+        return new OFSwitchConfigFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFTableModFailedErrorMsg.Builder buildTableModFailedErrorMsg() {
+        return new OFTableModFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFExperimenterErrorMsg.Builder buildExperimenterErrorMsg() {
+        return new OFExperimenterErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFRoleRequestFailedErrorMsg.Builder buildRoleRequestFailedErrorMsg() {
+        return new OFRoleRequestFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFMeterModFailedErrorMsg.Builder buildMeterModFailedErrorMsg() {
+        return new OFMeterModFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFTableFeaturesFailedErrorMsg.Builder buildTableFeaturesFailedErrorMsg() {
+        return new OFTableFeaturesFailedErrorMsgVer13.Builder().setXid(nextXid());
+    }
+
+    public OFMessageReader<OFErrorMsg> getReader() {
+        return OFErrorMsgVer13.READER;
+    }
+
+    public long nextXid() {
+        return xidGenerator.nextXid();
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorTypeSerializerVer13.java
new file mode 100644
index 0000000..9b9a1ae
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFErrorTypeSerializerVer13.java
@@ -0,0 +1,139 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFErrorType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFErrorTypeSerializerVer13 {
+
+    public final static short HELLO_FAILED_VAL = (short) 0x0;
+    public final static short BAD_REQUEST_VAL = (short) 0x1;
+    public final static short BAD_ACTION_VAL = (short) 0x2;
+    public final static short BAD_INSTRUCTION_VAL = (short) 0x3;
+    public final static short BAD_MATCH_VAL = (short) 0x4;
+    public final static short FLOW_MOD_FAILED_VAL = (short) 0x5;
+    public final static short GROUP_MOD_FAILED_VAL = (short) 0x6;
+    public final static short PORT_MOD_FAILED_VAL = (short) 0x7;
+    public final static short TABLE_MOD_FAILED_VAL = (short) 0x8;
+    public final static short QUEUE_OP_FAILED_VAL = (short) 0x9;
+    public final static short SWITCH_CONFIG_FAILED_VAL = (short) 0xa;
+    public final static short ROLE_REQUEST_FAILED_VAL = (short) 0xb;
+    public final static short METER_MOD_FAILED_VAL = (short) 0xc;
+    public final static short TABLE_FEATURES_FAILED_VAL = (short) 0xd;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFErrorType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFErrorType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFErrorType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFErrorType ofWireValue(short val) {
+        switch(val) {
+            case HELLO_FAILED_VAL:
+                return OFErrorType.HELLO_FAILED;
+            case BAD_REQUEST_VAL:
+                return OFErrorType.BAD_REQUEST;
+            case BAD_ACTION_VAL:
+                return OFErrorType.BAD_ACTION;
+            case BAD_INSTRUCTION_VAL:
+                return OFErrorType.BAD_INSTRUCTION;
+            case BAD_MATCH_VAL:
+                return OFErrorType.BAD_MATCH;
+            case FLOW_MOD_FAILED_VAL:
+                return OFErrorType.FLOW_MOD_FAILED;
+            case GROUP_MOD_FAILED_VAL:
+                return OFErrorType.GROUP_MOD_FAILED;
+            case PORT_MOD_FAILED_VAL:
+                return OFErrorType.PORT_MOD_FAILED;
+            case TABLE_MOD_FAILED_VAL:
+                return OFErrorType.TABLE_MOD_FAILED;
+            case QUEUE_OP_FAILED_VAL:
+                return OFErrorType.QUEUE_OP_FAILED;
+            case SWITCH_CONFIG_FAILED_VAL:
+                return OFErrorType.SWITCH_CONFIG_FAILED;
+            case ROLE_REQUEST_FAILED_VAL:
+                return OFErrorType.ROLE_REQUEST_FAILED;
+            case METER_MOD_FAILED_VAL:
+                return OFErrorType.METER_MOD_FAILED;
+            case TABLE_FEATURES_FAILED_VAL:
+                return OFErrorType.TABLE_FEATURES_FAILED;
+            case EXPERIMENTER_VAL:
+                return OFErrorType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFErrorType in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFErrorType e) {
+        switch(e) {
+            case HELLO_FAILED:
+                return HELLO_FAILED_VAL;
+            case BAD_REQUEST:
+                return BAD_REQUEST_VAL;
+            case BAD_ACTION:
+                return BAD_ACTION_VAL;
+            case BAD_INSTRUCTION:
+                return BAD_INSTRUCTION_VAL;
+            case BAD_MATCH:
+                return BAD_MATCH_VAL;
+            case FLOW_MOD_FAILED:
+                return FLOW_MOD_FAILED_VAL;
+            case GROUP_MOD_FAILED:
+                return GROUP_MOD_FAILED_VAL;
+            case PORT_MOD_FAILED:
+                return PORT_MOD_FAILED_VAL;
+            case TABLE_MOD_FAILED:
+                return TABLE_MOD_FAILED_VAL;
+            case QUEUE_OP_FAILED:
+                return QUEUE_OP_FAILED_VAL;
+            case SWITCH_CONFIG_FAILED:
+                return SWITCH_CONFIG_FAILED_VAL;
+            case ROLE_REQUEST_FAILED:
+                return ROLE_REQUEST_FAILED_VAL;
+            case METER_MOD_FAILED:
+                return METER_MOD_FAILED_VAL;
+            case TABLE_FEATURES_FAILED:
+                return TABLE_FEATURES_FAILED_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFErrorType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterErrorMsgVer13.java
new file mode 100644
index 0000000..4f1a25b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterErrorMsgVer13.java
@@ -0,0 +1,444 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFExperimenterErrorMsgVer13 implements OFExperimenterErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFExperimenterErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static int DEFAULT_SUBTYPE = 0x0;
+        private final static long DEFAULT_EXPERIMENTER = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final int subtype;
+    private final long experimenter;
+    private final OFErrorCauseData data;
+//
+    // Immutable default instance
+    final static OFExperimenterErrorMsgVer13 DEFAULT = new OFExperimenterErrorMsgVer13(
+        DEFAULT_XID, DEFAULT_SUBTYPE, DEFAULT_EXPERIMENTER, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFExperimenterErrorMsgVer13(long xid, int subtype, long experimenter, OFErrorCauseData data) {
+        this.xid = xid;
+        this.subtype = subtype;
+        this.experimenter = experimenter;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.EXPERIMENTER;
+    }
+
+    @Override
+    public int getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFExperimenterErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFExperimenterErrorMsg.Builder {
+        final OFExperimenterErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean subtypeSet;
+        private int subtype;
+        private boolean experimenterSet;
+        private long experimenter;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFExperimenterErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.EXPERIMENTER;
+    }
+
+    @Override
+    public int getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setSubtype(int subtype) {
+        this.subtype = subtype;
+        this.subtypeSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFExperimenterErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                int subtype = this.subtypeSet ? this.subtype : parentMessage.subtype;
+                long experimenter = this.experimenterSet ? this.experimenter : parentMessage.experimenter;
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFExperimenterErrorMsgVer13(
+                    xid,
+                    subtype,
+                    experimenter,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFExperimenterErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean subtypeSet;
+        private int subtype;
+        private boolean experimenterSet;
+        private long experimenter;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.EXPERIMENTER;
+    }
+
+    @Override
+    public int getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setSubtype(int subtype) {
+        this.subtype = subtype;
+        this.subtypeSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFExperimenterErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFExperimenterErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            int subtype = this.subtypeSet ? this.subtype : DEFAULT_SUBTYPE;
+            long experimenter = this.experimenterSet ? this.experimenter : DEFAULT_EXPERIMENTER;
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFExperimenterErrorMsgVer13(
+                    xid,
+                    subtype,
+                    experimenter,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFExperimenterErrorMsg> {
+        @Override
+        public OFExperimenterErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 65535
+            short errType = bb.readShort();
+            if(errType != (short) 0xffff)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.EXPERIMENTER(65535), got="+errType);
+            int subtype = U16.f(bb.readShort());
+            long experimenter = U32.f(bb.readInt());
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFExperimenterErrorMsgVer13 experimenterErrorMsgVer13 = new OFExperimenterErrorMsgVer13(
+                    xid,
+                      subtype,
+                      experimenter,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", experimenterErrorMsgVer13);
+            return experimenterErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFExperimenterErrorMsgVer13Funnel FUNNEL = new OFExperimenterErrorMsgVer13Funnel();
+    static class OFExperimenterErrorMsgVer13Funnel implements Funnel<OFExperimenterErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFExperimenterErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 65535
+            sink.putShort((short) 0xffff);
+            sink.putInt(message.subtype);
+            sink.putLong(message.experimenter);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFExperimenterErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFExperimenterErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 65535
+            bb.writeShort((short) 0xffff);
+            bb.writeShort(U16.t(message.subtype));
+            bb.writeInt(U32.t(message.experimenter));
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFExperimenterErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("subtype=").append(subtype);
+        b.append(", ");
+        b.append("experimenter=").append(experimenter);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFExperimenterErrorMsgVer13 other = (OFExperimenterErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( subtype != other.subtype)
+            return false;
+        if( experimenter != other.experimenter)
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + subtype;
+        result = prime *  (int) (experimenter ^ (experimenter >>> 32));
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterStatsReplyVer13.java
new file mode 100644
index 0000000..5e8a716
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterStatsReplyVer13.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterStatsReplyVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFExperimenterStatsReplyVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenterStatsReply> {
+        @Override
+        public OFExperimenterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsReplyVer13
+                   return OFBsnStatsReplyVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterStatsReplyVer13: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterStatsRequestVer13.java
new file mode 100644
index 0000000..f0d5d76
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterStatsRequestVer13.java
@@ -0,0 +1,72 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterStatsRequestVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+
+    public final static OFExperimenterStatsRequestVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenterStatsRequest<?>> {
+        @Override
+        public OFExperimenterStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property statsType == 65535
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xffff)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.EXPERIMENTER(65535), got="+statsType);
+            OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnStatsRequestVer13
+                   return OFBsnStatsRequestVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterStatsRequestVer13: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterVer13.java
new file mode 100644
index 0000000..8a8d50b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFExperimenterVer13.java
@@ -0,0 +1,68 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFExperimenterVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFExperimenterVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFExperimenter> {
+        @Override
+        public OFExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFBsnHeaderVer13
+                   return OFBsnHeaderVer13.READER.readFrom(bb);
+               case 0x2320:
+                   // discriminator value 0x2320L=0x2320L for class OFNiciraHeaderVer13
+                   return OFNiciraHeaderVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFExperimenterVer13: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFactoryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFactoryVer13.java
new file mode 100644
index 0000000..f5b2e34
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFactoryVer13.java
@@ -0,0 +1,1359 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import java.util.List;
+import org.projectfloodlight.openflow.protocol.OFOxmList;
+
+
+public class OFFactoryVer13 implements OFFactory {
+    public final static OFFactoryVer13 INSTANCE = new OFFactoryVer13();
+
+    private final XidGenerator xidGenerator = XidGenerators.global();
+
+    public OFActions actions() {
+        return OFActionsVer13.INSTANCE;
+    }
+    public OFInstructions instructions() {
+        return OFInstructionsVer13.INSTANCE;
+    }
+    public OFMeterBands meterBands() {
+        return OFMeterBandsVer13.INSTANCE;
+    }
+    public OFOxms oxms() {
+        return OFOxmsVer13.INSTANCE;
+    }
+    public OFQueueProps queueProps() {
+        return OFQueuePropsVer13.INSTANCE;
+    }
+    public OFErrorMsgs errorMsgs() {
+        return OFErrorMsgsVer13.INSTANCE;
+    }
+    public OFActionIds actionIds() {
+        return OFActionIdsVer13.INSTANCE;
+    }
+    public OFInstructionIds instructionIds() {
+        return OFInstructionIdsVer13.INSTANCE;
+    }
+    public OFBsnTlvs bsnTlvs() {
+        return OFBsnTlvsVer13.INSTANCE;
+    }
+
+
+    public OFAggregateStatsReply.Builder buildAggregateStatsReply() {
+        return new OFAggregateStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFAggregateStatsRequest.Builder buildAggregateStatsRequest() {
+        return new OFAggregateStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBarrierReply.Builder buildBarrierReply() {
+        return new OFBarrierReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBarrierReply barrierReply() {
+        return new OFBarrierReplyVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBarrierRequest.Builder buildBarrierRequest() {
+        return new OFBarrierRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBarrierRequest barrierRequest() {
+        return new OFBarrierRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwClearDataReply.Builder buildBsnBwClearDataReply() {
+        return new OFBsnBwClearDataReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnBwClearDataReply bsnBwClearDataReply(long status) {
+        return new OFBsnBwClearDataReplyVer13(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnBwClearDataRequest.Builder buildBsnBwClearDataRequest() {
+        return new OFBsnBwClearDataRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnBwClearDataRequest bsnBwClearDataRequest() {
+        return new OFBsnBwClearDataRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwEnableGetReply.Builder buildBsnBwEnableGetReply() {
+        return new OFBsnBwEnableGetReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableGetReply bsnBwEnableGetReply(long enabled) {
+        return new OFBsnBwEnableGetReplyVer13(
+                nextXid(),
+                      enabled
+                    );
+    }
+
+    public OFBsnBwEnableGetRequest.Builder buildBsnBwEnableGetRequest() {
+        return new OFBsnBwEnableGetRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableGetRequest bsnBwEnableGetRequest() {
+        return new OFBsnBwEnableGetRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBsnBwEnableSetReply.Builder buildBsnBwEnableSetReply() {
+        return new OFBsnBwEnableSetReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnBwEnableSetRequest.Builder buildBsnBwEnableSetRequest() {
+        return new OFBsnBwEnableSetRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnBwEnableSetRequest bsnBwEnableSetRequest(long enable) {
+        return new OFBsnBwEnableSetRequestVer13(
+                nextXid(),
+                      enable
+                    );
+    }
+
+    public OFBsnGetInterfacesReply.Builder buildBsnGetInterfacesReply() {
+        return new OFBsnGetInterfacesReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnGetInterfacesReply bsnGetInterfacesReply(List<OFBsnInterface> interfaces) {
+        return new OFBsnGetInterfacesReplyVer13(
+                nextXid(),
+                      interfaces
+                    );
+    }
+
+    public OFBsnGetInterfacesRequest.Builder buildBsnGetInterfacesRequest() {
+        return new OFBsnGetInterfacesRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnGetInterfacesRequest bsnGetInterfacesRequest() {
+        return new OFBsnGetInterfacesRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBsnGetIpMaskReply.Builder buildBsnGetIpMaskReply() {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskReply not supported in version 1.3");
+    }
+
+    public OFBsnGetIpMaskRequest.Builder buildBsnGetIpMaskRequest() {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskRequest not supported in version 1.3");
+    }
+    public OFBsnGetIpMaskRequest bsnGetIpMaskRequest(short index) {
+        throw new UnsupportedOperationException("OFBsnGetIpMaskRequest not supported in version 1.3");
+    }
+
+    public OFBsnGetL2TableReply.Builder buildBsnGetL2TableReply() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableReply not supported in version 1.3");
+    }
+
+    public OFBsnGetL2TableRequest.Builder buildBsnGetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableRequest not supported in version 1.3");
+    }
+    public OFBsnGetL2TableRequest bsnGetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnGetL2TableRequest not supported in version 1.3");
+    }
+
+    public OFBsnGetMirroringReply.Builder buildBsnGetMirroringReply() {
+        return new OFBsnGetMirroringReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnGetMirroringReply bsnGetMirroringReply(short reportMirrorPorts) {
+        return new OFBsnGetMirroringReplyVer13(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnGetMirroringRequest.Builder buildBsnGetMirroringRequest() {
+        return new OFBsnGetMirroringRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnGetMirroringRequest bsnGetMirroringRequest(short reportMirrorPorts) {
+        return new OFBsnGetMirroringRequestVer13(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnHybridGetReply.Builder buildBsnHybridGetReply() {
+        throw new UnsupportedOperationException("OFBsnHybridGetReply not supported in version 1.3");
+    }
+
+    public OFBsnHybridGetRequest.Builder buildBsnHybridGetRequest() {
+        throw new UnsupportedOperationException("OFBsnHybridGetRequest not supported in version 1.3");
+    }
+    public OFBsnHybridGetRequest bsnHybridGetRequest() {
+        throw new UnsupportedOperationException("OFBsnHybridGetRequest not supported in version 1.3");
+    }
+
+    public OFBsnInterface.Builder buildBsnInterface() {
+        return new OFBsnInterfaceVer13.Builder();
+    }
+
+    public OFBsnPduRxReply.Builder buildBsnPduRxReply() {
+        return new OFBsnPduRxReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduRxRequest.Builder buildBsnPduRxRequest() {
+        return new OFBsnPduRxRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduRxTimeout.Builder buildBsnPduRxTimeout() {
+        return new OFBsnPduRxTimeoutVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduTxReply.Builder buildBsnPduTxReply() {
+        return new OFBsnPduTxReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPduTxRequest.Builder buildBsnPduTxRequest() {
+        return new OFBsnPduTxRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetIpMask.Builder buildBsnSetIpMask() {
+        throw new UnsupportedOperationException("OFBsnSetIpMask not supported in version 1.3");
+    }
+
+    public OFBsnSetL2TableReply.Builder buildBsnSetL2TableReply() {
+        throw new UnsupportedOperationException("OFBsnSetL2TableReply not supported in version 1.3");
+    }
+
+    public OFBsnSetL2TableRequest.Builder buildBsnSetL2TableRequest() {
+        throw new UnsupportedOperationException("OFBsnSetL2TableRequest not supported in version 1.3");
+    }
+
+    public OFBsnSetMirroring.Builder buildBsnSetMirroring() {
+        return new OFBsnSetMirroringVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnSetMirroring bsnSetMirroring(short reportMirrorPorts) {
+        return new OFBsnSetMirroringVer13(
+                nextXid(),
+                      reportMirrorPorts
+                    );
+    }
+
+    public OFBsnSetPktinSuppressionReply.Builder buildBsnSetPktinSuppressionReply() {
+        return new OFBsnSetPktinSuppressionReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnSetPktinSuppressionReply bsnSetPktinSuppressionReply(long status) {
+        return new OFBsnSetPktinSuppressionReplyVer13(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnSetPktinSuppressionRequest.Builder buildBsnSetPktinSuppressionRequest() {
+        return new OFBsnSetPktinSuppressionRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnShellCommand.Builder buildBsnShellCommand() {
+        throw new UnsupportedOperationException("OFBsnShellCommand not supported in version 1.3");
+    }
+
+    public OFBsnShellOutput.Builder buildBsnShellOutput() {
+        throw new UnsupportedOperationException("OFBsnShellOutput not supported in version 1.3");
+    }
+    public OFBsnShellOutput bsnShellOutput(byte[] data) {
+        throw new UnsupportedOperationException("OFBsnShellOutput not supported in version 1.3");
+    }
+
+    public OFBsnShellStatus.Builder buildBsnShellStatus() {
+        throw new UnsupportedOperationException("OFBsnShellStatus not supported in version 1.3");
+    }
+    public OFBsnShellStatus bsnShellStatus(long status) {
+        throw new UnsupportedOperationException("OFBsnShellStatus not supported in version 1.3");
+    }
+
+    public OFBsnVirtualPortCreateReply.Builder buildBsnVirtualPortCreateReply() {
+        return new OFBsnVirtualPortCreateReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnVirtualPortCreateRequest.Builder buildBsnVirtualPortCreateRequest() {
+        return new OFBsnVirtualPortCreateRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest(OFBsnVport vport) {
+        return new OFBsnVirtualPortCreateRequestVer13(
+                nextXid(),
+                      vport
+                    );
+    }
+
+    public OFBsnVirtualPortRemoveReply.Builder buildBsnVirtualPortRemoveReply() {
+        return new OFBsnVirtualPortRemoveReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortRemoveReply bsnVirtualPortRemoveReply(long status) {
+        return new OFBsnVirtualPortRemoveReplyVer13(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnVirtualPortRemoveRequest.Builder buildBsnVirtualPortRemoveRequest() {
+        return new OFBsnVirtualPortRemoveRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnVirtualPortRemoveRequest bsnVirtualPortRemoveRequest(long vportNo) {
+        return new OFBsnVirtualPortRemoveRequestVer13(
+                nextXid(),
+                      vportNo
+                    );
+    }
+
+    public OFBsnVportL2Gre.Builder buildBsnVportL2Gre() {
+        return new OFBsnVportL2GreVer13.Builder();
+    }
+
+    public OFBsnVportQInQ.Builder buildBsnVportQInQ() {
+        return new OFBsnVportQInQVer13.Builder();
+    }
+
+    public OFDescStatsReply.Builder buildDescStatsReply() {
+        return new OFDescStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFDescStatsRequest.Builder buildDescStatsRequest() {
+        return new OFDescStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFDescStatsRequest descStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFDescStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFEchoReply.Builder buildEchoReply() {
+        return new OFEchoReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFEchoReply echoReply(byte[] data) {
+        return new OFEchoReplyVer13(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFEchoRequest.Builder buildEchoRequest() {
+        return new OFEchoRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFEchoRequest echoRequest(byte[] data) {
+        return new OFEchoRequestVer13(
+                nextXid(),
+                      data
+                    );
+    }
+
+    public OFFeaturesReply.Builder buildFeaturesReply() {
+        return new OFFeaturesReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFeaturesRequest.Builder buildFeaturesRequest() {
+        return new OFFeaturesRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFFeaturesRequest featuresRequest() {
+        return new OFFeaturesRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFFlowAdd.Builder buildFlowAdd() {
+        return new OFFlowAddVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFlowDelete.Builder buildFlowDelete() {
+        return new OFFlowDeleteVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFlowDeleteStrict.Builder buildFlowDeleteStrict() {
+        return new OFFlowDeleteStrictVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModify.Builder buildFlowModify() {
+        return new OFFlowModifyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFlowModifyStrict.Builder buildFlowModifyStrict() {
+        return new OFFlowModifyStrictVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFlowRemoved.Builder buildFlowRemoved() {
+        return new OFFlowRemovedVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFlowStatsEntry.Builder buildFlowStatsEntry() {
+        return new OFFlowStatsEntryVer13.Builder();
+    }
+
+    public OFFlowStatsReply.Builder buildFlowStatsReply() {
+        return new OFFlowStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFFlowStatsRequest.Builder buildFlowStatsRequest() {
+        return new OFFlowStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGetConfigReply.Builder buildGetConfigReply() {
+        return new OFGetConfigReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGetConfigRequest.Builder buildGetConfigRequest() {
+        return new OFGetConfigRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFGetConfigRequest getConfigRequest() {
+        return new OFGetConfigRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFHello.Builder buildHello() {
+        return new OFHelloVer13.Builder().setXid(nextXid());
+    }
+    public OFHello hello(List<OFHelloElem> elements) {
+        return new OFHelloVer13(
+                nextXid(),
+                      elements
+                    );
+    }
+
+    public OFMatchV1.Builder buildMatchV1() {
+        throw new UnsupportedOperationException("OFMatchV1 not supported in version 1.3");
+    }
+
+    public OFNiciraControllerRoleReply.Builder buildNiciraControllerRoleReply() {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleReply not supported in version 1.3");
+    }
+    public OFNiciraControllerRoleReply niciraControllerRoleReply(OFNiciraControllerRole role) {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleReply not supported in version 1.3");
+    }
+
+    public OFNiciraControllerRoleRequest.Builder buildNiciraControllerRoleRequest() {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleRequest not supported in version 1.3");
+    }
+    public OFNiciraControllerRoleRequest niciraControllerRoleRequest(OFNiciraControllerRole role) {
+        throw new UnsupportedOperationException("OFNiciraControllerRoleRequest not supported in version 1.3");
+    }
+
+    public OFPacketIn.Builder buildPacketIn() {
+        return new OFPacketInVer13.Builder().setXid(nextXid());
+    }
+
+    public OFPacketOut.Builder buildPacketOut() {
+        return new OFPacketOutVer13.Builder().setXid(nextXid());
+    }
+
+    public OFPacketQueue.Builder buildPacketQueue() {
+        return new OFPacketQueueVer13.Builder();
+    }
+
+    public OFPortDesc.Builder buildPortDesc() {
+        return new OFPortDescVer13.Builder();
+    }
+
+    public OFPortMod.Builder buildPortMod() {
+        return new OFPortModVer13.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatsEntry.Builder buildPortStatsEntry() {
+        return new OFPortStatsEntryVer13.Builder();
+    }
+
+    public OFPortStatsReply.Builder buildPortStatsReply() {
+        return new OFPortStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatsRequest.Builder buildPortStatsRequest() {
+        return new OFPortStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFPortStatus.Builder buildPortStatus() {
+        return new OFPortStatusVer13.Builder().setXid(nextXid());
+    }
+
+    public OFQueueGetConfigReply.Builder buildQueueGetConfigReply() {
+        return new OFQueueGetConfigReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFQueueGetConfigRequest.Builder buildQueueGetConfigRequest() {
+        return new OFQueueGetConfigRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFQueueGetConfigRequest queueGetConfigRequest(OFPort port) {
+        return new OFQueueGetConfigRequestVer13(
+                nextXid(),
+                      port
+                    );
+    }
+
+    public OFQueueStatsEntry.Builder buildQueueStatsEntry() {
+        return new OFQueueStatsEntryVer13.Builder();
+    }
+
+    public OFQueueStatsReply.Builder buildQueueStatsReply() {
+        return new OFQueueStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFQueueStatsRequest.Builder buildQueueStatsRequest() {
+        return new OFQueueStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFSetConfig.Builder buildSetConfig() {
+        return new OFSetConfigVer13.Builder().setXid(nextXid());
+    }
+
+    public OFTableMod.Builder buildTableMod() {
+        return new OFTableModVer13.Builder().setXid(nextXid());
+    }
+
+    public OFTableStatsEntry.Builder buildTableStatsEntry() {
+        return new OFTableStatsEntryVer13.Builder();
+    }
+
+    public OFTableStatsReply.Builder buildTableStatsReply() {
+        return new OFTableStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFTableStatsRequest.Builder buildTableStatsRequest() {
+        return new OFTableStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFTableStatsRequest tableStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFTableStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBucket.Builder buildBucket() {
+        return new OFBucketVer13.Builder();
+    }
+
+    public OFBucketCounter.Builder buildBucketCounter() {
+        return new OFBucketCounterVer13.Builder();
+    }
+    public OFBucketCounter bucketCounter(U64 packetCount, U64 byteCount) {
+        return new OFBucketCounterVer13(
+                packetCount,
+                      byteCount
+                    );
+    }
+
+    public OFGroupAdd.Builder buildGroupAdd() {
+        return new OFGroupAddVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDelete.Builder buildGroupDelete() {
+        return new OFGroupDeleteVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDescStatsEntry.Builder buildGroupDescStatsEntry() {
+        return new OFGroupDescStatsEntryVer13.Builder();
+    }
+
+    public OFGroupDescStatsReply.Builder buildGroupDescStatsReply() {
+        return new OFGroupDescStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGroupDescStatsRequest.Builder buildGroupDescStatsRequest() {
+        return new OFGroupDescStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFGroupDescStatsRequest groupDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFGroupDescStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFGroupModify.Builder buildGroupModify() {
+        return new OFGroupModifyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGroupStatsEntry.Builder buildGroupStatsEntry() {
+        return new OFGroupStatsEntryVer13.Builder();
+    }
+
+    public OFGroupStatsReply.Builder buildGroupStatsReply() {
+        return new OFGroupStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGroupStatsRequest.Builder buildGroupStatsRequest() {
+        return new OFGroupStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFMatchV2.Builder buildMatchV2() {
+        throw new UnsupportedOperationException("OFMatchV2 not supported in version 1.3");
+    }
+
+    public OFGroupFeaturesStatsReply.Builder buildGroupFeaturesStatsReply() {
+        return new OFGroupFeaturesStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFGroupFeaturesStatsRequest.Builder buildGroupFeaturesStatsRequest() {
+        return new OFGroupFeaturesStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFGroupFeaturesStatsRequest groupFeaturesStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFGroupFeaturesStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFMatchV3.Builder buildMatchV3() {
+        return new OFMatchV3Ver13.Builder();
+    }
+    public Match.Builder buildMatch() {
+        return new OFMatchV3Ver13.Builder();
+    }
+
+    final static Match MATCH_WILDCARD_ALL = OFMatchV3Ver13.DEFAULT;
+
+    public Match matchWildcardAll() {
+        return MATCH_WILDCARD_ALL;
+    }
+    public OFMatchV3 matchV3(OFOxmList oxmList) {
+        return new OFMatchV3Ver13(
+                oxmList
+                    );
+    }
+
+    public OFRoleReply.Builder buildRoleReply() {
+        return new OFRoleReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFRoleRequest.Builder buildRoleRequest() {
+        return new OFRoleRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFAsyncGetReply.Builder buildAsyncGetReply() {
+        return new OFAsyncGetReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFAsyncGetRequest.Builder buildAsyncGetRequest() {
+        return new OFAsyncGetRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFAsyncSet.Builder buildAsyncSet() {
+        return new OFAsyncSetVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnArpIdle.Builder buildBsnArpIdle() {
+        return new OFBsnArpIdleVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnControllerConnection.Builder buildBsnControllerConnection() {
+        return new OFBsnControllerConnectionVer13.Builder();
+    }
+
+    public OFBsnControllerConnectionsReply.Builder buildBsnControllerConnectionsReply() {
+        return new OFBsnControllerConnectionsReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnControllerConnectionsReply bsnControllerConnectionsReply(List<OFBsnControllerConnection> connections) {
+        return new OFBsnControllerConnectionsReplyVer13(
+                nextXid(),
+                      connections
+                    );
+    }
+
+    public OFBsnControllerConnectionsRequest.Builder buildBsnControllerConnectionsRequest() {
+        return new OFBsnControllerConnectionsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnControllerConnectionsRequest bsnControllerConnectionsRequest() {
+        return new OFBsnControllerConnectionsRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBsnDebugCounterDescStatsEntry.Builder buildBsnDebugCounterDescStatsEntry() {
+        return new OFBsnDebugCounterDescStatsEntryVer13.Builder();
+    }
+
+    public OFBsnDebugCounterDescStatsReply.Builder buildBsnDebugCounterDescStatsReply() {
+        return new OFBsnDebugCounterDescStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnDebugCounterDescStatsRequest.Builder buildBsnDebugCounterDescStatsRequest() {
+        return new OFBsnDebugCounterDescStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnDebugCounterDescStatsRequest bsnDebugCounterDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFBsnDebugCounterDescStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBsnDebugCounterStatsEntry.Builder buildBsnDebugCounterStatsEntry() {
+        return new OFBsnDebugCounterStatsEntryVer13.Builder();
+    }
+    public OFBsnDebugCounterStatsEntry bsnDebugCounterStatsEntry(U64 counterId, U64 value) {
+        return new OFBsnDebugCounterStatsEntryVer13(
+                counterId,
+                      value
+                    );
+    }
+
+    public OFBsnDebugCounterStatsReply.Builder buildBsnDebugCounterStatsReply() {
+        return new OFBsnDebugCounterStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnDebugCounterStatsRequest.Builder buildBsnDebugCounterStatsRequest() {
+        return new OFBsnDebugCounterStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnDebugCounterStatsRequest bsnDebugCounterStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFBsnDebugCounterStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBsnFlowChecksumBucketStatsEntry.Builder buildBsnFlowChecksumBucketStatsEntry() {
+        return new OFBsnFlowChecksumBucketStatsEntryVer13.Builder();
+    }
+    public OFBsnFlowChecksumBucketStatsEntry bsnFlowChecksumBucketStatsEntry(U64 checksum) {
+        return new OFBsnFlowChecksumBucketStatsEntryVer13(
+                checksum
+                    );
+    }
+
+    public OFBsnFlowChecksumBucketStatsReply.Builder buildBsnFlowChecksumBucketStatsReply() {
+        return new OFBsnFlowChecksumBucketStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnFlowChecksumBucketStatsRequest.Builder buildBsnFlowChecksumBucketStatsRequest() {
+        return new OFBsnFlowChecksumBucketStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnFlowIdle.Builder buildBsnFlowIdle() {
+        return new OFBsnFlowIdleVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnFlowIdleEnableGetReply.Builder buildBsnFlowIdleEnableGetReply() {
+        return new OFBsnFlowIdleEnableGetReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnFlowIdleEnableGetReply bsnFlowIdleEnableGetReply(long enabled) {
+        return new OFBsnFlowIdleEnableGetReplyVer13(
+                nextXid(),
+                      enabled
+                    );
+    }
+
+    public OFBsnFlowIdleEnableGetRequest.Builder buildBsnFlowIdleEnableGetRequest() {
+        return new OFBsnFlowIdleEnableGetRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnFlowIdleEnableGetRequest bsnFlowIdleEnableGetRequest() {
+        return new OFBsnFlowIdleEnableGetRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBsnFlowIdleEnableSetReply.Builder buildBsnFlowIdleEnableSetReply() {
+        return new OFBsnFlowIdleEnableSetReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnFlowIdleEnableSetRequest.Builder buildBsnFlowIdleEnableSetRequest() {
+        return new OFBsnFlowIdleEnableSetRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnFlowIdleEnableSetRequest bsnFlowIdleEnableSetRequest(long enable) {
+        return new OFBsnFlowIdleEnableSetRequestVer13(
+                nextXid(),
+                      enable
+                    );
+    }
+
+    public OFBsnGentableBucketStatsEntry.Builder buildBsnGentableBucketStatsEntry() {
+        return new OFBsnGentableBucketStatsEntryVer13.Builder();
+    }
+    public OFBsnGentableBucketStatsEntry bsnGentableBucketStatsEntry(U128 checksum) {
+        return new OFBsnGentableBucketStatsEntryVer13(
+                checksum
+                    );
+    }
+
+    public OFBsnGentableBucketStatsReply.Builder buildBsnGentableBucketStatsReply() {
+        return new OFBsnGentableBucketStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableBucketStatsRequest.Builder buildBsnGentableBucketStatsRequest() {
+        return new OFBsnGentableBucketStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableClearReply.Builder buildBsnGentableClearReply() {
+        return new OFBsnGentableClearReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableClearRequest.Builder buildBsnGentableClearRequest() {
+        return new OFBsnGentableClearRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableDescStatsEntry.Builder buildBsnGentableDescStatsEntry() {
+        return new OFBsnGentableDescStatsEntryVer13.Builder();
+    }
+
+    public OFBsnGentableDescStatsReply.Builder buildBsnGentableDescStatsReply() {
+        return new OFBsnGentableDescStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableDescStatsRequest.Builder buildBsnGentableDescStatsRequest() {
+        return new OFBsnGentableDescStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnGentableDescStatsRequest bsnGentableDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFBsnGentableDescStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBsnGentableEntryAdd.Builder buildBsnGentableEntryAdd() {
+        return new OFBsnGentableEntryAddVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableEntryDelete.Builder buildBsnGentableEntryDelete() {
+        return new OFBsnGentableEntryDeleteVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableEntryDescStatsEntry.Builder buildBsnGentableEntryDescStatsEntry() {
+        return new OFBsnGentableEntryDescStatsEntryVer13.Builder();
+    }
+
+    public OFBsnGentableEntryDescStatsReply.Builder buildBsnGentableEntryDescStatsReply() {
+        return new OFBsnGentableEntryDescStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableEntryDescStatsRequest.Builder buildBsnGentableEntryDescStatsRequest() {
+        return new OFBsnGentableEntryDescStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableEntryStatsEntry.Builder buildBsnGentableEntryStatsEntry() {
+        return new OFBsnGentableEntryStatsEntryVer13.Builder();
+    }
+    public OFBsnGentableEntryStatsEntry bsnGentableEntryStatsEntry(List<OFBsnTlv> key, List<OFBsnTlv> stats) {
+        return new OFBsnGentableEntryStatsEntryVer13(
+                key,
+                      stats
+                    );
+    }
+
+    public OFBsnGentableEntryStatsReply.Builder buildBsnGentableEntryStatsReply() {
+        return new OFBsnGentableEntryStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableEntryStatsRequest.Builder buildBsnGentableEntryStatsRequest() {
+        return new OFBsnGentableEntryStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableSetBucketsSize.Builder buildBsnGentableSetBucketsSize() {
+        return new OFBsnGentableSetBucketsSizeVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableStatsEntry.Builder buildBsnGentableStatsEntry() {
+        return new OFBsnGentableStatsEntryVer13.Builder();
+    }
+
+    public OFBsnGentableStatsReply.Builder buildBsnGentableStatsReply() {
+        return new OFBsnGentableStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnGentableStatsRequest.Builder buildBsnGentableStatsRequest() {
+        return new OFBsnGentableStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnGentableStatsRequest bsnGentableStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFBsnGentableStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBsnGetSwitchPipelineReply.Builder buildBsnGetSwitchPipelineReply() {
+        return new OFBsnGetSwitchPipelineReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnGetSwitchPipelineReply bsnGetSwitchPipelineReply(String pipeline) {
+        return new OFBsnGetSwitchPipelineReplyVer13(
+                nextXid(),
+                      pipeline
+                    );
+    }
+
+    public OFBsnGetSwitchPipelineRequest.Builder buildBsnGetSwitchPipelineRequest() {
+        return new OFBsnGetSwitchPipelineRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnGetSwitchPipelineRequest bsnGetSwitchPipelineRequest() {
+        return new OFBsnGetSwitchPipelineRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBsnImageDescStatsReply.Builder buildBsnImageDescStatsReply() {
+        return new OFBsnImageDescStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnImageDescStatsRequest.Builder buildBsnImageDescStatsRequest() {
+        return new OFBsnImageDescStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnImageDescStatsRequest bsnImageDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFBsnImageDescStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBsnLacpConvergenceNotif.Builder buildBsnLacpConvergenceNotif() {
+        return new OFBsnLacpConvergenceNotifVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnLacpStatsEntry.Builder buildBsnLacpStatsEntry() {
+        return new OFBsnLacpStatsEntryVer13.Builder();
+    }
+
+    public OFBsnLacpStatsReply.Builder buildBsnLacpStatsReply() {
+        return new OFBsnLacpStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnLacpStatsRequest.Builder buildBsnLacpStatsRequest() {
+        return new OFBsnLacpStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnLacpStatsRequest bsnLacpStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFBsnLacpStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBsnLog.Builder buildBsnLog() {
+        return new OFBsnLogVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPortCounterStatsEntry.Builder buildBsnPortCounterStatsEntry() {
+        return new OFBsnPortCounterStatsEntryVer13.Builder();
+    }
+    public OFBsnPortCounterStatsEntry bsnPortCounterStatsEntry(OFPort portNo, List<U64> values) {
+        return new OFBsnPortCounterStatsEntryVer13(
+                portNo,
+                      values
+                    );
+    }
+
+    public OFBsnPortCounterStatsReply.Builder buildBsnPortCounterStatsReply() {
+        return new OFBsnPortCounterStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnPortCounterStatsRequest.Builder buildBsnPortCounterStatsRequest() {
+        return new OFBsnPortCounterStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnRoleStatus.Builder buildBsnRoleStatus() {
+        return new OFBsnRoleStatusVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetAuxCxnsReply.Builder buildBsnSetAuxCxnsReply() {
+        return new OFBsnSetAuxCxnsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetAuxCxnsRequest.Builder buildBsnSetAuxCxnsRequest() {
+        return new OFBsnSetAuxCxnsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest(long numAux) {
+        return new OFBsnSetAuxCxnsRequestVer13(
+                nextXid(),
+                      numAux
+                    );
+    }
+
+    public OFBsnSetLacpReply.Builder buildBsnSetLacpReply() {
+        return new OFBsnSetLacpReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetLacpRequest.Builder buildBsnSetLacpRequest() {
+        return new OFBsnSetLacpRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSetSwitchPipelineReply.Builder buildBsnSetSwitchPipelineReply() {
+        return new OFBsnSetSwitchPipelineReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnSetSwitchPipelineReply bsnSetSwitchPipelineReply(long status) {
+        return new OFBsnSetSwitchPipelineReplyVer13(
+                nextXid(),
+                      status
+                    );
+    }
+
+    public OFBsnSetSwitchPipelineRequest.Builder buildBsnSetSwitchPipelineRequest() {
+        return new OFBsnSetSwitchPipelineRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnSetSwitchPipelineRequest bsnSetSwitchPipelineRequest(String pipeline) {
+        return new OFBsnSetSwitchPipelineRequestVer13(
+                nextXid(),
+                      pipeline
+                    );
+    }
+
+    public OFBsnSwitchPipelineStatsEntry.Builder buildBsnSwitchPipelineStatsEntry() {
+        return new OFBsnSwitchPipelineStatsEntryVer13.Builder();
+    }
+    public OFBsnSwitchPipelineStatsEntry bsnSwitchPipelineStatsEntry(String pipeline) {
+        return new OFBsnSwitchPipelineStatsEntryVer13(
+                pipeline
+                    );
+    }
+
+    public OFBsnSwitchPipelineStatsReply.Builder buildBsnSwitchPipelineStatsReply() {
+        return new OFBsnSwitchPipelineStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnSwitchPipelineStatsRequest.Builder buildBsnSwitchPipelineStatsRequest() {
+        return new OFBsnSwitchPipelineStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnSwitchPipelineStatsRequest bsnSwitchPipelineStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFBsnSwitchPipelineStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBsnTableChecksumStatsEntry.Builder buildBsnTableChecksumStatsEntry() {
+        return new OFBsnTableChecksumStatsEntryVer13.Builder();
+    }
+    public OFBsnTableChecksumStatsEntry bsnTableChecksumStatsEntry(TableId tableId, U64 checksum) {
+        return new OFBsnTableChecksumStatsEntryVer13(
+                tableId,
+                      checksum
+                    );
+    }
+
+    public OFBsnTableChecksumStatsReply.Builder buildBsnTableChecksumStatsReply() {
+        return new OFBsnTableChecksumStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnTableChecksumStatsRequest.Builder buildBsnTableChecksumStatsRequest() {
+        return new OFBsnTableChecksumStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnTableChecksumStatsRequest bsnTableChecksumStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFBsnTableChecksumStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFBsnTableSetBucketsSize.Builder buildBsnTableSetBucketsSize() {
+        return new OFBsnTableSetBucketsSizeVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnTimeReply.Builder buildBsnTimeReply() {
+        return new OFBsnTimeReplyVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnTimeReply bsnTimeReply(U64 timeMs) {
+        return new OFBsnTimeReplyVer13(
+                nextXid(),
+                      timeMs
+                    );
+    }
+
+    public OFBsnTimeRequest.Builder buildBsnTimeRequest() {
+        return new OFBsnTimeRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFBsnTimeRequest bsnTimeRequest() {
+        return new OFBsnTimeRequestVer13(
+                nextXid()
+                    );
+    }
+
+    public OFBsnVlanCounterStatsEntry.Builder buildBsnVlanCounterStatsEntry() {
+        return new OFBsnVlanCounterStatsEntryVer13.Builder();
+    }
+    public OFBsnVlanCounterStatsEntry bsnVlanCounterStatsEntry(int vlanVid, List<U64> values) {
+        return new OFBsnVlanCounterStatsEntryVer13(
+                vlanVid,
+                      values
+                    );
+    }
+
+    public OFBsnVlanCounterStatsReply.Builder buildBsnVlanCounterStatsReply() {
+        return new OFBsnVlanCounterStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnVlanCounterStatsRequest.Builder buildBsnVlanCounterStatsRequest() {
+        return new OFBsnVlanCounterStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnVrfCounterStatsEntry.Builder buildBsnVrfCounterStatsEntry() {
+        return new OFBsnVrfCounterStatsEntryVer13.Builder();
+    }
+    public OFBsnVrfCounterStatsEntry bsnVrfCounterStatsEntry(long vrf, List<U64> values) {
+        return new OFBsnVrfCounterStatsEntryVer13(
+                vrf,
+                      values
+                    );
+    }
+
+    public OFBsnVrfCounterStatsReply.Builder buildBsnVrfCounterStatsReply() {
+        return new OFBsnVrfCounterStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFBsnVrfCounterStatsRequest.Builder buildBsnVrfCounterStatsRequest() {
+        return new OFBsnVrfCounterStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFHelloElemVersionbitmap.Builder buildHelloElemVersionbitmap() {
+        return new OFHelloElemVersionbitmapVer13.Builder();
+    }
+    public OFHelloElemVersionbitmap helloElemVersionbitmap(List<U32> bitmaps) {
+        return new OFHelloElemVersionbitmapVer13(
+                bitmaps
+                    );
+    }
+
+    public OFMeterBandStats.Builder buildMeterBandStats() {
+        return new OFMeterBandStatsVer13.Builder();
+    }
+    public OFMeterBandStats meterBandStats(U64 packetBandCount, U64 byteBandCount) {
+        return new OFMeterBandStatsVer13(
+                packetBandCount,
+                      byteBandCount
+                    );
+    }
+
+    public OFMeterConfig.Builder buildMeterConfig() {
+        return new OFMeterConfigVer13.Builder();
+    }
+
+    public OFMeterConfigStatsReply.Builder buildMeterConfigStatsReply() {
+        return new OFMeterConfigStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFMeterConfigStatsRequest.Builder buildMeterConfigStatsRequest() {
+        return new OFMeterConfigStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFMeterFeatures.Builder buildMeterFeatures() {
+        return new OFMeterFeaturesVer13.Builder();
+    }
+
+    public OFMeterFeaturesStatsReply.Builder buildMeterFeaturesStatsReply() {
+        return new OFMeterFeaturesStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFMeterFeaturesStatsRequest.Builder buildMeterFeaturesStatsRequest() {
+        return new OFMeterFeaturesStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFMeterFeaturesStatsRequest meterFeaturesStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFMeterFeaturesStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFMeterMod.Builder buildMeterMod() {
+        return new OFMeterModVer13.Builder().setXid(nextXid());
+    }
+
+    public OFMeterStats.Builder buildMeterStats() {
+        return new OFMeterStatsVer13.Builder();
+    }
+
+    public OFMeterStatsReply.Builder buildMeterStatsReply() {
+        return new OFMeterStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFMeterStatsRequest.Builder buildMeterStatsRequest() {
+        return new OFMeterStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFPortDescStatsReply.Builder buildPortDescStatsReply() {
+        return new OFPortDescStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFPortDescStatsRequest.Builder buildPortDescStatsRequest() {
+        return new OFPortDescStatsRequestVer13.Builder().setXid(nextXid());
+    }
+    public OFPortDescStatsRequest portDescStatsRequest(Set<OFStatsRequestFlags> flags) {
+        return new OFPortDescStatsRequestVer13(
+                nextXid(),
+                      flags
+                    );
+    }
+
+    public OFTableFeaturePropApplyActions.Builder buildTableFeaturePropApplyActions() {
+        return new OFTableFeaturePropApplyActionsVer13.Builder();
+    }
+    public OFTableFeaturePropApplyActions tableFeaturePropApplyActions(List<OFActionId> actionIds) {
+        return new OFTableFeaturePropApplyActionsVer13(
+                actionIds
+                    );
+    }
+
+    public OFTableFeaturePropApplyActionsMiss.Builder buildTableFeaturePropApplyActionsMiss() {
+        return new OFTableFeaturePropApplyActionsMissVer13.Builder();
+    }
+    public OFTableFeaturePropApplyActionsMiss tableFeaturePropApplyActionsMiss(List<OFActionId> actionIds) {
+        return new OFTableFeaturePropApplyActionsMissVer13(
+                actionIds
+                    );
+    }
+
+    public OFTableFeaturePropApplySetfield.Builder buildTableFeaturePropApplySetfield() {
+        return new OFTableFeaturePropApplySetfieldVer13.Builder();
+    }
+    public OFTableFeaturePropApplySetfield tableFeaturePropApplySetfield(List<U32> oxmIds) {
+        return new OFTableFeaturePropApplySetfieldVer13(
+                oxmIds
+                    );
+    }
+
+    public OFTableFeaturePropApplySetfieldMiss.Builder buildTableFeaturePropApplySetfieldMiss() {
+        return new OFTableFeaturePropApplySetfieldMissVer13.Builder();
+    }
+    public OFTableFeaturePropApplySetfieldMiss tableFeaturePropApplySetfieldMiss(List<U32> oxmIds) {
+        return new OFTableFeaturePropApplySetfieldMissVer13(
+                oxmIds
+                    );
+    }
+
+    public OFTableFeaturePropExperimenter.Builder buildTableFeaturePropExperimenter() {
+        return new OFTableFeaturePropExperimenterVer13.Builder();
+    }
+
+    public OFTableFeaturePropExperimenterMiss.Builder buildTableFeaturePropExperimenterMiss() {
+        return new OFTableFeaturePropExperimenterMissVer13.Builder();
+    }
+
+    public OFTableFeaturePropInstructions.Builder buildTableFeaturePropInstructions() {
+        return new OFTableFeaturePropInstructionsVer13.Builder();
+    }
+    public OFTableFeaturePropInstructions tableFeaturePropInstructions(List<OFInstructionId> instructionIds) {
+        return new OFTableFeaturePropInstructionsVer13(
+                instructionIds
+                    );
+    }
+
+    public OFTableFeaturePropInstructionsMiss.Builder buildTableFeaturePropInstructionsMiss() {
+        return new OFTableFeaturePropInstructionsMissVer13.Builder();
+    }
+    public OFTableFeaturePropInstructionsMiss tableFeaturePropInstructionsMiss(List<OFInstructionId> instructionIds) {
+        return new OFTableFeaturePropInstructionsMissVer13(
+                instructionIds
+                    );
+    }
+
+    public OFTableFeaturePropMatch.Builder buildTableFeaturePropMatch() {
+        return new OFTableFeaturePropMatchVer13.Builder();
+    }
+    public OFTableFeaturePropMatch tableFeaturePropMatch(List<U32> oxmIds) {
+        return new OFTableFeaturePropMatchVer13(
+                oxmIds
+                    );
+    }
+
+    public OFTableFeaturePropNextTables.Builder buildTableFeaturePropNextTables() {
+        return new OFTableFeaturePropNextTablesVer13.Builder();
+    }
+    public OFTableFeaturePropNextTables tableFeaturePropNextTables(List<U8> nextTableIds) {
+        return new OFTableFeaturePropNextTablesVer13(
+                nextTableIds
+                    );
+    }
+
+    public OFTableFeaturePropNextTablesMiss.Builder buildTableFeaturePropNextTablesMiss() {
+        return new OFTableFeaturePropNextTablesMissVer13.Builder();
+    }
+    public OFTableFeaturePropNextTablesMiss tableFeaturePropNextTablesMiss(List<U8> nextTableIds) {
+        return new OFTableFeaturePropNextTablesMissVer13(
+                nextTableIds
+                    );
+    }
+
+    public OFTableFeaturePropWildcards.Builder buildTableFeaturePropWildcards() {
+        return new OFTableFeaturePropWildcardsVer13.Builder();
+    }
+    public OFTableFeaturePropWildcards tableFeaturePropWildcards(List<U32> oxmIds) {
+        return new OFTableFeaturePropWildcardsVer13(
+                oxmIds
+                    );
+    }
+
+    public OFTableFeaturePropWriteActions.Builder buildTableFeaturePropWriteActions() {
+        return new OFTableFeaturePropWriteActionsVer13.Builder();
+    }
+    public OFTableFeaturePropWriteActions tableFeaturePropWriteActions(List<OFActionId> actionIds) {
+        return new OFTableFeaturePropWriteActionsVer13(
+                actionIds
+                    );
+    }
+
+    public OFTableFeaturePropWriteActionsMiss.Builder buildTableFeaturePropWriteActionsMiss() {
+        return new OFTableFeaturePropWriteActionsMissVer13.Builder();
+    }
+    public OFTableFeaturePropWriteActionsMiss tableFeaturePropWriteActionsMiss(List<OFActionId> actionIds) {
+        return new OFTableFeaturePropWriteActionsMissVer13(
+                actionIds
+                    );
+    }
+
+    public OFTableFeaturePropWriteSetfield.Builder buildTableFeaturePropWriteSetfield() {
+        return new OFTableFeaturePropWriteSetfieldVer13.Builder();
+    }
+    public OFTableFeaturePropWriteSetfield tableFeaturePropWriteSetfield(List<U32> oxmIds) {
+        return new OFTableFeaturePropWriteSetfieldVer13(
+                oxmIds
+                    );
+    }
+
+    public OFTableFeaturePropWriteSetfieldMiss.Builder buildTableFeaturePropWriteSetfieldMiss() {
+        return new OFTableFeaturePropWriteSetfieldMissVer13.Builder();
+    }
+    public OFTableFeaturePropWriteSetfieldMiss tableFeaturePropWriteSetfieldMiss(List<U32> oxmIds) {
+        return new OFTableFeaturePropWriteSetfieldMissVer13(
+                oxmIds
+                    );
+    }
+
+    public OFTableFeatures.Builder buildTableFeatures() {
+        return new OFTableFeaturesVer13.Builder();
+    }
+
+    public OFTableFeaturesStatsReply.Builder buildTableFeaturesStatsReply() {
+        return new OFTableFeaturesStatsReplyVer13.Builder().setXid(nextXid());
+    }
+
+    public OFTableFeaturesStatsRequest.Builder buildTableFeaturesStatsRequest() {
+        return new OFTableFeaturesStatsRequestVer13.Builder().setXid(nextXid());
+    }
+
+    public OFUint64.Builder buildUint64() {
+        return new OFUint64Ver13.Builder();
+    }
+    public OFUint64 uint64(U64 value) {
+        return new OFUint64Ver13(
+                value
+                    );
+    }
+
+    public OFMessageReader<OFMessage> getReader() {
+        return OFMessageVer13.READER;
+    }
+
+    public long nextXid() {
+        return xidGenerator.nextXid();
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesReplyVer13.java
new file mode 100644
index 0000000..2f9c36b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesReplyVer13.java
@@ -0,0 +1,624 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFeaturesReplyVer13 implements OFFeaturesReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFFeaturesReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static DatapathId DEFAULT_DATAPATH_ID = DatapathId.NONE;
+        private final static long DEFAULT_N_BUFFERS = 0x0L;
+        private final static short DEFAULT_N_TABLES = (short) 0x0;
+        private final static OFAuxId DEFAULT_AUXILIARY_ID = OFAuxId.MAIN;
+        private final static Set<OFCapabilities> DEFAULT_CAPABILITIES = ImmutableSet.<OFCapabilities>of();
+        private final static long DEFAULT_RESERVED = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final DatapathId datapathId;
+    private final long nBuffers;
+    private final short nTables;
+    private final OFAuxId auxiliaryId;
+    private final Set<OFCapabilities> capabilities;
+    private final long reserved;
+//
+    // Immutable default instance
+    final static OFFeaturesReplyVer13 DEFAULT = new OFFeaturesReplyVer13(
+        DEFAULT_XID, DEFAULT_DATAPATH_ID, DEFAULT_N_BUFFERS, DEFAULT_N_TABLES, DEFAULT_AUXILIARY_ID, DEFAULT_CAPABILITIES, DEFAULT_RESERVED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFeaturesReplyVer13(long xid, DatapathId datapathId, long nBuffers, short nTables, OFAuxId auxiliaryId, Set<OFCapabilities> capabilities, long reserved) {
+        this.xid = xid;
+        this.datapathId = datapathId;
+        this.nBuffers = nBuffers;
+        this.nTables = nTables;
+        this.auxiliaryId = auxiliaryId;
+        this.capabilities = capabilities;
+        this.reserved = reserved;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public List<OFPortDesc> getPorts()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property ports not supported in version 1.3");
+    }
+
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+
+    @Override
+    public OFAuxId getAuxiliaryId() {
+        return auxiliaryId;
+    }
+
+
+
+    public OFFeaturesReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFeaturesReply.Builder {
+        final OFFeaturesReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean datapathIdSet;
+        private DatapathId datapathId;
+        private boolean nBuffersSet;
+        private long nBuffers;
+        private boolean nTablesSet;
+        private short nTables;
+        private boolean auxiliaryIdSet;
+        private OFAuxId auxiliaryId;
+        private boolean capabilitiesSet;
+        private Set<OFCapabilities> capabilities;
+        private boolean reservedSet;
+        private long reserved;
+
+        BuilderWithParent(OFFeaturesReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setDatapathId(DatapathId datapathId) {
+        this.datapathId = datapathId;
+        this.datapathIdSet = true;
+        return this;
+    }
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNBuffers(long nBuffers) {
+        this.nBuffers = nBuffers;
+        this.nBuffersSet = true;
+        return this;
+    }
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNTables(short nTables) {
+        this.nTables = nTables;
+        this.nTablesSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setCapabilities(Set<OFCapabilities> capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setReserved(long reserved) {
+        this.reserved = reserved;
+        this.reservedSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortDesc> getPorts()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property ports not supported in version 1.3");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setPorts(List<OFPortDesc> ports) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property ports not supported in version 1.3");
+    }
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setActions(Set<OFActionType> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+    @Override
+    public OFAuxId getAuxiliaryId() {
+        return auxiliaryId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setAuxiliaryId(OFAuxId auxiliaryId) {
+        this.auxiliaryId = auxiliaryId;
+        this.auxiliaryIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFeaturesReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                DatapathId datapathId = this.datapathIdSet ? this.datapathId : parentMessage.datapathId;
+                if(datapathId == null)
+                    throw new NullPointerException("Property datapathId must not be null");
+                long nBuffers = this.nBuffersSet ? this.nBuffers : parentMessage.nBuffers;
+                short nTables = this.nTablesSet ? this.nTables : parentMessage.nTables;
+                OFAuxId auxiliaryId = this.auxiliaryIdSet ? this.auxiliaryId : parentMessage.auxiliaryId;
+                if(auxiliaryId == null)
+                    throw new NullPointerException("Property auxiliaryId must not be null");
+                Set<OFCapabilities> capabilities = this.capabilitiesSet ? this.capabilities : parentMessage.capabilities;
+                if(capabilities == null)
+                    throw new NullPointerException("Property capabilities must not be null");
+                long reserved = this.reservedSet ? this.reserved : parentMessage.reserved;
+
+                //
+                return new OFFeaturesReplyVer13(
+                    xid,
+                    datapathId,
+                    nBuffers,
+                    nTables,
+                    auxiliaryId,
+                    capabilities,
+                    reserved
+                );
+        }
+
+    }
+
+    static class Builder implements OFFeaturesReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean datapathIdSet;
+        private DatapathId datapathId;
+        private boolean nBuffersSet;
+        private long nBuffers;
+        private boolean nTablesSet;
+        private short nTables;
+        private boolean auxiliaryIdSet;
+        private OFAuxId auxiliaryId;
+        private boolean capabilitiesSet;
+        private Set<OFCapabilities> capabilities;
+        private boolean reservedSet;
+        private long reserved;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public DatapathId getDatapathId() {
+        return datapathId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setDatapathId(DatapathId datapathId) {
+        this.datapathId = datapathId;
+        this.datapathIdSet = true;
+        return this;
+    }
+    @Override
+    public long getNBuffers() {
+        return nBuffers;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNBuffers(long nBuffers) {
+        this.nBuffers = nBuffers;
+        this.nBuffersSet = true;
+        return this;
+    }
+    @Override
+    public short getNTables() {
+        return nTables;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setNTables(short nTables) {
+        this.nTables = nTables;
+        this.nTablesSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFCapabilities> getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setCapabilities(Set<OFCapabilities> capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getReserved() {
+        return reserved;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setReserved(long reserved) {
+        this.reserved = reserved;
+        this.reservedSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortDesc> getPorts()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property ports not supported in version 1.3");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setPorts(List<OFPortDesc> ports) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property ports not supported in version 1.3");
+    }
+    @Override
+    public Set<OFActionType> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setActions(Set<OFActionType> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+    @Override
+    public OFAuxId getAuxiliaryId() {
+        return auxiliaryId;
+    }
+
+    @Override
+    public OFFeaturesReply.Builder setAuxiliaryId(OFAuxId auxiliaryId) {
+        this.auxiliaryId = auxiliaryId;
+        this.auxiliaryIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFeaturesReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            DatapathId datapathId = this.datapathIdSet ? this.datapathId : DEFAULT_DATAPATH_ID;
+            if(datapathId == null)
+                throw new NullPointerException("Property datapathId must not be null");
+            long nBuffers = this.nBuffersSet ? this.nBuffers : DEFAULT_N_BUFFERS;
+            short nTables = this.nTablesSet ? this.nTables : DEFAULT_N_TABLES;
+            OFAuxId auxiliaryId = this.auxiliaryIdSet ? this.auxiliaryId : DEFAULT_AUXILIARY_ID;
+            if(auxiliaryId == null)
+                throw new NullPointerException("Property auxiliaryId must not be null");
+            Set<OFCapabilities> capabilities = this.capabilitiesSet ? this.capabilities : DEFAULT_CAPABILITIES;
+            if(capabilities == null)
+                throw new NullPointerException("Property capabilities must not be null");
+            long reserved = this.reservedSet ? this.reserved : DEFAULT_RESERVED;
+
+
+            return new OFFeaturesReplyVer13(
+                    xid,
+                    datapathId,
+                    nBuffers,
+                    nTables,
+                    auxiliaryId,
+                    capabilities,
+                    reserved
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFeaturesReply> {
+        @Override
+        public OFFeaturesReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 6
+            byte type = bb.readByte();
+            if(type != (byte) 0x6)
+                throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REPLY(6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            DatapathId datapathId = DatapathId.of(bb.readLong());
+            long nBuffers = U32.f(bb.readInt());
+            short nTables = U8.f(bb.readByte());
+            OFAuxId auxiliaryId = OFAuxId.readByte(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Set<OFCapabilities> capabilities = OFCapabilitiesSerializerVer13.readFrom(bb);
+            long reserved = U32.f(bb.readInt());
+
+            OFFeaturesReplyVer13 featuresReplyVer13 = new OFFeaturesReplyVer13(
+                    xid,
+                      datapathId,
+                      nBuffers,
+                      nTables,
+                      auxiliaryId,
+                      capabilities,
+                      reserved
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", featuresReplyVer13);
+            return featuresReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFeaturesReplyVer13Funnel FUNNEL = new OFFeaturesReplyVer13Funnel();
+    static class OFFeaturesReplyVer13Funnel implements Funnel<OFFeaturesReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFeaturesReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 6
+            sink.putByte((byte) 0x6);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            message.datapathId.putTo(sink);
+            sink.putLong(message.nBuffers);
+            sink.putShort(message.nTables);
+            message.auxiliaryId.putTo(sink);
+            // skip pad (2 bytes)
+            OFCapabilitiesSerializerVer13.putTo(message.capabilities, sink);
+            sink.putLong(message.reserved);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFeaturesReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFeaturesReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 6
+            bb.writeByte((byte) 0x6);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.datapathId.getLong());
+            bb.writeInt(U32.t(message.nBuffers));
+            bb.writeByte(U8.t(message.nTables));
+            message.auxiliaryId.writeByte(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            OFCapabilitiesSerializerVer13.writeTo(bb, message.capabilities);
+            bb.writeInt(U32.t(message.reserved));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFeaturesReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("datapathId=").append(datapathId);
+        b.append(", ");
+        b.append("nBuffers=").append(nBuffers);
+        b.append(", ");
+        b.append("nTables=").append(nTables);
+        b.append(", ");
+        b.append("auxiliaryId=").append(auxiliaryId);
+        b.append(", ");
+        b.append("capabilities=").append(capabilities);
+        b.append(", ");
+        b.append("reserved=").append(reserved);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFeaturesReplyVer13 other = (OFFeaturesReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (datapathId == null) {
+            if (other.datapathId != null)
+                return false;
+        } else if (!datapathId.equals(other.datapathId))
+            return false;
+        if( nBuffers != other.nBuffers)
+            return false;
+        if( nTables != other.nTables)
+            return false;
+        if (auxiliaryId == null) {
+            if (other.auxiliaryId != null)
+                return false;
+        } else if (!auxiliaryId.equals(other.auxiliaryId))
+            return false;
+        if (capabilities == null) {
+            if (other.capabilities != null)
+                return false;
+        } else if (!capabilities.equals(other.capabilities))
+            return false;
+        if( reserved != other.reserved)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((datapathId == null) ? 0 : datapathId.hashCode());
+        result = prime *  (int) (nBuffers ^ (nBuffers >>> 32));
+        result = prime * result + nTables;
+        result = prime * result + ((auxiliaryId == null) ? 0 : auxiliaryId.hashCode());
+        result = prime * result + ((capabilities == null) ? 0 : capabilities.hashCode());
+        result = prime *  (int) (reserved ^ (reserved >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesRequestVer13.java
new file mode 100644
index 0000000..3b10c55
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesRequestVer13.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFeaturesRequestVer13 implements OFFeaturesRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFFeaturesRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFFeaturesRequestVer13 DEFAULT = new OFFeaturesRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFeaturesRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFFeaturesRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFeaturesRequest.Builder {
+        final OFFeaturesRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFFeaturesRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFeaturesRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFFeaturesRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFFeaturesRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FEATURES_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFeaturesRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFeaturesRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFFeaturesRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFeaturesRequest> {
+        @Override
+        public OFFeaturesRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 5
+            byte type = bb.readByte();
+            if(type != (byte) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REQUEST(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFFeaturesRequestVer13 featuresRequestVer13 = new OFFeaturesRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", featuresRequestVer13);
+            return featuresRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFeaturesRequestVer13Funnel FUNNEL = new OFFeaturesRequestVer13Funnel();
+    static class OFFeaturesRequestVer13Funnel implements Funnel<OFFeaturesRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFeaturesRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 5
+            sink.putByte((byte) 0x5);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFeaturesRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFeaturesRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 5
+            bb.writeByte((byte) 0x5);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFeaturesRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFeaturesRequestVer13 other = (OFFeaturesRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowAddVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowAddVer13.java
new file mode 100644
index 0000000..44a9cf5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowAddVer13.java
@@ -0,0 +1,987 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Collections;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowAddVer13 implements OFFlowAdd {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowAddVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowAddVer13 DEFAULT = new OFFlowAddVer13(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowAddVer13(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+
+    public OFFlowAdd.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowAdd.Builder {
+        final OFFlowAddVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowAddVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return parentMessage.getActions();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowAdd.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowAdd build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowAddVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowAdd.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.ADD;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowAdd.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return Collections.emptyList();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowAdd.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowAdd build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowAddVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowAdd> {
+        @Override
+        public OFFlowAdd readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 0
+            short command = bb.readByte();
+            if(command != (short) 0x0)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.ADD(0), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer13.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer13.READER);
+
+            OFFlowAddVer13 flowAddVer13 = new OFFlowAddVer13(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowAddVer13);
+            return flowAddVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowAddVer13Funnel FUNNEL = new OFFlowAddVer13Funnel();
+    static class OFFlowAddVer13Funnel implements Funnel<OFFlowAddVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowAddVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 0
+            sink.putShort((short) 0x0);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowAddVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowAddVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 0
+            bb.writeByte((short) 0x0);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowAddVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowAddVer13 other = (OFFlowAddVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteStrictVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteStrictVer13.java
new file mode 100644
index 0000000..aacdb04
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteStrictVer13.java
@@ -0,0 +1,987 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Collections;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowDeleteStrictVer13 implements OFFlowDeleteStrict {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteStrictVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowDeleteStrictVer13 DEFAULT = new OFFlowDeleteStrictVer13(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowDeleteStrictVer13(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+
+    public OFFlowDeleteStrict.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowDeleteStrict.Builder {
+        final OFFlowDeleteStrictVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowDeleteStrictVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return parentMessage.getActions();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowDeleteStrict build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowDeleteStrictVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowDeleteStrict.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return Collections.emptyList();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowDeleteStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowDeleteStrict build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowDeleteStrictVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowDeleteStrict> {
+        @Override
+        public OFFlowDeleteStrict readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 4
+            short command = bb.readByte();
+            if(command != (short) 0x4)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE_STRICT(4), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer13.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer13.READER);
+
+            OFFlowDeleteStrictVer13 flowDeleteStrictVer13 = new OFFlowDeleteStrictVer13(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowDeleteStrictVer13);
+            return flowDeleteStrictVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowDeleteStrictVer13Funnel FUNNEL = new OFFlowDeleteStrictVer13Funnel();
+    static class OFFlowDeleteStrictVer13Funnel implements Funnel<OFFlowDeleteStrictVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowDeleteStrictVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 4
+            sink.putShort((short) 0x4);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowDeleteStrictVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowDeleteStrictVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 4
+            bb.writeByte((short) 0x4);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowDeleteStrictVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowDeleteStrictVer13 other = (OFFlowDeleteStrictVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteVer13.java
new file mode 100644
index 0000000..1315068
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteVer13.java
@@ -0,0 +1,987 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Collections;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowDeleteVer13 implements OFFlowDelete {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowDeleteVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowDeleteVer13 DEFAULT = new OFFlowDeleteVer13(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowDeleteVer13(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+
+    public OFFlowDelete.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowDelete.Builder {
+        final OFFlowDeleteVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowDeleteVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return parentMessage.getActions();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowDelete.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowDelete build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowDeleteVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowDelete.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.DELETE;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowDelete.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return Collections.emptyList();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowDelete.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowDelete build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowDeleteVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowDelete> {
+        @Override
+        public OFFlowDelete readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 3
+            short command = bb.readByte();
+            if(command != (short) 0x3)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.DELETE(3), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer13.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer13.READER);
+
+            OFFlowDeleteVer13 flowDeleteVer13 = new OFFlowDeleteVer13(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowDeleteVer13);
+            return flowDeleteVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowDeleteVer13Funnel FUNNEL = new OFFlowDeleteVer13Funnel();
+    static class OFFlowDeleteVer13Funnel implements Funnel<OFFlowDeleteVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowDeleteVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 3
+            sink.putShort((short) 0x3);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowDeleteVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowDeleteVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 3
+            bb.writeByte((short) 0x3);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowDeleteVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowDeleteVer13 other = (OFFlowDeleteVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModCommandSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModCommandSerializerVer13.java
new file mode 100644
index 0000000..acc2ee7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModCommandSerializerVer13.java
@@ -0,0 +1,89 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModCommand;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowModCommandSerializerVer13 {
+
+    public final static byte ADD_VAL = (byte) 0x0;
+    public final static byte MODIFY_VAL = (byte) 0x1;
+    public final static byte MODIFY_STRICT_VAL = (byte) 0x2;
+    public final static byte DELETE_VAL = (byte) 0x3;
+    public final static byte DELETE_STRICT_VAL = (byte) 0x4;
+
+    public static OFFlowModCommand readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowModCommand e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowModCommand e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFFlowModCommand ofWireValue(byte val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFFlowModCommand.ADD;
+            case MODIFY_VAL:
+                return OFFlowModCommand.MODIFY;
+            case MODIFY_STRICT_VAL:
+                return OFFlowModCommand.MODIFY_STRICT;
+            case DELETE_VAL:
+                return OFFlowModCommand.DELETE;
+            case DELETE_STRICT_VAL:
+                return OFFlowModCommand.DELETE_STRICT;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowModCommand in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFFlowModCommand e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            case MODIFY_STRICT:
+                return MODIFY_STRICT_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case DELETE_STRICT:
+                return DELETE_STRICT_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowModCommand in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..cb3e72d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFailedCodeSerializerVer13.java
@@ -0,0 +1,104 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowModFailedCodeSerializerVer13 {
+
+    public final static short UNKNOWN_VAL = (short) 0x0;
+    public final static short TABLE_FULL_VAL = (short) 0x1;
+    public final static short BAD_TABLE_ID_VAL = (short) 0x2;
+    public final static short OVERLAP_VAL = (short) 0x3;
+    public final static short EPERM_VAL = (short) 0x4;
+    public final static short BAD_TIMEOUT_VAL = (short) 0x5;
+    public final static short BAD_COMMAND_VAL = (short) 0x6;
+    public final static short BAD_FLAGS_VAL = (short) 0x7;
+
+    public static OFFlowModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFFlowModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case UNKNOWN_VAL:
+                return OFFlowModFailedCode.UNKNOWN;
+            case TABLE_FULL_VAL:
+                return OFFlowModFailedCode.TABLE_FULL;
+            case BAD_TABLE_ID_VAL:
+                return OFFlowModFailedCode.BAD_TABLE_ID;
+            case OVERLAP_VAL:
+                return OFFlowModFailedCode.OVERLAP;
+            case EPERM_VAL:
+                return OFFlowModFailedCode.EPERM;
+            case BAD_TIMEOUT_VAL:
+                return OFFlowModFailedCode.BAD_TIMEOUT;
+            case BAD_COMMAND_VAL:
+                return OFFlowModFailedCode.BAD_COMMAND;
+            case BAD_FLAGS_VAL:
+                return OFFlowModFailedCode.BAD_FLAGS;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowModFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFFlowModFailedCode e) {
+        switch(e) {
+            case UNKNOWN:
+                return UNKNOWN_VAL;
+            case TABLE_FULL:
+                return TABLE_FULL_VAL;
+            case BAD_TABLE_ID:
+                return BAD_TABLE_ID_VAL;
+            case OVERLAP:
+                return OVERLAP_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            case BAD_TIMEOUT:
+                return BAD_TIMEOUT_VAL;
+            case BAD_COMMAND:
+                return BAD_COMMAND_VAL;
+            case BAD_FLAGS:
+                return BAD_FLAGS_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowModFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFailedErrorMsgVer13.java
new file mode 100644
index 0000000..20cf7b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModFailedErrorMsgVer13 implements OFFlowModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFFlowModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModFailedErrorMsgVer13(long xid, OFFlowModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFFlowModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModFailedErrorMsg.Builder {
+        final OFFlowModFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFFlowModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFFlowModFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setCode(OFFlowModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFFlowModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFFlowModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFFlowModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.FLOW_MOD_FAILED;
+    }
+
+    @Override
+    public OFFlowModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setCode(OFFlowModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFFlowModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFFlowModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModFailedErrorMsg> {
+        @Override
+        public OFFlowModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 5
+            short errType = bb.readShort();
+            if(errType != (short) 0x5)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.FLOW_MOD_FAILED(5), got="+errType);
+            OFFlowModFailedCode code = OFFlowModFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFFlowModFailedErrorMsgVer13 flowModFailedErrorMsgVer13 = new OFFlowModFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModFailedErrorMsgVer13);
+            return flowModFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModFailedErrorMsgVer13Funnel FUNNEL = new OFFlowModFailedErrorMsgVer13Funnel();
+    static class OFFlowModFailedErrorMsgVer13Funnel implements Funnel<OFFlowModFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 5
+            sink.putShort((short) 0x5);
+            OFFlowModFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 5
+            bb.writeShort((short) 0x5);
+            OFFlowModFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModFailedErrorMsgVer13 other = (OFFlowModFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFlagsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFlagsSerializerVer13.java
new file mode 100644
index 0000000..128609b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModFlagsSerializerVer13.java
@@ -0,0 +1,108 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowModFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFFlowModFlagsSerializerVer13 {
+
+    public final static short SEND_FLOW_REM_VAL = (short) 0x1;
+    public final static short CHECK_OVERLAP_VAL = (short) 0x2;
+    public final static short RESET_COUNTS_VAL = (short) 0x4;
+    public final static short NO_PKT_COUNTS_VAL = (short) 0x8;
+    public final static short NO_BYT_COUNTS_VAL = (short) 0x10;
+    public final static short BSN_SEND_IDLE_VAL = (short) 0x80;
+
+    public static Set<OFFlowModFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFFlowModFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFFlowModFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFFlowModFlags> ofWireValue(short val) {
+        EnumSet<OFFlowModFlags> set = EnumSet.noneOf(OFFlowModFlags.class);
+
+        if((val & SEND_FLOW_REM_VAL) != 0)
+            set.add(OFFlowModFlags.SEND_FLOW_REM);
+        if((val & CHECK_OVERLAP_VAL) != 0)
+            set.add(OFFlowModFlags.CHECK_OVERLAP);
+        if((val & RESET_COUNTS_VAL) != 0)
+            set.add(OFFlowModFlags.RESET_COUNTS);
+        if((val & NO_PKT_COUNTS_VAL) != 0)
+            set.add(OFFlowModFlags.NO_PKT_COUNTS);
+        if((val & NO_BYT_COUNTS_VAL) != 0)
+            set.add(OFFlowModFlags.NO_BYT_COUNTS);
+        if((val & BSN_SEND_IDLE_VAL) != 0)
+            set.add(OFFlowModFlags.BSN_SEND_IDLE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFFlowModFlags> set) {
+        short wireValue = 0;
+
+        for(OFFlowModFlags e: set) {
+            switch(e) {
+                case SEND_FLOW_REM:
+                    wireValue |= SEND_FLOW_REM_VAL;
+                    break;
+                case CHECK_OVERLAP:
+                    wireValue |= CHECK_OVERLAP_VAL;
+                    break;
+                case RESET_COUNTS:
+                    wireValue |= RESET_COUNTS_VAL;
+                    break;
+                case NO_PKT_COUNTS:
+                    wireValue |= NO_PKT_COUNTS_VAL;
+                    break;
+                case NO_BYT_COUNTS:
+                    wireValue |= NO_BYT_COUNTS_VAL;
+                    break;
+                case BSN_SEND_IDLE:
+                    wireValue |= BSN_SEND_IDLE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFFlowModFlags in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModVer13.java
new file mode 100644
index 0000000..a49a546
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModVer13.java
@@ -0,0 +1,80 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFFlowModVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+
+    public final static OFFlowModVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFFlowMod> {
+        @Override
+        public OFFlowMod readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            U64.ofRaw(bb.readLong());
+            U64.ofRaw(bb.readLong());
+            TableId.readByte(bb);
+            short command = bb.readByte();
+            bb.readerIndex(start);
+            switch(command) {
+               case (short) 0x0:
+                   // discriminator value OFFlowModCommand.ADD=0 for class OFFlowAddVer13
+                   return OFFlowAddVer13.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFFlowModCommand.DELETE=3 for class OFFlowDeleteVer13
+                   return OFFlowDeleteVer13.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFFlowModCommand.DELETE_STRICT=4 for class OFFlowDeleteStrictVer13
+                   return OFFlowDeleteStrictVer13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFFlowModCommand.MODIFY=1 for class OFFlowModifyVer13
+                   return OFFlowModifyVer13.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFFlowModCommand.MODIFY_STRICT=2 for class OFFlowModifyStrictVer13
+                   return OFFlowModifyStrictVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator command of class OFFlowModVer13: " + command);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyStrictVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyStrictVer13.java
new file mode 100644
index 0000000..40299fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyStrictVer13.java
@@ -0,0 +1,987 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Collections;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModifyStrictVer13 implements OFFlowModifyStrict {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModifyStrictVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowModifyStrictVer13 DEFAULT = new OFFlowModifyStrictVer13(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModifyStrictVer13(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+
+    public OFFlowModifyStrict.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModifyStrict.Builder {
+        final OFFlowModifyStrictVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowModifyStrictVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return parentMessage.getActions();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowModifyStrict build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowModifyStrictVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModifyStrict.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY_STRICT;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return Collections.emptyList();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowModifyStrict.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowModifyStrict build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowModifyStrictVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModifyStrict> {
+        @Override
+        public OFFlowModifyStrict readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 2
+            short command = bb.readByte();
+            if(command != (short) 0x2)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.MODIFY_STRICT(2), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer13.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer13.READER);
+
+            OFFlowModifyStrictVer13 flowModifyStrictVer13 = new OFFlowModifyStrictVer13(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModifyStrictVer13);
+            return flowModifyStrictVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModifyStrictVer13Funnel FUNNEL = new OFFlowModifyStrictVer13Funnel();
+    static class OFFlowModifyStrictVer13Funnel implements Funnel<OFFlowModifyStrictVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModifyStrictVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 2
+            sink.putShort((short) 0x2);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModifyStrictVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModifyStrictVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 2
+            bb.writeByte((short) 0x2);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModifyStrictVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModifyStrictVer13 other = (OFFlowModifyStrictVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyVer13.java
new file mode 100644
index 0000000..ad38926
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyVer13.java
@@ -0,0 +1,987 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Collections;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowModifyVer13 implements OFFlowModify {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowModifyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ZERO;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final TableId tableId;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final int priority;
+    private final OFBufferId bufferId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final Set<OFFlowModFlags> flags;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowModifyVer13 DEFAULT = new OFFlowModifyVer13(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_TABLE_ID, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PRIORITY, DEFAULT_BUFFER_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_FLAGS, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowModifyVer13(long xid, U64 cookie, U64 cookieMask, TableId tableId, int idleTimeout, int hardTimeout, int priority, OFBufferId bufferId, OFPort outPort, OFGroup outGroup, Set<OFFlowModFlags> flags, Match match, List<OFInstruction> instructions) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.tableId = tableId;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.priority = priority;
+        this.bufferId = bufferId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.flags = flags;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+
+    public OFFlowModify.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowModify.Builder {
+        final OFFlowModifyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowModifyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModify.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModify.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModify.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModify.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return parentMessage.getActions();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowModify.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowModify build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowModifyVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowModify.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean prioritySet;
+        private int priority;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowModify.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFFlowModCommand getCommand() {
+        return OFFlowModCommand.MODIFY;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowModify.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowModify.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFFlowModify.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowModify.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowModify.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowModify.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowModify.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        if (!this.instructionsSet)
+            return Collections.emptyList();
+        for (OFInstruction inst : this.instructions) {
+            if (inst instanceof OFInstructionApplyActions) {
+                OFInstructionApplyActions iap = (OFInstructionApplyActions)inst;
+                return iap.getActions();
+            }
+        }
+        return Collections.emptyList();
+    }
+
+    @Override
+    public OFFlowModify.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+        OFInstructionApplyActionsVer13.Builder builder = new OFInstructionApplyActionsVer13.Builder();
+        builder.setActions(actions);
+        this.instructions = Collections.singletonList((OFInstruction)builder.build());
+        this.instructionsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowModify build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowModifyVer13(
+                    xid,
+                    cookie,
+                    cookieMask,
+                    tableId,
+                    idleTimeout,
+                    hardTimeout,
+                    priority,
+                    bufferId,
+                    outPort,
+                    outGroup,
+                    flags,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowModify> {
+        @Override
+        public OFFlowModify readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 14
+            byte type = bb.readByte();
+            if(type != (byte) 0xe)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_MOD(14), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            TableId tableId = TableId.readByte(bb);
+            // fixed value property command == 1
+            short command = bb.readByte();
+            if(command != (short) 0x1)
+                throw new OFParseError("Wrong command: Expected=OFFlowModCommand.MODIFY(1), got="+command);
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            int priority = U16.f(bb.readShort());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer13.readFrom(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer13.READER);
+
+            OFFlowModifyVer13 flowModifyVer13 = new OFFlowModifyVer13(
+                    xid,
+                      cookie,
+                      cookieMask,
+                      tableId,
+                      idleTimeout,
+                      hardTimeout,
+                      priority,
+                      bufferId,
+                      outPort,
+                      outGroup,
+                      flags,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowModifyVer13);
+            return flowModifyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowModifyVer13Funnel FUNNEL = new OFFlowModifyVer13Funnel();
+    static class OFFlowModifyVer13Funnel implements Funnel<OFFlowModifyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowModifyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 14
+            sink.putByte((byte) 0xe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.tableId.putTo(sink);
+            // fixed value property command = 1
+            sink.putShort((short) 0x1);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            sink.putInt(message.priority);
+            message.bufferId.putTo(sink);
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            OFFlowModFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (2 bytes)
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowModifyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowModifyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 14
+            bb.writeByte((byte) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.tableId.writeByte(bb);
+            // fixed value property command = 1
+            bb.writeByte((short) 0x1);
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeInt(message.bufferId.getInt());
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            OFFlowModFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowModifyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowModifyVer13 other = (OFFlowModifyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + priority;
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedReasonSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedReasonSerializerVer13.java
new file mode 100644
index 0000000..da6b10d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedReasonSerializerVer13.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFFlowRemovedReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFFlowRemovedReasonSerializerVer13 {
+
+    public final static byte IDLE_TIMEOUT_VAL = (byte) 0x0;
+    public final static byte HARD_TIMEOUT_VAL = (byte) 0x1;
+    public final static byte DELETE_VAL = (byte) 0x2;
+    public final static byte GROUP_DELETE_VAL = (byte) 0x3;
+
+    public static OFFlowRemovedReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFFlowRemovedReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFFlowRemovedReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFFlowRemovedReason ofWireValue(byte val) {
+        switch(val) {
+            case IDLE_TIMEOUT_VAL:
+                return OFFlowRemovedReason.IDLE_TIMEOUT;
+            case HARD_TIMEOUT_VAL:
+                return OFFlowRemovedReason.HARD_TIMEOUT;
+            case DELETE_VAL:
+                return OFFlowRemovedReason.DELETE;
+            case GROUP_DELETE_VAL:
+                return OFFlowRemovedReason.GROUP_DELETE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFFlowRemovedReason in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFFlowRemovedReason e) {
+        switch(e) {
+            case IDLE_TIMEOUT:
+                return IDLE_TIMEOUT_VAL;
+            case HARD_TIMEOUT:
+                return HARD_TIMEOUT_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case GROUP_DELETE:
+                return GROUP_DELETE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFFlowRemovedReason in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedVer13.java
new file mode 100644
index 0000000..4850443
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedVer13.java
@@ -0,0 +1,825 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowRemovedVer13 implements OFFlowRemoved {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowRemovedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static short DEFAULT_REASON = (short) 0x0;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final U64 cookie;
+    private final int priority;
+    private final short reason;
+    private final TableId tableId;
+    private final long durationSec;
+    private final long durationNsec;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFFlowRemovedVer13 DEFAULT = new OFFlowRemovedVer13(
+        DEFAULT_XID, DEFAULT_COOKIE, DEFAULT_PRIORITY, DEFAULT_REASON, DEFAULT_TABLE_ID, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowRemovedVer13(long xid, U64 cookie, int priority, short reason, TableId tableId, long durationSec, long durationNsec, int idleTimeout, int hardTimeout, U64 packetCount, U64 byteCount, Match match) {
+        this.xid = xid;
+        this.cookie = cookie;
+        this.priority = priority;
+        this.reason = reason;
+        this.tableId = tableId;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFFlowRemoved.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowRemoved.Builder {
+        final OFFlowRemovedVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean reasonSet;
+        private short reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFFlowRemovedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setReason(short reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowRemoved build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                short reason = this.reasonSet ? this.reason : parentMessage.reason;
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFFlowRemovedVer13(
+                    xid,
+                    cookie,
+                    priority,
+                    reason,
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    idleTimeout,
+                    hardTimeout,
+                    packetCount,
+                    byteCount,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowRemoved.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean prioritySet;
+        private int priority;
+        private boolean reasonSet;
+        private short reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.FLOW_REMOVED;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public short getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setReason(short reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowRemoved.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowRemoved build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            short reason = this.reasonSet ? this.reason : DEFAULT_REASON;
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFFlowRemovedVer13(
+                    xid,
+                    cookie,
+                    priority,
+                    reason,
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    idleTimeout,
+                    hardTimeout,
+                    packetCount,
+                    byteCount,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowRemoved> {
+        @Override
+        public OFFlowRemoved readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 11
+            byte type = bb.readByte();
+            if(type != (byte) 0xb)
+                throw new OFParseError("Wrong type: Expected=OFType.FLOW_REMOVED(11), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            U64 cookie = U64.ofRaw(bb.readLong());
+            int priority = U16.f(bb.readShort());
+            short reason = U8.f(bb.readByte());
+            TableId tableId = TableId.readByte(bb);
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+
+            OFFlowRemovedVer13 flowRemovedVer13 = new OFFlowRemovedVer13(
+                    xid,
+                      cookie,
+                      priority,
+                      reason,
+                      tableId,
+                      durationSec,
+                      durationNsec,
+                      idleTimeout,
+                      hardTimeout,
+                      packetCount,
+                      byteCount,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowRemovedVer13);
+            return flowRemovedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowRemovedVer13Funnel FUNNEL = new OFFlowRemovedVer13Funnel();
+    static class OFFlowRemovedVer13Funnel implements Funnel<OFFlowRemovedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowRemovedVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 11
+            sink.putByte((byte) 0xb);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.cookie.putTo(sink);
+            sink.putInt(message.priority);
+            sink.putShort(message.reason);
+            message.tableId.putTo(sink);
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowRemovedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowRemovedVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 11
+            bb.writeByte((byte) 0xb);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeLong(message.cookie.getValue());
+            bb.writeShort(U16.t(message.priority));
+            bb.writeByte(U8.t(message.reason));
+            message.tableId.writeByte(bb);
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            message.match.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowRemovedVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowRemovedVer13 other = (OFFlowRemovedVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if( priority != other.priority)
+            return false;
+        if( reason != other.reason)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + priority;
+        result = prime * result + reason;
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsEntryVer13.java
new file mode 100644
index 0000000..8dccc1d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsEntryVer13.java
@@ -0,0 +1,844 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsEntryVer13 implements OFFlowStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static int DEFAULT_PRIORITY = 0x0;
+        private final static int DEFAULT_IDLE_TIMEOUT = 0x0;
+        private final static int DEFAULT_HARD_TIMEOUT = 0x0;
+        private final static Set<OFFlowModFlags> DEFAULT_FLAGS = ImmutableSet.<OFFlowModFlags>of();
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+        private final static List<OFInstruction> DEFAULT_INSTRUCTIONS = ImmutableList.<OFInstruction>of();
+
+    // OF message fields
+    private final TableId tableId;
+    private final long durationSec;
+    private final long durationNsec;
+    private final int priority;
+    private final int idleTimeout;
+    private final int hardTimeout;
+    private final Set<OFFlowModFlags> flags;
+    private final U64 cookie;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final Match match;
+    private final List<OFInstruction> instructions;
+//
+    // Immutable default instance
+    final static OFFlowStatsEntryVer13 DEFAULT = new OFFlowStatsEntryVer13(
+        DEFAULT_TABLE_ID, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_PRIORITY, DEFAULT_IDLE_TIMEOUT, DEFAULT_HARD_TIMEOUT, DEFAULT_FLAGS, DEFAULT_COOKIE, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_MATCH, DEFAULT_INSTRUCTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsEntryVer13(TableId tableId, long durationSec, long durationNsec, int priority, int idleTimeout, int hardTimeout, Set<OFFlowModFlags> flags, U64 cookie, U64 packetCount, U64 byteCount, Match match, List<OFInstruction> instructions) {
+        this.tableId = tableId;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.priority = priority;
+        this.idleTimeout = idleTimeout;
+        this.hardTimeout = hardTimeout;
+        this.flags = flags;
+        this.cookie = cookie;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.match = match;
+        this.instructions = instructions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFFlowStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsEntry.Builder {
+        final OFFlowStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean prioritySet;
+        private int priority;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+        BuilderWithParent(OFFlowStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFFlowStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                int priority = this.prioritySet ? this.priority : parentMessage.priority;
+                int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : parentMessage.idleTimeout;
+                int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : parentMessage.hardTimeout;
+                Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                List<OFInstruction> instructions = this.instructionsSet ? this.instructions : parentMessage.instructions;
+                if(instructions == null)
+                    throw new NullPointerException("Property instructions must not be null");
+
+                //
+                return new OFFlowStatsEntryVer13(
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    priority,
+                    idleTimeout,
+                    hardTimeout,
+                    flags,
+                    cookie,
+                    packetCount,
+                    byteCount,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean prioritySet;
+        private int priority;
+        private boolean idleTimeoutSet;
+        private int idleTimeout;
+        private boolean hardTimeoutSet;
+        private int hardTimeout;
+        private boolean flagsSet;
+        private Set<OFFlowModFlags> flags;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean matchSet;
+        private Match match;
+        private boolean instructionsSet;
+        private List<OFInstruction> instructions;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public int getPriority() {
+        return priority;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPriority(int priority) {
+        this.priority = priority;
+        this.prioritySet = true;
+        return this;
+    }
+    @Override
+    public int getIdleTimeout() {
+        return idleTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setIdleTimeout(int idleTimeout) {
+        this.idleTimeout = idleTimeout;
+        this.idleTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public int getHardTimeout() {
+        return hardTimeout;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setHardTimeout(int hardTimeout) {
+        this.hardTimeout = hardTimeout;
+        this.hardTimeoutSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public List<OFInstruction> getInstructions() {
+        return instructions;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setInstructions(List<OFInstruction> instructions) {
+        this.instructions = instructions;
+        this.instructionsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setActions(List<OFAction> actions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property actions not supported in version 1.3");
+    }
+    @Override
+    public Set<OFFlowModFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsEntry.Builder setFlags(Set<OFFlowModFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFFlowStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            int priority = this.prioritySet ? this.priority : DEFAULT_PRIORITY;
+            int idleTimeout = this.idleTimeoutSet ? this.idleTimeout : DEFAULT_IDLE_TIMEOUT;
+            int hardTimeout = this.hardTimeoutSet ? this.hardTimeout : DEFAULT_HARD_TIMEOUT;
+            Set<OFFlowModFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            List<OFInstruction> instructions = this.instructionsSet ? this.instructions : DEFAULT_INSTRUCTIONS;
+            if(instructions == null)
+                throw new NullPointerException("Property instructions must not be null");
+
+
+            return new OFFlowStatsEntryVer13(
+                    tableId,
+                    durationSec,
+                    durationNsec,
+                    priority,
+                    idleTimeout,
+                    hardTimeout,
+                    flags,
+                    cookie,
+                    packetCount,
+                    byteCount,
+                    match,
+                    instructions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsEntry> {
+        @Override
+        public OFFlowStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            int priority = U16.f(bb.readShort());
+            int idleTimeout = U16.f(bb.readShort());
+            int hardTimeout = U16.f(bb.readShort());
+            Set<OFFlowModFlags> flags = OFFlowModFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+            List<OFInstruction> instructions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionVer13.READER);
+
+            OFFlowStatsEntryVer13 flowStatsEntryVer13 = new OFFlowStatsEntryVer13(
+                    tableId,
+                      durationSec,
+                      durationNsec,
+                      priority,
+                      idleTimeout,
+                      hardTimeout,
+                      flags,
+                      cookie,
+                      packetCount,
+                      byteCount,
+                      match,
+                      instructions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsEntryVer13);
+            return flowStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsEntryVer13Funnel FUNNEL = new OFFlowStatsEntryVer13Funnel();
+    static class OFFlowStatsEntryVer13Funnel implements Funnel<OFFlowStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsEntryVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            message.tableId.putTo(sink);
+            // skip pad (1 bytes)
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            sink.putInt(message.priority);
+            sink.putInt(message.idleTimeout);
+            sink.putInt(message.hardTimeout);
+            OFFlowModFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.cookie.putTo(sink);
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            message.match.putTo(sink);
+            FunnelUtils.putList(message.instructions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsEntryVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.tableId.writeByte(bb);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            bb.writeShort(U16.t(message.priority));
+            bb.writeShort(U16.t(message.idleTimeout));
+            bb.writeShort(U16.t(message.hardTimeout));
+            OFFlowModFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            message.match.writeTo(bb);
+            ChannelUtils.writeList(bb, message.instructions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsEntryVer13(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("priority=").append(priority);
+        b.append(", ");
+        b.append("idleTimeout=").append(idleTimeout);
+        b.append(", ");
+        b.append("hardTimeout=").append(hardTimeout);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("instructions=").append(instructions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsEntryVer13 other = (OFFlowStatsEntryVer13) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if( priority != other.priority)
+            return false;
+        if( idleTimeout != other.idleTimeout)
+            return false;
+        if( hardTimeout != other.hardTimeout)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (instructions == null) {
+            if (other.instructions != null)
+                return false;
+        } else if (!instructions.equals(other.instructions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + priority;
+        result = prime * result + idleTimeout;
+        result = prime * result + hardTimeout;
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + ((instructions == null) ? 0 : instructions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsReplyVer13.java
new file mode 100644
index 0000000..f6ccc56
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsReplyVer13 implements OFFlowStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFFlowStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFFlowStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFFlowStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFFlowStatsReplyVer13 DEFAULT = new OFFlowStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFFlowStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFFlowStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsReply.Builder {
+        final OFFlowStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFFlowStatsEntry> entries;
+
+        BuilderWithParent(OFFlowStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setEntries(List<OFFlowStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFFlowStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFFlowStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFFlowStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFFlowStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFFlowStatsReply.Builder setEntries(List<OFFlowStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFFlowStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFFlowStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsReply> {
+        @Override
+        public OFFlowStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 1
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x1)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.FLOW(1), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFFlowStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFFlowStatsEntryVer13.READER);
+
+            OFFlowStatsReplyVer13 flowStatsReplyVer13 = new OFFlowStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsReplyVer13);
+            return flowStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsReplyVer13Funnel FUNNEL = new OFFlowStatsReplyVer13Funnel();
+    static class OFFlowStatsReplyVer13Funnel implements Funnel<OFFlowStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 1
+            sink.putShort((short) 0x1);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 1
+            bb.writeShort((short) 0x1);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsReplyVer13 other = (OFFlowStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsRequestVer13.java
new file mode 100644
index 0000000..ebf2cb9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowStatsRequestVer13.java
@@ -0,0 +1,690 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFFlowStatsRequestVer13 implements OFFlowStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFFlowStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static OFPort DEFAULT_OUT_PORT = OFPort.ANY;
+        private final static OFGroup DEFAULT_OUT_GROUP = OFGroup.ANY;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static U64 DEFAULT_COOKIE_MASK = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final TableId tableId;
+    private final OFPort outPort;
+    private final OFGroup outGroup;
+    private final U64 cookie;
+    private final U64 cookieMask;
+    private final Match match;
+//
+    // Immutable default instance
+    final static OFFlowStatsRequestVer13 DEFAULT = new OFFlowStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TABLE_ID, DEFAULT_OUT_PORT, DEFAULT_OUT_GROUP, DEFAULT_COOKIE, DEFAULT_COOKIE_MASK, DEFAULT_MATCH
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFFlowStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, TableId tableId, OFPort outPort, OFGroup outGroup, U64 cookie, U64 cookieMask, Match match) {
+        this.xid = xid;
+        this.flags = flags;
+        this.tableId = tableId;
+        this.outPort = outPort;
+        this.outGroup = outGroup;
+        this.cookie = cookie;
+        this.cookieMask = cookieMask;
+        this.match = match;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+
+
+    public OFFlowStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFFlowStatsRequest.Builder {
+        final OFFlowStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+        BuilderWithParent(OFFlowStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFFlowStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                OFPort outPort = this.outPortSet ? this.outPort : parentMessage.outPort;
+                if(outPort == null)
+                    throw new NullPointerException("Property outPort must not be null");
+                OFGroup outGroup = this.outGroupSet ? this.outGroup : parentMessage.outGroup;
+                if(outGroup == null)
+                    throw new NullPointerException("Property outGroup must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                U64 cookieMask = this.cookieMaskSet ? this.cookieMask : parentMessage.cookieMask;
+                if(cookieMask == null)
+                    throw new NullPointerException("Property cookieMask must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+
+                //
+                return new OFFlowStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+    static class Builder implements OFFlowStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean outPortSet;
+        private OFPort outPort;
+        private boolean outGroupSet;
+        private OFGroup outGroup;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean cookieMaskSet;
+        private U64 cookieMask;
+        private boolean matchSet;
+        private Match match;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.FLOW;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getOutPort() {
+        return outPort;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutPort(OFPort outPort) {
+        this.outPort = outPort;
+        this.outPortSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getOutGroup() {
+        return outGroup;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setOutGroup(OFGroup outGroup) {
+        this.outGroup = outGroup;
+        this.outGroupSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCookieMask() {
+        return cookieMask;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setCookieMask(U64 cookieMask) {
+        this.cookieMask = cookieMask;
+        this.cookieMaskSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFFlowStatsRequest.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFFlowStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            OFPort outPort = this.outPortSet ? this.outPort : DEFAULT_OUT_PORT;
+            if(outPort == null)
+                throw new NullPointerException("Property outPort must not be null");
+            OFGroup outGroup = this.outGroupSet ? this.outGroup : DEFAULT_OUT_GROUP;
+            if(outGroup == null)
+                throw new NullPointerException("Property outGroup must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            U64 cookieMask = this.cookieMaskSet ? this.cookieMask : DEFAULT_COOKIE_MASK;
+            if(cookieMask == null)
+                throw new NullPointerException("Property cookieMask must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+
+
+            return new OFFlowStatsRequestVer13(
+                    xid,
+                    flags,
+                    tableId,
+                    outPort,
+                    outGroup,
+                    cookie,
+                    cookieMask,
+                    match
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFFlowStatsRequest> {
+        @Override
+        public OFFlowStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 1
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x1)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.FLOW(1), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            OFPort outPort = OFPort.read4Bytes(bb);
+            OFGroup outGroup = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            U64 cookieMask = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+
+            OFFlowStatsRequestVer13 flowStatsRequestVer13 = new OFFlowStatsRequestVer13(
+                    xid,
+                      flags,
+                      tableId,
+                      outPort,
+                      outGroup,
+                      cookie,
+                      cookieMask,
+                      match
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", flowStatsRequestVer13);
+            return flowStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFFlowStatsRequestVer13Funnel FUNNEL = new OFFlowStatsRequestVer13Funnel();
+    static class OFFlowStatsRequestVer13Funnel implements Funnel<OFFlowStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFFlowStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 1
+            sink.putShort((short) 0x1);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            message.outPort.putTo(sink);
+            message.outGroup.putTo(sink);
+            // skip pad (4 bytes)
+            message.cookie.putTo(sink);
+            message.cookieMask.putTo(sink);
+            message.match.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFFlowStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFFlowStatsRequestVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 1
+            bb.writeShort((short) 0x1);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            message.outPort.write4Bytes(bb);
+            message.outGroup.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.cookie.getValue());
+            bb.writeLong(message.cookieMask.getValue());
+            message.match.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFFlowStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("outPort=").append(outPort);
+        b.append(", ");
+        b.append("outGroup=").append(outGroup);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("cookieMask=").append(cookieMask);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFFlowStatsRequestVer13 other = (OFFlowStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (outPort == null) {
+            if (other.outPort != null)
+                return false;
+        } else if (!outPort.equals(other.outPort))
+            return false;
+        if (outGroup == null) {
+            if (other.outGroup != null)
+                return false;
+        } else if (!outGroup.equals(other.outGroup))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (cookieMask == null) {
+            if (other.cookieMask != null)
+                return false;
+        } else if (!cookieMask.equals(other.cookieMask))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((outPort == null) ? 0 : outPort.hashCode());
+        result = prime * result + ((outGroup == null) ? 0 : outGroup.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((cookieMask == null) ? 0 : cookieMask.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigReplyVer13.java
new file mode 100644
index 0000000..d24c00c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigReplyVer13.java
@@ -0,0 +1,370 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGetConfigReplyVer13 implements OFGetConfigReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGetConfigReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFConfigFlags> DEFAULT_FLAGS = ImmutableSet.<OFConfigFlags>of();
+        private final static int DEFAULT_MISS_SEND_LEN = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFConfigFlags> flags;
+    private final int missSendLen;
+//
+    // Immutable default instance
+    final static OFGetConfigReplyVer13 DEFAULT = new OFGetConfigReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MISS_SEND_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGetConfigReplyVer13(long xid, Set<OFConfigFlags> flags, int missSendLen) {
+        this.xid = xid;
+        this.flags = flags;
+        this.missSendLen = missSendLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+
+
+    public OFGetConfigReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGetConfigReply.Builder {
+        final OFGetConfigReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+        BuilderWithParent(OFGetConfigReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGetConfigReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFConfigFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int missSendLen = this.missSendLenSet ? this.missSendLen : parentMessage.missSendLen;
+
+                //
+                return new OFGetConfigReplyVer13(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFGetConfigReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFGetConfigReply.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGetConfigReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFConfigFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int missSendLen = this.missSendLenSet ? this.missSendLen : DEFAULT_MISS_SEND_LEN;
+
+
+            return new OFGetConfigReplyVer13(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGetConfigReply> {
+        @Override
+        public OFGetConfigReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 8
+            byte type = bb.readByte();
+            if(type != (byte) 0x8)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REPLY(8), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Set<OFConfigFlags> flags = OFConfigFlagsSerializerVer13.readFrom(bb);
+            int missSendLen = U16.f(bb.readShort());
+
+            OFGetConfigReplyVer13 getConfigReplyVer13 = new OFGetConfigReplyVer13(
+                    xid,
+                      flags,
+                      missSendLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", getConfigReplyVer13);
+            return getConfigReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGetConfigReplyVer13Funnel FUNNEL = new OFGetConfigReplyVer13Funnel();
+    static class OFGetConfigReplyVer13Funnel implements Funnel<OFGetConfigReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGetConfigReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 8
+            sink.putByte((byte) 0x8);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            OFConfigFlagsSerializerVer13.putTo(message.flags, sink);
+            sink.putInt(message.missSendLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGetConfigReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGetConfigReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 8
+            bb.writeByte((byte) 0x8);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            OFConfigFlagsSerializerVer13.writeTo(bb, message.flags);
+            bb.writeShort(U16.t(message.missSendLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGetConfigReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("missSendLen=").append(missSendLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGetConfigReplyVer13 other = (OFGetConfigReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( missSendLen != other.missSendLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + missSendLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigRequestVer13.java
new file mode 100644
index 0000000..d137df4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigRequestVer13.java
@@ -0,0 +1,268 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGetConfigRequestVer13 implements OFGetConfigRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGetConfigRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+//
+    // Immutable default instance
+    final static OFGetConfigRequestVer13 DEFAULT = new OFGetConfigRequestVer13(
+        DEFAULT_XID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGetConfigRequestVer13(long xid) {
+        this.xid = xid;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+
+
+    public OFGetConfigRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGetConfigRequest.Builder {
+        final OFGetConfigRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+        BuilderWithParent(OFGetConfigRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGetConfigRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+
+                //
+                return new OFGetConfigRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+    static class Builder implements OFGetConfigRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGetConfigRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+
+
+            return new OFGetConfigRequestVer13(
+                    xid
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGetConfigRequest> {
+        @Override
+        public OFGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 7
+            byte type = bb.readByte();
+            if(type != (byte) 0x7)
+                throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REQUEST(7), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+
+            OFGetConfigRequestVer13 getConfigRequestVer13 = new OFGetConfigRequestVer13(
+                    xid
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", getConfigRequestVer13);
+            return getConfigRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGetConfigRequestVer13Funnel FUNNEL = new OFGetConfigRequestVer13Funnel();
+    static class OFGetConfigRequestVer13Funnel implements Funnel<OFGetConfigRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGetConfigRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 7
+            sink.putByte((byte) 0x7);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.xid);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGetConfigRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGetConfigRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 7
+            bb.writeByte((byte) 0x7);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.xid));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGetConfigRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGetConfigRequestVer13 other = (OFGetConfigRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupAddVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupAddVer13.java
new file mode 100644
index 0000000..0d4cab6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupAddVer13.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupAddVer13 implements OFGroupAdd {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupAddVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupAddVer13(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupAdd.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupAdd.Builder {
+        final OFGroupAddVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupAddVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupAdd build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupAddVer13(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupAdd.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.ADD;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupAdd.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupAdd build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupAddVer13(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupAdd> {
+        @Override
+        public OFGroupAdd readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 0
+            short command = bb.readShort();
+            if(command != (short) 0x0)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.ADD(0), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer13.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer13.READER);
+
+            OFGroupAddVer13 groupAddVer13 = new OFGroupAddVer13(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupAddVer13);
+            return groupAddVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupAddVer13Funnel FUNNEL = new OFGroupAddVer13Funnel();
+    static class OFGroupAddVer13Funnel implements Funnel<OFGroupAddVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupAddVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 0
+            sink.putShort((short) 0x0);
+            OFGroupTypeSerializerVer13.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupAddVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupAddVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 0
+            bb.writeShort((short) 0x0);
+            OFGroupTypeSerializerVer13.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupAddVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupAddVer13 other = (OFGroupAddVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupCapabilitiesSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupCapabilitiesSerializerVer13.java
new file mode 100644
index 0000000..c8622f5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupCapabilitiesSerializerVer13.java
@@ -0,0 +1,96 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupCapabilities;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFGroupCapabilitiesSerializerVer13 {
+
+    public final static int SELECT_WEIGHT_VAL = 0x1;
+    public final static int SELECT_LIVENESS_VAL = 0x2;
+    public final static int CHAINING_VAL = 0x4;
+    public final static int CHAINING_CHECKS_VAL = 0x8;
+
+    public static Set<OFGroupCapabilities> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFGroupCapabilities> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFGroupCapabilities> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFGroupCapabilities> ofWireValue(int val) {
+        EnumSet<OFGroupCapabilities> set = EnumSet.noneOf(OFGroupCapabilities.class);
+
+        if((val & SELECT_WEIGHT_VAL) != 0)
+            set.add(OFGroupCapabilities.SELECT_WEIGHT);
+        if((val & SELECT_LIVENESS_VAL) != 0)
+            set.add(OFGroupCapabilities.SELECT_LIVENESS);
+        if((val & CHAINING_VAL) != 0)
+            set.add(OFGroupCapabilities.CHAINING);
+        if((val & CHAINING_CHECKS_VAL) != 0)
+            set.add(OFGroupCapabilities.CHAINING_CHECKS);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFGroupCapabilities> set) {
+        int wireValue = 0;
+
+        for(OFGroupCapabilities e: set) {
+            switch(e) {
+                case SELECT_WEIGHT:
+                    wireValue |= SELECT_WEIGHT_VAL;
+                    break;
+                case SELECT_LIVENESS:
+                    wireValue |= SELECT_LIVENESS_VAL;
+                    break;
+                case CHAINING:
+                    wireValue |= CHAINING_VAL;
+                    break;
+                case CHAINING_CHECKS:
+                    wireValue |= CHAINING_CHECKS_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFGroupCapabilities in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDeleteVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDeleteVer13.java
new file mode 100644
index 0000000..c9b62bc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDeleteVer13.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDeleteVer13 implements OFGroupDelete {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDeleteVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDeleteVer13(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupDelete.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDelete.Builder {
+        final OFGroupDeleteVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupDeleteVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDelete build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupDeleteVer13(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDelete.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.DELETE;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDelete.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDelete build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupDeleteVer13(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDelete> {
+        @Override
+        public OFGroupDelete readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 2
+            short command = bb.readShort();
+            if(command != (short) 0x2)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.DELETE(2), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer13.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer13.READER);
+
+            OFGroupDeleteVer13 groupDeleteVer13 = new OFGroupDeleteVer13(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDeleteVer13);
+            return groupDeleteVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDeleteVer13Funnel FUNNEL = new OFGroupDeleteVer13Funnel();
+    static class OFGroupDeleteVer13Funnel implements Funnel<OFGroupDeleteVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDeleteVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 2
+            sink.putShort((short) 0x2);
+            OFGroupTypeSerializerVer13.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDeleteVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDeleteVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 2
+            bb.writeShort((short) 0x2);
+            OFGroupTypeSerializerVer13.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDeleteVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDeleteVer13 other = (OFGroupDeleteVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsEntryVer13.java
new file mode 100644
index 0000000..1a8de91
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsEntryVer13.java
@@ -0,0 +1,360 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsEntryVer13 implements OFGroupDescStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsEntryVer13(OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFGroupDescStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsEntry.Builder {
+        final OFGroupDescStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupDescStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFGroupDescStatsEntry build() {
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupDescStatsEntryVer13(
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsEntry.Builder {
+        // OF message fields
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupDescStatsEntry.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFGroupDescStatsEntry build() {
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupDescStatsEntryVer13(
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsEntry> {
+        @Override
+        public OFGroupDescStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFGroupType groupType = OFGroupTypeSerializerVer13.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer13.READER);
+
+            OFGroupDescStatsEntryVer13 groupDescStatsEntryVer13 = new OFGroupDescStatsEntryVer13(
+                    groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsEntryVer13);
+            return groupDescStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsEntryVer13Funnel FUNNEL = new OFGroupDescStatsEntryVer13Funnel();
+    static class OFGroupDescStatsEntryVer13Funnel implements Funnel<OFGroupDescStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsEntryVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            OFGroupTypeSerializerVer13.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsEntryVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            OFGroupTypeSerializerVer13.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsEntryVer13(");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsEntryVer13 other = (OFGroupDescStatsEntryVer13) obj;
+
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsReplyVer13.java
new file mode 100644
index 0000000..9faeb31
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsReplyVer13 implements OFGroupDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFGroupDescStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFGroupDescStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFGroupDescStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFGroupDescStatsReplyVer13 DEFAULT = new OFGroupDescStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFGroupDescStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFGroupDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsReply.Builder {
+        final OFGroupDescStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupDescStatsEntry> entries;
+
+        BuilderWithParent(OFGroupDescStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setEntries(List<OFGroupDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFGroupDescStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFGroupDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupDescStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupDescStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupDescStatsReply.Builder setEntries(List<OFGroupDescStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFGroupDescStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFGroupDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsReply> {
+        @Override
+        public OFGroupDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 7
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x7)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_DESC(7), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFGroupDescStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFGroupDescStatsEntryVer13.READER);
+
+            OFGroupDescStatsReplyVer13 groupDescStatsReplyVer13 = new OFGroupDescStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsReplyVer13);
+            return groupDescStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsReplyVer13Funnel FUNNEL = new OFGroupDescStatsReplyVer13Funnel();
+    static class OFGroupDescStatsReplyVer13Funnel implements Funnel<OFGroupDescStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 7
+            sink.putShort((short) 0x7);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 7
+            bb.writeShort((short) 0x7);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsReplyVer13 other = (OFGroupDescStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsRequestVer13.java
new file mode 100644
index 0000000..9feb06d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsRequestVer13.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupDescStatsRequestVer13 implements OFGroupDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupDescStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFGroupDescStatsRequestVer13 DEFAULT = new OFGroupDescStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupDescStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFGroupDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupDescStatsRequest.Builder {
+        final OFGroupDescStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFGroupDescStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFGroupDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFGroupDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupDescStatsRequest> {
+        @Override
+        public OFGroupDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 7
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x7)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_DESC(7), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFGroupDescStatsRequestVer13 groupDescStatsRequestVer13 = new OFGroupDescStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupDescStatsRequestVer13);
+            return groupDescStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupDescStatsRequestVer13Funnel FUNNEL = new OFGroupDescStatsRequestVer13Funnel();
+    static class OFGroupDescStatsRequestVer13Funnel implements Funnel<OFGroupDescStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupDescStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 7
+            sink.putShort((short) 0x7);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupDescStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupDescStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 7
+            bb.writeShort((short) 0x7);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupDescStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupDescStatsRequestVer13 other = (OFGroupDescStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupFeaturesStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupFeaturesStatsReplyVer13.java
new file mode 100644
index 0000000..0621a58
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupFeaturesStatsReplyVer13.java
@@ -0,0 +1,821 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupFeaturesStatsReplyVer13 implements OFGroupFeaturesStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupFeaturesStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 56;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static long DEFAULT_TYPES = 0x0L;
+        private final static long DEFAULT_CAPABILITIES = 0x0L;
+        private final static long DEFAULT_MAX_GROUPS_ALL = 0x0L;
+        private final static long DEFAULT_MAX_GROUPS_SELECT = 0x0L;
+        private final static long DEFAULT_MAX_GROUPS_INDIRECT = 0x0L;
+        private final static long DEFAULT_MAX_GROUPS_FF = 0x0L;
+        private final static long DEFAULT_ACTIONS_ALL = 0x0L;
+        private final static long DEFAULT_ACTIONS_SELECT = 0x0L;
+        private final static long DEFAULT_ACTIONS_INDIRECT = 0x0L;
+        private final static long DEFAULT_ACTIONS_FF = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final long types;
+    private final long capabilities;
+    private final long maxGroupsAll;
+    private final long maxGroupsSelect;
+    private final long maxGroupsIndirect;
+    private final long maxGroupsFf;
+    private final long actionsAll;
+    private final long actionsSelect;
+    private final long actionsIndirect;
+    private final long actionsFf;
+//
+    // Immutable default instance
+    final static OFGroupFeaturesStatsReplyVer13 DEFAULT = new OFGroupFeaturesStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_TYPES, DEFAULT_CAPABILITIES, DEFAULT_MAX_GROUPS_ALL, DEFAULT_MAX_GROUPS_SELECT, DEFAULT_MAX_GROUPS_INDIRECT, DEFAULT_MAX_GROUPS_FF, DEFAULT_ACTIONS_ALL, DEFAULT_ACTIONS_SELECT, DEFAULT_ACTIONS_INDIRECT, DEFAULT_ACTIONS_FF
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupFeaturesStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, long types, long capabilities, long maxGroupsAll, long maxGroupsSelect, long maxGroupsIndirect, long maxGroupsFf, long actionsAll, long actionsSelect, long actionsIndirect, long actionsFf) {
+        this.xid = xid;
+        this.flags = flags;
+        this.types = types;
+        this.capabilities = capabilities;
+        this.maxGroupsAll = maxGroupsAll;
+        this.maxGroupsSelect = maxGroupsSelect;
+        this.maxGroupsIndirect = maxGroupsIndirect;
+        this.maxGroupsFf = maxGroupsFf;
+        this.actionsAll = actionsAll;
+        this.actionsSelect = actionsSelect;
+        this.actionsIndirect = actionsIndirect;
+        this.actionsFf = actionsFf;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getTypes() {
+        return types;
+    }
+
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public long getMaxGroupsAll() {
+        return maxGroupsAll;
+    }
+
+    @Override
+    public long getMaxGroupsSelect() {
+        return maxGroupsSelect;
+    }
+
+    @Override
+    public long getMaxGroupsIndirect() {
+        return maxGroupsIndirect;
+    }
+
+    @Override
+    public long getMaxGroupsFf() {
+        return maxGroupsFf;
+    }
+
+    @Override
+    public long getActionsAll() {
+        return actionsAll;
+    }
+
+    @Override
+    public long getActionsSelect() {
+        return actionsSelect;
+    }
+
+    @Override
+    public long getActionsIndirect() {
+        return actionsIndirect;
+    }
+
+    @Override
+    public long getActionsFf() {
+        return actionsFf;
+    }
+
+
+
+    public OFGroupFeaturesStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupFeaturesStatsReply.Builder {
+        final OFGroupFeaturesStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean typesSet;
+        private long types;
+        private boolean capabilitiesSet;
+        private long capabilities;
+        private boolean maxGroupsAllSet;
+        private long maxGroupsAll;
+        private boolean maxGroupsSelectSet;
+        private long maxGroupsSelect;
+        private boolean maxGroupsIndirectSet;
+        private long maxGroupsIndirect;
+        private boolean maxGroupsFfSet;
+        private long maxGroupsFf;
+        private boolean actionsAllSet;
+        private long actionsAll;
+        private boolean actionsSelectSet;
+        private long actionsSelect;
+        private boolean actionsIndirectSet;
+        private long actionsIndirect;
+        private boolean actionsFfSet;
+        private long actionsFf;
+
+        BuilderWithParent(OFGroupFeaturesStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getTypes() {
+        return types;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setTypes(long types) {
+        this.types = types;
+        this.typesSet = true;
+        return this;
+    }
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setCapabilities(long capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsAll() {
+        return maxGroupsAll;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsAll(long maxGroupsAll) {
+        this.maxGroupsAll = maxGroupsAll;
+        this.maxGroupsAllSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsSelect() {
+        return maxGroupsSelect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsSelect(long maxGroupsSelect) {
+        this.maxGroupsSelect = maxGroupsSelect;
+        this.maxGroupsSelectSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsIndirect() {
+        return maxGroupsIndirect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsIndirect(long maxGroupsIndirect) {
+        this.maxGroupsIndirect = maxGroupsIndirect;
+        this.maxGroupsIndirectSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsFf() {
+        return maxGroupsFf;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsFf(long maxGroupsFf) {
+        this.maxGroupsFf = maxGroupsFf;
+        this.maxGroupsFfSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsAll() {
+        return actionsAll;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsAll(long actionsAll) {
+        this.actionsAll = actionsAll;
+        this.actionsAllSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsSelect() {
+        return actionsSelect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsSelect(long actionsSelect) {
+        this.actionsSelect = actionsSelect;
+        this.actionsSelectSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsIndirect() {
+        return actionsIndirect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsIndirect(long actionsIndirect) {
+        this.actionsIndirect = actionsIndirect;
+        this.actionsIndirectSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsFf() {
+        return actionsFf;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsFf(long actionsFf) {
+        this.actionsFf = actionsFf;
+        this.actionsFfSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupFeaturesStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                long types = this.typesSet ? this.types : parentMessage.types;
+                long capabilities = this.capabilitiesSet ? this.capabilities : parentMessage.capabilities;
+                long maxGroupsAll = this.maxGroupsAllSet ? this.maxGroupsAll : parentMessage.maxGroupsAll;
+                long maxGroupsSelect = this.maxGroupsSelectSet ? this.maxGroupsSelect : parentMessage.maxGroupsSelect;
+                long maxGroupsIndirect = this.maxGroupsIndirectSet ? this.maxGroupsIndirect : parentMessage.maxGroupsIndirect;
+                long maxGroupsFf = this.maxGroupsFfSet ? this.maxGroupsFf : parentMessage.maxGroupsFf;
+                long actionsAll = this.actionsAllSet ? this.actionsAll : parentMessage.actionsAll;
+                long actionsSelect = this.actionsSelectSet ? this.actionsSelect : parentMessage.actionsSelect;
+                long actionsIndirect = this.actionsIndirectSet ? this.actionsIndirect : parentMessage.actionsIndirect;
+                long actionsFf = this.actionsFfSet ? this.actionsFf : parentMessage.actionsFf;
+
+                //
+                return new OFGroupFeaturesStatsReplyVer13(
+                    xid,
+                    flags,
+                    types,
+                    capabilities,
+                    maxGroupsAll,
+                    maxGroupsSelect,
+                    maxGroupsIndirect,
+                    maxGroupsFf,
+                    actionsAll,
+                    actionsSelect,
+                    actionsIndirect,
+                    actionsFf
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupFeaturesStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean typesSet;
+        private long types;
+        private boolean capabilitiesSet;
+        private long capabilities;
+        private boolean maxGroupsAllSet;
+        private long maxGroupsAll;
+        private boolean maxGroupsSelectSet;
+        private long maxGroupsSelect;
+        private boolean maxGroupsIndirectSet;
+        private long maxGroupsIndirect;
+        private boolean maxGroupsFfSet;
+        private long maxGroupsFf;
+        private boolean actionsAllSet;
+        private long actionsAll;
+        private boolean actionsSelectSet;
+        private long actionsSelect;
+        private boolean actionsIndirectSet;
+        private long actionsIndirect;
+        private boolean actionsFfSet;
+        private long actionsFf;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getTypes() {
+        return types;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setTypes(long types) {
+        this.types = types;
+        this.typesSet = true;
+        return this;
+    }
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setCapabilities(long capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsAll() {
+        return maxGroupsAll;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsAll(long maxGroupsAll) {
+        this.maxGroupsAll = maxGroupsAll;
+        this.maxGroupsAllSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsSelect() {
+        return maxGroupsSelect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsSelect(long maxGroupsSelect) {
+        this.maxGroupsSelect = maxGroupsSelect;
+        this.maxGroupsSelectSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsIndirect() {
+        return maxGroupsIndirect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsIndirect(long maxGroupsIndirect) {
+        this.maxGroupsIndirect = maxGroupsIndirect;
+        this.maxGroupsIndirectSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxGroupsFf() {
+        return maxGroupsFf;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setMaxGroupsFf(long maxGroupsFf) {
+        this.maxGroupsFf = maxGroupsFf;
+        this.maxGroupsFfSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsAll() {
+        return actionsAll;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsAll(long actionsAll) {
+        this.actionsAll = actionsAll;
+        this.actionsAllSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsSelect() {
+        return actionsSelect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsSelect(long actionsSelect) {
+        this.actionsSelect = actionsSelect;
+        this.actionsSelectSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsIndirect() {
+        return actionsIndirect;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsIndirect(long actionsIndirect) {
+        this.actionsIndirect = actionsIndirect;
+        this.actionsIndirectSet = true;
+        return this;
+    }
+    @Override
+    public long getActionsFf() {
+        return actionsFf;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsReply.Builder setActionsFf(long actionsFf) {
+        this.actionsFf = actionsFf;
+        this.actionsFfSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupFeaturesStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            long types = this.typesSet ? this.types : DEFAULT_TYPES;
+            long capabilities = this.capabilitiesSet ? this.capabilities : DEFAULT_CAPABILITIES;
+            long maxGroupsAll = this.maxGroupsAllSet ? this.maxGroupsAll : DEFAULT_MAX_GROUPS_ALL;
+            long maxGroupsSelect = this.maxGroupsSelectSet ? this.maxGroupsSelect : DEFAULT_MAX_GROUPS_SELECT;
+            long maxGroupsIndirect = this.maxGroupsIndirectSet ? this.maxGroupsIndirect : DEFAULT_MAX_GROUPS_INDIRECT;
+            long maxGroupsFf = this.maxGroupsFfSet ? this.maxGroupsFf : DEFAULT_MAX_GROUPS_FF;
+            long actionsAll = this.actionsAllSet ? this.actionsAll : DEFAULT_ACTIONS_ALL;
+            long actionsSelect = this.actionsSelectSet ? this.actionsSelect : DEFAULT_ACTIONS_SELECT;
+            long actionsIndirect = this.actionsIndirectSet ? this.actionsIndirect : DEFAULT_ACTIONS_INDIRECT;
+            long actionsFf = this.actionsFfSet ? this.actionsFf : DEFAULT_ACTIONS_FF;
+
+
+            return new OFGroupFeaturesStatsReplyVer13(
+                    xid,
+                    flags,
+                    types,
+                    capabilities,
+                    maxGroupsAll,
+                    maxGroupsSelect,
+                    maxGroupsIndirect,
+                    maxGroupsFf,
+                    actionsAll,
+                    actionsSelect,
+                    actionsIndirect,
+                    actionsFf
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupFeaturesStatsReply> {
+        @Override
+        public OFGroupFeaturesStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 56)
+                throw new OFParseError("Wrong length: Expected=56(56), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 8
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x8)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_FEATURES(8), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            long types = U32.f(bb.readInt());
+            long capabilities = U32.f(bb.readInt());
+            long maxGroupsAll = U32.f(bb.readInt());
+            long maxGroupsSelect = U32.f(bb.readInt());
+            long maxGroupsIndirect = U32.f(bb.readInt());
+            long maxGroupsFf = U32.f(bb.readInt());
+            long actionsAll = U32.f(bb.readInt());
+            long actionsSelect = U32.f(bb.readInt());
+            long actionsIndirect = U32.f(bb.readInt());
+            long actionsFf = U32.f(bb.readInt());
+
+            OFGroupFeaturesStatsReplyVer13 groupFeaturesStatsReplyVer13 = new OFGroupFeaturesStatsReplyVer13(
+                    xid,
+                      flags,
+                      types,
+                      capabilities,
+                      maxGroupsAll,
+                      maxGroupsSelect,
+                      maxGroupsIndirect,
+                      maxGroupsFf,
+                      actionsAll,
+                      actionsSelect,
+                      actionsIndirect,
+                      actionsFf
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupFeaturesStatsReplyVer13);
+            return groupFeaturesStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupFeaturesStatsReplyVer13Funnel FUNNEL = new OFGroupFeaturesStatsReplyVer13Funnel();
+    static class OFGroupFeaturesStatsReplyVer13Funnel implements Funnel<OFGroupFeaturesStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupFeaturesStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 56
+            sink.putShort((short) 0x38);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 8
+            sink.putShort((short) 0x8);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            sink.putLong(message.types);
+            sink.putLong(message.capabilities);
+            sink.putLong(message.maxGroupsAll);
+            sink.putLong(message.maxGroupsSelect);
+            sink.putLong(message.maxGroupsIndirect);
+            sink.putLong(message.maxGroupsFf);
+            sink.putLong(message.actionsAll);
+            sink.putLong(message.actionsSelect);
+            sink.putLong(message.actionsIndirect);
+            sink.putLong(message.actionsFf);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupFeaturesStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupFeaturesStatsReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 56
+            bb.writeShort((short) 0x38);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 8
+            bb.writeShort((short) 0x8);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeInt(U32.t(message.types));
+            bb.writeInt(U32.t(message.capabilities));
+            bb.writeInt(U32.t(message.maxGroupsAll));
+            bb.writeInt(U32.t(message.maxGroupsSelect));
+            bb.writeInt(U32.t(message.maxGroupsIndirect));
+            bb.writeInt(U32.t(message.maxGroupsFf));
+            bb.writeInt(U32.t(message.actionsAll));
+            bb.writeInt(U32.t(message.actionsSelect));
+            bb.writeInt(U32.t(message.actionsIndirect));
+            bb.writeInt(U32.t(message.actionsFf));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupFeaturesStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("types=").append(types);
+        b.append(", ");
+        b.append("capabilities=").append(capabilities);
+        b.append(", ");
+        b.append("maxGroupsAll=").append(maxGroupsAll);
+        b.append(", ");
+        b.append("maxGroupsSelect=").append(maxGroupsSelect);
+        b.append(", ");
+        b.append("maxGroupsIndirect=").append(maxGroupsIndirect);
+        b.append(", ");
+        b.append("maxGroupsFf=").append(maxGroupsFf);
+        b.append(", ");
+        b.append("actionsAll=").append(actionsAll);
+        b.append(", ");
+        b.append("actionsSelect=").append(actionsSelect);
+        b.append(", ");
+        b.append("actionsIndirect=").append(actionsIndirect);
+        b.append(", ");
+        b.append("actionsFf=").append(actionsFf);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupFeaturesStatsReplyVer13 other = (OFGroupFeaturesStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( types != other.types)
+            return false;
+        if( capabilities != other.capabilities)
+            return false;
+        if( maxGroupsAll != other.maxGroupsAll)
+            return false;
+        if( maxGroupsSelect != other.maxGroupsSelect)
+            return false;
+        if( maxGroupsIndirect != other.maxGroupsIndirect)
+            return false;
+        if( maxGroupsFf != other.maxGroupsFf)
+            return false;
+        if( actionsAll != other.actionsAll)
+            return false;
+        if( actionsSelect != other.actionsSelect)
+            return false;
+        if( actionsIndirect != other.actionsIndirect)
+            return false;
+        if( actionsFf != other.actionsFf)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime *  (int) (types ^ (types >>> 32));
+        result = prime *  (int) (capabilities ^ (capabilities >>> 32));
+        result = prime *  (int) (maxGroupsAll ^ (maxGroupsAll >>> 32));
+        result = prime *  (int) (maxGroupsSelect ^ (maxGroupsSelect >>> 32));
+        result = prime *  (int) (maxGroupsIndirect ^ (maxGroupsIndirect >>> 32));
+        result = prime *  (int) (maxGroupsFf ^ (maxGroupsFf >>> 32));
+        result = prime *  (int) (actionsAll ^ (actionsAll >>> 32));
+        result = prime *  (int) (actionsSelect ^ (actionsSelect >>> 32));
+        result = prime *  (int) (actionsIndirect ^ (actionsIndirect >>> 32));
+        result = prime *  (int) (actionsFf ^ (actionsFf >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupFeaturesStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupFeaturesStatsRequestVer13.java
new file mode 100644
index 0000000..b181c11
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupFeaturesStatsRequestVer13.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupFeaturesStatsRequestVer13 implements OFGroupFeaturesStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupFeaturesStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFGroupFeaturesStatsRequestVer13 DEFAULT = new OFGroupFeaturesStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupFeaturesStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFGroupFeaturesStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupFeaturesStatsRequest.Builder {
+        final OFGroupFeaturesStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFGroupFeaturesStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupFeaturesStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFGroupFeaturesStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupFeaturesStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupFeaturesStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupFeaturesStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFGroupFeaturesStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupFeaturesStatsRequest> {
+        @Override
+        public OFGroupFeaturesStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 8
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x8)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP_FEATURES(8), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFGroupFeaturesStatsRequestVer13 groupFeaturesStatsRequestVer13 = new OFGroupFeaturesStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupFeaturesStatsRequestVer13);
+            return groupFeaturesStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupFeaturesStatsRequestVer13Funnel FUNNEL = new OFGroupFeaturesStatsRequestVer13Funnel();
+    static class OFGroupFeaturesStatsRequestVer13Funnel implements Funnel<OFGroupFeaturesStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupFeaturesStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 8
+            sink.putShort((short) 0x8);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupFeaturesStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupFeaturesStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 8
+            bb.writeShort((short) 0x8);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupFeaturesStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupFeaturesStatsRequestVer13 other = (OFGroupFeaturesStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModCommandSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModCommandSerializerVer13.java
new file mode 100644
index 0000000..79ca051
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModCommandSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupModCommand;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupModCommandSerializerVer13 {
+
+    public final static short ADD_VAL = (short) 0x0;
+    public final static short MODIFY_VAL = (short) 0x1;
+    public final static short DELETE_VAL = (short) 0x2;
+
+    public static OFGroupModCommand readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupModCommand e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupModCommand e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFGroupModCommand ofWireValue(short val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFGroupModCommand.ADD;
+            case MODIFY_VAL:
+                return OFGroupModCommand.MODIFY;
+            case DELETE_VAL:
+                return OFGroupModCommand.DELETE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupModCommand in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFGroupModCommand e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupModCommand in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..285e3a6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModFailedCodeSerializerVer13.java
@@ -0,0 +1,139 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupModFailedCodeSerializerVer13 {
+
+    public final static short GROUP_EXISTS_VAL = (short) 0x0;
+    public final static short INVALID_GROUP_VAL = (short) 0x1;
+    public final static short WEIGHT_UNSUPPORTED_VAL = (short) 0x2;
+    public final static short OUT_OF_GROUPS_VAL = (short) 0x3;
+    public final static short OUT_OF_BUCKETS_VAL = (short) 0x4;
+    public final static short CHAINING_UNSUPPORTED_VAL = (short) 0x5;
+    public final static short WATCH_UNSUPPORTED_VAL = (short) 0x6;
+    public final static short LOOP_VAL = (short) 0x7;
+    public final static short UNKNOWN_GROUP_VAL = (short) 0x8;
+    public final static short CHAINED_GROUP_VAL = (short) 0x9;
+    public final static short BAD_TYPE_VAL = (short) 0xa;
+    public final static short BAD_COMMAND_VAL = (short) 0xb;
+    public final static short BAD_BUCKET_VAL = (short) 0xc;
+    public final static short BAD_WATCH_VAL = (short) 0xd;
+    public final static short EPERM_VAL = (short) 0xe;
+
+    public static OFGroupModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFGroupModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case GROUP_EXISTS_VAL:
+                return OFGroupModFailedCode.GROUP_EXISTS;
+            case INVALID_GROUP_VAL:
+                return OFGroupModFailedCode.INVALID_GROUP;
+            case WEIGHT_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.WEIGHT_UNSUPPORTED;
+            case OUT_OF_GROUPS_VAL:
+                return OFGroupModFailedCode.OUT_OF_GROUPS;
+            case OUT_OF_BUCKETS_VAL:
+                return OFGroupModFailedCode.OUT_OF_BUCKETS;
+            case CHAINING_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.CHAINING_UNSUPPORTED;
+            case WATCH_UNSUPPORTED_VAL:
+                return OFGroupModFailedCode.WATCH_UNSUPPORTED;
+            case LOOP_VAL:
+                return OFGroupModFailedCode.LOOP;
+            case UNKNOWN_GROUP_VAL:
+                return OFGroupModFailedCode.UNKNOWN_GROUP;
+            case CHAINED_GROUP_VAL:
+                return OFGroupModFailedCode.CHAINED_GROUP;
+            case BAD_TYPE_VAL:
+                return OFGroupModFailedCode.BAD_TYPE;
+            case BAD_COMMAND_VAL:
+                return OFGroupModFailedCode.BAD_COMMAND;
+            case BAD_BUCKET_VAL:
+                return OFGroupModFailedCode.BAD_BUCKET;
+            case BAD_WATCH_VAL:
+                return OFGroupModFailedCode.BAD_WATCH;
+            case EPERM_VAL:
+                return OFGroupModFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupModFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFGroupModFailedCode e) {
+        switch(e) {
+            case GROUP_EXISTS:
+                return GROUP_EXISTS_VAL;
+            case INVALID_GROUP:
+                return INVALID_GROUP_VAL;
+            case WEIGHT_UNSUPPORTED:
+                return WEIGHT_UNSUPPORTED_VAL;
+            case OUT_OF_GROUPS:
+                return OUT_OF_GROUPS_VAL;
+            case OUT_OF_BUCKETS:
+                return OUT_OF_BUCKETS_VAL;
+            case CHAINING_UNSUPPORTED:
+                return CHAINING_UNSUPPORTED_VAL;
+            case WATCH_UNSUPPORTED:
+                return WATCH_UNSUPPORTED_VAL;
+            case LOOP:
+                return LOOP_VAL;
+            case UNKNOWN_GROUP:
+                return UNKNOWN_GROUP_VAL;
+            case CHAINED_GROUP:
+                return CHAINED_GROUP_VAL;
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_COMMAND:
+                return BAD_COMMAND_VAL;
+            case BAD_BUCKET:
+                return BAD_BUCKET_VAL;
+            case BAD_WATCH:
+                return BAD_WATCH_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupModFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModFailedErrorMsgVer13.java
new file mode 100644
index 0000000..17920f1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupModFailedErrorMsgVer13 implements OFGroupModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupModFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupModFailedErrorMsgVer13(long xid, OFGroupModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFGroupModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupModFailedErrorMsg.Builder {
+        final OFGroupModFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFGroupModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFGroupModFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setCode(OFGroupModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFGroupModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFGroupModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.GROUP_MOD_FAILED;
+    }
+
+    @Override
+    public OFGroupModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setCode(OFGroupModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFGroupModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFGroupModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupModFailedErrorMsg> {
+        @Override
+        public OFGroupModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 6
+            short errType = bb.readShort();
+            if(errType != (short) 0x6)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.GROUP_MOD_FAILED(6), got="+errType);
+            OFGroupModFailedCode code = OFGroupModFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFGroupModFailedErrorMsgVer13 groupModFailedErrorMsgVer13 = new OFGroupModFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupModFailedErrorMsgVer13);
+            return groupModFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupModFailedErrorMsgVer13Funnel FUNNEL = new OFGroupModFailedErrorMsgVer13Funnel();
+    static class OFGroupModFailedErrorMsgVer13Funnel implements Funnel<OFGroupModFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupModFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 6
+            sink.putShort((short) 0x6);
+            OFGroupModFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupModFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupModFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 6
+            bb.writeShort((short) 0x6);
+            OFGroupModFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupModFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupModFailedErrorMsgVer13 other = (OFGroupModFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModVer13.java
new file mode 100644
index 0000000..ef92d83
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModVer13.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFGroupModVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFGroupModVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFGroupMod> {
+        @Override
+        public OFGroupMod readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short command = bb.readShort();
+            bb.readerIndex(start);
+            switch(command) {
+               case (short) 0x0:
+                   // discriminator value OFGroupModCommand.ADD=0 for class OFGroupAddVer13
+                   return OFGroupAddVer13.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFGroupModCommand.DELETE=2 for class OFGroupDeleteVer13
+                   return OFGroupDeleteVer13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFGroupModCommand.MODIFY=1 for class OFGroupModifyVer13
+                   return OFGroupModifyVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator command of class OFGroupModVer13: " + command);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModifyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModifyVer13.java
new file mode 100644
index 0000000..bd33104
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModifyVer13.java
@@ -0,0 +1,461 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupModifyVer13 implements OFGroupModify {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupModifyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static List<OFBucket> DEFAULT_BUCKETS = ImmutableList.<OFBucket>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFGroupType groupType;
+    private final OFGroup group;
+    private final List<OFBucket> buckets;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupModifyVer13(long xid, OFGroupType groupType, OFGroup group, List<OFBucket> buckets) {
+        this.xid = xid;
+        this.groupType = groupType;
+        this.group = group;
+        this.buckets = buckets;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+
+
+    public OFGroupModify.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupModify.Builder {
+        final OFGroupModifyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+        BuilderWithParent(OFGroupModifyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupModify.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupModify build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFGroupType groupType = this.groupTypeSet ? this.groupType : parentMessage.groupType;
+                if(groupType == null)
+                    throw new NullPointerException("Property groupType must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                List<OFBucket> buckets = this.bucketsSet ? this.buckets : parentMessage.buckets;
+                if(buckets == null)
+                    throw new NullPointerException("Property buckets must not be null");
+
+                //
+                return new OFGroupModifyVer13(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupModify.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean groupTypeSet;
+        private OFGroupType groupType;
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean bucketsSet;
+        private List<OFBucket> buckets;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.GROUP_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupModify.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFGroupModCommand getCommand() {
+        return OFGroupModCommand.MODIFY;
+    }
+
+    @Override
+    public OFGroupType getGroupType() {
+        return groupType;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroupType(OFGroupType groupType) {
+        this.groupType = groupType;
+        this.groupTypeSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupModify.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucket> getBuckets() {
+        return buckets;
+    }
+
+    @Override
+    public OFGroupModify.Builder setBuckets(List<OFBucket> buckets) {
+        this.buckets = buckets;
+        this.bucketsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupModify build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.groupTypeSet)
+                throw new IllegalStateException("Property groupType doesn't have default value -- must be set");
+            if(groupType == null)
+                throw new NullPointerException("Property groupType must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            List<OFBucket> buckets = this.bucketsSet ? this.buckets : DEFAULT_BUCKETS;
+            if(buckets == null)
+                throw new NullPointerException("Property buckets must not be null");
+
+
+            return new OFGroupModifyVer13(
+                    xid,
+                    groupType,
+                    group,
+                    buckets
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupModify> {
+        @Override
+        public OFGroupModify readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 15
+            byte type = bb.readByte();
+            if(type != (byte) 0xf)
+                throw new OFParseError("Wrong type: Expected=OFType.GROUP_MOD(15), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property command == 1
+            short command = bb.readShort();
+            if(command != (short) 0x1)
+                throw new OFParseError("Wrong command: Expected=OFGroupModCommand.MODIFY(1), got="+command);
+            OFGroupType groupType = OFGroupTypeSerializerVer13.readFrom(bb);
+            // pad: 1 bytes
+            bb.skipBytes(1);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            List<OFBucket> buckets = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketVer13.READER);
+
+            OFGroupModifyVer13 groupModifyVer13 = new OFGroupModifyVer13(
+                    xid,
+                      groupType,
+                      group,
+                      buckets
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupModifyVer13);
+            return groupModifyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupModifyVer13Funnel FUNNEL = new OFGroupModifyVer13Funnel();
+    static class OFGroupModifyVer13Funnel implements Funnel<OFGroupModifyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupModifyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 15
+            sink.putByte((byte) 0xf);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property command = 1
+            sink.putShort((short) 0x1);
+            OFGroupTypeSerializerVer13.putTo(message.groupType, sink);
+            // skip pad (1 bytes)
+            message.group.putTo(sink);
+            FunnelUtils.putList(message.buckets, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupModifyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupModifyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 15
+            bb.writeByte((byte) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property command = 1
+            bb.writeShort((short) 0x1);
+            OFGroupTypeSerializerVer13.writeTo(bb, message.groupType);
+            // pad: 1 bytes
+            bb.writeZero(1);
+            message.group.write4Bytes(bb);
+            ChannelUtils.writeList(bb, message.buckets);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupModifyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("groupType=").append(groupType);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("buckets=").append(buckets);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupModifyVer13 other = (OFGroupModifyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (groupType == null) {
+            if (other.groupType != null)
+                return false;
+        } else if (!groupType.equals(other.groupType))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if (buckets == null) {
+            if (other.buckets != null)
+                return false;
+        } else if (!buckets.equals(other.buckets))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((groupType == null) ? 0 : groupType.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime * result + ((buckets == null) ? 0 : buckets.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsEntryVer13.java
new file mode 100644
index 0000000..02aa30b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsEntryVer13.java
@@ -0,0 +1,564 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsEntryVer13 implements OFGroupStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 40;
+
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+        private final static long DEFAULT_REF_COUNT = 0x0L;
+        private final static U64 DEFAULT_PACKET_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_COUNT = U64.ZERO;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static List<OFBucketCounter> DEFAULT_BUCKET_STATS = ImmutableList.<OFBucketCounter>of();
+
+    // OF message fields
+    private final OFGroup group;
+    private final long refCount;
+    private final U64 packetCount;
+    private final U64 byteCount;
+    private final long durationSec;
+    private final long durationNsec;
+    private final List<OFBucketCounter> bucketStats;
+//
+    // Immutable default instance
+    final static OFGroupStatsEntryVer13 DEFAULT = new OFGroupStatsEntryVer13(
+        DEFAULT_GROUP_ID, DEFAULT_REF_COUNT, DEFAULT_PACKET_COUNT, DEFAULT_BYTE_COUNT, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_BUCKET_STATS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsEntryVer13(OFGroup group, long refCount, U64 packetCount, U64 byteCount, long durationSec, long durationNsec, List<OFBucketCounter> bucketStats) {
+        this.group = group;
+        this.refCount = refCount;
+        this.packetCount = packetCount;
+        this.byteCount = byteCount;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.bucketStats = bucketStats;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFGroupStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsEntry.Builder {
+        final OFGroupStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean refCountSet;
+        private long refCount;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean bucketStatsSet;
+        private List<OFBucketCounter> bucketStats;
+
+        BuilderWithParent(OFGroupStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setRefCount(long refCount) {
+        this.refCount = refCount;
+        this.refCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setBucketStats(List<OFBucketCounter> bucketStats) {
+        this.bucketStats = bucketStats;
+        this.bucketStatsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFGroupStatsEntry build() {
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+                long refCount = this.refCountSet ? this.refCount : parentMessage.refCount;
+                U64 packetCount = this.packetCountSet ? this.packetCount : parentMessage.packetCount;
+                if(packetCount == null)
+                    throw new NullPointerException("Property packetCount must not be null");
+                U64 byteCount = this.byteCountSet ? this.byteCount : parentMessage.byteCount;
+                if(byteCount == null)
+                    throw new NullPointerException("Property byteCount must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                List<OFBucketCounter> bucketStats = this.bucketStatsSet ? this.bucketStats : parentMessage.bucketStats;
+                if(bucketStats == null)
+                    throw new NullPointerException("Property bucketStats must not be null");
+
+                //
+                return new OFGroupStatsEntryVer13(
+                    group,
+                    refCount,
+                    packetCount,
+                    byteCount,
+                    durationSec,
+                    durationNsec,
+                    bucketStats
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsEntry.Builder {
+        // OF message fields
+        private boolean groupSet;
+        private OFGroup group;
+        private boolean refCountSet;
+        private long refCount;
+        private boolean packetCountSet;
+        private U64 packetCount;
+        private boolean byteCountSet;
+        private U64 byteCount;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean bucketStatsSet;
+        private List<OFBucketCounter> bucketStats;
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+    @Override
+    public long getRefCount() {
+        return refCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setRefCount(long refCount) {
+        this.refCount = refCount;
+        this.refCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketCount() {
+        return packetCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setPacketCount(U64 packetCount) {
+        this.packetCount = packetCount;
+        this.packetCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteCount() {
+        return byteCount;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setByteCount(U64 byteCount) {
+        this.byteCount = byteCount;
+        this.byteCountSet = true;
+        return this;
+    }
+    @Override
+    public List<OFBucketCounter> getBucketStats() {
+        return bucketStats;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setBucketStats(List<OFBucketCounter> bucketStats) {
+        this.bucketStats = bucketStats;
+        this.bucketStatsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFGroupStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFGroupStatsEntry build() {
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+            long refCount = this.refCountSet ? this.refCount : DEFAULT_REF_COUNT;
+            U64 packetCount = this.packetCountSet ? this.packetCount : DEFAULT_PACKET_COUNT;
+            if(packetCount == null)
+                throw new NullPointerException("Property packetCount must not be null");
+            U64 byteCount = this.byteCountSet ? this.byteCount : DEFAULT_BYTE_COUNT;
+            if(byteCount == null)
+                throw new NullPointerException("Property byteCount must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            List<OFBucketCounter> bucketStats = this.bucketStatsSet ? this.bucketStats : DEFAULT_BUCKET_STATS;
+            if(bucketStats == null)
+                throw new NullPointerException("Property bucketStats must not be null");
+
+
+            return new OFGroupStatsEntryVer13(
+                    group,
+                    refCount,
+                    packetCount,
+                    byteCount,
+                    durationSec,
+                    durationNsec,
+                    bucketStats
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsEntry> {
+        @Override
+        public OFGroupStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            long refCount = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 packetCount = U64.ofRaw(bb.readLong());
+            U64 byteCount = U64.ofRaw(bb.readLong());
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            List<OFBucketCounter> bucketStats = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFBucketCounterVer13.READER);
+
+            OFGroupStatsEntryVer13 groupStatsEntryVer13 = new OFGroupStatsEntryVer13(
+                    group,
+                      refCount,
+                      packetCount,
+                      byteCount,
+                      durationSec,
+                      durationNsec,
+                      bucketStats
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsEntryVer13);
+            return groupStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsEntryVer13Funnel FUNNEL = new OFGroupStatsEntryVer13Funnel();
+    static class OFGroupStatsEntryVer13Funnel implements Funnel<OFGroupStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsEntryVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            // skip pad (2 bytes)
+            message.group.putTo(sink);
+            sink.putLong(message.refCount);
+            // skip pad (4 bytes)
+            message.packetCount.putTo(sink);
+            message.byteCount.putTo(sink);
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            FunnelUtils.putList(message.bucketStats, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsEntryVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 2 bytes
+            bb.writeZero(2);
+            message.group.write4Bytes(bb);
+            bb.writeInt(U32.t(message.refCount));
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.packetCount.getValue());
+            bb.writeLong(message.byteCount.getValue());
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            ChannelUtils.writeList(bb, message.bucketStats);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsEntryVer13(");
+        b.append("group=").append(group);
+        b.append(", ");
+        b.append("refCount=").append(refCount);
+        b.append(", ");
+        b.append("packetCount=").append(packetCount);
+        b.append(", ");
+        b.append("byteCount=").append(byteCount);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("bucketStats=").append(bucketStats);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsEntryVer13 other = (OFGroupStatsEntryVer13) obj;
+
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        if( refCount != other.refCount)
+            return false;
+        if (packetCount == null) {
+            if (other.packetCount != null)
+                return false;
+        } else if (!packetCount.equals(other.packetCount))
+            return false;
+        if (byteCount == null) {
+            if (other.byteCount != null)
+                return false;
+        } else if (!byteCount.equals(other.byteCount))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if (bucketStats == null) {
+            if (other.bucketStats != null)
+                return false;
+        } else if (!bucketStats.equals(other.bucketStats))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        result = prime *  (int) (refCount ^ (refCount >>> 32));
+        result = prime * result + ((packetCount == null) ? 0 : packetCount.hashCode());
+        result = prime * result + ((byteCount == null) ? 0 : byteCount.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + ((bucketStats == null) ? 0 : bucketStats.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsReplyVer13.java
new file mode 100644
index 0000000..ada614e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsReplyVer13 implements OFGroupStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFGroupStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFGroupStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFGroupStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFGroupStatsReplyVer13 DEFAULT = new OFGroupStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFGroupStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFGroupStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsReply.Builder {
+        final OFGroupStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupStatsEntry> entries;
+
+        BuilderWithParent(OFGroupStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setEntries(List<OFGroupStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFGroupStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFGroupStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFGroupStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFGroupStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFGroupStatsReply.Builder setEntries(List<OFGroupStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFGroupStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFGroupStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsReply> {
+        @Override
+        public OFGroupStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 6
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x6)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP(6), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFGroupStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFGroupStatsEntryVer13.READER);
+
+            OFGroupStatsReplyVer13 groupStatsReplyVer13 = new OFGroupStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsReplyVer13);
+            return groupStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsReplyVer13Funnel FUNNEL = new OFGroupStatsReplyVer13Funnel();
+    static class OFGroupStatsReplyVer13Funnel implements Funnel<OFGroupStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 6
+            sink.putShort((short) 0x6);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 6
+            bb.writeShort((short) 0x6);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsReplyVer13 other = (OFGroupStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsRequestVer13.java
new file mode 100644
index 0000000..beee7ec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsRequestVer13.java
@@ -0,0 +1,410 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFGroupStatsRequestVer13 implements OFGroupStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFGroupStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFGroup DEFAULT_GROUP_ID = OFGroup.ALL;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFGroup group;
+//
+    // Immutable default instance
+    final static OFGroupStatsRequestVer13 DEFAULT = new OFGroupStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_GROUP_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFGroupStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, OFGroup group) {
+        this.xid = xid;
+        this.flags = flags;
+        this.group = group;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+
+
+    public OFGroupStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFGroupStatsRequest.Builder {
+        final OFGroupStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean groupSet;
+        private OFGroup group;
+
+        BuilderWithParent(OFGroupStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFGroupStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFGroup group = this.groupSet ? this.group : parentMessage.group;
+                if(group == null)
+                    throw new NullPointerException("Property group must not be null");
+
+                //
+                return new OFGroupStatsRequestVer13(
+                    xid,
+                    flags,
+                    group
+                );
+        }
+
+    }
+
+    static class Builder implements OFGroupStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean groupSet;
+        private OFGroup group;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.GROUP;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFGroup getGroup() {
+        return group;
+    }
+
+    @Override
+    public OFGroupStatsRequest.Builder setGroup(OFGroup group) {
+        this.group = group;
+        this.groupSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFGroupStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFGroup group = this.groupSet ? this.group : DEFAULT_GROUP_ID;
+            if(group == null)
+                throw new NullPointerException("Property group must not be null");
+
+
+            return new OFGroupStatsRequestVer13(
+                    xid,
+                    flags,
+                    group
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFGroupStatsRequest> {
+        @Override
+        public OFGroupStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 6
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x6)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.GROUP(6), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFGroup group = OFGroup.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFGroupStatsRequestVer13 groupStatsRequestVer13 = new OFGroupStatsRequestVer13(
+                    xid,
+                      flags,
+                      group
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", groupStatsRequestVer13);
+            return groupStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFGroupStatsRequestVer13Funnel FUNNEL = new OFGroupStatsRequestVer13Funnel();
+    static class OFGroupStatsRequestVer13Funnel implements Funnel<OFGroupStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFGroupStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 6
+            sink.putShort((short) 0x6);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.group.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFGroupStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFGroupStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 6
+            bb.writeShort((short) 0x6);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.group.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFGroupStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("group=").append(group);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFGroupStatsRequestVer13 other = (OFGroupStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (group == null) {
+            if (other.group != null)
+                return false;
+        } else if (!group.equals(other.group))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((group == null) ? 0 : group.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupTypeSerializerVer13.java
new file mode 100644
index 0000000..a0e4dcb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupTypeSerializerVer13.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFGroupType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFGroupTypeSerializerVer13 {
+
+    public final static byte ALL_VAL = (byte) 0x0;
+    public final static byte SELECT_VAL = (byte) 0x1;
+    public final static byte INDIRECT_VAL = (byte) 0x2;
+    public final static byte FF_VAL = (byte) 0x3;
+
+    public static OFGroupType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFGroupType e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFGroupType e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFGroupType ofWireValue(byte val) {
+        switch(val) {
+            case ALL_VAL:
+                return OFGroupType.ALL;
+            case SELECT_VAL:
+                return OFGroupType.SELECT;
+            case INDIRECT_VAL:
+                return OFGroupType.INDIRECT;
+            case FF_VAL:
+                return OFGroupType.FF;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFGroupType in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFGroupType e) {
+        switch(e) {
+            case ALL:
+                return ALL_VAL;
+            case SELECT:
+                return SELECT_VAL;
+            case INDIRECT:
+                return INDIRECT_VAL;
+            case FF:
+                return FF_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFGroupType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemTypeSerializerVer13.java
new file mode 100644
index 0000000..2ad95cc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemTypeSerializerVer13.java
@@ -0,0 +1,69 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFHelloElemType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFHelloElemTypeSerializerVer13 {
+
+    public final static short VERSIONBITMAP_VAL = (short) 0x1;
+
+    public static OFHelloElemType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFHelloElemType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFHelloElemType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFHelloElemType ofWireValue(short val) {
+        switch(val) {
+            case VERSIONBITMAP_VAL:
+                return OFHelloElemType.VERSIONBITMAP;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFHelloElemType in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFHelloElemType e) {
+        switch(e) {
+            case VERSIONBITMAP:
+                return VERSIONBITMAP_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFHelloElemType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVer13.java
new file mode 100644
index 0000000..8a0d269
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVer13.java
@@ -0,0 +1,53 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFHelloElemVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFHelloElemVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFHelloElem> {
+        @Override
+        public OFHelloElem readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFHelloElemVersionbitmapVer13
+                   return OFHelloElemVersionbitmapVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFHelloElemVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVersionbitmapVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVersionbitmapVer13.java
new file mode 100644
index 0000000..73d6d29
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVersionbitmapVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloElemVersionbitmapVer13 implements OFHelloElemVersionbitmap {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloElemVersionbitmapVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U32> DEFAULT_BITMAPS = ImmutableList.<U32>of();
+
+    // OF message fields
+    private final List<U32> bitmaps;
+//
+    // Immutable default instance
+    final static OFHelloElemVersionbitmapVer13 DEFAULT = new OFHelloElemVersionbitmapVer13(
+        DEFAULT_BITMAPS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloElemVersionbitmapVer13(List<U32> bitmaps) {
+        this.bitmaps = bitmaps;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public List<U32> getBitmaps() {
+        return bitmaps;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFHelloElemVersionbitmap.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHelloElemVersionbitmap.Builder {
+        final OFHelloElemVersionbitmapVer13 parentMessage;
+
+        // OF message fields
+        private boolean bitmapsSet;
+        private List<U32> bitmaps;
+
+        BuilderWithParent(OFHelloElemVersionbitmapVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public List<U32> getBitmaps() {
+        return bitmaps;
+    }
+
+    @Override
+    public OFHelloElemVersionbitmap.Builder setBitmaps(List<U32> bitmaps) {
+        this.bitmaps = bitmaps;
+        this.bitmapsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFHelloElemVersionbitmap build() {
+                List<U32> bitmaps = this.bitmapsSet ? this.bitmaps : parentMessage.bitmaps;
+                if(bitmaps == null)
+                    throw new NullPointerException("Property bitmaps must not be null");
+
+                //
+                return new OFHelloElemVersionbitmapVer13(
+                    bitmaps
+                );
+        }
+
+    }
+
+    static class Builder implements OFHelloElemVersionbitmap.Builder {
+        // OF message fields
+        private boolean bitmapsSet;
+        private List<U32> bitmaps;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public List<U32> getBitmaps() {
+        return bitmaps;
+    }
+
+    @Override
+    public OFHelloElemVersionbitmap.Builder setBitmaps(List<U32> bitmaps) {
+        this.bitmaps = bitmaps;
+        this.bitmapsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFHelloElemVersionbitmap build() {
+            List<U32> bitmaps = this.bitmapsSet ? this.bitmaps : DEFAULT_BITMAPS;
+            if(bitmaps == null)
+                throw new NullPointerException("Property bitmaps must not be null");
+
+
+            return new OFHelloElemVersionbitmapVer13(
+                    bitmaps
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHelloElemVersionbitmap> {
+        @Override
+        public OFHelloElemVersionbitmap readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U32> bitmaps = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U32.READER);
+
+            OFHelloElemVersionbitmapVer13 helloElemVersionbitmapVer13 = new OFHelloElemVersionbitmapVer13(
+                    bitmaps
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloElemVersionbitmapVer13);
+            return helloElemVersionbitmapVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloElemVersionbitmapVer13Funnel FUNNEL = new OFHelloElemVersionbitmapVer13Funnel();
+    static class OFHelloElemVersionbitmapVer13Funnel implements Funnel<OFHelloElemVersionbitmapVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloElemVersionbitmapVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.bitmaps, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloElemVersionbitmapVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloElemVersionbitmapVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.bitmaps);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloElemVersionbitmapVer13(");
+        b.append("bitmaps=").append(bitmaps);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloElemVersionbitmapVer13 other = (OFHelloElemVersionbitmapVer13) obj;
+
+        if (bitmaps == null) {
+            if (other.bitmaps != null)
+                return false;
+        } else if (!bitmaps.equals(other.bitmaps))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((bitmaps == null) ? 0 : bitmaps.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..dec0f8d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloFailedCodeSerializerVer13.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFHelloFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFHelloFailedCodeSerializerVer13 {
+
+    public final static short INCOMPATIBLE_VAL = (short) 0x0;
+    public final static short EPERM_VAL = (short) 0x1;
+
+    public static OFHelloFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFHelloFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFHelloFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFHelloFailedCode ofWireValue(short val) {
+        switch(val) {
+            case INCOMPATIBLE_VAL:
+                return OFHelloFailedCode.INCOMPATIBLE;
+            case EPERM_VAL:
+                return OFHelloFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFHelloFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFHelloFailedCode e) {
+        switch(e) {
+            case INCOMPATIBLE:
+                return INCOMPATIBLE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFHelloFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloFailedErrorMsgVer13.java
new file mode 100644
index 0000000..b87102c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloFailedErrorMsgVer13 implements OFHelloFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFHelloFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloFailedErrorMsgVer13(long xid, OFHelloFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFHelloFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHelloFailedErrorMsg.Builder {
+        final OFHelloFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFHelloFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFHelloFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setCode(OFHelloFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFHelloFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFHelloFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFHelloFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFHelloFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFHelloFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.HELLO_FAILED;
+    }
+
+    @Override
+    public OFHelloFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setCode(OFHelloFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFHelloFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFHelloFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFHelloFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHelloFailedErrorMsg> {
+        @Override
+        public OFHelloFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 0
+            short errType = bb.readShort();
+            if(errType != (short) 0x0)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.HELLO_FAILED(0), got="+errType);
+            OFHelloFailedCode code = OFHelloFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFHelloFailedErrorMsgVer13 helloFailedErrorMsgVer13 = new OFHelloFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloFailedErrorMsgVer13);
+            return helloFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloFailedErrorMsgVer13Funnel FUNNEL = new OFHelloFailedErrorMsgVer13Funnel();
+    static class OFHelloFailedErrorMsgVer13Funnel implements Funnel<OFHelloFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 0
+            sink.putShort((short) 0x0);
+            OFHelloFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 0
+            bb.writeShort((short) 0x0);
+            OFHelloFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloFailedErrorMsgVer13 other = (OFHelloFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloVer13.java
new file mode 100644
index 0000000..b2db9be
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloVer13.java
@@ -0,0 +1,329 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFHelloVer13 implements OFHello {
+    private static final Logger logger = LoggerFactory.getLogger(OFHelloVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static List<OFHelloElem> DEFAULT_ELEMENTS = ImmutableList.<OFHelloElem>of();
+
+    // OF message fields
+    private final long xid;
+    private final List<OFHelloElem> elements;
+//
+    // Immutable default instance
+    final static OFHelloVer13 DEFAULT = new OFHelloVer13(
+        DEFAULT_XID, DEFAULT_ELEMENTS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFHelloVer13(long xid, List<OFHelloElem> elements) {
+        this.xid = xid;
+        this.elements = elements;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public List<OFHelloElem> getElements() {
+        return elements;
+    }
+
+
+
+    public OFHello.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFHello.Builder {
+        final OFHelloVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean elementsSet;
+        private List<OFHelloElem> elements;
+
+        BuilderWithParent(OFHelloVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHello.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public List<OFHelloElem> getElements() {
+        return elements;
+    }
+
+    @Override
+    public OFHello.Builder setElements(List<OFHelloElem> elements) {
+        this.elements = elements;
+        this.elementsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFHello build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                List<OFHelloElem> elements = this.elementsSet ? this.elements : parentMessage.elements;
+                if(elements == null)
+                    throw new NullPointerException("Property elements must not be null");
+
+                //
+                return new OFHelloVer13(
+                    xid,
+                    elements
+                );
+        }
+
+    }
+
+    static class Builder implements OFHello.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean elementsSet;
+        private List<OFHelloElem> elements;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.HELLO;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFHello.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public List<OFHelloElem> getElements() {
+        return elements;
+    }
+
+    @Override
+    public OFHello.Builder setElements(List<OFHelloElem> elements) {
+        this.elements = elements;
+        this.elementsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFHello build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            List<OFHelloElem> elements = this.elementsSet ? this.elements : DEFAULT_ELEMENTS;
+            if(elements == null)
+                throw new NullPointerException("Property elements must not be null");
+
+
+            return new OFHelloVer13(
+                    xid,
+                    elements
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFHello> {
+        @Override
+        public OFHello readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 0
+            byte type = bb.readByte();
+            if(type != (byte) 0x0)
+                throw new OFParseError("Wrong type: Expected=OFType.HELLO(0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            List<OFHelloElem> elements = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFHelloElemVer13.READER);
+
+            OFHelloVer13 helloVer13 = new OFHelloVer13(
+                    xid,
+                      elements
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", helloVer13);
+            return helloVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFHelloVer13Funnel FUNNEL = new OFHelloVer13Funnel();
+    static class OFHelloVer13Funnel implements Funnel<OFHelloVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFHelloVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 0
+            sink.putByte((byte) 0x0);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            FunnelUtils.putList(message.elements, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFHelloVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFHelloVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 0
+            bb.writeByte((byte) 0x0);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            ChannelUtils.writeList(bb, message.elements);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFHelloVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("elements=").append(elements);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFHelloVer13 other = (OFHelloVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (elements == null) {
+            if (other.elements != null)
+                return false;
+        } else if (!elements.equals(other.elements))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((elements == null) ? 0 : elements.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionApplyActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionApplyActionsVer13.java
new file mode 100644
index 0000000..eb2b93e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionApplyActionsVer13.java
@@ -0,0 +1,279 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionApplyActionsVer13 implements OFInstructionApplyActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionApplyActionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFInstructionApplyActionsVer13 DEFAULT = new OFInstructionApplyActionsVer13(
+        DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionApplyActionsVer13(List<OFAction> actions) {
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFInstructionApplyActions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionApplyActions.Builder {
+        final OFInstructionApplyActionsVer13 parentMessage;
+
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFInstructionApplyActionsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionApplyActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFInstructionApplyActions build() {
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFInstructionApplyActionsVer13(
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionApplyActions.Builder {
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionApplyActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFInstructionApplyActions build() {
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFInstructionApplyActionsVer13(
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionApplyActions> {
+        @Override
+        public OFInstructionApplyActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 4
+            short type = bb.readShort();
+            if(type != (short) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.APPLY_ACTIONS(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer13.READER);
+
+            OFInstructionApplyActionsVer13 instructionApplyActionsVer13 = new OFInstructionApplyActionsVer13(
+                    actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionApplyActionsVer13);
+            return instructionApplyActionsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionApplyActionsVer13Funnel FUNNEL = new OFInstructionApplyActionsVer13Funnel();
+    static class OFInstructionApplyActionsVer13Funnel implements Funnel<OFInstructionApplyActionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionApplyActionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 4
+            sink.putShort((short) 0x4);
+            // FIXME: skip funnel of length
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionApplyActionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionApplyActionsVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 4
+            bb.writeShort((short) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionApplyActionsVer13(");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionApplyActionsVer13 other = (OFInstructionApplyActionsVer13) obj;
+
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnArpOffloadVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnArpOffloadVer13.java
new file mode 100644
index 0000000..4eee210
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnArpOffloadVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnArpOffloadVer13 implements OFInstructionBsnArpOffload {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnArpOffloadVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnArpOffloadVer13 DEFAULT = new OFInstructionBsnArpOffloadVer13(
+
+    );
+
+    final static OFInstructionBsnArpOffloadVer13 INSTANCE = new OFInstructionBsnArpOffloadVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnArpOffloadVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnArpOffload.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnArpOffloadVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnArpOffload> {
+        @Override
+        public OFInstructionBsnArpOffload readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnArpOffloadVer13Funnel FUNNEL = new OFInstructionBsnArpOffloadVer13Funnel();
+    static class OFInstructionBsnArpOffloadVer13Funnel implements Funnel<OFInstructionBsnArpOffloadVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnArpOffloadVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnArpOffloadVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnArpOffloadVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnArpOffloadVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDenyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDenyVer13.java
new file mode 100644
index 0000000..75b9188
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDenyVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnDenyVer13 implements OFInstructionBsnDeny {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnDenyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnDenyVer13 DEFAULT = new OFInstructionBsnDenyVer13(
+
+    );
+
+    final static OFInstructionBsnDenyVer13 INSTANCE = new OFInstructionBsnDenyVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnDenyVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnDeny.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnDenyVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnDeny> {
+        @Override
+        public OFInstructionBsnDeny readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x5L
+            int subtype = bb.readInt();
+            if(subtype != 0x5)
+                throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnDenyVer13Funnel FUNNEL = new OFInstructionBsnDenyVer13Funnel();
+    static class OFInstructionBsnDenyVer13Funnel implements Funnel<OFInstructionBsnDenyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnDenyVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            sink.putInt(0x5);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnDenyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnDenyVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            bb.writeInt(0x5);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnDenyVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDhcpOffloadVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDhcpOffloadVer13.java
new file mode 100644
index 0000000..c46fc78
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDhcpOffloadVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnDhcpOffloadVer13 implements OFInstructionBsnDhcpOffload {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnDhcpOffloadVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnDhcpOffloadVer13 DEFAULT = new OFInstructionBsnDhcpOffloadVer13(
+
+    );
+
+    final static OFInstructionBsnDhcpOffloadVer13 INSTANCE = new OFInstructionBsnDhcpOffloadVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnDhcpOffloadVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnDhcpOffload.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnDhcpOffloadVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnDhcpOffload> {
+        @Override
+        public OFInstructionBsnDhcpOffload readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnDhcpOffloadVer13Funnel FUNNEL = new OFInstructionBsnDhcpOffloadVer13Funnel();
+    static class OFInstructionBsnDhcpOffloadVer13Funnel implements Funnel<OFInstructionBsnDhcpOffloadVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnDhcpOffloadVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnDhcpOffloadVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnDhcpOffloadVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnDhcpOffloadVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSplitHorizonCheckVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSplitHorizonCheckVer13.java
new file mode 100644
index 0000000..e69c09b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSplitHorizonCheckVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnDisableSplitHorizonCheckVer13 implements OFInstructionBsnDisableSplitHorizonCheck {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnDisableSplitHorizonCheckVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnDisableSplitHorizonCheckVer13 DEFAULT = new OFInstructionBsnDisableSplitHorizonCheckVer13(
+
+    );
+
+    final static OFInstructionBsnDisableSplitHorizonCheckVer13 INSTANCE = new OFInstructionBsnDisableSplitHorizonCheckVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnDisableSplitHorizonCheckVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnDisableSplitHorizonCheck.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableSplitHorizonCheckVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnDisableSplitHorizonCheck> {
+        @Override
+        public OFInstructionBsnDisableSplitHorizonCheck readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3L
+            int subtype = bb.readInt();
+            if(subtype != 0x3)
+                throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnDisableSplitHorizonCheckVer13Funnel FUNNEL = new OFInstructionBsnDisableSplitHorizonCheckVer13Funnel();
+    static class OFInstructionBsnDisableSplitHorizonCheckVer13Funnel implements Funnel<OFInstructionBsnDisableSplitHorizonCheckVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnDisableSplitHorizonCheckVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            sink.putInt(0x3);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnDisableSplitHorizonCheckVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnDisableSplitHorizonCheckVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            bb.writeInt(0x3);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnDisableSplitHorizonCheckVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSrcMacCheckVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSrcMacCheckVer13.java
new file mode 100644
index 0000000..868042f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSrcMacCheckVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnDisableSrcMacCheckVer13 implements OFInstructionBsnDisableSrcMacCheck {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnDisableSrcMacCheckVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnDisableSrcMacCheckVer13 DEFAULT = new OFInstructionBsnDisableSrcMacCheckVer13(
+
+    );
+
+    final static OFInstructionBsnDisableSrcMacCheckVer13 INSTANCE = new OFInstructionBsnDisableSrcMacCheckVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnDisableSrcMacCheckVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x0L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnDisableSrcMacCheck.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableSrcMacCheckVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnDisableSrcMacCheck> {
+        @Override
+        public OFInstructionBsnDisableSrcMacCheck readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x0L
+            int subtype = bb.readInt();
+            if(subtype != 0x0)
+                throw new OFParseError("Wrong subtype: Expected=0x0L(0x0L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnDisableSrcMacCheckVer13Funnel FUNNEL = new OFInstructionBsnDisableSrcMacCheckVer13Funnel();
+    static class OFInstructionBsnDisableSrcMacCheckVer13Funnel implements Funnel<OFInstructionBsnDisableSrcMacCheckVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnDisableSrcMacCheckVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x0L
+            sink.putInt(0x0);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnDisableSrcMacCheckVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnDisableSrcMacCheckVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x0L
+            bb.writeInt(0x0);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnDisableSrcMacCheckVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableVlanCountersVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableVlanCountersVer13.java
new file mode 100644
index 0000000..9e83b3b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableVlanCountersVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnDisableVlanCountersVer13 implements OFInstructionBsnDisableVlanCounters {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnDisableVlanCountersVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnDisableVlanCountersVer13 DEFAULT = new OFInstructionBsnDisableVlanCountersVer13(
+
+    );
+
+    final static OFInstructionBsnDisableVlanCountersVer13 INSTANCE = new OFInstructionBsnDisableVlanCountersVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnDisableVlanCountersVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnDisableVlanCounters.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnDisableVlanCountersVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnDisableVlanCounters> {
+        @Override
+        public OFInstructionBsnDisableVlanCounters readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x9L
+            int subtype = bb.readInt();
+            if(subtype != 0x9)
+                throw new OFParseError("Wrong subtype: Expected=0x9L(0x9L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnDisableVlanCountersVer13Funnel FUNNEL = new OFInstructionBsnDisableVlanCountersVer13Funnel();
+    static class OFInstructionBsnDisableVlanCountersVer13Funnel implements Funnel<OFInstructionBsnDisableVlanCountersVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnDisableVlanCountersVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            sink.putInt(0x9);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnDisableVlanCountersVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnDisableVlanCountersVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            bb.writeInt(0x9);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnDisableVlanCountersVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPacketOfDeathVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPacketOfDeathVer13.java
new file mode 100644
index 0000000..fd1b02d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPacketOfDeathVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnPacketOfDeathVer13 implements OFInstructionBsnPacketOfDeath {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnPacketOfDeathVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnPacketOfDeathVer13 DEFAULT = new OFInstructionBsnPacketOfDeathVer13(
+
+    );
+
+    final static OFInstructionBsnPacketOfDeathVer13 INSTANCE = new OFInstructionBsnPacketOfDeathVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnPacketOfDeathVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnPacketOfDeath.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnPacketOfDeathVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnPacketOfDeath> {
+        @Override
+        public OFInstructionBsnPacketOfDeath readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x6L
+            int subtype = bb.readInt();
+            if(subtype != 0x6)
+                throw new OFParseError("Wrong subtype: Expected=0x6L(0x6L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnPacketOfDeathVer13Funnel FUNNEL = new OFInstructionBsnPacketOfDeathVer13Funnel();
+    static class OFInstructionBsnPacketOfDeathVer13Funnel implements Funnel<OFInstructionBsnPacketOfDeathVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnPacketOfDeathVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            sink.putInt(0x6);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnPacketOfDeathVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnPacketOfDeathVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            bb.writeInt(0x6);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnPacketOfDeathVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPermitVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPermitVer13.java
new file mode 100644
index 0000000..4252f28
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPermitVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnPermitVer13 implements OFInstructionBsnPermit {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnPermitVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnPermitVer13 DEFAULT = new OFInstructionBsnPermitVer13(
+
+    );
+
+    final static OFInstructionBsnPermitVer13 INSTANCE = new OFInstructionBsnPermitVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnPermitVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnPermit.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnPermitVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnPermit> {
+        @Override
+        public OFInstructionBsnPermit readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnPermitVer13Funnel FUNNEL = new OFInstructionBsnPermitVer13Funnel();
+    static class OFInstructionBsnPermitVer13Funnel implements Funnel<OFInstructionBsnPermitVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnPermitVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnPermitVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnPermitVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnPermitVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPrioritizePdusVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPrioritizePdusVer13.java
new file mode 100644
index 0000000..9079a8d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnPrioritizePdusVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnPrioritizePdusVer13 implements OFInstructionBsnPrioritizePdus {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnPrioritizePdusVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnPrioritizePdusVer13 DEFAULT = new OFInstructionBsnPrioritizePdusVer13(
+
+    );
+
+    final static OFInstructionBsnPrioritizePdusVer13 INSTANCE = new OFInstructionBsnPrioritizePdusVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnPrioritizePdusVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnPrioritizePdus.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnPrioritizePdusVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnPrioritizePdus> {
+        @Override
+        public OFInstructionBsnPrioritizePdus readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x7L
+            int subtype = bb.readInt();
+            if(subtype != 0x7)
+                throw new OFParseError("Wrong subtype: Expected=0x7L(0x7L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnPrioritizePdusVer13Funnel FUNNEL = new OFInstructionBsnPrioritizePdusVer13Funnel();
+    static class OFInstructionBsnPrioritizePdusVer13Funnel implements Funnel<OFInstructionBsnPrioritizePdusVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnPrioritizePdusVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            sink.putInt(0x7);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnPrioritizePdusVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnPrioritizePdusVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            bb.writeInt(0x7);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnPrioritizePdusVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnRequireVlanXlateVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnRequireVlanXlateVer13.java
new file mode 100644
index 0000000..efd15dc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnRequireVlanXlateVer13.java
@@ -0,0 +1,187 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionBsnRequireVlanXlateVer13 implements OFInstructionBsnRequireVlanXlate {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionBsnRequireVlanXlateVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionBsnRequireVlanXlateVer13 DEFAULT = new OFInstructionBsnRequireVlanXlateVer13(
+
+    );
+
+    final static OFInstructionBsnRequireVlanXlateVer13 INSTANCE = new OFInstructionBsnRequireVlanXlateVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionBsnRequireVlanXlateVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionBsnRequireVlanXlate.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionBsnRequireVlanXlateVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionBsnRequireVlanXlate> {
+        @Override
+        public OFInstructionBsnRequireVlanXlate readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x8L
+            int subtype = bb.readInt();
+            if(subtype != 0x8)
+                throw new OFParseError("Wrong subtype: Expected=0x8L(0x8L), got="+subtype);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionBsnRequireVlanXlateVer13Funnel FUNNEL = new OFInstructionBsnRequireVlanXlateVer13Funnel();
+    static class OFInstructionBsnRequireVlanXlateVer13Funnel implements Funnel<OFInstructionBsnRequireVlanXlateVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionBsnRequireVlanXlateVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            sink.putInt(0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionBsnRequireVlanXlateVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionBsnRequireVlanXlateVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            bb.writeInt(0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionBsnRequireVlanXlateVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnVer13.java
new file mode 100644
index 0000000..5ec798b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnVer13.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionBsnVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFInstructionBsnVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstructionBsn> {
+        @Override
+        public OFInstructionBsn readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFInstructionBsnArpOffloadVer13
+                   return OFInstructionBsnArpOffloadVer13.READER.readFrom(bb);
+               case 0x5:
+                   // discriminator value 0x5L=0x5L for class OFInstructionBsnDenyVer13
+                   return OFInstructionBsnDenyVer13.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFInstructionBsnDhcpOffloadVer13
+                   return OFInstructionBsnDhcpOffloadVer13.READER.readFrom(bb);
+               case 0x3:
+                   // discriminator value 0x3L=0x3L for class OFInstructionBsnDisableSplitHorizonCheckVer13
+                   return OFInstructionBsnDisableSplitHorizonCheckVer13.READER.readFrom(bb);
+               case 0x0:
+                   // discriminator value 0x0L=0x0L for class OFInstructionBsnDisableSrcMacCheckVer13
+                   return OFInstructionBsnDisableSrcMacCheckVer13.READER.readFrom(bb);
+               case 0x9:
+                   // discriminator value 0x9L=0x9L for class OFInstructionBsnDisableVlanCountersVer13
+                   return OFInstructionBsnDisableVlanCountersVer13.READER.readFrom(bb);
+               case 0x6:
+                   // discriminator value 0x6L=0x6L for class OFInstructionBsnPacketOfDeathVer13
+                   return OFInstructionBsnPacketOfDeathVer13.READER.readFrom(bb);
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFInstructionBsnPermitVer13
+                   return OFInstructionBsnPermitVer13.READER.readFrom(bb);
+               case 0x7:
+                   // discriminator value 0x7L=0x7L for class OFInstructionBsnPrioritizePdusVer13
+                   return OFInstructionBsnPrioritizePdusVer13.READER.readFrom(bb);
+               case 0x8:
+                   // discriminator value 0x8L=0x8L for class OFInstructionBsnRequireVlanXlateVer13
+                   return OFInstructionBsnRequireVlanXlateVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFInstructionBsnVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionClearActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionClearActionsVer13.java
new file mode 100644
index 0000000..f35370b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionClearActionsVer13.java
@@ -0,0 +1,161 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionClearActionsVer13 implements OFInstructionClearActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionClearActionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionClearActionsVer13 DEFAULT = new OFInstructionClearActionsVer13(
+
+    );
+
+    final static OFInstructionClearActionsVer13 INSTANCE = new OFInstructionClearActionsVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionClearActionsVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.CLEAR_ACTIONS;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionClearActions.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionClearActionsVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionClearActions> {
+        @Override
+        public OFInstructionClearActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 5
+            short type = bb.readShort();
+            if(type != (short) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.CLEAR_ACTIONS(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionClearActionsVer13Funnel FUNNEL = new OFInstructionClearActionsVer13Funnel();
+    static class OFInstructionClearActionsVer13Funnel implements Funnel<OFInstructionClearActionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionClearActionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 5
+            sink.putShort((short) 0x5);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionClearActionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionClearActionsVer13 message) {
+            // fixed value property type = 5
+            bb.writeShort((short) 0x5);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionClearActionsVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionExperimenterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionExperimenterVer13.java
new file mode 100644
index 0000000..54b3c0d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionExperimenterVer13.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionExperimenterVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFInstructionExperimenterVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstructionExperimenter> {
+        @Override
+        public OFInstructionExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFInstructionBsnVer13
+                   return OFInstructionBsnVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFInstructionExperimenterVer13: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionGotoTableVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionGotoTableVer13.java
new file mode 100644
index 0000000..d6fa64c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionGotoTableVer13.java
@@ -0,0 +1,272 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionGotoTableVer13 implements OFInstructionGotoTable {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionGotoTableVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+
+    // OF message fields
+    private final TableId tableId;
+//
+    // Immutable default instance
+    final static OFInstructionGotoTableVer13 DEFAULT = new OFInstructionGotoTableVer13(
+        DEFAULT_TABLE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionGotoTableVer13(TableId tableId) {
+        this.tableId = tableId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFInstructionGotoTable.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionGotoTable.Builder {
+        final OFInstructionGotoTableVer13 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+
+        BuilderWithParent(OFInstructionGotoTableVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFInstructionGotoTable.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFInstructionGotoTable build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+
+                //
+                return new OFInstructionGotoTableVer13(
+                    tableId
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionGotoTable.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFInstructionGotoTable.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFInstructionGotoTable build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+
+
+            return new OFInstructionGotoTableVer13(
+                    tableId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionGotoTable> {
+        @Override
+        public OFInstructionGotoTable readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.GOTO_TABLE(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFInstructionGotoTableVer13 instructionGotoTableVer13 = new OFInstructionGotoTableVer13(
+                    tableId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionGotoTableVer13);
+            return instructionGotoTableVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionGotoTableVer13Funnel FUNNEL = new OFInstructionGotoTableVer13Funnel();
+    static class OFInstructionGotoTableVer13Funnel implements Funnel<OFInstructionGotoTableVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionGotoTableVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionGotoTableVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionGotoTableVer13 message) {
+            // fixed value property type = 1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionGotoTableVer13(");
+        b.append("tableId=").append(tableId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionGotoTableVer13 other = (OFInstructionGotoTableVer13) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdApplyActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdApplyActionsVer13.java
new file mode 100644
index 0000000..07c0144
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdApplyActionsVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdApplyActionsVer13 implements OFInstructionIdApplyActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdApplyActionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdApplyActionsVer13 DEFAULT = new OFInstructionIdApplyActionsVer13(
+
+    );
+
+    final static OFInstructionIdApplyActionsVer13 INSTANCE = new OFInstructionIdApplyActionsVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdApplyActionsVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.APPLY_ACTIONS;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdApplyActions.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdApplyActionsVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdApplyActions> {
+        @Override
+        public OFInstructionIdApplyActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 4
+            short type = bb.readShort();
+            if(type != (short) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.APPLY_ACTIONS(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdApplyActionsVer13Funnel FUNNEL = new OFInstructionIdApplyActionsVer13Funnel();
+    static class OFInstructionIdApplyActionsVer13Funnel implements Funnel<OFInstructionIdApplyActionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdApplyActionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 4
+            sink.putShort((short) 0x4);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdApplyActionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdApplyActionsVer13 message) {
+            // fixed value property type = 4
+            bb.writeShort((short) 0x4);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdApplyActionsVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnArpOffloadVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnArpOffloadVer13.java
new file mode 100644
index 0000000..f6e2cbb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnArpOffloadVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnArpOffloadVer13 implements OFInstructionIdBsnArpOffload {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnArpOffloadVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnArpOffloadVer13 DEFAULT = new OFInstructionIdBsnArpOffloadVer13(
+
+    );
+
+    final static OFInstructionIdBsnArpOffloadVer13 INSTANCE = new OFInstructionIdBsnArpOffloadVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnArpOffloadVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x1L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnArpOffload.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnArpOffloadVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnArpOffload> {
+        @Override
+        public OFInstructionIdBsnArpOffload readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x1L
+            int subtype = bb.readInt();
+            if(subtype != 0x1)
+                throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnArpOffloadVer13Funnel FUNNEL = new OFInstructionIdBsnArpOffloadVer13Funnel();
+    static class OFInstructionIdBsnArpOffloadVer13Funnel implements Funnel<OFInstructionIdBsnArpOffloadVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnArpOffloadVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            sink.putInt(0x1);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnArpOffloadVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnArpOffloadVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x1L
+            bb.writeInt(0x1);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnArpOffloadVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDenyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDenyVer13.java
new file mode 100644
index 0000000..5d2ada3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDenyVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnDenyVer13 implements OFInstructionIdBsnDeny {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnDenyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnDenyVer13 DEFAULT = new OFInstructionIdBsnDenyVer13(
+
+    );
+
+    final static OFInstructionIdBsnDenyVer13 INSTANCE = new OFInstructionIdBsnDenyVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnDenyVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x5L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnDeny.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDenyVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnDeny> {
+        @Override
+        public OFInstructionIdBsnDeny readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x5L
+            int subtype = bb.readInt();
+            if(subtype != 0x5)
+                throw new OFParseError("Wrong subtype: Expected=0x5L(0x5L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnDenyVer13Funnel FUNNEL = new OFInstructionIdBsnDenyVer13Funnel();
+    static class OFInstructionIdBsnDenyVer13Funnel implements Funnel<OFInstructionIdBsnDenyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnDenyVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            sink.putInt(0x5);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnDenyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnDenyVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x5L
+            bb.writeInt(0x5);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnDenyVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDhcpOffloadVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDhcpOffloadVer13.java
new file mode 100644
index 0000000..e0338b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDhcpOffloadVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnDhcpOffloadVer13 implements OFInstructionIdBsnDhcpOffload {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnDhcpOffloadVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnDhcpOffloadVer13 DEFAULT = new OFInstructionIdBsnDhcpOffloadVer13(
+
+    );
+
+    final static OFInstructionIdBsnDhcpOffloadVer13 INSTANCE = new OFInstructionIdBsnDhcpOffloadVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnDhcpOffloadVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x2L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnDhcpOffload.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDhcpOffloadVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnDhcpOffload> {
+        @Override
+        public OFInstructionIdBsnDhcpOffload readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x2L
+            int subtype = bb.readInt();
+            if(subtype != 0x2)
+                throw new OFParseError("Wrong subtype: Expected=0x2L(0x2L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnDhcpOffloadVer13Funnel FUNNEL = new OFInstructionIdBsnDhcpOffloadVer13Funnel();
+    static class OFInstructionIdBsnDhcpOffloadVer13Funnel implements Funnel<OFInstructionIdBsnDhcpOffloadVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnDhcpOffloadVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            sink.putInt(0x2);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnDhcpOffloadVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnDhcpOffloadVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x2L
+            bb.writeInt(0x2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnDhcpOffloadVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableSplitHorizonCheckVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableSplitHorizonCheckVer13.java
new file mode 100644
index 0000000..c207e09
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableSplitHorizonCheckVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnDisableSplitHorizonCheckVer13 implements OFInstructionIdBsnDisableSplitHorizonCheck {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnDisableSplitHorizonCheckVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnDisableSplitHorizonCheckVer13 DEFAULT = new OFInstructionIdBsnDisableSplitHorizonCheckVer13(
+
+    );
+
+    final static OFInstructionIdBsnDisableSplitHorizonCheckVer13 INSTANCE = new OFInstructionIdBsnDisableSplitHorizonCheckVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnDisableSplitHorizonCheckVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x3L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnDisableSplitHorizonCheck.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableSplitHorizonCheckVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnDisableSplitHorizonCheck> {
+        @Override
+        public OFInstructionIdBsnDisableSplitHorizonCheck readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x3L
+            int subtype = bb.readInt();
+            if(subtype != 0x3)
+                throw new OFParseError("Wrong subtype: Expected=0x3L(0x3L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnDisableSplitHorizonCheckVer13Funnel FUNNEL = new OFInstructionIdBsnDisableSplitHorizonCheckVer13Funnel();
+    static class OFInstructionIdBsnDisableSplitHorizonCheckVer13Funnel implements Funnel<OFInstructionIdBsnDisableSplitHorizonCheckVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnDisableSplitHorizonCheckVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            sink.putInt(0x3);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnDisableSplitHorizonCheckVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnDisableSplitHorizonCheckVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x3L
+            bb.writeInt(0x3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnDisableSplitHorizonCheckVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableSrcMacCheckVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableSrcMacCheckVer13.java
new file mode 100644
index 0000000..e8c1ab9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableSrcMacCheckVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnDisableSrcMacCheckVer13 implements OFInstructionIdBsnDisableSrcMacCheck {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnDisableSrcMacCheckVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnDisableSrcMacCheckVer13 DEFAULT = new OFInstructionIdBsnDisableSrcMacCheckVer13(
+
+    );
+
+    final static OFInstructionIdBsnDisableSrcMacCheckVer13 INSTANCE = new OFInstructionIdBsnDisableSrcMacCheckVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnDisableSrcMacCheckVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x0L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnDisableSrcMacCheck.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableSrcMacCheckVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnDisableSrcMacCheck> {
+        @Override
+        public OFInstructionIdBsnDisableSrcMacCheck readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x0L
+            int subtype = bb.readInt();
+            if(subtype != 0x0)
+                throw new OFParseError("Wrong subtype: Expected=0x0L(0x0L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnDisableSrcMacCheckVer13Funnel FUNNEL = new OFInstructionIdBsnDisableSrcMacCheckVer13Funnel();
+    static class OFInstructionIdBsnDisableSrcMacCheckVer13Funnel implements Funnel<OFInstructionIdBsnDisableSrcMacCheckVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnDisableSrcMacCheckVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x0L
+            sink.putInt(0x0);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnDisableSrcMacCheckVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnDisableSrcMacCheckVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x0L
+            bb.writeInt(0x0);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnDisableSrcMacCheckVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableVlanCountersVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableVlanCountersVer13.java
new file mode 100644
index 0000000..1ab7147
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnDisableVlanCountersVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnDisableVlanCountersVer13 implements OFInstructionIdBsnDisableVlanCounters {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnDisableVlanCountersVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnDisableVlanCountersVer13 DEFAULT = new OFInstructionIdBsnDisableVlanCountersVer13(
+
+    );
+
+    final static OFInstructionIdBsnDisableVlanCountersVer13 INSTANCE = new OFInstructionIdBsnDisableVlanCountersVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnDisableVlanCountersVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x9L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnDisableVlanCounters.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnDisableVlanCountersVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnDisableVlanCounters> {
+        @Override
+        public OFInstructionIdBsnDisableVlanCounters readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x9L
+            int subtype = bb.readInt();
+            if(subtype != 0x9)
+                throw new OFParseError("Wrong subtype: Expected=0x9L(0x9L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnDisableVlanCountersVer13Funnel FUNNEL = new OFInstructionIdBsnDisableVlanCountersVer13Funnel();
+    static class OFInstructionIdBsnDisableVlanCountersVer13Funnel implements Funnel<OFInstructionIdBsnDisableVlanCountersVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnDisableVlanCountersVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            sink.putInt(0x9);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnDisableVlanCountersVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnDisableVlanCountersVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x9L
+            bb.writeInt(0x9);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnDisableVlanCountersVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPacketOfDeathVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPacketOfDeathVer13.java
new file mode 100644
index 0000000..0e8e305
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPacketOfDeathVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnPacketOfDeathVer13 implements OFInstructionIdBsnPacketOfDeath {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnPacketOfDeathVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnPacketOfDeathVer13 DEFAULT = new OFInstructionIdBsnPacketOfDeathVer13(
+
+    );
+
+    final static OFInstructionIdBsnPacketOfDeathVer13 INSTANCE = new OFInstructionIdBsnPacketOfDeathVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnPacketOfDeathVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x6L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnPacketOfDeath.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPacketOfDeathVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnPacketOfDeath> {
+        @Override
+        public OFInstructionIdBsnPacketOfDeath readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x6L
+            int subtype = bb.readInt();
+            if(subtype != 0x6)
+                throw new OFParseError("Wrong subtype: Expected=0x6L(0x6L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnPacketOfDeathVer13Funnel FUNNEL = new OFInstructionIdBsnPacketOfDeathVer13Funnel();
+    static class OFInstructionIdBsnPacketOfDeathVer13Funnel implements Funnel<OFInstructionIdBsnPacketOfDeathVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnPacketOfDeathVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            sink.putInt(0x6);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnPacketOfDeathVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnPacketOfDeathVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x6L
+            bb.writeInt(0x6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnPacketOfDeathVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPermitVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPermitVer13.java
new file mode 100644
index 0000000..2d8b6de
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPermitVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnPermitVer13 implements OFInstructionIdBsnPermit {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnPermitVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnPermitVer13 DEFAULT = new OFInstructionIdBsnPermitVer13(
+
+    );
+
+    final static OFInstructionIdBsnPermitVer13 INSTANCE = new OFInstructionIdBsnPermitVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnPermitVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x4L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnPermit.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPermitVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnPermit> {
+        @Override
+        public OFInstructionIdBsnPermit readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x4L
+            int subtype = bb.readInt();
+            if(subtype != 0x4)
+                throw new OFParseError("Wrong subtype: Expected=0x4L(0x4L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnPermitVer13Funnel FUNNEL = new OFInstructionIdBsnPermitVer13Funnel();
+    static class OFInstructionIdBsnPermitVer13Funnel implements Funnel<OFInstructionIdBsnPermitVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnPermitVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            sink.putInt(0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnPermitVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnPermitVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x4L
+            bb.writeInt(0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnPermitVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPrioritizePdusVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPrioritizePdusVer13.java
new file mode 100644
index 0000000..bb6007f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnPrioritizePdusVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnPrioritizePdusVer13 implements OFInstructionIdBsnPrioritizePdus {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnPrioritizePdusVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnPrioritizePdusVer13 DEFAULT = new OFInstructionIdBsnPrioritizePdusVer13(
+
+    );
+
+    final static OFInstructionIdBsnPrioritizePdusVer13 INSTANCE = new OFInstructionIdBsnPrioritizePdusVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnPrioritizePdusVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x7L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnPrioritizePdus.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnPrioritizePdusVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnPrioritizePdus> {
+        @Override
+        public OFInstructionIdBsnPrioritizePdus readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x7L
+            int subtype = bb.readInt();
+            if(subtype != 0x7)
+                throw new OFParseError("Wrong subtype: Expected=0x7L(0x7L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnPrioritizePdusVer13Funnel FUNNEL = new OFInstructionIdBsnPrioritizePdusVer13Funnel();
+    static class OFInstructionIdBsnPrioritizePdusVer13Funnel implements Funnel<OFInstructionIdBsnPrioritizePdusVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnPrioritizePdusVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            sink.putInt(0x7);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnPrioritizePdusVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnPrioritizePdusVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x7L
+            bb.writeInt(0x7);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnPrioritizePdusVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnRequireVlanXlateVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnRequireVlanXlateVer13.java
new file mode 100644
index 0000000..ea36dd4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnRequireVlanXlateVer13.java
@@ -0,0 +1,182 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdBsnRequireVlanXlateVer13 implements OFInstructionIdBsnRequireVlanXlate {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdBsnRequireVlanXlateVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdBsnRequireVlanXlateVer13 DEFAULT = new OFInstructionIdBsnRequireVlanXlateVer13(
+
+    );
+
+    final static OFInstructionIdBsnRequireVlanXlateVer13 INSTANCE = new OFInstructionIdBsnRequireVlanXlateVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdBsnRequireVlanXlateVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.EXPERIMENTER;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return 0x5c16c7L;
+    }
+
+    @Override
+    public long getSubtype() {
+        return 0x8L;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdBsnRequireVlanXlate.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdBsnRequireVlanXlateVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdBsnRequireVlanXlate> {
+        @Override
+        public OFInstructionIdBsnRequireVlanXlate readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            // fixed value property subtype == 0x8L
+            int subtype = bb.readInt();
+            if(subtype != 0x8)
+                throw new OFParseError("Wrong subtype: Expected=0x8L(0x8L), got="+subtype);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdBsnRequireVlanXlateVer13Funnel FUNNEL = new OFInstructionIdBsnRequireVlanXlateVer13Funnel();
+    static class OFInstructionIdBsnRequireVlanXlateVer13Funnel implements Funnel<OFInstructionIdBsnRequireVlanXlateVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdBsnRequireVlanXlateVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 65535
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            sink.putInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            sink.putInt(0x8);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdBsnRequireVlanXlateVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdBsnRequireVlanXlateVer13 message) {
+            // fixed value property type = 65535
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            // fixed value property experimenter = 0x5c16c7L
+            bb.writeInt(0x5c16c7);
+            // fixed value property subtype = 0x8L
+            bb.writeInt(0x8);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdBsnRequireVlanXlateVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnVer13.java
new file mode 100644
index 0000000..7aca13b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdBsnVer13.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionIdBsnVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+
+    public final static OFInstructionIdBsnVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstructionIdBsn> {
+        @Override
+        public OFInstructionIdBsn readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // fixed value property experimenter == 0x5c16c7L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x5c16c7)
+                throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               case 0x1:
+                   // discriminator value 0x1L=0x1L for class OFInstructionIdBsnArpOffloadVer13
+                   return OFInstructionIdBsnArpOffloadVer13.READER.readFrom(bb);
+               case 0x5:
+                   // discriminator value 0x5L=0x5L for class OFInstructionIdBsnDenyVer13
+                   return OFInstructionIdBsnDenyVer13.READER.readFrom(bb);
+               case 0x2:
+                   // discriminator value 0x2L=0x2L for class OFInstructionIdBsnDhcpOffloadVer13
+                   return OFInstructionIdBsnDhcpOffloadVer13.READER.readFrom(bb);
+               case 0x3:
+                   // discriminator value 0x3L=0x3L for class OFInstructionIdBsnDisableSplitHorizonCheckVer13
+                   return OFInstructionIdBsnDisableSplitHorizonCheckVer13.READER.readFrom(bb);
+               case 0x0:
+                   // discriminator value 0x0L=0x0L for class OFInstructionIdBsnDisableSrcMacCheckVer13
+                   return OFInstructionIdBsnDisableSrcMacCheckVer13.READER.readFrom(bb);
+               case 0x9:
+                   // discriminator value 0x9L=0x9L for class OFInstructionIdBsnDisableVlanCountersVer13
+                   return OFInstructionIdBsnDisableVlanCountersVer13.READER.readFrom(bb);
+               case 0x6:
+                   // discriminator value 0x6L=0x6L for class OFInstructionIdBsnPacketOfDeathVer13
+                   return OFInstructionIdBsnPacketOfDeathVer13.READER.readFrom(bb);
+               case 0x4:
+                   // discriminator value 0x4L=0x4L for class OFInstructionIdBsnPermitVer13
+                   return OFInstructionIdBsnPermitVer13.READER.readFrom(bb);
+               case 0x7:
+                   // discriminator value 0x7L=0x7L for class OFInstructionIdBsnPrioritizePdusVer13
+                   return OFInstructionIdBsnPrioritizePdusVer13.READER.readFrom(bb);
+               case 0x8:
+                   // discriminator value 0x8L=0x8L for class OFInstructionIdBsnRequireVlanXlateVer13
+                   return OFInstructionIdBsnRequireVlanXlateVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFInstructionIdBsnVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdClearActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdClearActionsVer13.java
new file mode 100644
index 0000000..c37a7ba
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdClearActionsVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdClearActionsVer13 implements OFInstructionIdClearActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdClearActionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdClearActionsVer13 DEFAULT = new OFInstructionIdClearActionsVer13(
+
+    );
+
+    final static OFInstructionIdClearActionsVer13 INSTANCE = new OFInstructionIdClearActionsVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdClearActionsVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.CLEAR_ACTIONS;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdClearActions.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdClearActionsVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdClearActions> {
+        @Override
+        public OFInstructionIdClearActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 5
+            short type = bb.readShort();
+            if(type != (short) 0x5)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.CLEAR_ACTIONS(5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdClearActionsVer13Funnel FUNNEL = new OFInstructionIdClearActionsVer13Funnel();
+    static class OFInstructionIdClearActionsVer13Funnel implements Funnel<OFInstructionIdClearActionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdClearActionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 5
+            sink.putShort((short) 0x5);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdClearActionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdClearActionsVer13 message) {
+            // fixed value property type = 5
+            bb.writeShort((short) 0x5);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdClearActionsVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdExperimenterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdExperimenterVer13.java
new file mode 100644
index 0000000..4151049
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdExperimenterVer13.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionIdExperimenterVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFInstructionIdExperimenterVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstructionIdExperimenter> {
+        @Override
+        public OFInstructionIdExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 65535
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.EXPERIMENTER(65535), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               case 0x5c16c7:
+                   // discriminator value 0x5c16c7L=0x5c16c7L for class OFInstructionIdBsnVer13
+                   return OFInstructionIdBsnVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFInstructionIdExperimenterVer13: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdGotoTableVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdGotoTableVer13.java
new file mode 100644
index 0000000..1cb373c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdGotoTableVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdGotoTableVer13 implements OFInstructionIdGotoTable {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdGotoTableVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdGotoTableVer13 DEFAULT = new OFInstructionIdGotoTableVer13(
+
+    );
+
+    final static OFInstructionIdGotoTableVer13 INSTANCE = new OFInstructionIdGotoTableVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdGotoTableVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.GOTO_TABLE;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdGotoTable.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdGotoTableVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdGotoTable> {
+        @Override
+        public OFInstructionIdGotoTable readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.GOTO_TABLE(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdGotoTableVer13Funnel FUNNEL = new OFInstructionIdGotoTableVer13Funnel();
+    static class OFInstructionIdGotoTableVer13Funnel implements Funnel<OFInstructionIdGotoTableVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdGotoTableVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdGotoTableVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdGotoTableVer13 message) {
+            // fixed value property type = 1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdGotoTableVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdMeterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdMeterVer13.java
new file mode 100644
index 0000000..db8b340
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdMeterVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdMeterVer13 implements OFInstructionIdMeter {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdMeterVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdMeterVer13 DEFAULT = new OFInstructionIdMeterVer13(
+
+    );
+
+    final static OFInstructionIdMeterVer13 INSTANCE = new OFInstructionIdMeterVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdMeterVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.METER;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdMeter.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdMeterVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdMeter> {
+        @Override
+        public OFInstructionIdMeter readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 6
+            short type = bb.readShort();
+            if(type != (short) 0x6)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.METER(6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdMeterVer13Funnel FUNNEL = new OFInstructionIdMeterVer13Funnel();
+    static class OFInstructionIdMeterVer13Funnel implements Funnel<OFInstructionIdMeterVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdMeterVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 6
+            sink.putShort((short) 0x6);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdMeterVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdMeterVer13 message) {
+            // fixed value property type = 6
+            bb.writeShort((short) 0x6);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdMeterVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdVer13.java
new file mode 100644
index 0000000..2dd4250
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdVer13.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionIdVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFInstructionIdVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstructionId> {
+        @Override
+        public OFInstructionId readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x4:
+                   // discriminator value OFInstructionType.APPLY_ACTIONS=4 for class OFInstructionIdApplyActionsVer13
+                   return OFInstructionIdApplyActionsVer13.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFInstructionType.EXPERIMENTER=65535 for class OFInstructionIdExperimenterVer13
+                   return OFInstructionIdExperimenterVer13.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFInstructionType.CLEAR_ACTIONS=5 for class OFInstructionIdClearActionsVer13
+                   return OFInstructionIdClearActionsVer13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFInstructionType.GOTO_TABLE=1 for class OFInstructionIdGotoTableVer13
+                   return OFInstructionIdGotoTableVer13.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFInstructionType.METER=6 for class OFInstructionIdMeterVer13
+                   return OFInstructionIdMeterVer13.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFInstructionType.WRITE_ACTIONS=3 for class OFInstructionIdWriteActionsVer13
+                   return OFInstructionIdWriteActionsVer13.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFInstructionType.WRITE_METADATA=2 for class OFInstructionIdWriteMetadataVer13
+                   return OFInstructionIdWriteMetadataVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFInstructionIdVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdWriteActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdWriteActionsVer13.java
new file mode 100644
index 0000000..0e1af8e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdWriteActionsVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdWriteActionsVer13 implements OFInstructionIdWriteActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdWriteActionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdWriteActionsVer13 DEFAULT = new OFInstructionIdWriteActionsVer13(
+
+    );
+
+    final static OFInstructionIdWriteActionsVer13 INSTANCE = new OFInstructionIdWriteActionsVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdWriteActionsVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdWriteActions.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdWriteActionsVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdWriteActions> {
+        @Override
+        public OFInstructionIdWriteActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 3
+            short type = bb.readShort();
+            if(type != (short) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_ACTIONS(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdWriteActionsVer13Funnel FUNNEL = new OFInstructionIdWriteActionsVer13Funnel();
+    static class OFInstructionIdWriteActionsVer13Funnel implements Funnel<OFInstructionIdWriteActionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdWriteActionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 3
+            sink.putShort((short) 0x3);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdWriteActionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdWriteActionsVer13 message) {
+            // fixed value property type = 3
+            bb.writeShort((short) 0x3);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdWriteActionsVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdWriteMetadataVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdWriteMetadataVer13.java
new file mode 100644
index 0000000..ec2a25e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdWriteMetadataVer13.java
@@ -0,0 +1,156 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionIdWriteMetadataVer13 implements OFInstructionIdWriteMetadata {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionIdWriteMetadataVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 4;
+
+
+    // OF message fields
+//
+    // Immutable default instance
+    final static OFInstructionIdWriteMetadataVer13 DEFAULT = new OFInstructionIdWriteMetadataVer13(
+
+    );
+
+    final static OFInstructionIdWriteMetadataVer13 INSTANCE = new OFInstructionIdWriteMetadataVer13();
+    // private empty constructor - use shared instance!
+    private OFInstructionIdWriteMetadataVer13() {
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    // no data members - do not support builder
+    public OFInstructionIdWriteMetadata.Builder createBuilder() {
+        throw new UnsupportedOperationException("OFInstructionIdWriteMetadataVer13 has no mutable properties -- builder unneeded");
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionIdWriteMetadata> {
+        @Override
+        public OFInstructionIdWriteMetadata readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_METADATA(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 4)
+                throw new OFParseError("Wrong length: Expected=4(4), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - returning shared instance={}", INSTANCE);
+            return INSTANCE;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionIdWriteMetadataVer13Funnel FUNNEL = new OFInstructionIdWriteMetadataVer13Funnel();
+    static class OFInstructionIdWriteMetadataVer13Funnel implements Funnel<OFInstructionIdWriteMetadataVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionIdWriteMetadataVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 4
+            sink.putShort((short) 0x4);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionIdWriteMetadataVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionIdWriteMetadataVer13 message) {
+            // fixed value property type = 2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 4
+            bb.writeShort((short) 0x4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionIdWriteMetadataVer13(");
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 1;
+
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdsVer13.java
new file mode 100644
index 0000000..baeb782
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdsVer13.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFInstructionIdsVer13 implements OFInstructionIds {
+    public final static OFInstructionIdsVer13 INSTANCE = new OFInstructionIdsVer13();
+
+
+
+
+    public OFInstructionIdApplyActions applyActions() {
+        return OFInstructionIdApplyActionsVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnArpOffload bsnArpOffload() {
+        return OFInstructionIdBsnArpOffloadVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnDeny bsnDeny() {
+        return OFInstructionIdBsnDenyVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnDhcpOffload bsnDhcpOffload() {
+        return OFInstructionIdBsnDhcpOffloadVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck() {
+        return OFInstructionIdBsnDisableSplitHorizonCheckVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnDisableSrcMacCheck bsnDisableSrcMacCheck() {
+        return OFInstructionIdBsnDisableSrcMacCheckVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnDisableVlanCounters bsnDisableVlanCounters() {
+        return OFInstructionIdBsnDisableVlanCountersVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnPacketOfDeath bsnPacketOfDeath() {
+        return OFInstructionIdBsnPacketOfDeathVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnPermit bsnPermit() {
+        return OFInstructionIdBsnPermitVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnPrioritizePdus bsnPrioritizePdus() {
+        return OFInstructionIdBsnPrioritizePdusVer13.INSTANCE;
+    }
+
+    public OFInstructionIdBsnRequireVlanXlate bsnRequireVlanXlate() {
+        return OFInstructionIdBsnRequireVlanXlateVer13.INSTANCE;
+    }
+
+    public OFInstructionIdClearActions clearActions() {
+        return OFInstructionIdClearActionsVer13.INSTANCE;
+    }
+
+    public OFInstructionIdGotoTable gotoTable() {
+        return OFInstructionIdGotoTableVer13.INSTANCE;
+    }
+
+    public OFInstructionIdMeter meter() {
+        return OFInstructionIdMeterVer13.INSTANCE;
+    }
+
+    public OFInstructionIdWriteActions writeActions() {
+        return OFInstructionIdWriteActionsVer13.INSTANCE;
+    }
+
+    public OFInstructionIdWriteMetadata writeMetadata() {
+        return OFInstructionIdWriteMetadataVer13.INSTANCE;
+    }
+
+    public OFMessageReader<OFInstructionId> getReader() {
+        return OFInstructionIdVer13.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionMeterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionMeterVer13.java
new file mode 100644
index 0000000..39d5f77
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionMeterVer13.java
@@ -0,0 +1,260 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionMeterVer13 implements OFInstructionMeter {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionMeterVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static long DEFAULT_METER_ID = 0x0L;
+
+    // OF message fields
+    private final long meterId;
+//
+    // Immutable default instance
+    final static OFInstructionMeterVer13 DEFAULT = new OFInstructionMeterVer13(
+        DEFAULT_METER_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionMeterVer13(long meterId) {
+        this.meterId = meterId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.METER;
+    }
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFInstructionMeter.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionMeter.Builder {
+        final OFInstructionMeterVer13 parentMessage;
+
+        // OF message fields
+        private boolean meterIdSet;
+        private long meterId;
+
+        BuilderWithParent(OFInstructionMeterVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.METER;
+    }
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFInstructionMeter.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFInstructionMeter build() {
+                long meterId = this.meterIdSet ? this.meterId : parentMessage.meterId;
+
+                //
+                return new OFInstructionMeterVer13(
+                    meterId
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionMeter.Builder {
+        // OF message fields
+        private boolean meterIdSet;
+        private long meterId;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.METER;
+    }
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFInstructionMeter.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFInstructionMeter build() {
+            long meterId = this.meterIdSet ? this.meterId : DEFAULT_METER_ID;
+
+
+            return new OFInstructionMeterVer13(
+                    meterId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionMeter> {
+        @Override
+        public OFInstructionMeter readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 6
+            short type = bb.readShort();
+            if(type != (short) 0x6)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.METER(6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 8)
+                throw new OFParseError("Wrong length: Expected=8(8), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long meterId = U32.f(bb.readInt());
+
+            OFInstructionMeterVer13 instructionMeterVer13 = new OFInstructionMeterVer13(
+                    meterId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionMeterVer13);
+            return instructionMeterVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionMeterVer13Funnel FUNNEL = new OFInstructionMeterVer13Funnel();
+    static class OFInstructionMeterVer13Funnel implements Funnel<OFInstructionMeterVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionMeterVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 6
+            sink.putShort((short) 0x6);
+            // fixed value property length = 8
+            sink.putShort((short) 0x8);
+            sink.putLong(message.meterId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionMeterVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionMeterVer13 message) {
+            // fixed value property type = 6
+            bb.writeShort((short) 0x6);
+            // fixed value property length = 8
+            bb.writeShort((short) 0x8);
+            bb.writeInt(U32.t(message.meterId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionMeterVer13(");
+        b.append("meterId=").append(meterId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionMeterVer13 other = (OFInstructionMeterVer13) obj;
+
+        if( meterId != other.meterId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (meterId ^ (meterId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionTypeSerializerVer13.java
new file mode 100644
index 0000000..5715f17
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionTypeSerializerVer13.java
@@ -0,0 +1,114 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFInstructionType;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFInstructionTypeSerializerVer13 {
+
+    public final static short GOTO_TABLE_VAL = (short) 0x1;
+    public final static short WRITE_METADATA_VAL = (short) 0x2;
+    public final static short WRITE_ACTIONS_VAL = (short) 0x3;
+    public final static short APPLY_ACTIONS_VAL = (short) 0x4;
+    public final static short CLEAR_ACTIONS_VAL = (short) 0x5;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+    public final static short METER_VAL = (short) 0x6;
+
+    public static Set<OFInstructionType> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFInstructionType> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFInstructionType> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFInstructionType> ofWireValue(short val) {
+        EnumSet<OFInstructionType> set = EnumSet.noneOf(OFInstructionType.class);
+
+        if((val & GOTO_TABLE_VAL) != 0)
+            set.add(OFInstructionType.GOTO_TABLE);
+        if((val & WRITE_METADATA_VAL) != 0)
+            set.add(OFInstructionType.WRITE_METADATA);
+        if((val & WRITE_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.WRITE_ACTIONS);
+        if((val & APPLY_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.APPLY_ACTIONS);
+        if((val & CLEAR_ACTIONS_VAL) != 0)
+            set.add(OFInstructionType.CLEAR_ACTIONS);
+        if((val & EXPERIMENTER_VAL) != 0)
+            set.add(OFInstructionType.EXPERIMENTER);
+        if((val & METER_VAL) != 0)
+            set.add(OFInstructionType.METER);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFInstructionType> set) {
+        short wireValue = 0;
+
+        for(OFInstructionType e: set) {
+            switch(e) {
+                case GOTO_TABLE:
+                    wireValue |= GOTO_TABLE_VAL;
+                    break;
+                case WRITE_METADATA:
+                    wireValue |= WRITE_METADATA_VAL;
+                    break;
+                case WRITE_ACTIONS:
+                    wireValue |= WRITE_ACTIONS_VAL;
+                    break;
+                case APPLY_ACTIONS:
+                    wireValue |= APPLY_ACTIONS_VAL;
+                    break;
+                case CLEAR_ACTIONS:
+                    wireValue |= CLEAR_ACTIONS_VAL;
+                    break;
+                case EXPERIMENTER:
+                    wireValue |= EXPERIMENTER_VAL;
+                    break;
+                case METER:
+                    wireValue |= METER_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFInstructionType in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionVer13.java
new file mode 100644
index 0000000..180743d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionVer13.java
@@ -0,0 +1,71 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFInstructionVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFInstructionVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFInstruction> {
+        @Override
+        public OFInstruction readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x4:
+                   // discriminator value OFInstructionType.APPLY_ACTIONS=4 for class OFInstructionApplyActionsVer13
+                   return OFInstructionApplyActionsVer13.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFInstructionType.CLEAR_ACTIONS=5 for class OFInstructionClearActionsVer13
+                   return OFInstructionClearActionsVer13.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFInstructionType.EXPERIMENTER=65535 for class OFInstructionExperimenterVer13
+                   return OFInstructionExperimenterVer13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFInstructionType.GOTO_TABLE=1 for class OFInstructionGotoTableVer13
+                   return OFInstructionGotoTableVer13.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFInstructionType.WRITE_ACTIONS=3 for class OFInstructionWriteActionsVer13
+                   return OFInstructionWriteActionsVer13.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value OFInstructionType.WRITE_METADATA=2 for class OFInstructionWriteMetadataVer13
+                   return OFInstructionWriteMetadataVer13.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFInstructionType.METER=6 for class OFInstructionMeterVer13
+                   return OFInstructionMeterVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFInstructionVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionWriteActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionWriteActionsVer13.java
new file mode 100644
index 0000000..c775392
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionWriteActionsVer13.java
@@ -0,0 +1,279 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionWriteActionsVer13 implements OFInstructionWriteActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionWriteActionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+
+    // OF message fields
+    private final List<OFAction> actions;
+//
+    // Immutable default instance
+    final static OFInstructionWriteActionsVer13 DEFAULT = new OFInstructionWriteActionsVer13(
+        DEFAULT_ACTIONS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionWriteActionsVer13(List<OFAction> actions) {
+        this.actions = actions;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFInstructionWriteActions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionWriteActions.Builder {
+        final OFInstructionWriteActionsVer13 parentMessage;
+
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+        BuilderWithParent(OFInstructionWriteActionsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionWriteActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFInstructionWriteActions build() {
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+
+                //
+                return new OFInstructionWriteActionsVer13(
+                    actions
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionWriteActions.Builder {
+        // OF message fields
+        private boolean actionsSet;
+        private List<OFAction> actions;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_ACTIONS;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFInstructionWriteActions.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFInstructionWriteActions build() {
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+
+
+            return new OFInstructionWriteActionsVer13(
+                    actions
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionWriteActions> {
+        @Override
+        public OFInstructionWriteActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 3
+            short type = bb.readShort();
+            if(type != (short) 0x3)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_ACTIONS(3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFAction> actions = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionVer13.READER);
+
+            OFInstructionWriteActionsVer13 instructionWriteActionsVer13 = new OFInstructionWriteActionsVer13(
+                    actions
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionWriteActionsVer13);
+            return instructionWriteActionsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionWriteActionsVer13Funnel FUNNEL = new OFInstructionWriteActionsVer13Funnel();
+    static class OFInstructionWriteActionsVer13Funnel implements Funnel<OFInstructionWriteActionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionWriteActionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 3
+            sink.putShort((short) 0x3);
+            // FIXME: skip funnel of length
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.actions, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionWriteActionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionWriteActionsVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 3
+            bb.writeShort((short) 0x3);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.actions);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionWriteActionsVer13(");
+        b.append("actions=").append(actions);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionWriteActionsVer13 other = (OFInstructionWriteActionsVer13) obj;
+
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionWriteMetadataVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionWriteMetadataVer13.java
new file mode 100644
index 0000000..3438d86
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionWriteMetadataVer13.java
@@ -0,0 +1,326 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFInstructionWriteMetadataVer13 implements OFInstructionWriteMetadata {
+    private static final Logger logger = LoggerFactory.getLogger(OFInstructionWriteMetadataVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static U64 DEFAULT_METADATA = U64.ZERO;
+        private final static U64 DEFAULT_METADATA_MASK = U64.ZERO;
+
+    // OF message fields
+    private final U64 metadata;
+    private final U64 metadataMask;
+//
+    // Immutable default instance
+    final static OFInstructionWriteMetadataVer13 DEFAULT = new OFInstructionWriteMetadataVer13(
+        DEFAULT_METADATA, DEFAULT_METADATA_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFInstructionWriteMetadataVer13(U64 metadata, U64 metadataMask) {
+        this.metadata = metadata;
+        this.metadataMask = metadataMask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFInstructionWriteMetadata.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFInstructionWriteMetadata.Builder {
+        final OFInstructionWriteMetadataVer13 parentMessage;
+
+        // OF message fields
+        private boolean metadataSet;
+        private U64 metadata;
+        private boolean metadataMaskSet;
+        private U64 metadataMask;
+
+        BuilderWithParent(OFInstructionWriteMetadataVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadata(U64 metadata) {
+        this.metadata = metadata;
+        this.metadataSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadataMask(U64 metadataMask) {
+        this.metadataMask = metadataMask;
+        this.metadataMaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFInstructionWriteMetadata build() {
+                U64 metadata = this.metadataSet ? this.metadata : parentMessage.metadata;
+                if(metadata == null)
+                    throw new NullPointerException("Property metadata must not be null");
+                U64 metadataMask = this.metadataMaskSet ? this.metadataMask : parentMessage.metadataMask;
+                if(metadataMask == null)
+                    throw new NullPointerException("Property metadataMask must not be null");
+
+                //
+                return new OFInstructionWriteMetadataVer13(
+                    metadata,
+                    metadataMask
+                );
+        }
+
+    }
+
+    static class Builder implements OFInstructionWriteMetadata.Builder {
+        // OF message fields
+        private boolean metadataSet;
+        private U64 metadata;
+        private boolean metadataMaskSet;
+        private U64 metadataMask;
+
+    @Override
+    public OFInstructionType getType() {
+        return OFInstructionType.WRITE_METADATA;
+    }
+
+    @Override
+    public U64 getMetadata() {
+        return metadata;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadata(U64 metadata) {
+        this.metadata = metadata;
+        this.metadataSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMask() {
+        return metadataMask;
+    }
+
+    @Override
+    public OFInstructionWriteMetadata.Builder setMetadataMask(U64 metadataMask) {
+        this.metadataMask = metadataMask;
+        this.metadataMaskSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFInstructionWriteMetadata build() {
+            U64 metadata = this.metadataSet ? this.metadata : DEFAULT_METADATA;
+            if(metadata == null)
+                throw new NullPointerException("Property metadata must not be null");
+            U64 metadataMask = this.metadataMaskSet ? this.metadataMask : DEFAULT_METADATA_MASK;
+            if(metadataMask == null)
+                throw new NullPointerException("Property metadataMask must not be null");
+
+
+            return new OFInstructionWriteMetadataVer13(
+                    metadata,
+                    metadataMask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFInstructionWriteMetadata> {
+        @Override
+        public OFInstructionWriteMetadata readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_METADATA(2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 metadata = U64.ofRaw(bb.readLong());
+            U64 metadataMask = U64.ofRaw(bb.readLong());
+
+            OFInstructionWriteMetadataVer13 instructionWriteMetadataVer13 = new OFInstructionWriteMetadataVer13(
+                    metadata,
+                      metadataMask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", instructionWriteMetadataVer13);
+            return instructionWriteMetadataVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFInstructionWriteMetadataVer13Funnel FUNNEL = new OFInstructionWriteMetadataVer13Funnel();
+    static class OFInstructionWriteMetadataVer13Funnel implements Funnel<OFInstructionWriteMetadataVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFInstructionWriteMetadataVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            // skip pad (4 bytes)
+            message.metadata.putTo(sink);
+            message.metadataMask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFInstructionWriteMetadataVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFInstructionWriteMetadataVer13 message) {
+            // fixed value property type = 2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.metadata.getValue());
+            bb.writeLong(message.metadataMask.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFInstructionWriteMetadataVer13(");
+        b.append("metadata=").append(metadata);
+        b.append(", ");
+        b.append("metadataMask=").append(metadataMask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFInstructionWriteMetadataVer13 other = (OFInstructionWriteMetadataVer13) obj;
+
+        if (metadata == null) {
+            if (other.metadata != null)
+                return false;
+        } else if (!metadata.equals(other.metadata))
+            return false;
+        if (metadataMask == null) {
+            if (other.metadataMask != null)
+                return false;
+        } else if (!metadataMask.equals(other.metadataMask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
+        result = prime * result + ((metadataMask == null) ? 0 : metadataMask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionsVer13.java
new file mode 100644
index 0000000..b2451a0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionsVer13.java
@@ -0,0 +1,133 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.List;
+
+
+public class OFInstructionsVer13 implements OFInstructions {
+    public final static OFInstructionsVer13 INSTANCE = new OFInstructionsVer13();
+
+
+
+
+    public OFInstructionApplyActions.Builder buildApplyActions() {
+        return new OFInstructionApplyActionsVer13.Builder();
+    }
+    public OFInstructionApplyActions applyActions(List<OFAction> actions) {
+        return new OFInstructionApplyActionsVer13(
+                actions
+                    );
+    }
+
+    public OFInstructionClearActions clearActions() {
+        return OFInstructionClearActionsVer13.INSTANCE;
+    }
+
+    public OFInstructionGotoTable.Builder buildGotoTable() {
+        return new OFInstructionGotoTableVer13.Builder();
+    }
+    public OFInstructionGotoTable gotoTable(TableId tableId) {
+        return new OFInstructionGotoTableVer13(
+                tableId
+                    );
+    }
+
+    public OFInstructionWriteActions.Builder buildWriteActions() {
+        return new OFInstructionWriteActionsVer13.Builder();
+    }
+    public OFInstructionWriteActions writeActions(List<OFAction> actions) {
+        return new OFInstructionWriteActionsVer13(
+                actions
+                    );
+    }
+
+    public OFInstructionWriteMetadata.Builder buildWriteMetadata() {
+        return new OFInstructionWriteMetadataVer13.Builder();
+    }
+    public OFInstructionWriteMetadata writeMetadata(U64 metadata, U64 metadataMask) {
+        return new OFInstructionWriteMetadataVer13(
+                metadata,
+                      metadataMask
+                    );
+    }
+
+    public OFInstructionBsnArpOffload bsnArpOffload() {
+        return OFInstructionBsnArpOffloadVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnDeny bsnDeny() {
+        return OFInstructionBsnDenyVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnDhcpOffload bsnDhcpOffload() {
+        return OFInstructionBsnDhcpOffloadVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnDisableSplitHorizonCheck bsnDisableSplitHorizonCheck() {
+        return OFInstructionBsnDisableSplitHorizonCheckVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnDisableSrcMacCheck bsnDisableSrcMacCheck() {
+        return OFInstructionBsnDisableSrcMacCheckVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnDisableVlanCounters bsnDisableVlanCounters() {
+        return OFInstructionBsnDisableVlanCountersVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnPacketOfDeath bsnPacketOfDeath() {
+        return OFInstructionBsnPacketOfDeathVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnPermit bsnPermit() {
+        return OFInstructionBsnPermitVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnPrioritizePdus bsnPrioritizePdus() {
+        return OFInstructionBsnPrioritizePdusVer13.INSTANCE;
+    }
+
+    public OFInstructionBsnRequireVlanXlate bsnRequireVlanXlate() {
+        return OFInstructionBsnRequireVlanXlateVer13.INSTANCE;
+    }
+
+    public OFInstructionMeter.Builder buildMeter() {
+        return new OFInstructionMeterVer13.Builder();
+    }
+    public OFInstructionMeter meter(long meterId) {
+        return new OFInstructionMeterVer13(
+                meterId
+                    );
+    }
+
+    public OFMessageReader<OFInstruction> getReader() {
+        return OFInstructionVer13.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFIpv6ExthdrFlagsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFIpv6ExthdrFlagsSerializerVer13.java
new file mode 100644
index 0000000..a32a3b4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFIpv6ExthdrFlagsSerializerVer13.java
@@ -0,0 +1,126 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFIpv6ExthdrFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFIpv6ExthdrFlagsSerializerVer13 {
+
+    public final static short NONEXT_VAL = (short) 0x1;
+    public final static short ESP_VAL = (short) 0x2;
+    public final static short AUTH_VAL = (short) 0x4;
+    public final static short DEST_VAL = (short) 0x8;
+    public final static short FRAG_VAL = (short) 0x10;
+    public final static short ROUTER_VAL = (short) 0x20;
+    public final static short HOP_VAL = (short) 0x40;
+    public final static short UNREP_VAL = (short) 0x80;
+    public final static short UNSEQ_VAL = (short) 0x100;
+
+    public static Set<OFIpv6ExthdrFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFIpv6ExthdrFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFIpv6ExthdrFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFIpv6ExthdrFlags> ofWireValue(short val) {
+        EnumSet<OFIpv6ExthdrFlags> set = EnumSet.noneOf(OFIpv6ExthdrFlags.class);
+
+        if((val & NONEXT_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.NONEXT);
+        if((val & ESP_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.ESP);
+        if((val & AUTH_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.AUTH);
+        if((val & DEST_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.DEST);
+        if((val & FRAG_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.FRAG);
+        if((val & ROUTER_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.ROUTER);
+        if((val & HOP_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.HOP);
+        if((val & UNREP_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.UNREP);
+        if((val & UNSEQ_VAL) != 0)
+            set.add(OFIpv6ExthdrFlags.UNSEQ);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFIpv6ExthdrFlags> set) {
+        short wireValue = 0;
+
+        for(OFIpv6ExthdrFlags e: set) {
+            switch(e) {
+                case NONEXT:
+                    wireValue |= NONEXT_VAL;
+                    break;
+                case ESP:
+                    wireValue |= ESP_VAL;
+                    break;
+                case AUTH:
+                    wireValue |= AUTH_VAL;
+                    break;
+                case DEST:
+                    wireValue |= DEST_VAL;
+                    break;
+                case FRAG:
+                    wireValue |= FRAG_VAL;
+                    break;
+                case ROUTER:
+                    wireValue |= ROUTER_VAL;
+                    break;
+                case HOP:
+                    wireValue |= HOP_VAL;
+                    break;
+                case UNREP:
+                    wireValue |= UNREP_VAL;
+                    break;
+                case UNSEQ:
+                    wireValue |= UNSEQ_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFIpv6ExthdrFlags in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchTypeSerializerVer13.java
new file mode 100644
index 0000000..0f27141
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchTypeSerializerVer13.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFMatchType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFMatchTypeSerializerVer13 {
+
+    public final static short STANDARD_VAL = (short) 0x0;
+    public final static short OXM_VAL = (short) 0x1;
+
+    public static OFMatchType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFMatchType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFMatchType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFMatchType ofWireValue(short val) {
+        switch(val) {
+            case STANDARD_VAL:
+                return OFMatchType.STANDARD;
+            case OXM_VAL:
+                return OFMatchType.OXM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFMatchType in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFMatchType e) {
+        switch(e) {
+            case STANDARD:
+                return STANDARD_VAL;
+            case OXM:
+                return OXM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFMatchType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchV3Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchV3Ver13.java
new file mode 100644
index 0000000..4ca8864
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchV3Ver13.java
@@ -0,0 +1,659 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import java.util.Iterator;
+import com.google.common.collect.AbstractIterator;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMatchV3Ver13 implements OFMatchV3 {
+    private static final Logger logger = LoggerFactory.getLogger(OFMatchV3Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static OFOxmList DEFAULT_OXM_LIST = OFOxmList.EMPTY;
+
+    // OF message fields
+    private final OFOxmList oxmList;
+//
+    // Immutable default instance
+    final static OFMatchV3Ver13 DEFAULT = new OFMatchV3Ver13(
+        DEFAULT_OXM_LIST
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMatchV3Ver13(OFOxmList oxmList) {
+        this.oxmList = oxmList;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public OFOxmList getOxmList() {
+        return oxmList;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+    @Override
+    public <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        if (!supports(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
+
+        OFOxm<F> oxm = this.oxmList.get(field);
+
+        if (oxm == null || !field.arePrerequisitesOK(this))
+            return null;
+
+        return oxm.getValue();
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        if (!supportsMasked(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support masked matching on field " + field.getName());
+
+        OFOxm<F> oxm = this.oxmList.get(field);
+
+        if (oxm == null || !field.arePrerequisitesOK(this))
+            return null;
+
+        if (oxm.getMask() == null)
+            return null;
+
+        // TODO: Make OfOxm extend Masked and just return the OXM?
+        return Masked.of(oxm.getValue(), oxm.getMask());
+    }
+
+    private static boolean supportsField(MatchField<?> field) {
+        switch (field.id) {
+            case ARP_OP:
+            case ARP_SHA:
+            case ARP_SPA:
+            case ARP_THA:
+            case ARP_TPA:
+            case BSN_EGR_PORT_GROUP_ID:
+            case BSN_GLOBAL_VRF_ALLOWED:
+            case BSN_IN_PORTS_128:
+            case BSN_L3_DST_CLASS_ID:
+            case BSN_L3_INTERFACE_CLASS_ID:
+            case BSN_L3_SRC_CLASS_ID:
+            case BSN_LAG_ID:
+            case BSN_TCP_FLAGS:
+            case BSN_UDF0:
+            case BSN_UDF1:
+            case BSN_UDF2:
+            case BSN_UDF3:
+            case BSN_UDF4:
+            case BSN_UDF5:
+            case BSN_UDF6:
+            case BSN_UDF7:
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+            case BSN_VRF:
+            case ETH_DST:
+            case ETH_SRC:
+            case ETH_TYPE:
+            case ICMPV4_CODE:
+            case ICMPV4_TYPE:
+            case ICMPV6_CODE:
+            case ICMPV6_TYPE:
+            case IN_PHY_PORT:
+            case IN_PORT:
+            case IPV4_DST:
+            case IPV4_SRC:
+            case IPV6_DST:
+            case IPV6_FLABEL:
+            case IPV6_ND_SLL:
+            case IPV6_ND_TARGET:
+            case IPV6_ND_TLL:
+            case IPV6_SRC:
+            case IP_DSCP:
+            case IP_ECN:
+            case IP_PROTO:
+            case METADATA:
+            case MPLS_LABEL:
+            case MPLS_TC:
+            case SCTP_DST:
+            case SCTP_SRC:
+            case TCP_DST:
+            case TCP_SRC:
+            case TUNNEL_ID:
+            case UDP_DST:
+            case UDP_SRC:
+            case VLAN_PCP:
+            case VLAN_VID:
+                return true;
+            default:
+                return false;
+        }
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean isExact(MatchField<?> field) {
+        if (!supports(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
+
+        OFOxm<?> oxm = this.oxmList.get(field);
+
+        return oxm != null && !oxm.isMasked();
+    }
+
+    @Override
+    public boolean isFullyWildcarded(MatchField<?> field) {
+        if (!supports(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
+
+        OFOxm<?> oxm = this.oxmList.get(field);
+
+        return oxm == null;
+    }
+
+    @Override
+    public boolean isPartiallyMasked(MatchField<?> field) {
+        if (!supports(field))
+            throw new UnsupportedOperationException("OFMatchV3Ver13 does not support matching on field " + field.getName());
+
+        OFOxm<?> oxm = this.oxmList.get(field);
+
+        return oxm != null && oxm.isMasked();
+    }
+
+    private class MatchFieldIterator extends AbstractIterator<MatchField<?>> {
+        private Iterator<OFOxm<?>> oxmIterator;
+
+        MatchFieldIterator() {
+            oxmIterator = oxmList.iterator();
+        }
+
+        @Override
+        protected MatchField<?> computeNext() {
+            while(oxmIterator.hasNext()) {
+                OFOxm<?> oxm = oxmIterator.next();
+                if(oxm.getMatchField().arePrerequisitesOK(OFMatchV3Ver13.this))
+                   return oxm.getMatchField();
+            }
+            endOfData();
+            return null;
+        }
+    }
+
+    @Override
+    public Iterable<MatchField<?>> getMatchFields() {
+        return new Iterable<MatchField<?>>() {
+            public Iterator<MatchField<?>> iterator() {
+                return new MatchFieldIterator();
+            }
+        };
+    }
+
+    public OFMatchV3.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMatchV3.Builder {
+        final OFMatchV3Ver13 parentMessage;
+
+        // OF message fields
+        private boolean oxmListSet;
+        private OFOxmList oxmList;
+
+        BuilderWithParent(OFMatchV3Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public OFOxmList getOxmList() {
+        return oxmList;
+    }
+
+    @Override
+    public OFMatchV3.Builder setOxmList(OFOxmList oxmList) {
+        this.oxmList = oxmList;
+        this.oxmListSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFMatchV3 build() {
+                OFOxmList oxmList = this.oxmListSet ? this.oxmList : parentMessage.oxmList;
+                if(oxmList == null)
+                    throw new NullPointerException("Property oxmList must not be null");
+
+                //
+                return new OFMatchV3Ver13(
+                    oxmList
+                );
+        }
+
+    private OFOxmList.Builder oxmListBuilder;
+
+    private void initBuilder() {
+        if (oxmListBuilder != null)
+            return;
+        oxmListBuilder = new OFOxmList.Builder();
+    }
+
+    private void updateOxmList() {
+        this.oxmList = this.oxmListBuilder.build();
+        this.oxmListSet = true;
+    }
+
+    private <F extends OFValueType<F>> OFOxm<F> getOxm(MatchField<F> field) {
+        return this.oxmListSet ? this.oxmList.get(field) : parentMessage.oxmList.get(field);
+    }
+
+    @Override
+    public <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        OFOxm<F> value = getOxm(field);
+        if (value == null)
+            return null;
+        return value.getValue();
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        OFOxm<F> value = getOxm(field);
+        if (value == null || !value.isMasked())
+            return null;
+        // TODO: If changing OXMs to extend Masked, then use it here
+        return Masked.of(value.getValue(), value.getMask());
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean isExact(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value != null && !value.isMasked());
+    }
+
+    @Override
+    public boolean isFullyWildcarded(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value == null);
+    }
+
+    @Override
+    public boolean isPartiallyMasked(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value != null && value.isMasked());
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setExact(
+            MatchField<F> field, F value) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromValue(value, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, F value, F mask) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromValueAndMask(value, mask, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, Masked<F> valueWithMask) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromMasked(valueWithMask, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+        initBuilder();
+        this.oxmListBuilder.unset(field);
+        updateOxmList();
+        return this;
+    }
+
+
+    }
+
+    static class Builder implements OFMatchV3.Builder {
+        // OF message fields
+        private boolean oxmListSet;
+        private OFOxmList oxmList;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public OFOxmList getOxmList() {
+        return oxmList;
+    }
+
+    @Override
+    public OFMatchV3.Builder setOxmList(OFOxmList oxmList) {
+        this.oxmList = oxmList;
+        this.oxmListSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFMatchV3 build() {
+            OFOxmList oxmList = this.oxmListSet ? this.oxmList : DEFAULT_OXM_LIST;
+            if(oxmList == null)
+                throw new NullPointerException("Property oxmList must not be null");
+
+
+            return new OFMatchV3Ver13(
+                    oxmList
+                );
+        }
+
+    private OFOxmList.Builder oxmListBuilder;
+
+    private void initBuilder() {
+        if (oxmListBuilder != null)
+            return;
+        oxmListBuilder = new OFOxmList.Builder();
+    }
+
+    private void updateOxmList() {
+        this.oxmList = this.oxmListBuilder.build();
+        this.oxmListSet = true;
+    }
+
+    private <F extends OFValueType<F>> OFOxm<F> getOxm(MatchField<F> field) {
+        return this.oxmListSet ? this.oxmList.get(field) : null;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> F get(MatchField<F> field)
+            throws UnsupportedOperationException {
+        OFOxm<F> value = getOxm(field);
+        if (value == null)
+            return null;
+        return value.getValue();
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Masked<F> getMasked(MatchField<F> field)
+            throws UnsupportedOperationException {
+        OFOxm<F> value = getOxm(field);
+        if (value == null || !value.isMasked())
+            return null;
+        // TODO: If changing OXMs to extend Masked, then use it here
+        return Masked.of(value.getValue(), value.getMask());
+    }
+
+    @Override
+    public boolean supports(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean supportsMasked(MatchField<?> field) {
+        return supportsField(field);
+    }
+
+    @Override
+    public boolean isExact(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value != null && !value.isMasked());
+    }
+
+    @Override
+    public boolean isFullyWildcarded(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value == null);
+    }
+
+    @Override
+    public boolean isPartiallyMasked(MatchField<?> field) {
+        OFOxm<?> value = getOxm(field);
+        return (value != null && value.isMasked());
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setExact(
+            MatchField<F> field, F value) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromValue(value, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, F value, F mask) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromValueAndMask(value, mask, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder setMasked(
+            MatchField<F> field, Masked<F> valueWithMask) {
+        initBuilder();
+        OFOxm<F> oxm = OFFactories.getFactory(OFVersion.OF_13).oxms().fromMasked(valueWithMask, field);
+        this.oxmListBuilder.set(oxm);
+        updateOxmList();
+        return this;
+    }
+
+    @Override
+    public <F extends OFValueType<F>> Match.Builder wildcard(MatchField<F> field) {
+        initBuilder();
+        this.oxmListBuilder.unset(field);
+        updateOxmList();
+        return this;
+    }
+
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMatchV3> {
+        @Override
+        public OFMatchV3 readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            OFOxmList oxmList = OFOxmList.readFrom(bb, length - (bb.readerIndex() - start), OFOxmVer13.READER);
+            // align message to 8 bytes (length does not contain alignment)
+            bb.skipBytes(((length + 7)/8 * 8 ) - length );
+
+            OFMatchV3Ver13 matchV3Ver13 = new OFMatchV3Ver13(
+                    oxmList
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", matchV3Ver13);
+            return matchV3Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMatchV3Ver13Funnel FUNNEL = new OFMatchV3Ver13Funnel();
+    static class OFMatchV3Ver13Funnel implements Funnel<OFMatchV3Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMatchV3Ver13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // FIXME: skip funnel of length
+            message.oxmList.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMatchV3Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMatchV3Ver13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.oxmList.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            int alignedLength = ((length + 7)/8 * 8);
+            bb.setShort(lengthIndex, length);
+            // align message to 8 bytes
+            bb.writeZero(alignedLength - length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMatchV3Ver13(");
+        boolean first = true;
+        for(MatchField<?> field : getMatchFields()) {
+            if(first)
+                first = false;
+            else
+                b.append(", ");
+            String name = field.getName();
+            b.append(name).append('=').append(this.get(field));
+            if(isPartiallyMasked(field)) {
+                b.append('/').append(this.getMasked(field).getMask());
+            }
+        }
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMatchV3Ver13 other = (OFMatchV3Ver13) obj;
+
+        if (oxmList == null) {
+            if (other.oxmList != null)
+                return false;
+        } else if (!oxmList.equals(other.oxmList))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((oxmList == null) ? 0 : oxmList.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMessageVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMessageVer13.java
new file mode 100644
index 0000000..b98160c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMessageVer13.java
@@ -0,0 +1,145 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFMessageVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFMessageVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFMessage> {
+        @Override
+        public OFMessage readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            byte type = bb.readByte();
+            bb.readerIndex(start);
+            switch(type) {
+               case (byte) 0x13:
+                   // discriminator value OFType.STATS_REPLY=19 for class OFStatsReplyVer13
+                   return OFStatsReplyVer13.READER.readFrom(bb);
+               case (byte) 0x12:
+                   // discriminator value OFType.STATS_REQUEST=18 for class OFStatsRequestVer13
+                   return OFStatsRequestVer13.READER.readFrom(bb);
+               case (byte) 0x1:
+                   // discriminator value OFType.ERROR=1 for class OFErrorMsgVer13
+                   return OFErrorMsgVer13.READER.readFrom(bb);
+               case (byte) 0x15:
+                   // discriminator value OFType.BARRIER_REPLY=21 for class OFBarrierReplyVer13
+                   return OFBarrierReplyVer13.READER.readFrom(bb);
+               case (byte) 0x14:
+                   // discriminator value OFType.BARRIER_REQUEST=20 for class OFBarrierRequestVer13
+                   return OFBarrierRequestVer13.READER.readFrom(bb);
+               case (byte) 0x4:
+                   // discriminator value OFType.EXPERIMENTER=4 for class OFExperimenterVer13
+                   return OFExperimenterVer13.READER.readFrom(bb);
+               case (byte) 0x3:
+                   // discriminator value OFType.ECHO_REPLY=3 for class OFEchoReplyVer13
+                   return OFEchoReplyVer13.READER.readFrom(bb);
+               case (byte) 0x2:
+                   // discriminator value OFType.ECHO_REQUEST=2 for class OFEchoRequestVer13
+                   return OFEchoRequestVer13.READER.readFrom(bb);
+               case (byte) 0x6:
+                   // discriminator value OFType.FEATURES_REPLY=6 for class OFFeaturesReplyVer13
+                   return OFFeaturesReplyVer13.READER.readFrom(bb);
+               case (byte) 0x5:
+                   // discriminator value OFType.FEATURES_REQUEST=5 for class OFFeaturesRequestVer13
+                   return OFFeaturesRequestVer13.READER.readFrom(bb);
+               case (byte) 0xe:
+                   // discriminator value OFType.FLOW_MOD=14 for class OFFlowModVer13
+                   return OFFlowModVer13.READER.readFrom(bb);
+               case (byte) 0xb:
+                   // discriminator value OFType.FLOW_REMOVED=11 for class OFFlowRemovedVer13
+                   return OFFlowRemovedVer13.READER.readFrom(bb);
+               case (byte) 0x8:
+                   // discriminator value OFType.GET_CONFIG_REPLY=8 for class OFGetConfigReplyVer13
+                   return OFGetConfigReplyVer13.READER.readFrom(bb);
+               case (byte) 0x7:
+                   // discriminator value OFType.GET_CONFIG_REQUEST=7 for class OFGetConfigRequestVer13
+                   return OFGetConfigRequestVer13.READER.readFrom(bb);
+               case (byte) 0x0:
+                   // discriminator value OFType.HELLO=0 for class OFHelloVer13
+                   return OFHelloVer13.READER.readFrom(bb);
+               case (byte) 0xa:
+                   // discriminator value OFType.PACKET_IN=10 for class OFPacketInVer13
+                   return OFPacketInVer13.READER.readFrom(bb);
+               case (byte) 0xd:
+                   // discriminator value OFType.PACKET_OUT=13 for class OFPacketOutVer13
+                   return OFPacketOutVer13.READER.readFrom(bb);
+               case (byte) 0x10:
+                   // discriminator value OFType.PORT_MOD=16 for class OFPortModVer13
+                   return OFPortModVer13.READER.readFrom(bb);
+               case (byte) 0xc:
+                   // discriminator value OFType.PORT_STATUS=12 for class OFPortStatusVer13
+                   return OFPortStatusVer13.READER.readFrom(bb);
+               case (byte) 0x17:
+                   // discriminator value OFType.QUEUE_GET_CONFIG_REPLY=23 for class OFQueueGetConfigReplyVer13
+                   return OFQueueGetConfigReplyVer13.READER.readFrom(bb);
+               case (byte) 0x16:
+                   // discriminator value OFType.QUEUE_GET_CONFIG_REQUEST=22 for class OFQueueGetConfigRequestVer13
+                   return OFQueueGetConfigRequestVer13.READER.readFrom(bb);
+               case (byte) 0x9:
+                   // discriminator value OFType.SET_CONFIG=9 for class OFSetConfigVer13
+                   return OFSetConfigVer13.READER.readFrom(bb);
+               case (byte) 0x11:
+                   // discriminator value OFType.TABLE_MOD=17 for class OFTableModVer13
+                   return OFTableModVer13.READER.readFrom(bb);
+               case (byte) 0xf:
+                   // discriminator value OFType.GROUP_MOD=15 for class OFGroupModVer13
+                   return OFGroupModVer13.READER.readFrom(bb);
+               case (byte) 0x19:
+                   // discriminator value OFType.ROLE_REPLY=25 for class OFRoleReplyVer13
+                   return OFRoleReplyVer13.READER.readFrom(bb);
+               case (byte) 0x18:
+                   // discriminator value OFType.ROLE_REQUEST=24 for class OFRoleRequestVer13
+                   return OFRoleRequestVer13.READER.readFrom(bb);
+               case (byte) 0x1b:
+                   // discriminator value OFType.GET_ASYNC_REPLY=27 for class OFAsyncGetReplyVer13
+                   return OFAsyncGetReplyVer13.READER.readFrom(bb);
+               case (byte) 0x1a:
+                   // discriminator value OFType.GET_ASYNC_REQUEST=26 for class OFAsyncGetRequestVer13
+                   return OFAsyncGetRequestVer13.READER.readFrom(bb);
+               case (byte) 0x1c:
+                   // discriminator value OFType.SET_ASYNC=28 for class OFAsyncSetVer13
+                   return OFAsyncSetVer13.READER.readFrom(bb);
+               case (byte) 0x1d:
+                   // discriminator value OFType.METER_MOD=29 for class OFMeterModVer13
+                   return OFMeterModVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFMessageVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandDropVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandDropVer13.java
new file mode 100644
index 0000000..3bbe176
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandDropVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterBandDropVer13 implements OFMeterBandDrop {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterBandDropVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_RATE = 0x0L;
+        private final static long DEFAULT_BURST_SIZE = 0x0L;
+
+    // OF message fields
+    private final long rate;
+    private final long burstSize;
+//
+    // Immutable default instance
+    final static OFMeterBandDropVer13 DEFAULT = new OFMeterBandDropVer13(
+        DEFAULT_RATE, DEFAULT_BURST_SIZE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterBandDropVer13(long rate, long burstSize) {
+        this.rate = rate;
+        this.burstSize = burstSize;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFMeterBandDrop.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterBandDrop.Builder {
+        final OFMeterBandDropVer13 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private long rate;
+        private boolean burstSizeSet;
+        private long burstSize;
+
+        BuilderWithParent(OFMeterBandDropVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFMeterBandDrop.Builder setRate(long rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public OFMeterBandDrop.Builder setBurstSize(long burstSize) {
+        this.burstSize = burstSize;
+        this.burstSizeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFMeterBandDrop build() {
+                long rate = this.rateSet ? this.rate : parentMessage.rate;
+                long burstSize = this.burstSizeSet ? this.burstSize : parentMessage.burstSize;
+
+                //
+                return new OFMeterBandDropVer13(
+                    rate,
+                    burstSize
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterBandDrop.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private long rate;
+        private boolean burstSizeSet;
+        private long burstSize;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFMeterBandDrop.Builder setRate(long rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public OFMeterBandDrop.Builder setBurstSize(long burstSize) {
+        this.burstSize = burstSize;
+        this.burstSizeSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFMeterBandDrop build() {
+            long rate = this.rateSet ? this.rate : DEFAULT_RATE;
+            long burstSize = this.burstSizeSet ? this.burstSize : DEFAULT_BURST_SIZE;
+
+
+            return new OFMeterBandDropVer13(
+                    rate,
+                    burstSize
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterBandDrop> {
+        @Override
+        public OFMeterBandDrop readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long rate = U32.f(bb.readInt());
+            long burstSize = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFMeterBandDropVer13 meterBandDropVer13 = new OFMeterBandDropVer13(
+                    rate,
+                      burstSize
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterBandDropVer13);
+            return meterBandDropVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterBandDropVer13Funnel FUNNEL = new OFMeterBandDropVer13Funnel();
+    static class OFMeterBandDropVer13Funnel implements Funnel<OFMeterBandDropVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterBandDropVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.rate);
+            sink.putLong(message.burstSize);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterBandDropVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterBandDropVer13 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.rate));
+            bb.writeInt(U32.t(message.burstSize));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterBandDropVer13(");
+        b.append("rate=").append(rate);
+        b.append(", ");
+        b.append("burstSize=").append(burstSize);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterBandDropVer13 other = (OFMeterBandDropVer13) obj;
+
+        if( rate != other.rate)
+            return false;
+        if( burstSize != other.burstSize)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (rate ^ (rate >>> 32));
+        result = prime *  (int) (burstSize ^ (burstSize >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandDscpRemarkVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandDscpRemarkVer13.java
new file mode 100644
index 0000000..9321db4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandDscpRemarkVer13.java
@@ -0,0 +1,359 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterBandDscpRemarkVer13 implements OFMeterBandDscpRemark {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterBandDscpRemarkVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_RATE = 0x0L;
+        private final static long DEFAULT_BURST_SIZE = 0x0L;
+        private final static short DEFAULT_PREC_LEVEL = (short) 0x0;
+
+    // OF message fields
+    private final long rate;
+    private final long burstSize;
+    private final short precLevel;
+//
+    // Immutable default instance
+    final static OFMeterBandDscpRemarkVer13 DEFAULT = new OFMeterBandDscpRemarkVer13(
+        DEFAULT_RATE, DEFAULT_BURST_SIZE, DEFAULT_PREC_LEVEL
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterBandDscpRemarkVer13(long rate, long burstSize, short precLevel) {
+        this.rate = rate;
+        this.burstSize = burstSize;
+        this.precLevel = precLevel;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public short getPrecLevel() {
+        return precLevel;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFMeterBandDscpRemark.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterBandDscpRemark.Builder {
+        final OFMeterBandDscpRemarkVer13 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private long rate;
+        private boolean burstSizeSet;
+        private long burstSize;
+        private boolean precLevelSet;
+        private short precLevel;
+
+        BuilderWithParent(OFMeterBandDscpRemarkVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFMeterBandDscpRemark.Builder setRate(long rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public OFMeterBandDscpRemark.Builder setBurstSize(long burstSize) {
+        this.burstSize = burstSize;
+        this.burstSizeSet = true;
+        return this;
+    }
+    @Override
+    public short getPrecLevel() {
+        return precLevel;
+    }
+
+    @Override
+    public OFMeterBandDscpRemark.Builder setPrecLevel(short precLevel) {
+        this.precLevel = precLevel;
+        this.precLevelSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFMeterBandDscpRemark build() {
+                long rate = this.rateSet ? this.rate : parentMessage.rate;
+                long burstSize = this.burstSizeSet ? this.burstSize : parentMessage.burstSize;
+                short precLevel = this.precLevelSet ? this.precLevel : parentMessage.precLevel;
+
+                //
+                return new OFMeterBandDscpRemarkVer13(
+                    rate,
+                    burstSize,
+                    precLevel
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterBandDscpRemark.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private long rate;
+        private boolean burstSizeSet;
+        private long burstSize;
+        private boolean precLevelSet;
+        private short precLevel;
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFMeterBandDscpRemark.Builder setRate(long rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public OFMeterBandDscpRemark.Builder setBurstSize(long burstSize) {
+        this.burstSize = burstSize;
+        this.burstSizeSet = true;
+        return this;
+    }
+    @Override
+    public short getPrecLevel() {
+        return precLevel;
+    }
+
+    @Override
+    public OFMeterBandDscpRemark.Builder setPrecLevel(short precLevel) {
+        this.precLevel = precLevel;
+        this.precLevelSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFMeterBandDscpRemark build() {
+            long rate = this.rateSet ? this.rate : DEFAULT_RATE;
+            long burstSize = this.burstSizeSet ? this.burstSize : DEFAULT_BURST_SIZE;
+            short precLevel = this.precLevelSet ? this.precLevel : DEFAULT_PREC_LEVEL;
+
+
+            return new OFMeterBandDscpRemarkVer13(
+                    rate,
+                    burstSize,
+                    precLevel
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterBandDscpRemark> {
+        @Override
+        public OFMeterBandDscpRemark readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=0x2(0x2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long rate = U32.f(bb.readInt());
+            long burstSize = U32.f(bb.readInt());
+            short precLevel = U8.f(bb.readByte());
+            // pad: 3 bytes
+            bb.skipBytes(3);
+
+            OFMeterBandDscpRemarkVer13 meterBandDscpRemarkVer13 = new OFMeterBandDscpRemarkVer13(
+                    rate,
+                      burstSize,
+                      precLevel
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterBandDscpRemarkVer13);
+            return meterBandDscpRemarkVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterBandDscpRemarkVer13Funnel FUNNEL = new OFMeterBandDscpRemarkVer13Funnel();
+    static class OFMeterBandDscpRemarkVer13Funnel implements Funnel<OFMeterBandDscpRemarkVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterBandDscpRemarkVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.rate);
+            sink.putLong(message.burstSize);
+            sink.putShort(message.precLevel);
+            // skip pad (3 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterBandDscpRemarkVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterBandDscpRemarkVer13 message) {
+            // fixed value property type = 0x2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.rate));
+            bb.writeInt(U32.t(message.burstSize));
+            bb.writeByte(U8.t(message.precLevel));
+            // pad: 3 bytes
+            bb.writeZero(3);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterBandDscpRemarkVer13(");
+        b.append("rate=").append(rate);
+        b.append(", ");
+        b.append("burstSize=").append(burstSize);
+        b.append(", ");
+        b.append("precLevel=").append(precLevel);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterBandDscpRemarkVer13 other = (OFMeterBandDscpRemarkVer13) obj;
+
+        if( rate != other.rate)
+            return false;
+        if( burstSize != other.burstSize)
+            return false;
+        if( precLevel != other.precLevel)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (rate ^ (rate >>> 32));
+        result = prime *  (int) (burstSize ^ (burstSize >>> 32));
+        result = prime * result + precLevel;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandExperimenterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandExperimenterVer13.java
new file mode 100644
index 0000000..a85fd93
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandExperimenterVer13.java
@@ -0,0 +1,354 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterBandExperimenterVer13 implements OFMeterBandExperimenter {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterBandExperimenterVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_RATE = 0x0L;
+        private final static long DEFAULT_BURST_SIZE = 0x0L;
+        private final static long DEFAULT_EXPERIMENTER = 0x0L;
+
+    // OF message fields
+    private final long rate;
+    private final long burstSize;
+    private final long experimenter;
+//
+    // Immutable default instance
+    final static OFMeterBandExperimenterVer13 DEFAULT = new OFMeterBandExperimenterVer13(
+        DEFAULT_RATE, DEFAULT_BURST_SIZE, DEFAULT_EXPERIMENTER
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterBandExperimenterVer13(long rate, long burstSize, long experimenter) {
+        this.rate = rate;
+        this.burstSize = burstSize;
+        this.experimenter = experimenter;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xffff;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFMeterBandExperimenter.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterBandExperimenter.Builder {
+        final OFMeterBandExperimenterVer13 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private long rate;
+        private boolean burstSizeSet;
+        private long burstSize;
+        private boolean experimenterSet;
+        private long experimenter;
+
+        BuilderWithParent(OFMeterBandExperimenterVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xffff;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFMeterBandExperimenter.Builder setRate(long rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public OFMeterBandExperimenter.Builder setBurstSize(long burstSize) {
+        this.burstSize = burstSize;
+        this.burstSizeSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFMeterBandExperimenter.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFMeterBandExperimenter build() {
+                long rate = this.rateSet ? this.rate : parentMessage.rate;
+                long burstSize = this.burstSizeSet ? this.burstSize : parentMessage.burstSize;
+                long experimenter = this.experimenterSet ? this.experimenter : parentMessage.experimenter;
+
+                //
+                return new OFMeterBandExperimenterVer13(
+                    rate,
+                    burstSize,
+                    experimenter
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterBandExperimenter.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private long rate;
+        private boolean burstSizeSet;
+        private long burstSize;
+        private boolean experimenterSet;
+        private long experimenter;
+
+    @Override
+    public int getType() {
+        return 0xffff;
+    }
+
+    @Override
+    public long getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFMeterBandExperimenter.Builder setRate(long rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public long getBurstSize() {
+        return burstSize;
+    }
+
+    @Override
+    public OFMeterBandExperimenter.Builder setBurstSize(long burstSize) {
+        this.burstSize = burstSize;
+        this.burstSizeSet = true;
+        return this;
+    }
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFMeterBandExperimenter.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFMeterBandExperimenter build() {
+            long rate = this.rateSet ? this.rate : DEFAULT_RATE;
+            long burstSize = this.burstSizeSet ? this.burstSize : DEFAULT_BURST_SIZE;
+            long experimenter = this.experimenterSet ? this.experimenter : DEFAULT_EXPERIMENTER;
+
+
+            return new OFMeterBandExperimenterVer13(
+                    rate,
+                    burstSize,
+                    experimenter
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterBandExperimenter> {
+        @Override
+        public OFMeterBandExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xffff
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=0xffff(0xffff), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long rate = U32.f(bb.readInt());
+            long burstSize = U32.f(bb.readInt());
+            long experimenter = U32.f(bb.readInt());
+
+            OFMeterBandExperimenterVer13 meterBandExperimenterVer13 = new OFMeterBandExperimenterVer13(
+                    rate,
+                      burstSize,
+                      experimenter
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterBandExperimenterVer13);
+            return meterBandExperimenterVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterBandExperimenterVer13Funnel FUNNEL = new OFMeterBandExperimenterVer13Funnel();
+    static class OFMeterBandExperimenterVer13Funnel implements Funnel<OFMeterBandExperimenterVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterBandExperimenterVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xffff
+            sink.putShort((short) 0xffff);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.rate);
+            sink.putLong(message.burstSize);
+            sink.putLong(message.experimenter);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterBandExperimenterVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterBandExperimenterVer13 message) {
+            // fixed value property type = 0xffff
+            bb.writeShort((short) 0xffff);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.rate));
+            bb.writeInt(U32.t(message.burstSize));
+            bb.writeInt(U32.t(message.experimenter));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterBandExperimenterVer13(");
+        b.append("rate=").append(rate);
+        b.append(", ");
+        b.append("burstSize=").append(burstSize);
+        b.append(", ");
+        b.append("experimenter=").append(experimenter);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterBandExperimenterVer13 other = (OFMeterBandExperimenterVer13) obj;
+
+        if( rate != other.rate)
+            return false;
+        if( burstSize != other.burstSize)
+            return false;
+        if( experimenter != other.experimenter)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (rate ^ (rate >>> 32));
+        result = prime *  (int) (burstSize ^ (burstSize >>> 32));
+        result = prime *  (int) (experimenter ^ (experimenter >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandStatsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandStatsVer13.java
new file mode 100644
index 0000000..7f641e5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandStatsVer13.java
@@ -0,0 +1,283 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterBandStatsVer13 implements OFMeterBandStats {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterBandStatsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static U64 DEFAULT_PACKET_BAND_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_BAND_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final U64 packetBandCount;
+    private final U64 byteBandCount;
+//
+    // Immutable default instance
+    final static OFMeterBandStatsVer13 DEFAULT = new OFMeterBandStatsVer13(
+        DEFAULT_PACKET_BAND_COUNT, DEFAULT_BYTE_BAND_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterBandStatsVer13(U64 packetBandCount, U64 byteBandCount) {
+        this.packetBandCount = packetBandCount;
+        this.byteBandCount = byteBandCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U64 getPacketBandCount() {
+        return packetBandCount;
+    }
+
+    @Override
+    public U64 getByteBandCount() {
+        return byteBandCount;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFMeterBandStats.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterBandStats.Builder {
+        final OFMeterBandStatsVer13 parentMessage;
+
+        // OF message fields
+        private boolean packetBandCountSet;
+        private U64 packetBandCount;
+        private boolean byteBandCountSet;
+        private U64 byteBandCount;
+
+        BuilderWithParent(OFMeterBandStatsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U64 getPacketBandCount() {
+        return packetBandCount;
+    }
+
+    @Override
+    public OFMeterBandStats.Builder setPacketBandCount(U64 packetBandCount) {
+        this.packetBandCount = packetBandCount;
+        this.packetBandCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteBandCount() {
+        return byteBandCount;
+    }
+
+    @Override
+    public OFMeterBandStats.Builder setByteBandCount(U64 byteBandCount) {
+        this.byteBandCount = byteBandCount;
+        this.byteBandCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFMeterBandStats build() {
+                U64 packetBandCount = this.packetBandCountSet ? this.packetBandCount : parentMessage.packetBandCount;
+                if(packetBandCount == null)
+                    throw new NullPointerException("Property packetBandCount must not be null");
+                U64 byteBandCount = this.byteBandCountSet ? this.byteBandCount : parentMessage.byteBandCount;
+                if(byteBandCount == null)
+                    throw new NullPointerException("Property byteBandCount must not be null");
+
+                //
+                return new OFMeterBandStatsVer13(
+                    packetBandCount,
+                    byteBandCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterBandStats.Builder {
+        // OF message fields
+        private boolean packetBandCountSet;
+        private U64 packetBandCount;
+        private boolean byteBandCountSet;
+        private U64 byteBandCount;
+
+    @Override
+    public U64 getPacketBandCount() {
+        return packetBandCount;
+    }
+
+    @Override
+    public OFMeterBandStats.Builder setPacketBandCount(U64 packetBandCount) {
+        this.packetBandCount = packetBandCount;
+        this.packetBandCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteBandCount() {
+        return byteBandCount;
+    }
+
+    @Override
+    public OFMeterBandStats.Builder setByteBandCount(U64 byteBandCount) {
+        this.byteBandCount = byteBandCount;
+        this.byteBandCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFMeterBandStats build() {
+            U64 packetBandCount = this.packetBandCountSet ? this.packetBandCount : DEFAULT_PACKET_BAND_COUNT;
+            if(packetBandCount == null)
+                throw new NullPointerException("Property packetBandCount must not be null");
+            U64 byteBandCount = this.byteBandCountSet ? this.byteBandCount : DEFAULT_BYTE_BAND_COUNT;
+            if(byteBandCount == null)
+                throw new NullPointerException("Property byteBandCount must not be null");
+
+
+            return new OFMeterBandStatsVer13(
+                    packetBandCount,
+                    byteBandCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterBandStats> {
+        @Override
+        public OFMeterBandStats readFrom(ChannelBuffer bb) throws OFParseError {
+            U64 packetBandCount = U64.ofRaw(bb.readLong());
+            U64 byteBandCount = U64.ofRaw(bb.readLong());
+
+            OFMeterBandStatsVer13 meterBandStatsVer13 = new OFMeterBandStatsVer13(
+                    packetBandCount,
+                      byteBandCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterBandStatsVer13);
+            return meterBandStatsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterBandStatsVer13Funnel FUNNEL = new OFMeterBandStatsVer13Funnel();
+    static class OFMeterBandStatsVer13Funnel implements Funnel<OFMeterBandStatsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterBandStatsVer13 message, PrimitiveSink sink) {
+            message.packetBandCount.putTo(sink);
+            message.byteBandCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterBandStatsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterBandStatsVer13 message) {
+            bb.writeLong(message.packetBandCount.getValue());
+            bb.writeLong(message.byteBandCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterBandStatsVer13(");
+        b.append("packetBandCount=").append(packetBandCount);
+        b.append(", ");
+        b.append("byteBandCount=").append(byteBandCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterBandStatsVer13 other = (OFMeterBandStatsVer13) obj;
+
+        if (packetBandCount == null) {
+            if (other.packetBandCount != null)
+                return false;
+        } else if (!packetBandCount.equals(other.packetBandCount))
+            return false;
+        if (byteBandCount == null) {
+            if (other.byteBandCount != null)
+                return false;
+        } else if (!byteBandCount.equals(other.byteBandCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((packetBandCount == null) ? 0 : packetBandCount.hashCode());
+        result = prime * result + ((byteBandCount == null) ? 0 : byteBandCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandTypeSerializerVer13.java
new file mode 100644
index 0000000..d425c9a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandTypeSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFMeterBandType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFMeterBandTypeSerializerVer13 {
+
+    public final static short DROP_VAL = (short) 0x1;
+    public final static short DSCP_REMARK_VAL = (short) 0x2;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFMeterBandType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFMeterBandType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFMeterBandType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFMeterBandType ofWireValue(short val) {
+        switch(val) {
+            case DROP_VAL:
+                return OFMeterBandType.DROP;
+            case DSCP_REMARK_VAL:
+                return OFMeterBandType.DSCP_REMARK;
+            case EXPERIMENTER_VAL:
+                return OFMeterBandType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFMeterBandType in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFMeterBandType e) {
+        switch(e) {
+            case DROP:
+                return DROP_VAL;
+            case DSCP_REMARK:
+                return DSCP_REMARK_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFMeterBandType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandVer13.java
new file mode 100644
index 0000000..d7348f2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandVer13.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFMeterBandVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFMeterBandVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFMeterBand> {
+        @Override
+        public OFMeterBand readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFMeterBandDropVer13
+                   return OFMeterBandDropVer13.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value 0x2=0x2 for class OFMeterBandDscpRemarkVer13
+                   return OFMeterBandDscpRemarkVer13.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value 0xffff=0xffff for class OFMeterBandExperimenterVer13
+                   return OFMeterBandExperimenterVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFMeterBandVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandsVer13.java
new file mode 100644
index 0000000..f3760dd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterBandsVer13.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFMeterBandsVer13 implements OFMeterBands {
+    public final static OFMeterBandsVer13 INSTANCE = new OFMeterBandsVer13();
+
+
+
+
+    public OFMeterBandDrop.Builder buildDrop() {
+        return new OFMeterBandDropVer13.Builder();
+    }
+    public OFMeterBandDrop drop(long rate, long burstSize) {
+        return new OFMeterBandDropVer13(
+                rate,
+                      burstSize
+                    );
+    }
+
+    public OFMeterBandDscpRemark.Builder buildDscpRemark() {
+        return new OFMeterBandDscpRemarkVer13.Builder();
+    }
+
+    public OFMeterBandExperimenter.Builder buildExperimenter() {
+        return new OFMeterBandExperimenterVer13.Builder();
+    }
+
+    public OFMessageReader<OFMeterBand> getReader() {
+        return OFMeterBandVer13.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsReplyVer13.java
new file mode 100644
index 0000000..90c03dd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterConfigStatsReplyVer13 implements OFMeterConfigStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterConfigStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFMeterBand> DEFAULT_ENTRIES = ImmutableList.<OFMeterBand>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFMeterBand> entries;
+//
+    // Immutable default instance
+    final static OFMeterConfigStatsReplyVer13 DEFAULT = new OFMeterConfigStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterConfigStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFMeterBand> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_CONFIG;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFMeterBand> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFMeterConfigStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterConfigStatsReply.Builder {
+        final OFMeterConfigStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFMeterBand> entries;
+
+        BuilderWithParent(OFMeterConfigStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterConfigStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_CONFIG;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterConfigStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterBand> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFMeterConfigStatsReply.Builder setEntries(List<OFMeterBand> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFMeterConfigStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFMeterBand> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFMeterConfigStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterConfigStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFMeterBand> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterConfigStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_CONFIG;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterConfigStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterBand> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFMeterConfigStatsReply.Builder setEntries(List<OFMeterBand> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFMeterConfigStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFMeterBand> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFMeterConfigStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterConfigStatsReply> {
+        @Override
+        public OFMeterConfigStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 10
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xa)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.METER_CONFIG(10), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFMeterBand> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFMeterBandVer13.READER);
+
+            OFMeterConfigStatsReplyVer13 meterConfigStatsReplyVer13 = new OFMeterConfigStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterConfigStatsReplyVer13);
+            return meterConfigStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterConfigStatsReplyVer13Funnel FUNNEL = new OFMeterConfigStatsReplyVer13Funnel();
+    static class OFMeterConfigStatsReplyVer13Funnel implements Funnel<OFMeterConfigStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterConfigStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 10
+            sink.putShort((short) 0xa);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterConfigStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterConfigStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 10
+            bb.writeShort((short) 0xa);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterConfigStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterConfigStatsReplyVer13 other = (OFMeterConfigStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsRequestVer13.java
new file mode 100644
index 0000000..fcd1ac9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsRequestVer13.java
@@ -0,0 +1,403 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterConfigStatsRequestVer13 implements OFMeterConfigStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterConfigStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static long DEFAULT_METER_ID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final long meterId;
+//
+    // Immutable default instance
+    final static OFMeterConfigStatsRequestVer13 DEFAULT = new OFMeterConfigStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_METER_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterConfigStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, long meterId) {
+        this.xid = xid;
+        this.flags = flags;
+        this.meterId = meterId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_CONFIG;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+
+
+    public OFMeterConfigStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterConfigStatsRequest.Builder {
+        final OFMeterConfigStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean meterIdSet;
+        private long meterId;
+
+        BuilderWithParent(OFMeterConfigStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterConfigStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_CONFIG;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterConfigStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterConfigStatsRequest.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFMeterConfigStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                long meterId = this.meterIdSet ? this.meterId : parentMessage.meterId;
+
+                //
+                return new OFMeterConfigStatsRequestVer13(
+                    xid,
+                    flags,
+                    meterId
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterConfigStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean meterIdSet;
+        private long meterId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterConfigStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_CONFIG;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterConfigStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterConfigStatsRequest.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFMeterConfigStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            long meterId = this.meterIdSet ? this.meterId : DEFAULT_METER_ID;
+
+
+            return new OFMeterConfigStatsRequestVer13(
+                    xid,
+                    flags,
+                    meterId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterConfigStatsRequest> {
+        @Override
+        public OFMeterConfigStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 10
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xa)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.METER_CONFIG(10), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            long meterId = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFMeterConfigStatsRequestVer13 meterConfigStatsRequestVer13 = new OFMeterConfigStatsRequestVer13(
+                    xid,
+                      flags,
+                      meterId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterConfigStatsRequestVer13);
+            return meterConfigStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterConfigStatsRequestVer13Funnel FUNNEL = new OFMeterConfigStatsRequestVer13Funnel();
+    static class OFMeterConfigStatsRequestVer13Funnel implements Funnel<OFMeterConfigStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterConfigStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 10
+            sink.putShort((short) 0xa);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            sink.putLong(message.meterId);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterConfigStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterConfigStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 10
+            bb.writeShort((short) 0xa);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeInt(U32.t(message.meterId));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterConfigStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("meterId=").append(meterId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterConfigStatsRequestVer13 other = (OFMeterConfigStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( meterId != other.meterId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime *  (int) (meterId ^ (meterId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigVer13.java
new file mode 100644
index 0000000..ac8b348
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigVer13.java
@@ -0,0 +1,345 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterConfigVer13 implements OFMeterConfig {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterConfigVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+        private final static int DEFAULT_FLAGS = 0x0;
+        private final static long DEFAULT_METER_ID = 0x0L;
+        private final static List<OFMeterBand> DEFAULT_ENTRIES = ImmutableList.<OFMeterBand>of();
+
+    // OF message fields
+    private final int flags;
+    private final long meterId;
+    private final List<OFMeterBand> entries;
+//
+    // Immutable default instance
+    final static OFMeterConfigVer13 DEFAULT = new OFMeterConfigVer13(
+        DEFAULT_FLAGS, DEFAULT_METER_ID, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterConfigVer13(int flags, long meterId, List<OFMeterBand> entries) {
+        this.flags = flags;
+        this.meterId = meterId;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public List<OFMeterBand> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFMeterConfig.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterConfig.Builder {
+        final OFMeterConfigVer13 parentMessage;
+
+        // OF message fields
+        private boolean flagsSet;
+        private int flags;
+        private boolean meterIdSet;
+        private long meterId;
+        private boolean entriesSet;
+        private List<OFMeterBand> entries;
+
+        BuilderWithParent(OFMeterConfigVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterConfig.Builder setFlags(int flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterConfig.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterBand> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFMeterConfig.Builder setEntries(List<OFMeterBand> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFMeterConfig build() {
+                int flags = this.flagsSet ? this.flags : parentMessage.flags;
+                long meterId = this.meterIdSet ? this.meterId : parentMessage.meterId;
+                List<OFMeterBand> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFMeterConfigVer13(
+                    flags,
+                    meterId,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterConfig.Builder {
+        // OF message fields
+        private boolean flagsSet;
+        private int flags;
+        private boolean meterIdSet;
+        private long meterId;
+        private boolean entriesSet;
+        private List<OFMeterBand> entries;
+
+    @Override
+    public int getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterConfig.Builder setFlags(int flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterConfig.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterBand> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFMeterConfig.Builder setEntries(List<OFMeterBand> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFMeterConfig build() {
+            int flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            long meterId = this.meterIdSet ? this.meterId : DEFAULT_METER_ID;
+            List<OFMeterBand> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFMeterConfigVer13(
+                    flags,
+                    meterId,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterConfig> {
+        @Override
+        public OFMeterConfig readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            int flags = U16.f(bb.readShort());
+            long meterId = U32.f(bb.readInt());
+            List<OFMeterBand> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFMeterBandVer13.READER);
+
+            OFMeterConfigVer13 meterConfigVer13 = new OFMeterConfigVer13(
+                    flags,
+                      meterId,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterConfigVer13);
+            return meterConfigVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterConfigVer13Funnel FUNNEL = new OFMeterConfigVer13Funnel();
+    static class OFMeterConfigVer13Funnel implements Funnel<OFMeterConfigVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterConfigVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            sink.putInt(message.flags);
+            sink.putLong(message.meterId);
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterConfigVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterConfigVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeShort(U16.t(message.flags));
+            bb.writeInt(U32.t(message.meterId));
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterConfigVer13(");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("meterId=").append(meterId);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterConfigVer13 other = (OFMeterConfigVer13) obj;
+
+        if( flags != other.flags)
+            return false;
+        if( meterId != other.meterId)
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + flags;
+        result = prime *  (int) (meterId ^ (meterId >>> 32));
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesStatsReplyVer13.java
new file mode 100644
index 0000000..da0f2ec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesStatsReplyVer13.java
@@ -0,0 +1,401 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterFeaturesStatsReplyVer13 implements OFMeterFeaturesStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterFeaturesStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 32;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final OFMeterFeatures features;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterFeaturesStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, OFMeterFeatures features) {
+        this.xid = xid;
+        this.flags = flags;
+        this.features = features;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterFeatures getFeatures() {
+        return features;
+    }
+
+
+
+    public OFMeterFeaturesStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterFeaturesStatsReply.Builder {
+        final OFMeterFeaturesStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean featuresSet;
+        private OFMeterFeatures features;
+
+        BuilderWithParent(OFMeterFeaturesStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFMeterFeatures getFeatures() {
+        return features;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsReply.Builder setFeatures(OFMeterFeatures features) {
+        this.features = features;
+        this.featuresSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFMeterFeaturesStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFMeterFeatures features = this.featuresSet ? this.features : parentMessage.features;
+                if(features == null)
+                    throw new NullPointerException("Property features must not be null");
+
+                //
+                return new OFMeterFeaturesStatsReplyVer13(
+                    xid,
+                    flags,
+                    features
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterFeaturesStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean featuresSet;
+        private OFMeterFeatures features;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFMeterFeatures getFeatures() {
+        return features;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsReply.Builder setFeatures(OFMeterFeatures features) {
+        this.features = features;
+        this.featuresSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFMeterFeaturesStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            if(!this.featuresSet)
+                throw new IllegalStateException("Property features doesn't have default value -- must be set");
+            if(features == null)
+                throw new NullPointerException("Property features must not be null");
+
+
+            return new OFMeterFeaturesStatsReplyVer13(
+                    xid,
+                    flags,
+                    features
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterFeaturesStatsReply> {
+        @Override
+        public OFMeterFeaturesStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 32)
+                throw new OFParseError("Wrong length: Expected=32(32), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 11
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xb)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.METER_FEATURES(11), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFMeterFeatures features = OFMeterFeaturesVer13.READER.readFrom(bb);
+
+            OFMeterFeaturesStatsReplyVer13 meterFeaturesStatsReplyVer13 = new OFMeterFeaturesStatsReplyVer13(
+                    xid,
+                      flags,
+                      features
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterFeaturesStatsReplyVer13);
+            return meterFeaturesStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterFeaturesStatsReplyVer13Funnel FUNNEL = new OFMeterFeaturesStatsReplyVer13Funnel();
+    static class OFMeterFeaturesStatsReplyVer13Funnel implements Funnel<OFMeterFeaturesStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterFeaturesStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // fixed value property length = 32
+            sink.putShort((short) 0x20);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 11
+            sink.putShort((short) 0xb);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.features.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterFeaturesStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterFeaturesStatsReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // fixed value property length = 32
+            bb.writeShort((short) 0x20);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 11
+            bb.writeShort((short) 0xb);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.features.writeTo(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterFeaturesStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("features=").append(features);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterFeaturesStatsReplyVer13 other = (OFMeterFeaturesStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (features == null) {
+            if (other.features != null)
+                return false;
+        } else if (!features.equals(other.features))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((features == null) ? 0 : features.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesStatsRequestVer13.java
new file mode 100644
index 0000000..2c5c314
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesStatsRequestVer13.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterFeaturesStatsRequestVer13 implements OFMeterFeaturesStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterFeaturesStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFMeterFeaturesStatsRequestVer13 DEFAULT = new OFMeterFeaturesStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterFeaturesStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFMeterFeaturesStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterFeaturesStatsRequest.Builder {
+        final OFMeterFeaturesStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFMeterFeaturesStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFMeterFeaturesStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFMeterFeaturesStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterFeaturesStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterFeaturesStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFMeterFeaturesStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFMeterFeaturesStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterFeaturesStatsRequest> {
+        @Override
+        public OFMeterFeaturesStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 11
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xb)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.METER_FEATURES(11), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFMeterFeaturesStatsRequestVer13 meterFeaturesStatsRequestVer13 = new OFMeterFeaturesStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterFeaturesStatsRequestVer13);
+            return meterFeaturesStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterFeaturesStatsRequestVer13Funnel FUNNEL = new OFMeterFeaturesStatsRequestVer13Funnel();
+    static class OFMeterFeaturesStatsRequestVer13Funnel implements Funnel<OFMeterFeaturesStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterFeaturesStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 11
+            sink.putShort((short) 0xb);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterFeaturesStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterFeaturesStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 11
+            bb.writeShort((short) 0xb);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterFeaturesStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterFeaturesStatsRequestVer13 other = (OFMeterFeaturesStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesVer13.java
new file mode 100644
index 0000000..a1168da
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFeaturesVer13.java
@@ -0,0 +1,415 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterFeaturesVer13 implements OFMeterFeatures {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterFeaturesVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_MAX_METER = 0x0L;
+        private final static long DEFAULT_BAND_TYPES = 0x0L;
+        private final static long DEFAULT_CAPABILITIES = 0x0L;
+        private final static short DEFAULT_MAX_BANDS = (short) 0x0;
+        private final static short DEFAULT_MAX_COLOR = (short) 0x0;
+
+    // OF message fields
+    private final long maxMeter;
+    private final long bandTypes;
+    private final long capabilities;
+    private final short maxBands;
+    private final short maxColor;
+//
+    // Immutable default instance
+    final static OFMeterFeaturesVer13 DEFAULT = new OFMeterFeaturesVer13(
+        DEFAULT_MAX_METER, DEFAULT_BAND_TYPES, DEFAULT_CAPABILITIES, DEFAULT_MAX_BANDS, DEFAULT_MAX_COLOR
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterFeaturesVer13(long maxMeter, long bandTypes, long capabilities, short maxBands, short maxColor) {
+        this.maxMeter = maxMeter;
+        this.bandTypes = bandTypes;
+        this.capabilities = capabilities;
+        this.maxBands = maxBands;
+        this.maxColor = maxColor;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getMaxMeter() {
+        return maxMeter;
+    }
+
+    @Override
+    public long getBandTypes() {
+        return bandTypes;
+    }
+
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public short getMaxBands() {
+        return maxBands;
+    }
+
+    @Override
+    public short getMaxColor() {
+        return maxColor;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFMeterFeatures.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterFeatures.Builder {
+        final OFMeterFeaturesVer13 parentMessage;
+
+        // OF message fields
+        private boolean maxMeterSet;
+        private long maxMeter;
+        private boolean bandTypesSet;
+        private long bandTypes;
+        private boolean capabilitiesSet;
+        private long capabilities;
+        private boolean maxBandsSet;
+        private short maxBands;
+        private boolean maxColorSet;
+        private short maxColor;
+
+        BuilderWithParent(OFMeterFeaturesVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getMaxMeter() {
+        return maxMeter;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setMaxMeter(long maxMeter) {
+        this.maxMeter = maxMeter;
+        this.maxMeterSet = true;
+        return this;
+    }
+    @Override
+    public long getBandTypes() {
+        return bandTypes;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setBandTypes(long bandTypes) {
+        this.bandTypes = bandTypes;
+        this.bandTypesSet = true;
+        return this;
+    }
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setCapabilities(long capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public short getMaxBands() {
+        return maxBands;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setMaxBands(short maxBands) {
+        this.maxBands = maxBands;
+        this.maxBandsSet = true;
+        return this;
+    }
+    @Override
+    public short getMaxColor() {
+        return maxColor;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setMaxColor(short maxColor) {
+        this.maxColor = maxColor;
+        this.maxColorSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFMeterFeatures build() {
+                long maxMeter = this.maxMeterSet ? this.maxMeter : parentMessage.maxMeter;
+                long bandTypes = this.bandTypesSet ? this.bandTypes : parentMessage.bandTypes;
+                long capabilities = this.capabilitiesSet ? this.capabilities : parentMessage.capabilities;
+                short maxBands = this.maxBandsSet ? this.maxBands : parentMessage.maxBands;
+                short maxColor = this.maxColorSet ? this.maxColor : parentMessage.maxColor;
+
+                //
+                return new OFMeterFeaturesVer13(
+                    maxMeter,
+                    bandTypes,
+                    capabilities,
+                    maxBands,
+                    maxColor
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterFeatures.Builder {
+        // OF message fields
+        private boolean maxMeterSet;
+        private long maxMeter;
+        private boolean bandTypesSet;
+        private long bandTypes;
+        private boolean capabilitiesSet;
+        private long capabilities;
+        private boolean maxBandsSet;
+        private short maxBands;
+        private boolean maxColorSet;
+        private short maxColor;
+
+    @Override
+    public long getMaxMeter() {
+        return maxMeter;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setMaxMeter(long maxMeter) {
+        this.maxMeter = maxMeter;
+        this.maxMeterSet = true;
+        return this;
+    }
+    @Override
+    public long getBandTypes() {
+        return bandTypes;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setBandTypes(long bandTypes) {
+        this.bandTypes = bandTypes;
+        this.bandTypesSet = true;
+        return this;
+    }
+    @Override
+    public long getCapabilities() {
+        return capabilities;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setCapabilities(long capabilities) {
+        this.capabilities = capabilities;
+        this.capabilitiesSet = true;
+        return this;
+    }
+    @Override
+    public short getMaxBands() {
+        return maxBands;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setMaxBands(short maxBands) {
+        this.maxBands = maxBands;
+        this.maxBandsSet = true;
+        return this;
+    }
+    @Override
+    public short getMaxColor() {
+        return maxColor;
+    }
+
+    @Override
+    public OFMeterFeatures.Builder setMaxColor(short maxColor) {
+        this.maxColor = maxColor;
+        this.maxColorSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFMeterFeatures build() {
+            long maxMeter = this.maxMeterSet ? this.maxMeter : DEFAULT_MAX_METER;
+            long bandTypes = this.bandTypesSet ? this.bandTypes : DEFAULT_BAND_TYPES;
+            long capabilities = this.capabilitiesSet ? this.capabilities : DEFAULT_CAPABILITIES;
+            short maxBands = this.maxBandsSet ? this.maxBands : DEFAULT_MAX_BANDS;
+            short maxColor = this.maxColorSet ? this.maxColor : DEFAULT_MAX_COLOR;
+
+
+            return new OFMeterFeaturesVer13(
+                    maxMeter,
+                    bandTypes,
+                    capabilities,
+                    maxBands,
+                    maxColor
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterFeatures> {
+        @Override
+        public OFMeterFeatures readFrom(ChannelBuffer bb) throws OFParseError {
+            long maxMeter = U32.f(bb.readInt());
+            long bandTypes = U32.f(bb.readInt());
+            long capabilities = U32.f(bb.readInt());
+            short maxBands = U8.f(bb.readByte());
+            short maxColor = U8.f(bb.readByte());
+            // pad: 2 bytes
+            bb.skipBytes(2);
+
+            OFMeterFeaturesVer13 meterFeaturesVer13 = new OFMeterFeaturesVer13(
+                    maxMeter,
+                      bandTypes,
+                      capabilities,
+                      maxBands,
+                      maxColor
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterFeaturesVer13);
+            return meterFeaturesVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterFeaturesVer13Funnel FUNNEL = new OFMeterFeaturesVer13Funnel();
+    static class OFMeterFeaturesVer13Funnel implements Funnel<OFMeterFeaturesVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterFeaturesVer13 message, PrimitiveSink sink) {
+            sink.putLong(message.maxMeter);
+            sink.putLong(message.bandTypes);
+            sink.putLong(message.capabilities);
+            sink.putShort(message.maxBands);
+            sink.putShort(message.maxColor);
+            // skip pad (2 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterFeaturesVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterFeaturesVer13 message) {
+            bb.writeInt(U32.t(message.maxMeter));
+            bb.writeInt(U32.t(message.bandTypes));
+            bb.writeInt(U32.t(message.capabilities));
+            bb.writeByte(U8.t(message.maxBands));
+            bb.writeByte(U8.t(message.maxColor));
+            // pad: 2 bytes
+            bb.writeZero(2);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterFeaturesVer13(");
+        b.append("maxMeter=").append(maxMeter);
+        b.append(", ");
+        b.append("bandTypes=").append(bandTypes);
+        b.append(", ");
+        b.append("capabilities=").append(capabilities);
+        b.append(", ");
+        b.append("maxBands=").append(maxBands);
+        b.append(", ");
+        b.append("maxColor=").append(maxColor);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterFeaturesVer13 other = (OFMeterFeaturesVer13) obj;
+
+        if( maxMeter != other.maxMeter)
+            return false;
+        if( bandTypes != other.bandTypes)
+            return false;
+        if( capabilities != other.capabilities)
+            return false;
+        if( maxBands != other.maxBands)
+            return false;
+        if( maxColor != other.maxColor)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (maxMeter ^ (maxMeter >>> 32));
+        result = prime *  (int) (bandTypes ^ (bandTypes >>> 32));
+        result = prime *  (int) (capabilities ^ (capabilities >>> 32));
+        result = prime * result + maxBands;
+        result = prime * result + maxColor;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFlagsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFlagsSerializerVer13.java
new file mode 100644
index 0000000..8a5eb05
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterFlagsSerializerVer13.java
@@ -0,0 +1,96 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFMeterFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFMeterFlagsSerializerVer13 {
+
+    public final static short KBPS_VAL = (short) 0x1;
+    public final static short PKTPS_VAL = (short) 0x2;
+    public final static short BURST_VAL = (short) 0x4;
+    public final static short STATS_VAL = (short) 0x8;
+
+    public static Set<OFMeterFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFMeterFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFMeterFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFMeterFlags> ofWireValue(short val) {
+        EnumSet<OFMeterFlags> set = EnumSet.noneOf(OFMeterFlags.class);
+
+        if((val & KBPS_VAL) != 0)
+            set.add(OFMeterFlags.KBPS);
+        if((val & PKTPS_VAL) != 0)
+            set.add(OFMeterFlags.PKTPS);
+        if((val & BURST_VAL) != 0)
+            set.add(OFMeterFlags.BURST);
+        if((val & STATS_VAL) != 0)
+            set.add(OFMeterFlags.STATS);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFMeterFlags> set) {
+        short wireValue = 0;
+
+        for(OFMeterFlags e: set) {
+            switch(e) {
+                case KBPS:
+                    wireValue |= KBPS_VAL;
+                    break;
+                case PKTPS:
+                    wireValue |= PKTPS_VAL;
+                    break;
+                case BURST:
+                    wireValue |= BURST_VAL;
+                    break;
+                case STATS:
+                    wireValue |= STATS_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFMeterFlags in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModCommandSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModCommandSerializerVer13.java
new file mode 100644
index 0000000..4668dab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModCommandSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFMeterModCommand;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFMeterModCommandSerializerVer13 {
+
+    public final static short ADD_VAL = (short) 0x0;
+    public final static short MODIFY_VAL = (short) 0x1;
+    public final static short DELETE_VAL = (short) 0x2;
+
+    public static OFMeterModCommand readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFMeterModCommand e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFMeterModCommand e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFMeterModCommand ofWireValue(short val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFMeterModCommand.ADD;
+            case MODIFY_VAL:
+                return OFMeterModCommand.MODIFY;
+            case DELETE_VAL:
+                return OFMeterModCommand.DELETE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFMeterModCommand in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFMeterModCommand e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFMeterModCommand in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..114f21b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModFailedCodeSerializerVer13.java
@@ -0,0 +1,124 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFMeterModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFMeterModFailedCodeSerializerVer13 {
+
+    public final static short UNKNOWN_VAL = (short) 0x0;
+    public final static short METER_EXISTS_VAL = (short) 0x1;
+    public final static short INVALID_METER_VAL = (short) 0x2;
+    public final static short UNKNOWN_METER_VAL = (short) 0x3;
+    public final static short BAD_COMMAND_VAL = (short) 0x4;
+    public final static short BAD_FLAGS_VAL = (short) 0x5;
+    public final static short BAD_RATE_VAL = (short) 0x6;
+    public final static short BAD_BURST_VAL = (short) 0x7;
+    public final static short BAD_BAND_VAL = (short) 0x8;
+    public final static short BAD_BAND_VALUE_VAL = (short) 0x9;
+    public final static short OUT_OF_METERS_VAL = (short) 0xa;
+    public final static short OUT_OF_BANDS_VAL = (short) 0xb;
+
+    public static OFMeterModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFMeterModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFMeterModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFMeterModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case UNKNOWN_VAL:
+                return OFMeterModFailedCode.UNKNOWN;
+            case METER_EXISTS_VAL:
+                return OFMeterModFailedCode.METER_EXISTS;
+            case INVALID_METER_VAL:
+                return OFMeterModFailedCode.INVALID_METER;
+            case UNKNOWN_METER_VAL:
+                return OFMeterModFailedCode.UNKNOWN_METER;
+            case BAD_COMMAND_VAL:
+                return OFMeterModFailedCode.BAD_COMMAND;
+            case BAD_FLAGS_VAL:
+                return OFMeterModFailedCode.BAD_FLAGS;
+            case BAD_RATE_VAL:
+                return OFMeterModFailedCode.BAD_RATE;
+            case BAD_BURST_VAL:
+                return OFMeterModFailedCode.BAD_BURST;
+            case BAD_BAND_VAL:
+                return OFMeterModFailedCode.BAD_BAND;
+            case BAD_BAND_VALUE_VAL:
+                return OFMeterModFailedCode.BAD_BAND_VALUE;
+            case OUT_OF_METERS_VAL:
+                return OFMeterModFailedCode.OUT_OF_METERS;
+            case OUT_OF_BANDS_VAL:
+                return OFMeterModFailedCode.OUT_OF_BANDS;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFMeterModFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFMeterModFailedCode e) {
+        switch(e) {
+            case UNKNOWN:
+                return UNKNOWN_VAL;
+            case METER_EXISTS:
+                return METER_EXISTS_VAL;
+            case INVALID_METER:
+                return INVALID_METER_VAL;
+            case UNKNOWN_METER:
+                return UNKNOWN_METER_VAL;
+            case BAD_COMMAND:
+                return BAD_COMMAND_VAL;
+            case BAD_FLAGS:
+                return BAD_FLAGS_VAL;
+            case BAD_RATE:
+                return BAD_RATE_VAL;
+            case BAD_BURST:
+                return BAD_BURST_VAL;
+            case BAD_BAND:
+                return BAD_BAND_VAL;
+            case BAD_BAND_VALUE:
+                return BAD_BAND_VALUE_VAL;
+            case OUT_OF_METERS:
+                return OUT_OF_METERS_VAL;
+            case OUT_OF_BANDS:
+                return OUT_OF_BANDS_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFMeterModFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModFailedErrorMsgVer13.java
new file mode 100644
index 0000000..be2281d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterModFailedErrorMsgVer13 implements OFMeterModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterModFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFMeterModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterModFailedErrorMsgVer13(long xid, OFMeterModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.METER_MOD_FAILED;
+    }
+
+    @Override
+    public OFMeterModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFMeterModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterModFailedErrorMsg.Builder {
+        final OFMeterModFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFMeterModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFMeterModFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.METER_MOD_FAILED;
+    }
+
+    @Override
+    public OFMeterModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFMeterModFailedErrorMsg.Builder setCode(OFMeterModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFMeterModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFMeterModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFMeterModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFMeterModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFMeterModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.METER_MOD_FAILED;
+    }
+
+    @Override
+    public OFMeterModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFMeterModFailedErrorMsg.Builder setCode(OFMeterModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFMeterModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFMeterModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFMeterModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterModFailedErrorMsg> {
+        @Override
+        public OFMeterModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 12
+            short errType = bb.readShort();
+            if(errType != (short) 0xc)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.METER_MOD_FAILED(12), got="+errType);
+            OFMeterModFailedCode code = OFMeterModFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFMeterModFailedErrorMsgVer13 meterModFailedErrorMsgVer13 = new OFMeterModFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterModFailedErrorMsgVer13);
+            return meterModFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterModFailedErrorMsgVer13Funnel FUNNEL = new OFMeterModFailedErrorMsgVer13Funnel();
+    static class OFMeterModFailedErrorMsgVer13Funnel implements Funnel<OFMeterModFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterModFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 12
+            sink.putShort((short) 0xc);
+            OFMeterModFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterModFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterModFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 12
+            bb.writeShort((short) 0xc);
+            OFMeterModFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterModFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterModFailedErrorMsgVer13 other = (OFMeterModFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModVer13.java
new file mode 100644
index 0000000..e9aeb25
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterModVer13.java
@@ -0,0 +1,470 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterModVer13 implements OFMeterMod {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterModVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static int DEFAULT_COMMAND = 0x0;
+        private final static int DEFAULT_FLAGS = 0x0;
+        private final static long DEFAULT_METER_ID = 0x0L;
+        private final static List<OFMeterBand> DEFAULT_METERS = ImmutableList.<OFMeterBand>of();
+
+    // OF message fields
+    private final long xid;
+    private final int command;
+    private final int flags;
+    private final long meterId;
+    private final List<OFMeterBand> meters;
+//
+    // Immutable default instance
+    final static OFMeterModVer13 DEFAULT = new OFMeterModVer13(
+        DEFAULT_XID, DEFAULT_COMMAND, DEFAULT_FLAGS, DEFAULT_METER_ID, DEFAULT_METERS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterModVer13(long xid, int command, int flags, long meterId, List<OFMeterBand> meters) {
+        this.xid = xid;
+        this.command = command;
+        this.flags = flags;
+        this.meterId = meterId;
+        this.meters = meters;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.METER_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public int getCommand() {
+        return command;
+    }
+
+    @Override
+    public int getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public List<OFMeterBand> getMeters() {
+        return meters;
+    }
+
+
+
+    public OFMeterMod.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterMod.Builder {
+        final OFMeterModVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean commandSet;
+        private int command;
+        private boolean flagsSet;
+        private int flags;
+        private boolean meterIdSet;
+        private long meterId;
+        private boolean metersSet;
+        private List<OFMeterBand> meters;
+
+        BuilderWithParent(OFMeterModVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.METER_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public int getCommand() {
+        return command;
+    }
+
+    @Override
+    public OFMeterMod.Builder setCommand(int command) {
+        this.command = command;
+        this.commandSet = true;
+        return this;
+    }
+    @Override
+    public int getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterMod.Builder setFlags(int flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterMod.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterBand> getMeters() {
+        return meters;
+    }
+
+    @Override
+    public OFMeterMod.Builder setMeters(List<OFMeterBand> meters) {
+        this.meters = meters;
+        this.metersSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFMeterMod build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                int command = this.commandSet ? this.command : parentMessage.command;
+                int flags = this.flagsSet ? this.flags : parentMessage.flags;
+                long meterId = this.meterIdSet ? this.meterId : parentMessage.meterId;
+                List<OFMeterBand> meters = this.metersSet ? this.meters : parentMessage.meters;
+                if(meters == null)
+                    throw new NullPointerException("Property meters must not be null");
+
+                //
+                return new OFMeterModVer13(
+                    xid,
+                    command,
+                    flags,
+                    meterId,
+                    meters
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterMod.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean commandSet;
+        private int command;
+        private boolean flagsSet;
+        private int flags;
+        private boolean meterIdSet;
+        private long meterId;
+        private boolean metersSet;
+        private List<OFMeterBand> meters;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.METER_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public int getCommand() {
+        return command;
+    }
+
+    @Override
+    public OFMeterMod.Builder setCommand(int command) {
+        this.command = command;
+        this.commandSet = true;
+        return this;
+    }
+    @Override
+    public int getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterMod.Builder setFlags(int flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterMod.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterBand> getMeters() {
+        return meters;
+    }
+
+    @Override
+    public OFMeterMod.Builder setMeters(List<OFMeterBand> meters) {
+        this.meters = meters;
+        this.metersSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFMeterMod build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            int command = this.commandSet ? this.command : DEFAULT_COMMAND;
+            int flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            long meterId = this.meterIdSet ? this.meterId : DEFAULT_METER_ID;
+            List<OFMeterBand> meters = this.metersSet ? this.meters : DEFAULT_METERS;
+            if(meters == null)
+                throw new NullPointerException("Property meters must not be null");
+
+
+            return new OFMeterModVer13(
+                    xid,
+                    command,
+                    flags,
+                    meterId,
+                    meters
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterMod> {
+        @Override
+        public OFMeterMod readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 29
+            byte type = bb.readByte();
+            if(type != (byte) 0x1d)
+                throw new OFParseError("Wrong type: Expected=OFType.METER_MOD(29), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            int command = U16.f(bb.readShort());
+            int flags = U16.f(bb.readShort());
+            long meterId = U32.f(bb.readInt());
+            List<OFMeterBand> meters = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFMeterBandVer13.READER);
+
+            OFMeterModVer13 meterModVer13 = new OFMeterModVer13(
+                    xid,
+                      command,
+                      flags,
+                      meterId,
+                      meters
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterModVer13);
+            return meterModVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterModVer13Funnel FUNNEL = new OFMeterModVer13Funnel();
+    static class OFMeterModVer13Funnel implements Funnel<OFMeterModVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterModVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 29
+            sink.putByte((byte) 0x1d);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            sink.putInt(message.command);
+            sink.putInt(message.flags);
+            sink.putLong(message.meterId);
+            FunnelUtils.putList(message.meters, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterModVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterModVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 29
+            bb.writeByte((byte) 0x1d);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeShort(U16.t(message.command));
+            bb.writeShort(U16.t(message.flags));
+            bb.writeInt(U32.t(message.meterId));
+            ChannelUtils.writeList(bb, message.meters);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterModVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("command=").append(command);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("meterId=").append(meterId);
+        b.append(", ");
+        b.append("meters=").append(meters);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterModVer13 other = (OFMeterModVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if( command != other.command)
+            return false;
+        if( flags != other.flags)
+            return false;
+        if( meterId != other.meterId)
+            return false;
+        if (meters == null) {
+            if (other.meters != null)
+                return false;
+        } else if (!meters.equals(other.meters))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + command;
+        result = prime * result + flags;
+        result = prime *  (int) (meterId ^ (meterId >>> 32));
+        result = prime * result + ((meters == null) ? 0 : meters.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterSerializerVer13.java
new file mode 100644
index 0000000..141cfe4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterSerializerVer13.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFMeter;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFMeterSerializerVer13 {
+
+    public final static int MAX_VAL = (int) 0xffff0000;
+    public final static int SLOWPATH_VAL = (int) 0xfffffffd;
+    public final static int CONTROLLER_VAL = (int) 0xfffffffe;
+    public final static int ALL_VAL = (int) 0xffffffff;
+
+    public static OFMeter readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFMeter e) {
+        bb.writeInt(toWireValue(e));
+    }
+
+    public static void putTo(OFMeter e, PrimitiveSink sink) {
+        sink.putInt(toWireValue(e));
+    }
+
+    public static OFMeter ofWireValue(int val) {
+        switch(val) {
+            case MAX_VAL:
+                return OFMeter.MAX;
+            case SLOWPATH_VAL:
+                return OFMeter.SLOWPATH;
+            case CONTROLLER_VAL:
+                return OFMeter.CONTROLLER;
+            case ALL_VAL:
+                return OFMeter.ALL;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFMeter in version 1.3: " + val);
+        }
+    }
+
+
+    public static int toWireValue(OFMeter e) {
+        switch(e) {
+            case MAX:
+                return MAX_VAL;
+            case SLOWPATH:
+                return SLOWPATH_VAL;
+            case CONTROLLER:
+                return CONTROLLER_VAL;
+            case ALL:
+                return ALL_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFMeter in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsReplyVer13.java
new file mode 100644
index 0000000..135f96b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterStatsReplyVer13 implements OFMeterStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFMeterStats> DEFAULT_ENTRIES = ImmutableList.<OFMeterStats>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFMeterStats> entries;
+//
+    // Immutable default instance
+    final static OFMeterStatsReplyVer13 DEFAULT = new OFMeterStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFMeterStats> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFMeterStats> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFMeterStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterStatsReply.Builder {
+        final OFMeterStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFMeterStats> entries;
+
+        BuilderWithParent(OFMeterStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterStats> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFMeterStatsReply.Builder setEntries(List<OFMeterStats> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFMeterStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFMeterStats> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFMeterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFMeterStats> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterStats> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFMeterStatsReply.Builder setEntries(List<OFMeterStats> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFMeterStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFMeterStats> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFMeterStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterStatsReply> {
+        @Override
+        public OFMeterStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 9
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x9)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.METER(9), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFMeterStats> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFMeterStatsVer13.READER);
+
+            OFMeterStatsReplyVer13 meterStatsReplyVer13 = new OFMeterStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterStatsReplyVer13);
+            return meterStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterStatsReplyVer13Funnel FUNNEL = new OFMeterStatsReplyVer13Funnel();
+    static class OFMeterStatsReplyVer13Funnel implements Funnel<OFMeterStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 9
+            sink.putShort((short) 0x9);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 9
+            bb.writeShort((short) 0x9);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterStatsReplyVer13 other = (OFMeterStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsRequestVer13.java
new file mode 100644
index 0000000..c9a0133
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsRequestVer13.java
@@ -0,0 +1,403 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterStatsRequestVer13 implements OFMeterStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static long DEFAULT_METER_ID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final long meterId;
+//
+    // Immutable default instance
+    final static OFMeterStatsRequestVer13 DEFAULT = new OFMeterStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_METER_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, long meterId) {
+        this.xid = xid;
+        this.flags = flags;
+        this.meterId = meterId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+
+
+    public OFMeterStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterStatsRequest.Builder {
+        final OFMeterStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean meterIdSet;
+        private long meterId;
+
+        BuilderWithParent(OFMeterStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterStatsRequest.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFMeterStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                long meterId = this.meterIdSet ? this.meterId : parentMessage.meterId;
+
+                //
+                return new OFMeterStatsRequestVer13(
+                    xid,
+                    flags,
+                    meterId
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean meterIdSet;
+        private long meterId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFMeterStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.METER;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFMeterStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterStatsRequest.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFMeterStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            long meterId = this.meterIdSet ? this.meterId : DEFAULT_METER_ID;
+
+
+            return new OFMeterStatsRequestVer13(
+                    xid,
+                    flags,
+                    meterId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterStatsRequest> {
+        @Override
+        public OFMeterStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 9
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x9)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.METER(9), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            long meterId = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFMeterStatsRequestVer13 meterStatsRequestVer13 = new OFMeterStatsRequestVer13(
+                    xid,
+                      flags,
+                      meterId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterStatsRequestVer13);
+            return meterStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterStatsRequestVer13Funnel FUNNEL = new OFMeterStatsRequestVer13Funnel();
+    static class OFMeterStatsRequestVer13Funnel implements Funnel<OFMeterStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 9
+            sink.putShort((short) 0x9);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            sink.putLong(message.meterId);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 9
+            bb.writeShort((short) 0x9);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeInt(U32.t(message.meterId));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("meterId=").append(meterId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterStatsRequestVer13 other = (OFMeterStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( meterId != other.meterId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime *  (int) (meterId ^ (meterId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsVer13.java
new file mode 100644
index 0000000..e5f5591
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsVer13.java
@@ -0,0 +1,552 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFMeterStatsVer13 implements OFMeterStats {
+    private static final Logger logger = LoggerFactory.getLogger(OFMeterStatsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 40;
+
+        private final static long DEFAULT_METER_ID = 0x0L;
+        private final static long DEFAULT_FLOW_COUNT = 0x0L;
+        private final static U64 DEFAULT_PACKET_IN_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_BYTE_IN_COUNT = U64.ZERO;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+        private final static List<OFMeterBandStats> DEFAULT_BAND_STATS = ImmutableList.<OFMeterBandStats>of();
+
+    // OF message fields
+    private final long meterId;
+    private final long flowCount;
+    private final U64 packetInCount;
+    private final U64 byteInCount;
+    private final long durationSec;
+    private final long durationNsec;
+    private final List<OFMeterBandStats> bandStats;
+//
+    // Immutable default instance
+    final static OFMeterStatsVer13 DEFAULT = new OFMeterStatsVer13(
+        DEFAULT_METER_ID, DEFAULT_FLOW_COUNT, DEFAULT_PACKET_IN_COUNT, DEFAULT_BYTE_IN_COUNT, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC, DEFAULT_BAND_STATS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFMeterStatsVer13(long meterId, long flowCount, U64 packetInCount, U64 byteInCount, long durationSec, long durationNsec, List<OFMeterBandStats> bandStats) {
+        this.meterId = meterId;
+        this.flowCount = flowCount;
+        this.packetInCount = packetInCount;
+        this.byteInCount = byteInCount;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+        this.bandStats = bandStats;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public U64 getPacketInCount() {
+        return packetInCount;
+    }
+
+    @Override
+    public U64 getByteInCount() {
+        return byteInCount;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public List<OFMeterBandStats> getBandStats() {
+        return bandStats;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFMeterStats.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFMeterStats.Builder {
+        final OFMeterStatsVer13 parentMessage;
+
+        // OF message fields
+        private boolean meterIdSet;
+        private long meterId;
+        private boolean flowCountSet;
+        private long flowCount;
+        private boolean packetInCountSet;
+        private U64 packetInCount;
+        private boolean byteInCountSet;
+        private U64 byteInCount;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean bandStatsSet;
+        private List<OFMeterBandStats> bandStats;
+
+        BuilderWithParent(OFMeterStatsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterStats.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFMeterStats.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketInCount() {
+        return packetInCount;
+    }
+
+    @Override
+    public OFMeterStats.Builder setPacketInCount(U64 packetInCount) {
+        this.packetInCount = packetInCount;
+        this.packetInCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteInCount() {
+        return byteInCount;
+    }
+
+    @Override
+    public OFMeterStats.Builder setByteInCount(U64 byteInCount) {
+        this.byteInCount = byteInCount;
+        this.byteInCountSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFMeterStats.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFMeterStats.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterBandStats> getBandStats() {
+        return bandStats;
+    }
+
+    @Override
+    public OFMeterStats.Builder setBandStats(List<OFMeterBandStats> bandStats) {
+        this.bandStats = bandStats;
+        this.bandStatsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFMeterStats build() {
+                long meterId = this.meterIdSet ? this.meterId : parentMessage.meterId;
+                long flowCount = this.flowCountSet ? this.flowCount : parentMessage.flowCount;
+                U64 packetInCount = this.packetInCountSet ? this.packetInCount : parentMessage.packetInCount;
+                if(packetInCount == null)
+                    throw new NullPointerException("Property packetInCount must not be null");
+                U64 byteInCount = this.byteInCountSet ? this.byteInCount : parentMessage.byteInCount;
+                if(byteInCount == null)
+                    throw new NullPointerException("Property byteInCount must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+                List<OFMeterBandStats> bandStats = this.bandStatsSet ? this.bandStats : parentMessage.bandStats;
+                if(bandStats == null)
+                    throw new NullPointerException("Property bandStats must not be null");
+
+                //
+                return new OFMeterStatsVer13(
+                    meterId,
+                    flowCount,
+                    packetInCount,
+                    byteInCount,
+                    durationSec,
+                    durationNsec,
+                    bandStats
+                );
+        }
+
+    }
+
+    static class Builder implements OFMeterStats.Builder {
+        // OF message fields
+        private boolean meterIdSet;
+        private long meterId;
+        private boolean flowCountSet;
+        private long flowCount;
+        private boolean packetInCountSet;
+        private U64 packetInCount;
+        private boolean byteInCountSet;
+        private U64 byteInCount;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+        private boolean bandStatsSet;
+        private List<OFMeterBandStats> bandStats;
+
+    @Override
+    public long getMeterId() {
+        return meterId;
+    }
+
+    @Override
+    public OFMeterStats.Builder setMeterId(long meterId) {
+        this.meterId = meterId;
+        this.meterIdSet = true;
+        return this;
+    }
+    @Override
+    public long getFlowCount() {
+        return flowCount;
+    }
+
+    @Override
+    public OFMeterStats.Builder setFlowCount(long flowCount) {
+        this.flowCount = flowCount;
+        this.flowCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getPacketInCount() {
+        return packetInCount;
+    }
+
+    @Override
+    public OFMeterStats.Builder setPacketInCount(U64 packetInCount) {
+        this.packetInCount = packetInCount;
+        this.packetInCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getByteInCount() {
+        return byteInCount;
+    }
+
+    @Override
+    public OFMeterStats.Builder setByteInCount(U64 byteInCount) {
+        this.byteInCount = byteInCount;
+        this.byteInCountSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFMeterStats.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFMeterStats.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public List<OFMeterBandStats> getBandStats() {
+        return bandStats;
+    }
+
+    @Override
+    public OFMeterStats.Builder setBandStats(List<OFMeterBandStats> bandStats) {
+        this.bandStats = bandStats;
+        this.bandStatsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFMeterStats build() {
+            long meterId = this.meterIdSet ? this.meterId : DEFAULT_METER_ID;
+            long flowCount = this.flowCountSet ? this.flowCount : DEFAULT_FLOW_COUNT;
+            U64 packetInCount = this.packetInCountSet ? this.packetInCount : DEFAULT_PACKET_IN_COUNT;
+            if(packetInCount == null)
+                throw new NullPointerException("Property packetInCount must not be null");
+            U64 byteInCount = this.byteInCountSet ? this.byteInCount : DEFAULT_BYTE_IN_COUNT;
+            if(byteInCount == null)
+                throw new NullPointerException("Property byteInCount must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+            List<OFMeterBandStats> bandStats = this.bandStatsSet ? this.bandStats : DEFAULT_BAND_STATS;
+            if(bandStats == null)
+                throw new NullPointerException("Property bandStats must not be null");
+
+
+            return new OFMeterStatsVer13(
+                    meterId,
+                    flowCount,
+                    packetInCount,
+                    byteInCount,
+                    durationSec,
+                    durationNsec,
+                    bandStats
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFMeterStats> {
+        @Override
+        public OFMeterStats readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            long meterId = U32.f(bb.readInt());
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            long flowCount = U32.f(bb.readInt());
+            U64 packetInCount = U64.ofRaw(bb.readLong());
+            U64 byteInCount = U64.ofRaw(bb.readLong());
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+            List<OFMeterBandStats> bandStats = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFMeterBandStatsVer13.READER);
+
+            OFMeterStatsVer13 meterStatsVer13 = new OFMeterStatsVer13(
+                    meterId,
+                      flowCount,
+                      packetInCount,
+                      byteInCount,
+                      durationSec,
+                      durationNsec,
+                      bandStats
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", meterStatsVer13);
+            return meterStatsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFMeterStatsVer13Funnel FUNNEL = new OFMeterStatsVer13Funnel();
+    static class OFMeterStatsVer13Funnel implements Funnel<OFMeterStatsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFMeterStatsVer13 message, PrimitiveSink sink) {
+            sink.putLong(message.meterId);
+            // FIXME: skip funnel of length
+            // skip pad (6 bytes)
+            sink.putLong(message.flowCount);
+            message.packetInCount.putTo(sink);
+            message.byteInCount.putTo(sink);
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+            FunnelUtils.putList(message.bandStats, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFMeterStatsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFMeterStatsVer13 message) {
+            int startIndex = bb.writerIndex();
+            bb.writeInt(U32.t(message.meterId));
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 6 bytes
+            bb.writeZero(6);
+            bb.writeInt(U32.t(message.flowCount));
+            bb.writeLong(message.packetInCount.getValue());
+            bb.writeLong(message.byteInCount.getValue());
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+            ChannelUtils.writeList(bb, message.bandStats);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFMeterStatsVer13(");
+        b.append("meterId=").append(meterId);
+        b.append(", ");
+        b.append("flowCount=").append(flowCount);
+        b.append(", ");
+        b.append("packetInCount=").append(packetInCount);
+        b.append(", ");
+        b.append("byteInCount=").append(byteInCount);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(", ");
+        b.append("bandStats=").append(bandStats);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFMeterStatsVer13 other = (OFMeterStatsVer13) obj;
+
+        if( meterId != other.meterId)
+            return false;
+        if( flowCount != other.flowCount)
+            return false;
+        if (packetInCount == null) {
+            if (other.packetInCount != null)
+                return false;
+        } else if (!packetInCount.equals(other.packetInCount))
+            return false;
+        if (byteInCount == null) {
+            if (other.byteInCount != null)
+                return false;
+        } else if (!byteInCount.equals(other.byteInCount))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        if (bandStats == null) {
+            if (other.bandStats != null)
+                return false;
+        } else if (!bandStats.equals(other.bandStats))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (meterId ^ (meterId >>> 32));
+        result = prime *  (int) (flowCount ^ (flowCount >>> 32));
+        result = prime * result + ((packetInCount == null) ? 0 : packetInCount.hashCode());
+        result = prime * result + ((byteInCount == null) ? 0 : byteInCount.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        result = prime * result + ((bandStats == null) ? 0 : bandStats.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFNiciraHeaderVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFNiciraHeaderVer13.java
new file mode 100644
index 0000000..2c6fbf9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFNiciraHeaderVer13.java
@@ -0,0 +1,66 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFNiciraHeaderVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFNiciraHeaderVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFNiciraHeader> {
+        @Override
+        public OFNiciraHeader readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 4
+            byte type = bb.readByte();
+            if(type != (byte) 0x4)
+                throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            // fixed value property experimenter == 0x2320L
+            int experimenter = bb.readInt();
+            if(experimenter != 0x2320)
+                throw new OFParseError("Wrong experimenter: Expected=0x2320L(0x2320L), got="+experimenter);
+            int subtype = bb.readInt();
+            bb.readerIndex(start);
+            switch(subtype) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator subtype of class OFNiciraHeaderVer13: " + subtype);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpOpMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpOpMaskedVer13.java
new file mode 100644
index 0000000..2505004
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpOpMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpOpMaskedVer13 implements OFOxmArpOpMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpOpMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static ArpOpcode DEFAULT_VALUE = ArpOpcode.NONE;
+        private final static ArpOpcode DEFAULT_VALUE_MASK = ArpOpcode.NONE;
+
+    // OF message fields
+    private final ArpOpcode value;
+    private final ArpOpcode mask;
+//
+    // Immutable default instance
+    final static OFOxmArpOpMaskedVer13 DEFAULT = new OFOxmArpOpMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpOpMaskedVer13(ArpOpcode value, ArpOpcode mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002b04L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public ArpOpcode getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ArpOpcode> getCanonical() {
+        if (ArpOpcode.NO_MASK.equals(mask)) {
+            return new OFOxmArpOpVer13(value);
+        } else if(ArpOpcode.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpOpMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpOpMasked.Builder {
+        final OFOxmArpOpMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ArpOpcode value;
+        private boolean maskSet;
+        private ArpOpcode mask;
+
+        BuilderWithParent(OFOxmArpOpMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002b04L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpOpMasked.Builder setValue(ArpOpcode value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ArpOpcode getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpOpMasked.Builder setMask(ArpOpcode mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ArpOpcode> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpOpMasked build() {
+                ArpOpcode value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ArpOpcode mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpOpMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpOpMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ArpOpcode value;
+        private boolean maskSet;
+        private ArpOpcode mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002b04L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpOpMasked.Builder setValue(ArpOpcode value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ArpOpcode getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpOpMasked.Builder setMask(ArpOpcode mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ArpOpcode> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpOpMasked build() {
+            ArpOpcode value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ArpOpcode mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpOpMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpOpMasked> {
+        @Override
+        public OFOxmArpOpMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002b04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002b04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002b04L(0x80002b04L), got="+typeLen);
+            ArpOpcode value = ArpOpcode.read2Bytes(bb);
+            ArpOpcode mask = ArpOpcode.read2Bytes(bb);
+
+            OFOxmArpOpMaskedVer13 oxmArpOpMaskedVer13 = new OFOxmArpOpMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpOpMaskedVer13);
+            return oxmArpOpMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpOpMaskedVer13Funnel FUNNEL = new OFOxmArpOpMaskedVer13Funnel();
+    static class OFOxmArpOpMaskedVer13Funnel implements Funnel<OFOxmArpOpMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpOpMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002b04L
+            sink.putInt((int) 0x80002b04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpOpMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpOpMaskedVer13 message) {
+            // fixed value property typeLen = 0x80002b04L
+            bb.writeInt((int) 0x80002b04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpOpMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpOpMaskedVer13 other = (OFOxmArpOpMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpOpVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpOpVer13.java
new file mode 100644
index 0000000..e3e2456
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpOpVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpOpVer13 implements OFOxmArpOp {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpOpVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static ArpOpcode DEFAULT_VALUE = ArpOpcode.NONE;
+
+    // OF message fields
+    private final ArpOpcode value;
+//
+    // Immutable default instance
+    final static OFOxmArpOpVer13 DEFAULT = new OFOxmArpOpVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpOpVer13(ArpOpcode value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002a02L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ArpOpcode> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ArpOpcode getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpOp.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpOp.Builder {
+        final OFOxmArpOpVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ArpOpcode value;
+
+        BuilderWithParent(OFOxmArpOpVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002a02L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpOp.Builder setValue(ArpOpcode value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ArpOpcode> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ArpOpcode getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpOp build() {
+                ArpOpcode value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpOpVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpOp.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ArpOpcode value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002a02L;
+    }
+
+    @Override
+    public ArpOpcode getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpOp.Builder setValue(ArpOpcode value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ArpOpcode> getMatchField() {
+        return MatchField.ARP_OP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ArpOpcode> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ArpOpcode getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpOp build() {
+            ArpOpcode value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpOpVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpOp> {
+        @Override
+        public OFOxmArpOp readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002a02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002a02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002a02L(0x80002a02L), got="+typeLen);
+            ArpOpcode value = ArpOpcode.read2Bytes(bb);
+
+            OFOxmArpOpVer13 oxmArpOpVer13 = new OFOxmArpOpVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpOpVer13);
+            return oxmArpOpVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpOpVer13Funnel FUNNEL = new OFOxmArpOpVer13Funnel();
+    static class OFOxmArpOpVer13Funnel implements Funnel<OFOxmArpOpVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpOpVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002a02L
+            sink.putInt((int) 0x80002a02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpOpVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpOpVer13 message) {
+            // fixed value property typeLen = 0x80002a02L
+            bb.writeInt((int) 0x80002a02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpOpVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpOpVer13 other = (OFOxmArpOpVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpShaMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpShaMaskedVer13.java
new file mode 100644
index 0000000..359cde4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpShaMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpShaMaskedVer13 implements OFOxmArpShaMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpShaMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmArpShaMaskedVer13 DEFAULT = new OFOxmArpShaMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpShaMaskedVer13(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000310cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmArpShaVer13(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpShaMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpShaMasked.Builder {
+        final OFOxmArpShaMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmArpShaMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000310cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpShaMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpShaMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpShaMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpShaMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpShaMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000310cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpShaMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpShaMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpShaMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpShaMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpShaMasked> {
+        @Override
+        public OFOxmArpShaMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000310cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000310c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000310cL(0x8000310cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmArpShaMaskedVer13 oxmArpShaMaskedVer13 = new OFOxmArpShaMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpShaMaskedVer13);
+            return oxmArpShaMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpShaMaskedVer13Funnel FUNNEL = new OFOxmArpShaMaskedVer13Funnel();
+    static class OFOxmArpShaMaskedVer13Funnel implements Funnel<OFOxmArpShaMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpShaMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000310cL
+            sink.putInt((int) 0x8000310c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpShaMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpShaMaskedVer13 message) {
+            // fixed value property typeLen = 0x8000310cL
+            bb.writeInt((int) 0x8000310c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpShaMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpShaMaskedVer13 other = (OFOxmArpShaMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpShaVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpShaVer13.java
new file mode 100644
index 0000000..7cb0173
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpShaVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpShaVer13 implements OFOxmArpSha {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpShaVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmArpShaVer13 DEFAULT = new OFOxmArpShaVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpShaVer13(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpSha.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpSha.Builder {
+        final OFOxmArpShaVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmArpShaVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSha.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpSha build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpShaVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpSha.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSha.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_SHA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpSha build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpShaVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpSha> {
+        @Override
+        public OFOxmArpSha readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003006L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003006)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003006L(0x80003006L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmArpShaVer13 oxmArpShaVer13 = new OFOxmArpShaVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpShaVer13);
+            return oxmArpShaVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpShaVer13Funnel FUNNEL = new OFOxmArpShaVer13Funnel();
+    static class OFOxmArpShaVer13Funnel implements Funnel<OFOxmArpShaVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpShaVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003006L
+            sink.putInt((int) 0x80003006);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpShaVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpShaVer13 message) {
+            // fixed value property typeLen = 0x80003006L
+            bb.writeInt((int) 0x80003006);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpShaVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpShaVer13 other = (OFOxmArpShaVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpSpaMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpSpaMaskedVer13.java
new file mode 100644
index 0000000..bd61419
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpSpaMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpSpaMaskedVer13 implements OFOxmArpSpaMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpSpaMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_VALUE_MASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+    private final IPv4Address mask;
+//
+    // Immutable default instance
+    final static OFOxmArpSpaMaskedVer13 DEFAULT = new OFOxmArpSpaMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpSpaMaskedVer13(IPv4Address value, IPv4Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002d08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        if (IPv4Address.NO_MASK.equals(mask)) {
+            return new OFOxmArpSpaVer13(value);
+        } else if(IPv4Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpSpaMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpSpaMasked.Builder {
+        final OFOxmArpSpaMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+        BuilderWithParent(OFOxmArpSpaMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002d08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSpaMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpSpaMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpSpaMasked build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv4Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpSpaMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpSpaMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002d08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSpaMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpSpaMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpSpaMasked build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv4Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpSpaMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpSpaMasked> {
+        @Override
+        public OFOxmArpSpaMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002d08L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002d08)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002d08L(0x80002d08L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+            IPv4Address mask = IPv4Address.read4Bytes(bb);
+
+            OFOxmArpSpaMaskedVer13 oxmArpSpaMaskedVer13 = new OFOxmArpSpaMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpSpaMaskedVer13);
+            return oxmArpSpaMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpSpaMaskedVer13Funnel FUNNEL = new OFOxmArpSpaMaskedVer13Funnel();
+    static class OFOxmArpSpaMaskedVer13Funnel implements Funnel<OFOxmArpSpaMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpSpaMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002d08L
+            sink.putInt((int) 0x80002d08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpSpaMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpSpaMaskedVer13 message) {
+            // fixed value property typeLen = 0x80002d08L
+            bb.writeInt((int) 0x80002d08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpSpaMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpSpaMaskedVer13 other = (OFOxmArpSpaMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpSpaVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpSpaVer13.java
new file mode 100644
index 0000000..ee87344
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpSpaVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpSpaVer13 implements OFOxmArpSpa {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpSpaVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFOxmArpSpaVer13 DEFAULT = new OFOxmArpSpaVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpSpaVer13(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002c04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpSpa.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpSpa.Builder {
+        final OFOxmArpSpaVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFOxmArpSpaVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002c04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSpa.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpSpa build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpSpaVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpSpa.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002c04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpSpa.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_SPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpSpa build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpSpaVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpSpa> {
+        @Override
+        public OFOxmArpSpa readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002c04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002c04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002c04L(0x80002c04L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFOxmArpSpaVer13 oxmArpSpaVer13 = new OFOxmArpSpaVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpSpaVer13);
+            return oxmArpSpaVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpSpaVer13Funnel FUNNEL = new OFOxmArpSpaVer13Funnel();
+    static class OFOxmArpSpaVer13Funnel implements Funnel<OFOxmArpSpaVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpSpaVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002c04L
+            sink.putInt((int) 0x80002c04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpSpaVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpSpaVer13 message) {
+            // fixed value property typeLen = 0x80002c04L
+            bb.writeInt((int) 0x80002c04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpSpaVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpSpaVer13 other = (OFOxmArpSpaVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpThaMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpThaMaskedVer13.java
new file mode 100644
index 0000000..5ee778d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpThaMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpThaMaskedVer13 implements OFOxmArpThaMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpThaMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmArpThaMaskedVer13 DEFAULT = new OFOxmArpThaMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpThaMaskedVer13(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000330cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmArpThaVer13(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpThaMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpThaMasked.Builder {
+        final OFOxmArpThaMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmArpThaMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000330cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpThaMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpThaMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpThaMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpThaMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpThaMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000330cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpThaMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpThaMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpThaMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpThaMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpThaMasked> {
+        @Override
+        public OFOxmArpThaMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000330cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000330c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000330cL(0x8000330cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmArpThaMaskedVer13 oxmArpThaMaskedVer13 = new OFOxmArpThaMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpThaMaskedVer13);
+            return oxmArpThaMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpThaMaskedVer13Funnel FUNNEL = new OFOxmArpThaMaskedVer13Funnel();
+    static class OFOxmArpThaMaskedVer13Funnel implements Funnel<OFOxmArpThaMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpThaMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000330cL
+            sink.putInt((int) 0x8000330c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpThaMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpThaMaskedVer13 message) {
+            // fixed value property typeLen = 0x8000330cL
+            bb.writeInt((int) 0x8000330c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpThaMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpThaMaskedVer13 other = (OFOxmArpThaMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpThaVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpThaVer13.java
new file mode 100644
index 0000000..44773e8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpThaVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpThaVer13 implements OFOxmArpTha {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpThaVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmArpThaVer13 DEFAULT = new OFOxmArpThaVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpThaVer13(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpTha.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpTha.Builder {
+        final OFOxmArpThaVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmArpThaVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTha.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpTha build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpThaVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpTha.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTha.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ARP_THA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpTha build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpThaVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpTha> {
+        @Override
+        public OFOxmArpTha readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003206L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003206)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003206L(0x80003206L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmArpThaVer13 oxmArpThaVer13 = new OFOxmArpThaVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpThaVer13);
+            return oxmArpThaVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpThaVer13Funnel FUNNEL = new OFOxmArpThaVer13Funnel();
+    static class OFOxmArpThaVer13Funnel implements Funnel<OFOxmArpThaVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpThaVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003206L
+            sink.putInt((int) 0x80003206);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpThaVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpThaVer13 message) {
+            // fixed value property typeLen = 0x80003206L
+            bb.writeInt((int) 0x80003206);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpThaVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpThaVer13 other = (OFOxmArpThaVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpTpaMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpTpaMaskedVer13.java
new file mode 100644
index 0000000..4abe2fe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpTpaMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpTpaMaskedVer13 implements OFOxmArpTpaMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpTpaMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_VALUE_MASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+    private final IPv4Address mask;
+//
+    // Immutable default instance
+    final static OFOxmArpTpaMaskedVer13 DEFAULT = new OFOxmArpTpaMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpTpaMaskedVer13(IPv4Address value, IPv4Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002f08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        if (IPv4Address.NO_MASK.equals(mask)) {
+            return new OFOxmArpTpaVer13(value);
+        } else if(IPv4Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpTpaMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpTpaMasked.Builder {
+        final OFOxmArpTpaMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+        BuilderWithParent(OFOxmArpTpaMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002f08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTpaMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpTpaMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpTpaMasked build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv4Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmArpTpaMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpTpaMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002f08L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTpaMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmArpTpaMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpTpaMasked build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv4Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmArpTpaMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpTpaMasked> {
+        @Override
+        public OFOxmArpTpaMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002f08L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002f08)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002f08L(0x80002f08L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+            IPv4Address mask = IPv4Address.read4Bytes(bb);
+
+            OFOxmArpTpaMaskedVer13 oxmArpTpaMaskedVer13 = new OFOxmArpTpaMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpTpaMaskedVer13);
+            return oxmArpTpaMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpTpaMaskedVer13Funnel FUNNEL = new OFOxmArpTpaMaskedVer13Funnel();
+    static class OFOxmArpTpaMaskedVer13Funnel implements Funnel<OFOxmArpTpaMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpTpaMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002f08L
+            sink.putInt((int) 0x80002f08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpTpaMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpTpaMaskedVer13 message) {
+            // fixed value property typeLen = 0x80002f08L
+            bb.writeInt((int) 0x80002f08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpTpaMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpTpaMaskedVer13 other = (OFOxmArpTpaMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpTpaVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpTpaVer13.java
new file mode 100644
index 0000000..db2492e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmArpTpaVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmArpTpaVer13 implements OFOxmArpTpa {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmArpTpaVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFOxmArpTpaVer13 DEFAULT = new OFOxmArpTpaVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmArpTpaVer13(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002e04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmArpTpa.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmArpTpa.Builder {
+        final OFOxmArpTpaVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFOxmArpTpaVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002e04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTpa.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmArpTpa build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmArpTpaVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmArpTpa.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002e04L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmArpTpa.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.ARP_TPA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmArpTpa build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmArpTpaVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmArpTpa> {
+        @Override
+        public OFOxmArpTpa readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002e04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002e04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002e04L(0x80002e04L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFOxmArpTpaVer13 oxmArpTpaVer13 = new OFOxmArpTpaVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmArpTpaVer13);
+            return oxmArpTpaVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmArpTpaVer13Funnel FUNNEL = new OFOxmArpTpaVer13Funnel();
+    static class OFOxmArpTpaVer13Funnel implements Funnel<OFOxmArpTpaVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmArpTpaVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002e04L
+            sink.putInt((int) 0x80002e04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmArpTpaVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmArpTpaVer13 message) {
+            // fixed value property typeLen = 0x80002e04L
+            bb.writeInt((int) 0x80002e04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmArpTpaVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmArpTpaVer13 other = (OFOxmArpTpaVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnEgrPortGroupIdMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnEgrPortGroupIdMaskedVer13.java
new file mode 100644
index 0000000..b0d05f5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnEgrPortGroupIdMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnEgrPortGroupIdMaskedVer13 implements OFOxmBsnEgrPortGroupIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnEgrPortGroupIdMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnEgrPortGroupIdMaskedVer13 DEFAULT = new OFOxmBsnEgrPortGroupIdMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnEgrPortGroupIdMaskedVer13(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30f08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnEgrPortGroupIdVer13(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnEgrPortGroupIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnEgrPortGroupIdMasked.Builder {
+        final OFOxmBsnEgrPortGroupIdMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnEgrPortGroupIdMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30f08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnEgrPortGroupIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnEgrPortGroupIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnEgrPortGroupIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30f08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnEgrPortGroupIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnEgrPortGroupIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnEgrPortGroupIdMasked> {
+        @Override
+        public OFOxmBsnEgrPortGroupIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30f08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30f08)
+                throw new OFParseError("Wrong typeLen: Expected=0x30f08L(0x30f08L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnEgrPortGroupIdMaskedVer13 oxmBsnEgrPortGroupIdMaskedVer13 = new OFOxmBsnEgrPortGroupIdMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnEgrPortGroupIdMaskedVer13);
+            return oxmBsnEgrPortGroupIdMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnEgrPortGroupIdMaskedVer13Funnel FUNNEL = new OFOxmBsnEgrPortGroupIdMaskedVer13Funnel();
+    static class OFOxmBsnEgrPortGroupIdMaskedVer13Funnel implements Funnel<OFOxmBsnEgrPortGroupIdMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnEgrPortGroupIdMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30f08L
+            sink.putInt(0x30f08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnEgrPortGroupIdMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnEgrPortGroupIdMaskedVer13 message) {
+            // fixed value property typeLen = 0x30f08L
+            bb.writeInt(0x30f08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnEgrPortGroupIdMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnEgrPortGroupIdMaskedVer13 other = (OFOxmBsnEgrPortGroupIdMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnEgrPortGroupIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnEgrPortGroupIdVer13.java
new file mode 100644
index 0000000..249f1ee
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnEgrPortGroupIdVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnEgrPortGroupIdVer13 implements OFOxmBsnEgrPortGroupId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnEgrPortGroupIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnEgrPortGroupIdVer13 DEFAULT = new OFOxmBsnEgrPortGroupIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnEgrPortGroupIdVer13(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30e04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnEgrPortGroupId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnEgrPortGroupId.Builder {
+        final OFOxmBsnEgrPortGroupIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnEgrPortGroupIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30e04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnEgrPortGroupId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnEgrPortGroupIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnEgrPortGroupId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30e04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnEgrPortGroupId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_EGR_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnEgrPortGroupId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnEgrPortGroupIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnEgrPortGroupId> {
+        @Override
+        public OFOxmBsnEgrPortGroupId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30e04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30e04)
+                throw new OFParseError("Wrong typeLen: Expected=0x30e04L(0x30e04L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnEgrPortGroupIdVer13 oxmBsnEgrPortGroupIdVer13 = new OFOxmBsnEgrPortGroupIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnEgrPortGroupIdVer13);
+            return oxmBsnEgrPortGroupIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnEgrPortGroupIdVer13Funnel FUNNEL = new OFOxmBsnEgrPortGroupIdVer13Funnel();
+    static class OFOxmBsnEgrPortGroupIdVer13Funnel implements Funnel<OFOxmBsnEgrPortGroupIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnEgrPortGroupIdVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30e04L
+            sink.putInt(0x30e04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnEgrPortGroupIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnEgrPortGroupIdVer13 message) {
+            // fixed value property typeLen = 0x30e04L
+            bb.writeInt(0x30e04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnEgrPortGroupIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnEgrPortGroupIdVer13 other = (OFOxmBsnEgrPortGroupIdVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedMaskedVer13.java
new file mode 100644
index 0000000..296e1d7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnGlobalVrfAllowedMaskedVer13 implements OFOxmBsnGlobalVrfAllowedMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnGlobalVrfAllowedMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static OFBooleanValue DEFAULT_VALUE = OFBooleanValue.FALSE;
+        private final static OFBooleanValue DEFAULT_VALUE_MASK = OFBooleanValue.FALSE;
+
+    // OF message fields
+    private final OFBooleanValue value;
+    private final OFBooleanValue mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnGlobalVrfAllowedMaskedVer13 DEFAULT = new OFOxmBsnGlobalVrfAllowedMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnGlobalVrfAllowedMaskedVer13(OFBooleanValue value, OFBooleanValue mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30702L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBooleanValue getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFBooleanValue> getCanonical() {
+        if (OFBooleanValue.NO_MASK.equals(mask)) {
+            return new OFOxmBsnGlobalVrfAllowedVer13(value);
+        } else if(OFBooleanValue.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnGlobalVrfAllowedMasked.Builder {
+        final OFOxmBsnGlobalVrfAllowedMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBooleanValue value;
+        private boolean maskSet;
+        private OFBooleanValue mask;
+
+        BuilderWithParent(OFOxmBsnGlobalVrfAllowedMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30702L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder setValue(OFBooleanValue value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFBooleanValue getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder setMask(OFBooleanValue mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFBooleanValue> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnGlobalVrfAllowedMasked build() {
+                OFBooleanValue value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFBooleanValue mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnGlobalVrfAllowedMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnGlobalVrfAllowedMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBooleanValue value;
+        private boolean maskSet;
+        private OFBooleanValue mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30702L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder setValue(OFBooleanValue value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFBooleanValue getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder setMask(OFBooleanValue mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFBooleanValue> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnGlobalVrfAllowedMasked build() {
+            OFBooleanValue value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFBooleanValue mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnGlobalVrfAllowedMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnGlobalVrfAllowedMasked> {
+        @Override
+        public OFOxmBsnGlobalVrfAllowedMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30702L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30702)
+                throw new OFParseError("Wrong typeLen: Expected=0x30702L(0x30702L), got="+typeLen);
+            OFBooleanValue value = OFBooleanValue.of(bb.readByte() != 0);
+            OFBooleanValue mask = OFBooleanValue.of(bb.readByte() != 0);
+
+            OFOxmBsnGlobalVrfAllowedMaskedVer13 oxmBsnGlobalVrfAllowedMaskedVer13 = new OFOxmBsnGlobalVrfAllowedMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnGlobalVrfAllowedMaskedVer13);
+            return oxmBsnGlobalVrfAllowedMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnGlobalVrfAllowedMaskedVer13Funnel FUNNEL = new OFOxmBsnGlobalVrfAllowedMaskedVer13Funnel();
+    static class OFOxmBsnGlobalVrfAllowedMaskedVer13Funnel implements Funnel<OFOxmBsnGlobalVrfAllowedMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnGlobalVrfAllowedMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30702L
+            sink.putInt(0x30702);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnGlobalVrfAllowedMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnGlobalVrfAllowedMaskedVer13 message) {
+            // fixed value property typeLen = 0x30702L
+            bb.writeInt(0x30702);
+            bb.writeByte(message.value.getInt());
+            bb.writeByte(message.mask.getInt());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnGlobalVrfAllowedMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnGlobalVrfAllowedMaskedVer13 other = (OFOxmBsnGlobalVrfAllowedMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedVer13.java
new file mode 100644
index 0000000..c1add8a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnGlobalVrfAllowedVer13 implements OFOxmBsnGlobalVrfAllowed {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnGlobalVrfAllowedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static OFBooleanValue DEFAULT_VALUE = OFBooleanValue.FALSE;
+
+    // OF message fields
+    private final OFBooleanValue value;
+//
+    // Immutable default instance
+    final static OFOxmBsnGlobalVrfAllowedVer13 DEFAULT = new OFOxmBsnGlobalVrfAllowedVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnGlobalVrfAllowedVer13(OFBooleanValue value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30601L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFBooleanValue> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFBooleanValue getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnGlobalVrfAllowed.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnGlobalVrfAllowed.Builder {
+        final OFOxmBsnGlobalVrfAllowedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBooleanValue value;
+
+        BuilderWithParent(OFOxmBsnGlobalVrfAllowedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30601L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowed.Builder setValue(OFBooleanValue value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFBooleanValue> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFBooleanValue getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnGlobalVrfAllowed build() {
+                OFBooleanValue value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnGlobalVrfAllowedVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnGlobalVrfAllowed.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBooleanValue value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30601L;
+    }
+
+    @Override
+    public OFBooleanValue getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnGlobalVrfAllowed.Builder setValue(OFBooleanValue value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBooleanValue> getMatchField() {
+        return MatchField.BSN_GLOBAL_VRF_ALLOWED;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFBooleanValue> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFBooleanValue getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnGlobalVrfAllowed build() {
+            OFBooleanValue value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnGlobalVrfAllowedVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnGlobalVrfAllowed> {
+        @Override
+        public OFOxmBsnGlobalVrfAllowed readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30601L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30601)
+                throw new OFParseError("Wrong typeLen: Expected=0x30601L(0x30601L), got="+typeLen);
+            OFBooleanValue value = OFBooleanValue.of(bb.readByte() != 0);
+
+            OFOxmBsnGlobalVrfAllowedVer13 oxmBsnGlobalVrfAllowedVer13 = new OFOxmBsnGlobalVrfAllowedVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnGlobalVrfAllowedVer13);
+            return oxmBsnGlobalVrfAllowedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnGlobalVrfAllowedVer13Funnel FUNNEL = new OFOxmBsnGlobalVrfAllowedVer13Funnel();
+    static class OFOxmBsnGlobalVrfAllowedVer13Funnel implements Funnel<OFOxmBsnGlobalVrfAllowedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnGlobalVrfAllowedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30601L
+            sink.putInt(0x30601);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnGlobalVrfAllowedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnGlobalVrfAllowedVer13 message) {
+            // fixed value property typeLen = 0x30601L
+            bb.writeInt(0x30601);
+            bb.writeByte(message.value.getInt());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnGlobalVrfAllowedVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnGlobalVrfAllowedVer13 other = (OFOxmBsnGlobalVrfAllowedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnInPorts128MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnInPorts128MaskedVer13.java
new file mode 100644
index 0000000..6a90ff6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnInPorts128MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnInPorts128MaskedVer13 implements OFOxmBsnInPorts128Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnInPorts128MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 36;
+
+        private final static OFBitMask128 DEFAULT_VALUE = OFBitMask128.NONE;
+        private final static OFBitMask128 DEFAULT_VALUE_MASK = OFBitMask128.NONE;
+
+    // OF message fields
+    private final OFBitMask128 value;
+    private final OFBitMask128 mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnInPorts128MaskedVer13 DEFAULT = new OFOxmBsnInPorts128MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnInPorts128MaskedVer13(OFBitMask128 value, OFBitMask128 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30120L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFBitMask128 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFBitMask128> getCanonical() {
+        if (OFBitMask128.NO_MASK.equals(mask)) {
+            return new OFOxmBsnInPorts128Ver13(value);
+        } else if(OFBitMask128.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnInPorts128Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnInPorts128Masked.Builder {
+        final OFOxmBsnInPorts128MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBitMask128 value;
+        private boolean maskSet;
+        private OFBitMask128 mask;
+
+        BuilderWithParent(OFOxmBsnInPorts128MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30120L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128Masked.Builder setValue(OFBitMask128 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFBitMask128 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128Masked.Builder setMask(OFBitMask128 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFBitMask128> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnInPorts128Masked build() {
+                OFBitMask128 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFBitMask128 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnInPorts128MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnInPorts128Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBitMask128 value;
+        private boolean maskSet;
+        private OFBitMask128 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30120L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128Masked.Builder setValue(OFBitMask128 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFBitMask128 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128Masked.Builder setMask(OFBitMask128 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFBitMask128> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnInPorts128Masked build() {
+            OFBitMask128 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFBitMask128 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnInPorts128MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnInPorts128Masked> {
+        @Override
+        public OFOxmBsnInPorts128Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30120L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30120)
+                throw new OFParseError("Wrong typeLen: Expected=0x30120L(0x30120L), got="+typeLen);
+            OFBitMask128 value = OFBitMask128.read16Bytes(bb);
+            OFBitMask128 mask = OFBitMask128.read16Bytes(bb);
+
+            OFOxmBsnInPorts128MaskedVer13 oxmBsnInPorts128MaskedVer13 = new OFOxmBsnInPorts128MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnInPorts128MaskedVer13);
+            return oxmBsnInPorts128MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnInPorts128MaskedVer13Funnel FUNNEL = new OFOxmBsnInPorts128MaskedVer13Funnel();
+    static class OFOxmBsnInPorts128MaskedVer13Funnel implements Funnel<OFOxmBsnInPorts128MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnInPorts128MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30120L
+            sink.putInt(0x30120);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnInPorts128MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnInPorts128MaskedVer13 message) {
+            // fixed value property typeLen = 0x30120L
+            bb.writeInt(0x30120);
+            message.value.write16Bytes(bb);
+            message.mask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnInPorts128MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnInPorts128MaskedVer13 other = (OFOxmBsnInPorts128MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnInPorts128Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnInPorts128Ver13.java
new file mode 100644
index 0000000..13fc1fb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnInPorts128Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnInPorts128Ver13 implements OFOxmBsnInPorts128 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnInPorts128Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static OFBitMask128 DEFAULT_VALUE = OFBitMask128.NONE;
+
+    // OF message fields
+    private final OFBitMask128 value;
+//
+    // Immutable default instance
+    final static OFOxmBsnInPorts128Ver13 DEFAULT = new OFOxmBsnInPorts128Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnInPorts128Ver13(OFBitMask128 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30010L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFBitMask128> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFBitMask128 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnInPorts128.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnInPorts128.Builder {
+        final OFOxmBsnInPorts128Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFBitMask128 value;
+
+        BuilderWithParent(OFOxmBsnInPorts128Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30010L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128.Builder setValue(OFBitMask128 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFBitMask128> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFBitMask128 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnInPorts128 build() {
+                OFBitMask128 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnInPorts128Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnInPorts128.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFBitMask128 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30010L;
+    }
+
+    @Override
+    public OFBitMask128 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnInPorts128.Builder setValue(OFBitMask128 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFBitMask128> getMatchField() {
+        return MatchField.BSN_IN_PORTS_128;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFBitMask128> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFBitMask128 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnInPorts128 build() {
+            OFBitMask128 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnInPorts128Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnInPorts128> {
+        @Override
+        public OFOxmBsnInPorts128 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30010L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30010)
+                throw new OFParseError("Wrong typeLen: Expected=0x30010L(0x30010L), got="+typeLen);
+            OFBitMask128 value = OFBitMask128.read16Bytes(bb);
+
+            OFOxmBsnInPorts128Ver13 oxmBsnInPorts128Ver13 = new OFOxmBsnInPorts128Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnInPorts128Ver13);
+            return oxmBsnInPorts128Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnInPorts128Ver13Funnel FUNNEL = new OFOxmBsnInPorts128Ver13Funnel();
+    static class OFOxmBsnInPorts128Ver13Funnel implements Funnel<OFOxmBsnInPorts128Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnInPorts128Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30010L
+            sink.putInt(0x30010);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnInPorts128Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnInPorts128Ver13 message) {
+            // fixed value property typeLen = 0x30010L
+            bb.writeInt(0x30010);
+            message.value.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnInPorts128Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnInPorts128Ver13 other = (OFOxmBsnInPorts128Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3DstClassIdMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3DstClassIdMaskedVer13.java
new file mode 100644
index 0000000..61b009d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3DstClassIdMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3DstClassIdMaskedVer13 implements OFOxmBsnL3DstClassIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3DstClassIdMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3DstClassIdMaskedVer13 DEFAULT = new OFOxmBsnL3DstClassIdMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3DstClassIdMaskedVer13(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30d08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnL3DstClassIdVer13(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnL3DstClassIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3DstClassIdMasked.Builder {
+        final OFOxmBsnL3DstClassIdMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnL3DstClassIdMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30d08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3DstClassIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnL3DstClassIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3DstClassIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30d08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3DstClassIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnL3DstClassIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3DstClassIdMasked> {
+        @Override
+        public OFOxmBsnL3DstClassIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30d08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30d08)
+                throw new OFParseError("Wrong typeLen: Expected=0x30d08L(0x30d08L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3DstClassIdMaskedVer13 oxmBsnL3DstClassIdMaskedVer13 = new OFOxmBsnL3DstClassIdMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3DstClassIdMaskedVer13);
+            return oxmBsnL3DstClassIdMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3DstClassIdMaskedVer13Funnel FUNNEL = new OFOxmBsnL3DstClassIdMaskedVer13Funnel();
+    static class OFOxmBsnL3DstClassIdMaskedVer13Funnel implements Funnel<OFOxmBsnL3DstClassIdMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3DstClassIdMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30d08L
+            sink.putInt(0x30d08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3DstClassIdMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3DstClassIdMaskedVer13 message) {
+            // fixed value property typeLen = 0x30d08L
+            bb.writeInt(0x30d08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3DstClassIdMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3DstClassIdMaskedVer13 other = (OFOxmBsnL3DstClassIdMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3DstClassIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3DstClassIdVer13.java
new file mode 100644
index 0000000..4aa45ba
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3DstClassIdVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3DstClassIdVer13 implements OFOxmBsnL3DstClassId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3DstClassIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3DstClassIdVer13 DEFAULT = new OFOxmBsnL3DstClassIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3DstClassIdVer13(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30c04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnL3DstClassId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3DstClassId.Builder {
+        final OFOxmBsnL3DstClassIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnL3DstClassIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30c04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3DstClassId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnL3DstClassIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3DstClassId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30c04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3DstClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_DST_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3DstClassId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnL3DstClassIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3DstClassId> {
+        @Override
+        public OFOxmBsnL3DstClassId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30c04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30c04)
+                throw new OFParseError("Wrong typeLen: Expected=0x30c04L(0x30c04L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3DstClassIdVer13 oxmBsnL3DstClassIdVer13 = new OFOxmBsnL3DstClassIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3DstClassIdVer13);
+            return oxmBsnL3DstClassIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3DstClassIdVer13Funnel FUNNEL = new OFOxmBsnL3DstClassIdVer13Funnel();
+    static class OFOxmBsnL3DstClassIdVer13Funnel implements Funnel<OFOxmBsnL3DstClassIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3DstClassIdVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30c04L
+            sink.putInt(0x30c04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3DstClassIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3DstClassIdVer13 message) {
+            // fixed value property typeLen = 0x30c04L
+            bb.writeInt(0x30c04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3DstClassIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3DstClassIdVer13 other = (OFOxmBsnL3DstClassIdVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3InterfaceClassIdMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3InterfaceClassIdMaskedVer13.java
new file mode 100644
index 0000000..b3523d9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3InterfaceClassIdMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3InterfaceClassIdMaskedVer13 implements OFOxmBsnL3InterfaceClassIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3InterfaceClassIdMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3InterfaceClassIdMaskedVer13 DEFAULT = new OFOxmBsnL3InterfaceClassIdMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3InterfaceClassIdMaskedVer13(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30908L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnL3InterfaceClassIdVer13(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3InterfaceClassIdMasked.Builder {
+        final OFOxmBsnL3InterfaceClassIdMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnL3InterfaceClassIdMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30908L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3InterfaceClassIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnL3InterfaceClassIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3InterfaceClassIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30908L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3InterfaceClassIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnL3InterfaceClassIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3InterfaceClassIdMasked> {
+        @Override
+        public OFOxmBsnL3InterfaceClassIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30908L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30908)
+                throw new OFParseError("Wrong typeLen: Expected=0x30908L(0x30908L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3InterfaceClassIdMaskedVer13 oxmBsnL3InterfaceClassIdMaskedVer13 = new OFOxmBsnL3InterfaceClassIdMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3InterfaceClassIdMaskedVer13);
+            return oxmBsnL3InterfaceClassIdMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3InterfaceClassIdMaskedVer13Funnel FUNNEL = new OFOxmBsnL3InterfaceClassIdMaskedVer13Funnel();
+    static class OFOxmBsnL3InterfaceClassIdMaskedVer13Funnel implements Funnel<OFOxmBsnL3InterfaceClassIdMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3InterfaceClassIdMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30908L
+            sink.putInt(0x30908);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3InterfaceClassIdMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3InterfaceClassIdMaskedVer13 message) {
+            // fixed value property typeLen = 0x30908L
+            bb.writeInt(0x30908);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3InterfaceClassIdMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3InterfaceClassIdMaskedVer13 other = (OFOxmBsnL3InterfaceClassIdMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3InterfaceClassIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3InterfaceClassIdVer13.java
new file mode 100644
index 0000000..0a0c306
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3InterfaceClassIdVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3InterfaceClassIdVer13 implements OFOxmBsnL3InterfaceClassId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3InterfaceClassIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3InterfaceClassIdVer13 DEFAULT = new OFOxmBsnL3InterfaceClassIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3InterfaceClassIdVer13(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30804L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnL3InterfaceClassId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3InterfaceClassId.Builder {
+        final OFOxmBsnL3InterfaceClassIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnL3InterfaceClassIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30804L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3InterfaceClassId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnL3InterfaceClassIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3InterfaceClassId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30804L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3InterfaceClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_INTERFACE_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3InterfaceClassId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnL3InterfaceClassIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3InterfaceClassId> {
+        @Override
+        public OFOxmBsnL3InterfaceClassId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30804L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30804)
+                throw new OFParseError("Wrong typeLen: Expected=0x30804L(0x30804L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3InterfaceClassIdVer13 oxmBsnL3InterfaceClassIdVer13 = new OFOxmBsnL3InterfaceClassIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3InterfaceClassIdVer13);
+            return oxmBsnL3InterfaceClassIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3InterfaceClassIdVer13Funnel FUNNEL = new OFOxmBsnL3InterfaceClassIdVer13Funnel();
+    static class OFOxmBsnL3InterfaceClassIdVer13Funnel implements Funnel<OFOxmBsnL3InterfaceClassIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3InterfaceClassIdVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30804L
+            sink.putInt(0x30804);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3InterfaceClassIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3InterfaceClassIdVer13 message) {
+            // fixed value property typeLen = 0x30804L
+            bb.writeInt(0x30804);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3InterfaceClassIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3InterfaceClassIdVer13 other = (OFOxmBsnL3InterfaceClassIdVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdMaskedVer13.java
new file mode 100644
index 0000000..87326ab
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3SrcClassIdMaskedVer13 implements OFOxmBsnL3SrcClassIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3SrcClassIdMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3SrcClassIdMaskedVer13 DEFAULT = new OFOxmBsnL3SrcClassIdMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3SrcClassIdMaskedVer13(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30b08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnL3SrcClassIdVer13(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnL3SrcClassIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3SrcClassIdMasked.Builder {
+        final OFOxmBsnL3SrcClassIdMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnL3SrcClassIdMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30b08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3SrcClassIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnL3SrcClassIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3SrcClassIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30b08L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3SrcClassIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnL3SrcClassIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3SrcClassIdMasked> {
+        @Override
+        public OFOxmBsnL3SrcClassIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30b08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30b08)
+                throw new OFParseError("Wrong typeLen: Expected=0x30b08L(0x30b08L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3SrcClassIdMaskedVer13 oxmBsnL3SrcClassIdMaskedVer13 = new OFOxmBsnL3SrcClassIdMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3SrcClassIdMaskedVer13);
+            return oxmBsnL3SrcClassIdMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3SrcClassIdMaskedVer13Funnel FUNNEL = new OFOxmBsnL3SrcClassIdMaskedVer13Funnel();
+    static class OFOxmBsnL3SrcClassIdMaskedVer13Funnel implements Funnel<OFOxmBsnL3SrcClassIdMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3SrcClassIdMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30b08L
+            sink.putInt(0x30b08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3SrcClassIdMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3SrcClassIdMaskedVer13 message) {
+            // fixed value property typeLen = 0x30b08L
+            bb.writeInt(0x30b08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3SrcClassIdMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3SrcClassIdMaskedVer13 other = (OFOxmBsnL3SrcClassIdMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdVer13.java
new file mode 100644
index 0000000..e1eca44
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnL3SrcClassIdVer13 implements OFOxmBsnL3SrcClassId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnL3SrcClassIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnL3SrcClassIdVer13 DEFAULT = new OFOxmBsnL3SrcClassIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnL3SrcClassIdVer13(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30a04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnL3SrcClassId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnL3SrcClassId.Builder {
+        final OFOxmBsnL3SrcClassIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnL3SrcClassIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30a04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnL3SrcClassId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnL3SrcClassIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnL3SrcClassId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30a04L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnL3SrcClassId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_L3_SRC_CLASS_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnL3SrcClassId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnL3SrcClassIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnL3SrcClassId> {
+        @Override
+        public OFOxmBsnL3SrcClassId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30a04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30a04)
+                throw new OFParseError("Wrong typeLen: Expected=0x30a04L(0x30a04L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnL3SrcClassIdVer13 oxmBsnL3SrcClassIdVer13 = new OFOxmBsnL3SrcClassIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnL3SrcClassIdVer13);
+            return oxmBsnL3SrcClassIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnL3SrcClassIdVer13Funnel FUNNEL = new OFOxmBsnL3SrcClassIdVer13Funnel();
+    static class OFOxmBsnL3SrcClassIdVer13Funnel implements Funnel<OFOxmBsnL3SrcClassIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnL3SrcClassIdVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30a04L
+            sink.putInt(0x30a04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnL3SrcClassIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnL3SrcClassIdVer13 message) {
+            // fixed value property typeLen = 0x30a04L
+            bb.writeInt(0x30a04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnL3SrcClassIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnL3SrcClassIdVer13 other = (OFOxmBsnL3SrcClassIdVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdMaskedVer13.java
new file mode 100644
index 0000000..44837f1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnLagIdMaskedVer13 implements OFOxmBsnLagIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnLagIdMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static LagId DEFAULT_VALUE = LagId.NONE;
+        private final static LagId DEFAULT_VALUE_MASK = LagId.NONE;
+
+    // OF message fields
+    private final LagId value;
+    private final LagId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnLagIdMaskedVer13 DEFAULT = new OFOxmBsnLagIdMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnLagIdMaskedVer13(LagId value, LagId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30308L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public LagId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<LagId> getCanonical() {
+        if (LagId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnLagIdVer13(value);
+        } else if(LagId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnLagIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnLagIdMasked.Builder {
+        final OFOxmBsnLagIdMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private LagId value;
+        private boolean maskSet;
+        private LagId mask;
+
+        BuilderWithParent(OFOxmBsnLagIdMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30308L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnLagIdMasked.Builder setValue(LagId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public LagId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnLagIdMasked.Builder setMask(LagId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<LagId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnLagIdMasked build() {
+                LagId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                LagId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnLagIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnLagIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private LagId value;
+        private boolean maskSet;
+        private LagId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30308L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnLagIdMasked.Builder setValue(LagId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public LagId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnLagIdMasked.Builder setMask(LagId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<LagId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnLagIdMasked build() {
+            LagId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            LagId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnLagIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnLagIdMasked> {
+        @Override
+        public OFOxmBsnLagIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30308L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30308)
+                throw new OFParseError("Wrong typeLen: Expected=0x30308L(0x30308L), got="+typeLen);
+            LagId value = LagId.read4Bytes(bb);
+            LagId mask = LagId.read4Bytes(bb);
+
+            OFOxmBsnLagIdMaskedVer13 oxmBsnLagIdMaskedVer13 = new OFOxmBsnLagIdMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnLagIdMaskedVer13);
+            return oxmBsnLagIdMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnLagIdMaskedVer13Funnel FUNNEL = new OFOxmBsnLagIdMaskedVer13Funnel();
+    static class OFOxmBsnLagIdMaskedVer13Funnel implements Funnel<OFOxmBsnLagIdMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnLagIdMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30308L
+            sink.putInt(0x30308);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnLagIdMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnLagIdMaskedVer13 message) {
+            // fixed value property typeLen = 0x30308L
+            bb.writeInt(0x30308);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnLagIdMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnLagIdMaskedVer13 other = (OFOxmBsnLagIdMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdVer13.java
new file mode 100644
index 0000000..66bd513
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnLagIdVer13 implements OFOxmBsnLagId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnLagIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static LagId DEFAULT_VALUE = LagId.NONE;
+
+    // OF message fields
+    private final LagId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnLagIdVer13 DEFAULT = new OFOxmBsnLagIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnLagIdVer13(LagId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30204L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<LagId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public LagId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnLagId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnLagId.Builder {
+        final OFOxmBsnLagIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private LagId value;
+
+        BuilderWithParent(OFOxmBsnLagIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30204L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnLagId.Builder setValue(LagId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<LagId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public LagId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnLagId build() {
+                LagId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnLagIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnLagId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private LagId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30204L;
+    }
+
+    @Override
+    public LagId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnLagId.Builder setValue(LagId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<LagId> getMatchField() {
+        return MatchField.BSN_LAG_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<LagId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public LagId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnLagId build() {
+            LagId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnLagIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnLagId> {
+        @Override
+        public OFOxmBsnLagId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30204L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30204)
+                throw new OFParseError("Wrong typeLen: Expected=0x30204L(0x30204L), got="+typeLen);
+            LagId value = LagId.read4Bytes(bb);
+
+            OFOxmBsnLagIdVer13 oxmBsnLagIdVer13 = new OFOxmBsnLagIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnLagIdVer13);
+            return oxmBsnLagIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnLagIdVer13Funnel FUNNEL = new OFOxmBsnLagIdVer13Funnel();
+    static class OFOxmBsnLagIdVer13Funnel implements Funnel<OFOxmBsnLagIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnLagIdVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30204L
+            sink.putInt(0x30204);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnLagIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnLagIdVer13 message) {
+            // fixed value property typeLen = 0x30204L
+            bb.writeInt(0x30204);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnLagIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnLagIdVer13 other = (OFOxmBsnLagIdVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnTcpFlagsMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnTcpFlagsMaskedVer13.java
new file mode 100644
index 0000000..dc18e36
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnTcpFlagsMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnTcpFlagsMaskedVer13 implements OFOxmBsnTcpFlagsMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnTcpFlagsMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static U16 DEFAULT_VALUE = U16.ZERO;
+        private final static U16 DEFAULT_VALUE_MASK = U16.ZERO;
+
+    // OF message fields
+    private final U16 value;
+    private final U16 mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnTcpFlagsMaskedVer13 DEFAULT = new OFOxmBsnTcpFlagsMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnTcpFlagsMaskedVer13(U16 value, U16 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x32104L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public U16 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U16> getCanonical() {
+        if (U16.NO_MASK.equals(mask)) {
+            return new OFOxmBsnTcpFlagsVer13(value);
+        } else if(U16.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnTcpFlagsMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnTcpFlagsMasked.Builder {
+        final OFOxmBsnTcpFlagsMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U16 value;
+        private boolean maskSet;
+        private U16 mask;
+
+        BuilderWithParent(OFOxmBsnTcpFlagsMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x32104L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlagsMasked.Builder setValue(U16 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U16 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlagsMasked.Builder setMask(U16 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U16> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnTcpFlagsMasked build() {
+                U16 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U16 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnTcpFlagsMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnTcpFlagsMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U16 value;
+        private boolean maskSet;
+        private U16 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x32104L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlagsMasked.Builder setValue(U16 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U16 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlagsMasked.Builder setMask(U16 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U16> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnTcpFlagsMasked build() {
+            U16 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U16 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnTcpFlagsMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnTcpFlagsMasked> {
+        @Override
+        public OFOxmBsnTcpFlagsMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x32104L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x32104)
+                throw new OFParseError("Wrong typeLen: Expected=0x32104L(0x32104L), got="+typeLen);
+            U16 value = U16.of(bb.readShort());
+            U16 mask = U16.of(bb.readShort());
+
+            OFOxmBsnTcpFlagsMaskedVer13 oxmBsnTcpFlagsMaskedVer13 = new OFOxmBsnTcpFlagsMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnTcpFlagsMaskedVer13);
+            return oxmBsnTcpFlagsMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnTcpFlagsMaskedVer13Funnel FUNNEL = new OFOxmBsnTcpFlagsMaskedVer13Funnel();
+    static class OFOxmBsnTcpFlagsMaskedVer13Funnel implements Funnel<OFOxmBsnTcpFlagsMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnTcpFlagsMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x32104L
+            sink.putInt(0x32104);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnTcpFlagsMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnTcpFlagsMaskedVer13 message) {
+            // fixed value property typeLen = 0x32104L
+            bb.writeInt(0x32104);
+            bb.writeShort(message.value.getRaw());
+            bb.writeShort(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnTcpFlagsMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnTcpFlagsMaskedVer13 other = (OFOxmBsnTcpFlagsMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnTcpFlagsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnTcpFlagsVer13.java
new file mode 100644
index 0000000..75d5243
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnTcpFlagsVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnTcpFlagsVer13 implements OFOxmBsnTcpFlags {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnTcpFlagsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static U16 DEFAULT_VALUE = U16.ZERO;
+
+    // OF message fields
+    private final U16 value;
+//
+    // Immutable default instance
+    final static OFOxmBsnTcpFlagsVer13 DEFAULT = new OFOxmBsnTcpFlagsVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnTcpFlagsVer13(U16 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x32002L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U16> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U16 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnTcpFlags.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnTcpFlags.Builder {
+        final OFOxmBsnTcpFlagsVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U16 value;
+
+        BuilderWithParent(OFOxmBsnTcpFlagsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x32002L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlags.Builder setValue(U16 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U16> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U16 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnTcpFlags build() {
+                U16 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnTcpFlagsVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnTcpFlags.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U16 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x32002L;
+    }
+
+    @Override
+    public U16 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnTcpFlags.Builder setValue(U16 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U16> getMatchField() {
+        return MatchField.BSN_TCP_FLAGS;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U16> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U16 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnTcpFlags build() {
+            U16 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnTcpFlagsVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnTcpFlags> {
+        @Override
+        public OFOxmBsnTcpFlags readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x32002L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x32002)
+                throw new OFParseError("Wrong typeLen: Expected=0x32002L(0x32002L), got="+typeLen);
+            U16 value = U16.of(bb.readShort());
+
+            OFOxmBsnTcpFlagsVer13 oxmBsnTcpFlagsVer13 = new OFOxmBsnTcpFlagsVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnTcpFlagsVer13);
+            return oxmBsnTcpFlagsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnTcpFlagsVer13Funnel FUNNEL = new OFOxmBsnTcpFlagsVer13Funnel();
+    static class OFOxmBsnTcpFlagsVer13Funnel implements Funnel<OFOxmBsnTcpFlagsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnTcpFlagsVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x32002L
+            sink.putInt(0x32002);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnTcpFlagsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnTcpFlagsVer13 message) {
+            // fixed value property typeLen = 0x32002L
+            bb.writeInt(0x32002);
+            bb.writeShort(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnTcpFlagsVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnTcpFlagsVer13 other = (OFOxmBsnTcpFlagsVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf0MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf0MaskedVer13.java
new file mode 100644
index 0000000..6efe442
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf0MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf0MaskedVer13 implements OFOxmBsnUdf0Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf0MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf0MaskedVer13 DEFAULT = new OFOxmBsnUdf0MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf0MaskedVer13(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31108L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf0Ver13(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf0Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf0Masked.Builder {
+        final OFOxmBsnUdf0MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf0MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31108L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf0Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf0Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf0Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf0MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf0Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31108L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf0Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf0Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf0Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf0MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf0Masked> {
+        @Override
+        public OFOxmBsnUdf0Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31108L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31108)
+                throw new OFParseError("Wrong typeLen: Expected=0x31108L(0x31108L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf0MaskedVer13 oxmBsnUdf0MaskedVer13 = new OFOxmBsnUdf0MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf0MaskedVer13);
+            return oxmBsnUdf0MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf0MaskedVer13Funnel FUNNEL = new OFOxmBsnUdf0MaskedVer13Funnel();
+    static class OFOxmBsnUdf0MaskedVer13Funnel implements Funnel<OFOxmBsnUdf0MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf0MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31108L
+            sink.putInt(0x31108);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf0MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf0MaskedVer13 message) {
+            // fixed value property typeLen = 0x31108L
+            bb.writeInt(0x31108);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf0MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf0MaskedVer13 other = (OFOxmBsnUdf0MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf0Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf0Ver13.java
new file mode 100644
index 0000000..4ce015f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf0Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf0Ver13 implements OFOxmBsnUdf0 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf0Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf0Ver13 DEFAULT = new OFOxmBsnUdf0Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf0Ver13(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31004L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf0.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf0.Builder {
+        final OFOxmBsnUdf0Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf0Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31004L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf0.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf0 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf0Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf0.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31004L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf0.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF0;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf0 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf0Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf0> {
+        @Override
+        public OFOxmBsnUdf0 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31004L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31004)
+                throw new OFParseError("Wrong typeLen: Expected=0x31004L(0x31004L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf0Ver13 oxmBsnUdf0Ver13 = new OFOxmBsnUdf0Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf0Ver13);
+            return oxmBsnUdf0Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf0Ver13Funnel FUNNEL = new OFOxmBsnUdf0Ver13Funnel();
+    static class OFOxmBsnUdf0Ver13Funnel implements Funnel<OFOxmBsnUdf0Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf0Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31004L
+            sink.putInt(0x31004);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf0Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf0Ver13 message) {
+            // fixed value property typeLen = 0x31004L
+            bb.writeInt(0x31004);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf0Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf0Ver13 other = (OFOxmBsnUdf0Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf1MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf1MaskedVer13.java
new file mode 100644
index 0000000..f57ef31
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf1MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf1MaskedVer13 implements OFOxmBsnUdf1Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf1MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf1MaskedVer13 DEFAULT = new OFOxmBsnUdf1MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf1MaskedVer13(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31308L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf1Ver13(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf1Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf1Masked.Builder {
+        final OFOxmBsnUdf1MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf1MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31308L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf1Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf1Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf1Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf1MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf1Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31308L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf1Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf1Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf1Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf1MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf1Masked> {
+        @Override
+        public OFOxmBsnUdf1Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31308L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31308)
+                throw new OFParseError("Wrong typeLen: Expected=0x31308L(0x31308L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf1MaskedVer13 oxmBsnUdf1MaskedVer13 = new OFOxmBsnUdf1MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf1MaskedVer13);
+            return oxmBsnUdf1MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf1MaskedVer13Funnel FUNNEL = new OFOxmBsnUdf1MaskedVer13Funnel();
+    static class OFOxmBsnUdf1MaskedVer13Funnel implements Funnel<OFOxmBsnUdf1MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf1MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31308L
+            sink.putInt(0x31308);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf1MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf1MaskedVer13 message) {
+            // fixed value property typeLen = 0x31308L
+            bb.writeInt(0x31308);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf1MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf1MaskedVer13 other = (OFOxmBsnUdf1MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf1Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf1Ver13.java
new file mode 100644
index 0000000..1f54e29
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf1Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf1Ver13 implements OFOxmBsnUdf1 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf1Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf1Ver13 DEFAULT = new OFOxmBsnUdf1Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf1Ver13(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31204L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf1.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf1.Builder {
+        final OFOxmBsnUdf1Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf1Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31204L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf1.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf1 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf1Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf1.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31204L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf1.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF1;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf1 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf1Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf1> {
+        @Override
+        public OFOxmBsnUdf1 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31204L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31204)
+                throw new OFParseError("Wrong typeLen: Expected=0x31204L(0x31204L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf1Ver13 oxmBsnUdf1Ver13 = new OFOxmBsnUdf1Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf1Ver13);
+            return oxmBsnUdf1Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf1Ver13Funnel FUNNEL = new OFOxmBsnUdf1Ver13Funnel();
+    static class OFOxmBsnUdf1Ver13Funnel implements Funnel<OFOxmBsnUdf1Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf1Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31204L
+            sink.putInt(0x31204);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf1Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf1Ver13 message) {
+            // fixed value property typeLen = 0x31204L
+            bb.writeInt(0x31204);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf1Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf1Ver13 other = (OFOxmBsnUdf1Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf2MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf2MaskedVer13.java
new file mode 100644
index 0000000..368eacb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf2MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf2MaskedVer13 implements OFOxmBsnUdf2Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf2MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf2MaskedVer13 DEFAULT = new OFOxmBsnUdf2MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf2MaskedVer13(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31508L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf2Ver13(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf2Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf2Masked.Builder {
+        final OFOxmBsnUdf2MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf2MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31508L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf2Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf2Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf2Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf2MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf2Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31508L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf2Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf2Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf2Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf2MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf2Masked> {
+        @Override
+        public OFOxmBsnUdf2Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31508L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31508)
+                throw new OFParseError("Wrong typeLen: Expected=0x31508L(0x31508L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf2MaskedVer13 oxmBsnUdf2MaskedVer13 = new OFOxmBsnUdf2MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf2MaskedVer13);
+            return oxmBsnUdf2MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf2MaskedVer13Funnel FUNNEL = new OFOxmBsnUdf2MaskedVer13Funnel();
+    static class OFOxmBsnUdf2MaskedVer13Funnel implements Funnel<OFOxmBsnUdf2MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf2MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31508L
+            sink.putInt(0x31508);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf2MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf2MaskedVer13 message) {
+            // fixed value property typeLen = 0x31508L
+            bb.writeInt(0x31508);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf2MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf2MaskedVer13 other = (OFOxmBsnUdf2MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf2Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf2Ver13.java
new file mode 100644
index 0000000..511ec40
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf2Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf2Ver13 implements OFOxmBsnUdf2 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf2Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf2Ver13 DEFAULT = new OFOxmBsnUdf2Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf2Ver13(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31404L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf2.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf2.Builder {
+        final OFOxmBsnUdf2Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf2Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31404L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf2.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf2 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf2Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf2.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31404L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf2.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF2;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf2 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf2Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf2> {
+        @Override
+        public OFOxmBsnUdf2 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31404L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31404)
+                throw new OFParseError("Wrong typeLen: Expected=0x31404L(0x31404L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf2Ver13 oxmBsnUdf2Ver13 = new OFOxmBsnUdf2Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf2Ver13);
+            return oxmBsnUdf2Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf2Ver13Funnel FUNNEL = new OFOxmBsnUdf2Ver13Funnel();
+    static class OFOxmBsnUdf2Ver13Funnel implements Funnel<OFOxmBsnUdf2Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf2Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31404L
+            sink.putInt(0x31404);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf2Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf2Ver13 message) {
+            // fixed value property typeLen = 0x31404L
+            bb.writeInt(0x31404);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf2Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf2Ver13 other = (OFOxmBsnUdf2Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf3MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf3MaskedVer13.java
new file mode 100644
index 0000000..4b70152
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf3MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf3MaskedVer13 implements OFOxmBsnUdf3Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf3MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf3MaskedVer13 DEFAULT = new OFOxmBsnUdf3MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf3MaskedVer13(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31708L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf3Ver13(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf3Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf3Masked.Builder {
+        final OFOxmBsnUdf3MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf3MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31708L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf3Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf3Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf3Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf3MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf3Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31708L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf3Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf3Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf3Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf3MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf3Masked> {
+        @Override
+        public OFOxmBsnUdf3Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31708L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31708)
+                throw new OFParseError("Wrong typeLen: Expected=0x31708L(0x31708L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf3MaskedVer13 oxmBsnUdf3MaskedVer13 = new OFOxmBsnUdf3MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf3MaskedVer13);
+            return oxmBsnUdf3MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf3MaskedVer13Funnel FUNNEL = new OFOxmBsnUdf3MaskedVer13Funnel();
+    static class OFOxmBsnUdf3MaskedVer13Funnel implements Funnel<OFOxmBsnUdf3MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf3MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31708L
+            sink.putInt(0x31708);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf3MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf3MaskedVer13 message) {
+            // fixed value property typeLen = 0x31708L
+            bb.writeInt(0x31708);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf3MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf3MaskedVer13 other = (OFOxmBsnUdf3MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf3Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf3Ver13.java
new file mode 100644
index 0000000..cec1db9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf3Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf3Ver13 implements OFOxmBsnUdf3 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf3Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf3Ver13 DEFAULT = new OFOxmBsnUdf3Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf3Ver13(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31604L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf3.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf3.Builder {
+        final OFOxmBsnUdf3Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf3Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31604L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf3.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf3 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf3Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf3.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31604L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf3.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF3;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf3 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf3Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf3> {
+        @Override
+        public OFOxmBsnUdf3 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31604L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31604)
+                throw new OFParseError("Wrong typeLen: Expected=0x31604L(0x31604L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf3Ver13 oxmBsnUdf3Ver13 = new OFOxmBsnUdf3Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf3Ver13);
+            return oxmBsnUdf3Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf3Ver13Funnel FUNNEL = new OFOxmBsnUdf3Ver13Funnel();
+    static class OFOxmBsnUdf3Ver13Funnel implements Funnel<OFOxmBsnUdf3Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf3Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31604L
+            sink.putInt(0x31604);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf3Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf3Ver13 message) {
+            // fixed value property typeLen = 0x31604L
+            bb.writeInt(0x31604);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf3Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf3Ver13 other = (OFOxmBsnUdf3Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf4MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf4MaskedVer13.java
new file mode 100644
index 0000000..f896cff
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf4MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf4MaskedVer13 implements OFOxmBsnUdf4Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf4MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf4MaskedVer13 DEFAULT = new OFOxmBsnUdf4MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf4MaskedVer13(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31908L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf4Ver13(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf4Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf4Masked.Builder {
+        final OFOxmBsnUdf4MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf4MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31908L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf4Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf4Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf4Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf4MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf4Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31908L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf4Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf4Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf4Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf4MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf4Masked> {
+        @Override
+        public OFOxmBsnUdf4Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31908L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31908)
+                throw new OFParseError("Wrong typeLen: Expected=0x31908L(0x31908L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf4MaskedVer13 oxmBsnUdf4MaskedVer13 = new OFOxmBsnUdf4MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf4MaskedVer13);
+            return oxmBsnUdf4MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf4MaskedVer13Funnel FUNNEL = new OFOxmBsnUdf4MaskedVer13Funnel();
+    static class OFOxmBsnUdf4MaskedVer13Funnel implements Funnel<OFOxmBsnUdf4MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf4MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31908L
+            sink.putInt(0x31908);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf4MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf4MaskedVer13 message) {
+            // fixed value property typeLen = 0x31908L
+            bb.writeInt(0x31908);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf4MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf4MaskedVer13 other = (OFOxmBsnUdf4MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf4Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf4Ver13.java
new file mode 100644
index 0000000..ddd0e61
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf4Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf4Ver13 implements OFOxmBsnUdf4 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf4Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf4Ver13 DEFAULT = new OFOxmBsnUdf4Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf4Ver13(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31804L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf4.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf4.Builder {
+        final OFOxmBsnUdf4Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf4Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31804L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf4.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf4 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf4Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf4.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31804L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf4.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF4;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf4 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf4Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf4> {
+        @Override
+        public OFOxmBsnUdf4 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31804L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31804)
+                throw new OFParseError("Wrong typeLen: Expected=0x31804L(0x31804L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf4Ver13 oxmBsnUdf4Ver13 = new OFOxmBsnUdf4Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf4Ver13);
+            return oxmBsnUdf4Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf4Ver13Funnel FUNNEL = new OFOxmBsnUdf4Ver13Funnel();
+    static class OFOxmBsnUdf4Ver13Funnel implements Funnel<OFOxmBsnUdf4Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf4Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31804L
+            sink.putInt(0x31804);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf4Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf4Ver13 message) {
+            // fixed value property typeLen = 0x31804L
+            bb.writeInt(0x31804);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf4Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf4Ver13 other = (OFOxmBsnUdf4Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf5MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf5MaskedVer13.java
new file mode 100644
index 0000000..16aeb31
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf5MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf5MaskedVer13 implements OFOxmBsnUdf5Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf5MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf5MaskedVer13 DEFAULT = new OFOxmBsnUdf5MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf5MaskedVer13(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31b08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf5Ver13(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf5Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf5Masked.Builder {
+        final OFOxmBsnUdf5MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf5MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31b08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf5Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf5Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf5Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf5MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf5Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31b08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf5Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf5Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf5Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf5MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf5Masked> {
+        @Override
+        public OFOxmBsnUdf5Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31b08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31b08)
+                throw new OFParseError("Wrong typeLen: Expected=0x31b08L(0x31b08L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf5MaskedVer13 oxmBsnUdf5MaskedVer13 = new OFOxmBsnUdf5MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf5MaskedVer13);
+            return oxmBsnUdf5MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf5MaskedVer13Funnel FUNNEL = new OFOxmBsnUdf5MaskedVer13Funnel();
+    static class OFOxmBsnUdf5MaskedVer13Funnel implements Funnel<OFOxmBsnUdf5MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf5MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31b08L
+            sink.putInt(0x31b08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf5MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf5MaskedVer13 message) {
+            // fixed value property typeLen = 0x31b08L
+            bb.writeInt(0x31b08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf5MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf5MaskedVer13 other = (OFOxmBsnUdf5MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf5Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf5Ver13.java
new file mode 100644
index 0000000..a3e9fdf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf5Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf5Ver13 implements OFOxmBsnUdf5 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf5Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf5Ver13 DEFAULT = new OFOxmBsnUdf5Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf5Ver13(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31a04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf5.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf5.Builder {
+        final OFOxmBsnUdf5Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf5Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31a04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf5.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf5 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf5Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf5.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31a04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf5.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF5;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf5 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf5Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf5> {
+        @Override
+        public OFOxmBsnUdf5 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31a04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31a04)
+                throw new OFParseError("Wrong typeLen: Expected=0x31a04L(0x31a04L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf5Ver13 oxmBsnUdf5Ver13 = new OFOxmBsnUdf5Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf5Ver13);
+            return oxmBsnUdf5Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf5Ver13Funnel FUNNEL = new OFOxmBsnUdf5Ver13Funnel();
+    static class OFOxmBsnUdf5Ver13Funnel implements Funnel<OFOxmBsnUdf5Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf5Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31a04L
+            sink.putInt(0x31a04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf5Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf5Ver13 message) {
+            // fixed value property typeLen = 0x31a04L
+            bb.writeInt(0x31a04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf5Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf5Ver13 other = (OFOxmBsnUdf5Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf6MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf6MaskedVer13.java
new file mode 100644
index 0000000..7813970
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf6MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf6MaskedVer13 implements OFOxmBsnUdf6Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf6MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf6MaskedVer13 DEFAULT = new OFOxmBsnUdf6MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf6MaskedVer13(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31d08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf6Ver13(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf6Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf6Masked.Builder {
+        final OFOxmBsnUdf6MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf6MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31d08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf6Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf6Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf6Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf6MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf6Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31d08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf6Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf6Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf6Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf6MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf6Masked> {
+        @Override
+        public OFOxmBsnUdf6Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31d08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31d08)
+                throw new OFParseError("Wrong typeLen: Expected=0x31d08L(0x31d08L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf6MaskedVer13 oxmBsnUdf6MaskedVer13 = new OFOxmBsnUdf6MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf6MaskedVer13);
+            return oxmBsnUdf6MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf6MaskedVer13Funnel FUNNEL = new OFOxmBsnUdf6MaskedVer13Funnel();
+    static class OFOxmBsnUdf6MaskedVer13Funnel implements Funnel<OFOxmBsnUdf6MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf6MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31d08L
+            sink.putInt(0x31d08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf6MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf6MaskedVer13 message) {
+            // fixed value property typeLen = 0x31d08L
+            bb.writeInt(0x31d08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf6MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf6MaskedVer13 other = (OFOxmBsnUdf6MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf6Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf6Ver13.java
new file mode 100644
index 0000000..e9b2fa4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf6Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf6Ver13 implements OFOxmBsnUdf6 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf6Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf6Ver13 DEFAULT = new OFOxmBsnUdf6Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf6Ver13(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31c04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf6.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf6.Builder {
+        final OFOxmBsnUdf6Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf6Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31c04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf6.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf6 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf6Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf6.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31c04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf6.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF6;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf6 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf6Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf6> {
+        @Override
+        public OFOxmBsnUdf6 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31c04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31c04)
+                throw new OFParseError("Wrong typeLen: Expected=0x31c04L(0x31c04L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf6Ver13 oxmBsnUdf6Ver13 = new OFOxmBsnUdf6Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf6Ver13);
+            return oxmBsnUdf6Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf6Ver13Funnel FUNNEL = new OFOxmBsnUdf6Ver13Funnel();
+    static class OFOxmBsnUdf6Ver13Funnel implements Funnel<OFOxmBsnUdf6Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf6Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31c04L
+            sink.putInt(0x31c04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf6Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf6Ver13 message) {
+            // fixed value property typeLen = 0x31c04L
+            bb.writeInt(0x31c04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf6Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf6Ver13 other = (OFOxmBsnUdf6Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf7MaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf7MaskedVer13.java
new file mode 100644
index 0000000..b4249ce
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf7MaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf7MaskedVer13 implements OFOxmBsnUdf7Masked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf7MaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+        private final static UDF DEFAULT_VALUE_MASK = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+    private final UDF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf7MaskedVer13 DEFAULT = new OFOxmBsnUdf7MaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf7MaskedVer13(UDF value, UDF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31f08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        if (UDF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnUdf7Ver13(value);
+        } else if(UDF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf7Masked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf7Masked.Builder {
+        final OFOxmBsnUdf7MaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+        BuilderWithParent(OFOxmBsnUdf7MaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31f08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf7Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf7Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf7Masked build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                UDF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnUdf7MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf7Masked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+        private boolean maskSet;
+        private UDF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31f08L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf7Masked.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public UDF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnUdf7Masked.Builder setMask(UDF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf7Masked build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            UDF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnUdf7MaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf7Masked> {
+        @Override
+        public OFOxmBsnUdf7Masked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31f08L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31f08)
+                throw new OFParseError("Wrong typeLen: Expected=0x31f08L(0x31f08L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+            UDF mask = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf7MaskedVer13 oxmBsnUdf7MaskedVer13 = new OFOxmBsnUdf7MaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf7MaskedVer13);
+            return oxmBsnUdf7MaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf7MaskedVer13Funnel FUNNEL = new OFOxmBsnUdf7MaskedVer13Funnel();
+    static class OFOxmBsnUdf7MaskedVer13Funnel implements Funnel<OFOxmBsnUdf7MaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf7MaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31f08L
+            sink.putInt(0x31f08);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf7MaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf7MaskedVer13 message) {
+            // fixed value property typeLen = 0x31f08L
+            bb.writeInt(0x31f08);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf7MaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf7MaskedVer13 other = (OFOxmBsnUdf7MaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf7Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf7Ver13.java
new file mode 100644
index 0000000..5ec36b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnUdf7Ver13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnUdf7Ver13 implements OFOxmBsnUdf7 {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnUdf7Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static UDF DEFAULT_VALUE = UDF.ZERO;
+
+    // OF message fields
+    private final UDF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnUdf7Ver13 DEFAULT = new OFOxmBsnUdf7Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnUdf7Ver13(UDF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x31e04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<UDF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnUdf7.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnUdf7.Builder {
+        final OFOxmBsnUdf7Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+        BuilderWithParent(OFOxmBsnUdf7Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x31e04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf7.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnUdf7 build() {
+                UDF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnUdf7Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnUdf7.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private UDF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x31e04L;
+    }
+
+    @Override
+    public UDF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnUdf7.Builder setValue(UDF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<UDF> getMatchField() {
+        return MatchField.BSN_UDF7;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<UDF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public UDF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnUdf7 build() {
+            UDF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnUdf7Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnUdf7> {
+        @Override
+        public OFOxmBsnUdf7 readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x31e04L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x31e04)
+                throw new OFParseError("Wrong typeLen: Expected=0x31e04L(0x31e04L), got="+typeLen);
+            UDF value = UDF.read4Bytes(bb);
+
+            OFOxmBsnUdf7Ver13 oxmBsnUdf7Ver13 = new OFOxmBsnUdf7Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnUdf7Ver13);
+            return oxmBsnUdf7Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnUdf7Ver13Funnel FUNNEL = new OFOxmBsnUdf7Ver13Funnel();
+    static class OFOxmBsnUdf7Ver13Funnel implements Funnel<OFOxmBsnUdf7Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnUdf7Ver13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x31e04L
+            sink.putInt(0x31e04);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnUdf7Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnUdf7Ver13 message) {
+            // fixed value property typeLen = 0x31e04L
+            bb.writeInt(0x31e04);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnUdf7Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnUdf7Ver13 other = (OFOxmBsnUdf7Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVlanXlatePortGroupIdMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVlanXlatePortGroupIdMaskedVer13.java
new file mode 100644
index 0000000..d302d1f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVlanXlatePortGroupIdMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnVlanXlatePortGroupIdMaskedVer13 implements OFOxmBsnVlanXlatePortGroupIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnVlanXlatePortGroupIdMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+        private final static ClassId DEFAULT_VALUE_MASK = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+    private final ClassId mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnVlanXlatePortGroupIdMaskedVer13 DEFAULT = new OFOxmBsnVlanXlatePortGroupIdMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnVlanXlatePortGroupIdMaskedVer13(ClassId value, ClassId mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x32308L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        if (ClassId.NO_MASK.equals(mask)) {
+            return new OFOxmBsnVlanXlatePortGroupIdVer13(value);
+        } else if(ClassId.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnVlanXlatePortGroupIdMasked.Builder {
+        final OFOxmBsnVlanXlatePortGroupIdMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+        BuilderWithParent(OFOxmBsnVlanXlatePortGroupIdMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x32308L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnVlanXlatePortGroupIdMasked build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ClassId mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnVlanXlatePortGroupIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnVlanXlatePortGroupIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+        private boolean maskSet;
+        private ClassId mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x32308L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ClassId getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder setMask(ClassId mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnVlanXlatePortGroupIdMasked build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ClassId mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnVlanXlatePortGroupIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnVlanXlatePortGroupIdMasked> {
+        @Override
+        public OFOxmBsnVlanXlatePortGroupIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x32308L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x32308)
+                throw new OFParseError("Wrong typeLen: Expected=0x32308L(0x32308L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+            ClassId mask = ClassId.read4Bytes(bb);
+
+            OFOxmBsnVlanXlatePortGroupIdMaskedVer13 oxmBsnVlanXlatePortGroupIdMaskedVer13 = new OFOxmBsnVlanXlatePortGroupIdMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnVlanXlatePortGroupIdMaskedVer13);
+            return oxmBsnVlanXlatePortGroupIdMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnVlanXlatePortGroupIdMaskedVer13Funnel FUNNEL = new OFOxmBsnVlanXlatePortGroupIdMaskedVer13Funnel();
+    static class OFOxmBsnVlanXlatePortGroupIdMaskedVer13Funnel implements Funnel<OFOxmBsnVlanXlatePortGroupIdMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnVlanXlatePortGroupIdMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x32308L
+            sink.putInt(0x32308);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnVlanXlatePortGroupIdMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnVlanXlatePortGroupIdMaskedVer13 message) {
+            // fixed value property typeLen = 0x32308L
+            bb.writeInt(0x32308);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnVlanXlatePortGroupIdMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnVlanXlatePortGroupIdMaskedVer13 other = (OFOxmBsnVlanXlatePortGroupIdMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVlanXlatePortGroupIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVlanXlatePortGroupIdVer13.java
new file mode 100644
index 0000000..b1ff79a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVlanXlatePortGroupIdVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnVlanXlatePortGroupIdVer13 implements OFOxmBsnVlanXlatePortGroupId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnVlanXlatePortGroupIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static ClassId DEFAULT_VALUE = ClassId.NONE;
+
+    // OF message fields
+    private final ClassId value;
+//
+    // Immutable default instance
+    final static OFOxmBsnVlanXlatePortGroupIdVer13 DEFAULT = new OFOxmBsnVlanXlatePortGroupIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnVlanXlatePortGroupIdVer13(ClassId value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x32204L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ClassId> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnVlanXlatePortGroupId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnVlanXlatePortGroupId.Builder {
+        final OFOxmBsnVlanXlatePortGroupIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+        BuilderWithParent(OFOxmBsnVlanXlatePortGroupIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x32204L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnVlanXlatePortGroupId build() {
+                ClassId value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnVlanXlatePortGroupIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnVlanXlatePortGroupId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ClassId value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x32204L;
+    }
+
+    @Override
+    public ClassId getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVlanXlatePortGroupId.Builder setValue(ClassId value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ClassId> getMatchField() {
+        return MatchField.BSN_VLAN_XLATE_PORT_GROUP_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ClassId> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ClassId getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnVlanXlatePortGroupId build() {
+            ClassId value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnVlanXlatePortGroupIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnVlanXlatePortGroupId> {
+        @Override
+        public OFOxmBsnVlanXlatePortGroupId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x32204L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x32204)
+                throw new OFParseError("Wrong typeLen: Expected=0x32204L(0x32204L), got="+typeLen);
+            ClassId value = ClassId.read4Bytes(bb);
+
+            OFOxmBsnVlanXlatePortGroupIdVer13 oxmBsnVlanXlatePortGroupIdVer13 = new OFOxmBsnVlanXlatePortGroupIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnVlanXlatePortGroupIdVer13);
+            return oxmBsnVlanXlatePortGroupIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnVlanXlatePortGroupIdVer13Funnel FUNNEL = new OFOxmBsnVlanXlatePortGroupIdVer13Funnel();
+    static class OFOxmBsnVlanXlatePortGroupIdVer13Funnel implements Funnel<OFOxmBsnVlanXlatePortGroupIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnVlanXlatePortGroupIdVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x32204L
+            sink.putInt(0x32204);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnVlanXlatePortGroupIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnVlanXlatePortGroupIdVer13 message) {
+            // fixed value property typeLen = 0x32204L
+            bb.writeInt(0x32204);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnVlanXlatePortGroupIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnVlanXlatePortGroupIdVer13 other = (OFOxmBsnVlanXlatePortGroupIdVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVrfMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVrfMaskedVer13.java
new file mode 100644
index 0000000..8f1f2cb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVrfMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnVrfMaskedVer13 implements OFOxmBsnVrfMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnVrfMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static VRF DEFAULT_VALUE = VRF.ZERO;
+        private final static VRF DEFAULT_VALUE_MASK = VRF.ZERO;
+
+    // OF message fields
+    private final VRF value;
+    private final VRF mask;
+//
+    // Immutable default instance
+    final static OFOxmBsnVrfMaskedVer13 DEFAULT = new OFOxmBsnVrfMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnVrfMaskedVer13(VRF value, VRF mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30508L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public VRF getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<VRF> getCanonical() {
+        if (VRF.NO_MASK.equals(mask)) {
+            return new OFOxmBsnVrfVer13(value);
+        } else if(VRF.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnVrfMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnVrfMasked.Builder {
+        final OFOxmBsnVrfMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VRF value;
+        private boolean maskSet;
+        private VRF mask;
+
+        BuilderWithParent(OFOxmBsnVrfMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30508L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVrfMasked.Builder setValue(VRF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public VRF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnVrfMasked.Builder setMask(VRF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<VRF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnVrfMasked build() {
+                VRF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                VRF mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmBsnVrfMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnVrfMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VRF value;
+        private boolean maskSet;
+        private VRF mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30508L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVrfMasked.Builder setValue(VRF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public VRF getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmBsnVrfMasked.Builder setMask(VRF mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<VRF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnVrfMasked build() {
+            VRF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            VRF mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmBsnVrfMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnVrfMasked> {
+        @Override
+        public OFOxmBsnVrfMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30508L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30508)
+                throw new OFParseError("Wrong typeLen: Expected=0x30508L(0x30508L), got="+typeLen);
+            VRF value = VRF.read4Bytes(bb);
+            VRF mask = VRF.read4Bytes(bb);
+
+            OFOxmBsnVrfMaskedVer13 oxmBsnVrfMaskedVer13 = new OFOxmBsnVrfMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnVrfMaskedVer13);
+            return oxmBsnVrfMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnVrfMaskedVer13Funnel FUNNEL = new OFOxmBsnVrfMaskedVer13Funnel();
+    static class OFOxmBsnVrfMaskedVer13Funnel implements Funnel<OFOxmBsnVrfMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnVrfMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30508L
+            sink.putInt(0x30508);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnVrfMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnVrfMaskedVer13 message) {
+            // fixed value property typeLen = 0x30508L
+            bb.writeInt(0x30508);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnVrfMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnVrfMaskedVer13 other = (OFOxmBsnVrfMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVrfVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVrfVer13.java
new file mode 100644
index 0000000..64b6ccb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnVrfVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmBsnVrfVer13 implements OFOxmBsnVrf {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmBsnVrfVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static VRF DEFAULT_VALUE = VRF.ZERO;
+
+    // OF message fields
+    private final VRF value;
+//
+    // Immutable default instance
+    final static OFOxmBsnVrfVer13 DEFAULT = new OFOxmBsnVrfVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmBsnVrfVer13(VRF value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x30404L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<VRF> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public VRF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmBsnVrf.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmBsnVrf.Builder {
+        final OFOxmBsnVrfVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VRF value;
+
+        BuilderWithParent(OFOxmBsnVrfVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x30404L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVrf.Builder setValue(VRF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<VRF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public VRF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmBsnVrf build() {
+                VRF value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmBsnVrfVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmBsnVrf.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VRF value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x30404L;
+    }
+
+    @Override
+    public VRF getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmBsnVrf.Builder setValue(VRF value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VRF> getMatchField() {
+        return MatchField.BSN_VRF;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<VRF> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public VRF getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmBsnVrf build() {
+            VRF value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmBsnVrfVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmBsnVrf> {
+        @Override
+        public OFOxmBsnVrf readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x30404L
+            int typeLen = bb.readInt();
+            if(typeLen != 0x30404)
+                throw new OFParseError("Wrong typeLen: Expected=0x30404L(0x30404L), got="+typeLen);
+            VRF value = VRF.read4Bytes(bb);
+
+            OFOxmBsnVrfVer13 oxmBsnVrfVer13 = new OFOxmBsnVrfVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmBsnVrfVer13);
+            return oxmBsnVrfVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmBsnVrfVer13Funnel FUNNEL = new OFOxmBsnVrfVer13Funnel();
+    static class OFOxmBsnVrfVer13Funnel implements Funnel<OFOxmBsnVrfVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmBsnVrfVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x30404L
+            sink.putInt(0x30404);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmBsnVrfVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmBsnVrfVer13 message) {
+            // fixed value property typeLen = 0x30404L
+            bb.writeInt(0x30404);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmBsnVrfVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmBsnVrfVer13 other = (OFOxmBsnVrfVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmClassSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmClassSerializerVer13.java
new file mode 100644
index 0000000..2b33431
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmClassSerializerVer13.java
@@ -0,0 +1,84 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFOxmClass;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFOxmClassSerializerVer13 {
+
+    public final static short NXM_0_VAL = (short) 0x0;
+    public final static short NXM_1_VAL = (short) 0x1;
+    public final static short OPENFLOW_BASIC_VAL = (short) 0x8000;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFOxmClass readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFOxmClass e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFOxmClass e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFOxmClass ofWireValue(short val) {
+        switch(val) {
+            case NXM_0_VAL:
+                return OFOxmClass.NXM_0;
+            case NXM_1_VAL:
+                return OFOxmClass.NXM_1;
+            case OPENFLOW_BASIC_VAL:
+                return OFOxmClass.OPENFLOW_BASIC;
+            case EXPERIMENTER_VAL:
+                return OFOxmClass.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFOxmClass in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFOxmClass e) {
+        switch(e) {
+            case NXM_0:
+                return NXM_0_VAL;
+            case NXM_1:
+                return NXM_1_VAL;
+            case OPENFLOW_BASIC:
+                return OPENFLOW_BASIC_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFOxmClass in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthDstMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthDstMaskedVer13.java
new file mode 100644
index 0000000..b35ec20
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthDstMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthDstMaskedVer13 implements OFOxmEthDstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthDstMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmEthDstMaskedVer13 DEFAULT = new OFOxmEthDstMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthDstMaskedVer13(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000070cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmEthDstVer13(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmEthDstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthDstMasked.Builder {
+        final OFOxmEthDstMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmEthDstMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000070cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthDstMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthDstMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmEthDstMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmEthDstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthDstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000070cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthDstMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthDstMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmEthDstMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmEthDstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthDstMasked> {
+        @Override
+        public OFOxmEthDstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000070cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000070c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000070cL(0x8000070cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmEthDstMaskedVer13 oxmEthDstMaskedVer13 = new OFOxmEthDstMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthDstMaskedVer13);
+            return oxmEthDstMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthDstMaskedVer13Funnel FUNNEL = new OFOxmEthDstMaskedVer13Funnel();
+    static class OFOxmEthDstMaskedVer13Funnel implements Funnel<OFOxmEthDstMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthDstMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000070cL
+            sink.putInt((int) 0x8000070c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthDstMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthDstMaskedVer13 message) {
+            // fixed value property typeLen = 0x8000070cL
+            bb.writeInt((int) 0x8000070c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthDstMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthDstMaskedVer13 other = (OFOxmEthDstMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthDstVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthDstVer13.java
new file mode 100644
index 0000000..f5d4052
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthDstVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthDstVer13 implements OFOxmEthDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthDstVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmEthDstVer13 DEFAULT = new OFOxmEthDstVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthDstVer13(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000606L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmEthDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthDst.Builder {
+        final OFOxmEthDstVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmEthDstVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000606L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthDst.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmEthDst build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmEthDstVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthDst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000606L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthDst.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmEthDst build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmEthDstVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthDst> {
+        @Override
+        public OFOxmEthDst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000606L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000606)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000606L(0x80000606L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmEthDstVer13 oxmEthDstVer13 = new OFOxmEthDstVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthDstVer13);
+            return oxmEthDstVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthDstVer13Funnel FUNNEL = new OFOxmEthDstVer13Funnel();
+    static class OFOxmEthDstVer13Funnel implements Funnel<OFOxmEthDstVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthDstVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000606L
+            sink.putInt((int) 0x80000606);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthDstVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthDstVer13 message) {
+            // fixed value property typeLen = 0x80000606L
+            bb.writeInt((int) 0x80000606);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthDstVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthDstVer13 other = (OFOxmEthDstVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthSrcMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthSrcMaskedVer13.java
new file mode 100644
index 0000000..9f1fcbf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthSrcMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthSrcMaskedVer13 implements OFOxmEthSrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthSrcMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmEthSrcMaskedVer13 DEFAULT = new OFOxmEthSrcMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthSrcMaskedVer13(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000090cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmEthSrcVer13(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmEthSrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthSrcMasked.Builder {
+        final OFOxmEthSrcMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmEthSrcMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000090cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthSrcMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthSrcMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmEthSrcMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmEthSrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthSrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000090cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthSrcMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthSrcMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmEthSrcMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmEthSrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthSrcMasked> {
+        @Override
+        public OFOxmEthSrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000090cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000090c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000090cL(0x8000090cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmEthSrcMaskedVer13 oxmEthSrcMaskedVer13 = new OFOxmEthSrcMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthSrcMaskedVer13);
+            return oxmEthSrcMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthSrcMaskedVer13Funnel FUNNEL = new OFOxmEthSrcMaskedVer13Funnel();
+    static class OFOxmEthSrcMaskedVer13Funnel implements Funnel<OFOxmEthSrcMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthSrcMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000090cL
+            sink.putInt((int) 0x8000090c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthSrcMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthSrcMaskedVer13 message) {
+            // fixed value property typeLen = 0x8000090cL
+            bb.writeInt((int) 0x8000090c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthSrcMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthSrcMaskedVer13 other = (OFOxmEthSrcMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthSrcVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthSrcVer13.java
new file mode 100644
index 0000000..ff92c59
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthSrcVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthSrcVer13 implements OFOxmEthSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthSrcVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmEthSrcVer13 DEFAULT = new OFOxmEthSrcVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthSrcVer13(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000806L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmEthSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthSrc.Builder {
+        final OFOxmEthSrcVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmEthSrcVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000806L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthSrc.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmEthSrc build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmEthSrcVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthSrc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000806L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthSrc.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.ETH_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmEthSrc build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmEthSrcVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthSrc> {
+        @Override
+        public OFOxmEthSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000806L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000806)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000806L(0x80000806L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmEthSrcVer13 oxmEthSrcVer13 = new OFOxmEthSrcVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthSrcVer13);
+            return oxmEthSrcVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthSrcVer13Funnel FUNNEL = new OFOxmEthSrcVer13Funnel();
+    static class OFOxmEthSrcVer13Funnel implements Funnel<OFOxmEthSrcVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthSrcVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000806L
+            sink.putInt((int) 0x80000806);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthSrcVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthSrcVer13 message) {
+            // fixed value property typeLen = 0x80000806L
+            bb.writeInt((int) 0x80000806);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthSrcVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthSrcVer13 other = (OFOxmEthSrcVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthTypeMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthTypeMaskedVer13.java
new file mode 100644
index 0000000..5d4bb6e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthTypeMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthTypeMaskedVer13 implements OFOxmEthTypeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthTypeMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static EthType DEFAULT_VALUE = EthType.NONE;
+        private final static EthType DEFAULT_VALUE_MASK = EthType.NONE;
+
+    // OF message fields
+    private final EthType value;
+    private final EthType mask;
+//
+    // Immutable default instance
+    final static OFOxmEthTypeMaskedVer13 DEFAULT = new OFOxmEthTypeMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthTypeMaskedVer13(EthType value, EthType mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000b04L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public EthType getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<EthType> getCanonical() {
+        if (EthType.NO_MASK.equals(mask)) {
+            return new OFOxmEthTypeVer13(value);
+        } else if(EthType.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmEthTypeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthTypeMasked.Builder {
+        final OFOxmEthTypeMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private EthType value;
+        private boolean maskSet;
+        private EthType mask;
+
+        BuilderWithParent(OFOxmEthTypeMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000b04L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthTypeMasked.Builder setValue(EthType value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public EthType getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthTypeMasked.Builder setMask(EthType mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<EthType> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmEthTypeMasked build() {
+                EthType value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                EthType mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmEthTypeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthTypeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private EthType value;
+        private boolean maskSet;
+        private EthType mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000b04L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthTypeMasked.Builder setValue(EthType value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public EthType getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmEthTypeMasked.Builder setMask(EthType mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<EthType> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmEthTypeMasked build() {
+            EthType value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            EthType mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmEthTypeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthTypeMasked> {
+        @Override
+        public OFOxmEthTypeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000b04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000b04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000b04L(0x80000b04L), got="+typeLen);
+            EthType value = EthType.read2Bytes(bb);
+            EthType mask = EthType.read2Bytes(bb);
+
+            OFOxmEthTypeMaskedVer13 oxmEthTypeMaskedVer13 = new OFOxmEthTypeMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthTypeMaskedVer13);
+            return oxmEthTypeMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthTypeMaskedVer13Funnel FUNNEL = new OFOxmEthTypeMaskedVer13Funnel();
+    static class OFOxmEthTypeMaskedVer13Funnel implements Funnel<OFOxmEthTypeMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthTypeMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000b04L
+            sink.putInt((int) 0x80000b04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthTypeMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthTypeMaskedVer13 message) {
+            // fixed value property typeLen = 0x80000b04L
+            bb.writeInt((int) 0x80000b04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthTypeMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthTypeMaskedVer13 other = (OFOxmEthTypeMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthTypeVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthTypeVer13.java
new file mode 100644
index 0000000..a328c5e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmEthTypeVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmEthTypeVer13 implements OFOxmEthType {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmEthTypeVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static EthType DEFAULT_VALUE = EthType.NONE;
+
+    // OF message fields
+    private final EthType value;
+//
+    // Immutable default instance
+    final static OFOxmEthTypeVer13 DEFAULT = new OFOxmEthTypeVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmEthTypeVer13(EthType value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000a02L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<EthType> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public EthType getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmEthType.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmEthType.Builder {
+        final OFOxmEthTypeVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private EthType value;
+
+        BuilderWithParent(OFOxmEthTypeVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000a02L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthType.Builder setValue(EthType value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<EthType> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public EthType getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmEthType build() {
+                EthType value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmEthTypeVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmEthType.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private EthType value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000a02L;
+    }
+
+    @Override
+    public EthType getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmEthType.Builder setValue(EthType value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<EthType> getMatchField() {
+        return MatchField.ETH_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<EthType> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public EthType getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmEthType build() {
+            EthType value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmEthTypeVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmEthType> {
+        @Override
+        public OFOxmEthType readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000a02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000a02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000a02L(0x80000a02L), got="+typeLen);
+            EthType value = EthType.read2Bytes(bb);
+
+            OFOxmEthTypeVer13 oxmEthTypeVer13 = new OFOxmEthTypeVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmEthTypeVer13);
+            return oxmEthTypeVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmEthTypeVer13Funnel FUNNEL = new OFOxmEthTypeVer13Funnel();
+    static class OFOxmEthTypeVer13Funnel implements Funnel<OFOxmEthTypeVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmEthTypeVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000a02L
+            sink.putInt((int) 0x80000a02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmEthTypeVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmEthTypeVer13 message) {
+            // fixed value property typeLen = 0x80000a02L
+            bb.writeInt((int) 0x80000a02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmEthTypeVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmEthTypeVer13 other = (OFOxmEthTypeVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4CodeMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4CodeMaskedVer13.java
new file mode 100644
index 0000000..a9d8ddd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4CodeMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv4CodeMaskedVer13 implements OFOxmIcmpv4CodeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv4CodeMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static ICMPv4Code DEFAULT_VALUE = ICMPv4Code.NONE;
+        private final static ICMPv4Code DEFAULT_VALUE_MASK = ICMPv4Code.NONE;
+
+    // OF message fields
+    private final ICMPv4Code value;
+    private final ICMPv4Code mask;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv4CodeMaskedVer13 DEFAULT = new OFOxmIcmpv4CodeMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv4CodeMaskedVer13(ICMPv4Code value, ICMPv4Code mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002902L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public ICMPv4Code getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ICMPv4Code> getCanonical() {
+        if (ICMPv4Code.NO_MASK.equals(mask)) {
+            return new OFOxmIcmpv4CodeVer13(value);
+        } else if(ICMPv4Code.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIcmpv4CodeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv4CodeMasked.Builder {
+        final OFOxmIcmpv4CodeMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Code value;
+        private boolean maskSet;
+        private ICMPv4Code mask;
+
+        BuilderWithParent(OFOxmIcmpv4CodeMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002902L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4CodeMasked.Builder setValue(ICMPv4Code value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ICMPv4Code getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv4CodeMasked.Builder setMask(ICMPv4Code mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Code> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv4CodeMasked build() {
+                ICMPv4Code value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ICMPv4Code mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIcmpv4CodeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv4CodeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Code value;
+        private boolean maskSet;
+        private ICMPv4Code mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002902L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4CodeMasked.Builder setValue(ICMPv4Code value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ICMPv4Code getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv4CodeMasked.Builder setMask(ICMPv4Code mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Code> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv4CodeMasked build() {
+            ICMPv4Code value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ICMPv4Code mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIcmpv4CodeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv4CodeMasked> {
+        @Override
+        public OFOxmIcmpv4CodeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002902L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002902)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002902L(0x80002902L), got="+typeLen);
+            ICMPv4Code value = ICMPv4Code.readByte(bb);
+            ICMPv4Code mask = ICMPv4Code.readByte(bb);
+
+            OFOxmIcmpv4CodeMaskedVer13 oxmIcmpv4CodeMaskedVer13 = new OFOxmIcmpv4CodeMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv4CodeMaskedVer13);
+            return oxmIcmpv4CodeMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv4CodeMaskedVer13Funnel FUNNEL = new OFOxmIcmpv4CodeMaskedVer13Funnel();
+    static class OFOxmIcmpv4CodeMaskedVer13Funnel implements Funnel<OFOxmIcmpv4CodeMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv4CodeMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002902L
+            sink.putInt((int) 0x80002902);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv4CodeMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv4CodeMaskedVer13 message) {
+            // fixed value property typeLen = 0x80002902L
+            bb.writeInt((int) 0x80002902);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv4CodeMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv4CodeMaskedVer13 other = (OFOxmIcmpv4CodeMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4CodeVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4CodeVer13.java
new file mode 100644
index 0000000..62576b4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4CodeVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv4CodeVer13 implements OFOxmIcmpv4Code {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv4CodeVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static ICMPv4Code DEFAULT_VALUE = ICMPv4Code.NONE;
+
+    // OF message fields
+    private final ICMPv4Code value;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv4CodeVer13 DEFAULT = new OFOxmIcmpv4CodeVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv4CodeVer13(ICMPv4Code value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002801L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ICMPv4Code> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ICMPv4Code getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIcmpv4Code.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv4Code.Builder {
+        final OFOxmIcmpv4CodeVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Code value;
+
+        BuilderWithParent(OFOxmIcmpv4CodeVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002801L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4Code.Builder setValue(ICMPv4Code value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Code> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ICMPv4Code getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv4Code build() {
+                ICMPv4Code value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIcmpv4CodeVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv4Code.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Code value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002801L;
+    }
+
+    @Override
+    public ICMPv4Code getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4Code.Builder setValue(ICMPv4Code value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Code> getMatchField() {
+        return MatchField.ICMPV4_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Code> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ICMPv4Code getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv4Code build() {
+            ICMPv4Code value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIcmpv4CodeVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv4Code> {
+        @Override
+        public OFOxmIcmpv4Code readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002801L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002801)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002801L(0x80002801L), got="+typeLen);
+            ICMPv4Code value = ICMPv4Code.readByte(bb);
+
+            OFOxmIcmpv4CodeVer13 oxmIcmpv4CodeVer13 = new OFOxmIcmpv4CodeVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv4CodeVer13);
+            return oxmIcmpv4CodeVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv4CodeVer13Funnel FUNNEL = new OFOxmIcmpv4CodeVer13Funnel();
+    static class OFOxmIcmpv4CodeVer13Funnel implements Funnel<OFOxmIcmpv4CodeVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv4CodeVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002801L
+            sink.putInt((int) 0x80002801);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv4CodeVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv4CodeVer13 message) {
+            // fixed value property typeLen = 0x80002801L
+            bb.writeInt((int) 0x80002801);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv4CodeVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv4CodeVer13 other = (OFOxmIcmpv4CodeVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4TypeMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4TypeMaskedVer13.java
new file mode 100644
index 0000000..020004e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4TypeMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv4TypeMaskedVer13 implements OFOxmIcmpv4TypeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv4TypeMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static ICMPv4Type DEFAULT_VALUE = ICMPv4Type.NONE;
+        private final static ICMPv4Type DEFAULT_VALUE_MASK = ICMPv4Type.NONE;
+
+    // OF message fields
+    private final ICMPv4Type value;
+    private final ICMPv4Type mask;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv4TypeMaskedVer13 DEFAULT = new OFOxmIcmpv4TypeMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv4TypeMaskedVer13(ICMPv4Type value, ICMPv4Type mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002702L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public ICMPv4Type getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<ICMPv4Type> getCanonical() {
+        if (ICMPv4Type.NO_MASK.equals(mask)) {
+            return new OFOxmIcmpv4TypeVer13(value);
+        } else if(ICMPv4Type.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIcmpv4TypeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv4TypeMasked.Builder {
+        final OFOxmIcmpv4TypeMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Type value;
+        private boolean maskSet;
+        private ICMPv4Type mask;
+
+        BuilderWithParent(OFOxmIcmpv4TypeMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002702L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4TypeMasked.Builder setValue(ICMPv4Type value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ICMPv4Type getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv4TypeMasked.Builder setMask(ICMPv4Type mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Type> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv4TypeMasked build() {
+                ICMPv4Type value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                ICMPv4Type mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIcmpv4TypeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv4TypeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Type value;
+        private boolean maskSet;
+        private ICMPv4Type mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002702L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4TypeMasked.Builder setValue(ICMPv4Type value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public ICMPv4Type getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv4TypeMasked.Builder setMask(ICMPv4Type mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Type> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv4TypeMasked build() {
+            ICMPv4Type value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            ICMPv4Type mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIcmpv4TypeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv4TypeMasked> {
+        @Override
+        public OFOxmIcmpv4TypeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002702L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002702)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002702L(0x80002702L), got="+typeLen);
+            ICMPv4Type value = ICMPv4Type.readByte(bb);
+            ICMPv4Type mask = ICMPv4Type.readByte(bb);
+
+            OFOxmIcmpv4TypeMaskedVer13 oxmIcmpv4TypeMaskedVer13 = new OFOxmIcmpv4TypeMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv4TypeMaskedVer13);
+            return oxmIcmpv4TypeMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv4TypeMaskedVer13Funnel FUNNEL = new OFOxmIcmpv4TypeMaskedVer13Funnel();
+    static class OFOxmIcmpv4TypeMaskedVer13Funnel implements Funnel<OFOxmIcmpv4TypeMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv4TypeMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002702L
+            sink.putInt((int) 0x80002702);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv4TypeMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv4TypeMaskedVer13 message) {
+            // fixed value property typeLen = 0x80002702L
+            bb.writeInt((int) 0x80002702);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv4TypeMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv4TypeMaskedVer13 other = (OFOxmIcmpv4TypeMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4TypeVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4TypeVer13.java
new file mode 100644
index 0000000..b14a6bc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv4TypeVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv4TypeVer13 implements OFOxmIcmpv4Type {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv4TypeVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static ICMPv4Type DEFAULT_VALUE = ICMPv4Type.NONE;
+
+    // OF message fields
+    private final ICMPv4Type value;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv4TypeVer13 DEFAULT = new OFOxmIcmpv4TypeVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv4TypeVer13(ICMPv4Type value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002601L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<ICMPv4Type> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public ICMPv4Type getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIcmpv4Type.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv4Type.Builder {
+        final OFOxmIcmpv4TypeVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Type value;
+
+        BuilderWithParent(OFOxmIcmpv4TypeVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002601L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4Type.Builder setValue(ICMPv4Type value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Type> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ICMPv4Type getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv4Type build() {
+                ICMPv4Type value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIcmpv4TypeVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv4Type.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private ICMPv4Type value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002601L;
+    }
+
+    @Override
+    public ICMPv4Type getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv4Type.Builder setValue(ICMPv4Type value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<ICMPv4Type> getMatchField() {
+        return MatchField.ICMPV4_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<ICMPv4Type> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public ICMPv4Type getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv4Type build() {
+            ICMPv4Type value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIcmpv4TypeVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv4Type> {
+        @Override
+        public OFOxmIcmpv4Type readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002601L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002601)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002601L(0x80002601L), got="+typeLen);
+            ICMPv4Type value = ICMPv4Type.readByte(bb);
+
+            OFOxmIcmpv4TypeVer13 oxmIcmpv4TypeVer13 = new OFOxmIcmpv4TypeVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv4TypeVer13);
+            return oxmIcmpv4TypeVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv4TypeVer13Funnel FUNNEL = new OFOxmIcmpv4TypeVer13Funnel();
+    static class OFOxmIcmpv4TypeVer13Funnel implements Funnel<OFOxmIcmpv4TypeVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv4TypeVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002601L
+            sink.putInt((int) 0x80002601);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv4TypeVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv4TypeVer13 message) {
+            // fixed value property typeLen = 0x80002601L
+            bb.writeInt((int) 0x80002601);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv4TypeVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv4TypeVer13 other = (OFOxmIcmpv4TypeVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6CodeMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6CodeMaskedVer13.java
new file mode 100644
index 0000000..3da5885
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6CodeMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv6CodeMaskedVer13 implements OFOxmIcmpv6CodeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6CodeMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+        private final static U8 DEFAULT_VALUE_MASK = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+    private final U8 mask;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv6CodeMaskedVer13 DEFAULT = new OFOxmIcmpv6CodeMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv6CodeMaskedVer13(U8 value, U8 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003d02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        if (U8.NO_MASK.equals(mask)) {
+            return new OFOxmIcmpv6CodeVer13(value);
+        } else if(U8.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIcmpv6CodeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv6CodeMasked.Builder {
+        final OFOxmIcmpv6CodeMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+        BuilderWithParent(OFOxmIcmpv6CodeMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003d02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6CodeMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv6CodeMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv6CodeMasked build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U8 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIcmpv6CodeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv6CodeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003d02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6CodeMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv6CodeMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv6CodeMasked build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U8 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIcmpv6CodeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv6CodeMasked> {
+        @Override
+        public OFOxmIcmpv6CodeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003d02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003d02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003d02L(0x80003d02L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+            U8 mask = U8.of(bb.readByte());
+
+            OFOxmIcmpv6CodeMaskedVer13 oxmIcmpv6CodeMaskedVer13 = new OFOxmIcmpv6CodeMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv6CodeMaskedVer13);
+            return oxmIcmpv6CodeMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv6CodeMaskedVer13Funnel FUNNEL = new OFOxmIcmpv6CodeMaskedVer13Funnel();
+    static class OFOxmIcmpv6CodeMaskedVer13Funnel implements Funnel<OFOxmIcmpv6CodeMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv6CodeMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003d02L
+            sink.putInt((int) 0x80003d02);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv6CodeMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv6CodeMaskedVer13 message) {
+            // fixed value property typeLen = 0x80003d02L
+            bb.writeInt((int) 0x80003d02);
+            bb.writeByte(message.value.getRaw());
+            bb.writeByte(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv6CodeMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv6CodeMaskedVer13 other = (OFOxmIcmpv6CodeMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6CodeVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6CodeVer13.java
new file mode 100644
index 0000000..3e52c19
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6CodeVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv6CodeVer13 implements OFOxmIcmpv6Code {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6CodeVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv6CodeVer13 DEFAULT = new OFOxmIcmpv6CodeVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv6CodeVer13(U8 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003c01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIcmpv6Code.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv6Code.Builder {
+        final OFOxmIcmpv6CodeVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+        BuilderWithParent(OFOxmIcmpv6CodeVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003c01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6Code.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv6Code build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIcmpv6CodeVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv6Code.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003c01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6Code.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_CODE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv6Code build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIcmpv6CodeVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv6Code> {
+        @Override
+        public OFOxmIcmpv6Code readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003c01L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003c01)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003c01L(0x80003c01L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+
+            OFOxmIcmpv6CodeVer13 oxmIcmpv6CodeVer13 = new OFOxmIcmpv6CodeVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv6CodeVer13);
+            return oxmIcmpv6CodeVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv6CodeVer13Funnel FUNNEL = new OFOxmIcmpv6CodeVer13Funnel();
+    static class OFOxmIcmpv6CodeVer13Funnel implements Funnel<OFOxmIcmpv6CodeVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv6CodeVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003c01L
+            sink.putInt((int) 0x80003c01);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv6CodeVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv6CodeVer13 message) {
+            // fixed value property typeLen = 0x80003c01L
+            bb.writeInt((int) 0x80003c01);
+            bb.writeByte(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv6CodeVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv6CodeVer13 other = (OFOxmIcmpv6CodeVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6TypeMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6TypeMaskedVer13.java
new file mode 100644
index 0000000..cfd4494
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6TypeMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv6TypeMaskedVer13 implements OFOxmIcmpv6TypeMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6TypeMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+        private final static U8 DEFAULT_VALUE_MASK = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+    private final U8 mask;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv6TypeMaskedVer13 DEFAULT = new OFOxmIcmpv6TypeMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv6TypeMaskedVer13(U8 value, U8 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003b02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        if (U8.NO_MASK.equals(mask)) {
+            return new OFOxmIcmpv6TypeVer13(value);
+        } else if(U8.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIcmpv6TypeMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv6TypeMasked.Builder {
+        final OFOxmIcmpv6TypeMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+        BuilderWithParent(OFOxmIcmpv6TypeMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003b02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6TypeMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv6TypeMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv6TypeMasked build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U8 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIcmpv6TypeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv6TypeMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003b02L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6TypeMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIcmpv6TypeMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv6TypeMasked build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U8 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIcmpv6TypeMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv6TypeMasked> {
+        @Override
+        public OFOxmIcmpv6TypeMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003b02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003b02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003b02L(0x80003b02L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+            U8 mask = U8.of(bb.readByte());
+
+            OFOxmIcmpv6TypeMaskedVer13 oxmIcmpv6TypeMaskedVer13 = new OFOxmIcmpv6TypeMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv6TypeMaskedVer13);
+            return oxmIcmpv6TypeMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv6TypeMaskedVer13Funnel FUNNEL = new OFOxmIcmpv6TypeMaskedVer13Funnel();
+    static class OFOxmIcmpv6TypeMaskedVer13Funnel implements Funnel<OFOxmIcmpv6TypeMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv6TypeMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003b02L
+            sink.putInt((int) 0x80003b02);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv6TypeMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv6TypeMaskedVer13 message) {
+            // fixed value property typeLen = 0x80003b02L
+            bb.writeInt((int) 0x80003b02);
+            bb.writeByte(message.value.getRaw());
+            bb.writeByte(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv6TypeMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv6TypeMaskedVer13 other = (OFOxmIcmpv6TypeMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6TypeVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6TypeVer13.java
new file mode 100644
index 0000000..aab7955
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIcmpv6TypeVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIcmpv6TypeVer13 implements OFOxmIcmpv6Type {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6TypeVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+//
+    // Immutable default instance
+    final static OFOxmIcmpv6TypeVer13 DEFAULT = new OFOxmIcmpv6TypeVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIcmpv6TypeVer13(U8 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003a01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIcmpv6Type.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIcmpv6Type.Builder {
+        final OFOxmIcmpv6TypeVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+        BuilderWithParent(OFOxmIcmpv6TypeVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003a01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6Type.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIcmpv6Type build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIcmpv6TypeVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIcmpv6Type.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003a01L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIcmpv6Type.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.ICMPV6_TYPE;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIcmpv6Type build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIcmpv6TypeVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIcmpv6Type> {
+        @Override
+        public OFOxmIcmpv6Type readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003a01L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003a01)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003a01L(0x80003a01L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+
+            OFOxmIcmpv6TypeVer13 oxmIcmpv6TypeVer13 = new OFOxmIcmpv6TypeVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIcmpv6TypeVer13);
+            return oxmIcmpv6TypeVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIcmpv6TypeVer13Funnel FUNNEL = new OFOxmIcmpv6TypeVer13Funnel();
+    static class OFOxmIcmpv6TypeVer13Funnel implements Funnel<OFOxmIcmpv6TypeVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIcmpv6TypeVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003a01L
+            sink.putInt((int) 0x80003a01);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIcmpv6TypeVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIcmpv6TypeVer13 message) {
+            // fixed value property typeLen = 0x80003a01L
+            bb.writeInt((int) 0x80003a01);
+            bb.writeByte(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIcmpv6TypeVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIcmpv6TypeVer13 other = (OFOxmIcmpv6TypeVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortMaskedVer13.java
new file mode 100644
index 0000000..c1ddbe7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmInPhyPortMaskedVer13 implements OFOxmInPhyPortMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmInPhyPortMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+        private final static OFPort DEFAULT_VALUE_MASK = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+    private final OFPort mask;
+//
+    // Immutable default instance
+    final static OFOxmInPhyPortMaskedVer13 DEFAULT = new OFOxmInPhyPortMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmInPhyPortMaskedVer13(OFPort value, OFPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000308L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFPort> getCanonical() {
+        if (OFPort.NO_MASK.equals(mask)) {
+            return new OFOxmInPhyPortVer13(value);
+        } else if(OFPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmInPhyPortMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmInPhyPortMasked.Builder {
+        final OFOxmInPhyPortMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+        private boolean maskSet;
+        private OFPort mask;
+
+        BuilderWithParent(OFOxmInPhyPortMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000308L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPhyPortMasked.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmInPhyPortMasked.Builder setMask(OFPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmInPhyPortMasked build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmInPhyPortMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmInPhyPortMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+        private boolean maskSet;
+        private OFPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000308L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPhyPortMasked.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmInPhyPortMasked.Builder setMask(OFPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmInPhyPortMasked build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmInPhyPortMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmInPhyPortMasked> {
+        @Override
+        public OFOxmInPhyPortMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000308L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000308)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000308L(0x80000308L), got="+typeLen);
+            OFPort value = OFPort.read4Bytes(bb);
+            OFPort mask = OFPort.read4Bytes(bb);
+
+            OFOxmInPhyPortMaskedVer13 oxmInPhyPortMaskedVer13 = new OFOxmInPhyPortMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmInPhyPortMaskedVer13);
+            return oxmInPhyPortMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmInPhyPortMaskedVer13Funnel FUNNEL = new OFOxmInPhyPortMaskedVer13Funnel();
+    static class OFOxmInPhyPortMaskedVer13Funnel implements Funnel<OFOxmInPhyPortMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmInPhyPortMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000308L
+            sink.putInt((int) 0x80000308);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmInPhyPortMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmInPhyPortMaskedVer13 message) {
+            // fixed value property typeLen = 0x80000308L
+            bb.writeInt((int) 0x80000308);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmInPhyPortMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmInPhyPortMaskedVer13 other = (OFOxmInPhyPortMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortVer13.java
new file mode 100644
index 0000000..36c82d7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmInPhyPortVer13 implements OFOxmInPhyPort {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmInPhyPortVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+//
+    // Immutable default instance
+    final static OFOxmInPhyPortVer13 DEFAULT = new OFOxmInPhyPortVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmInPhyPortVer13(OFPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000204L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmInPhyPort.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmInPhyPort.Builder {
+        final OFOxmInPhyPortVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+        BuilderWithParent(OFOxmInPhyPortVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000204L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPhyPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmInPhyPort build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmInPhyPortVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmInPhyPort.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000204L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPhyPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PHY_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmInPhyPort build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmInPhyPortVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmInPhyPort> {
+        @Override
+        public OFOxmInPhyPort readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000204L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000204)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000204L(0x80000204L), got="+typeLen);
+            OFPort value = OFPort.read4Bytes(bb);
+
+            OFOxmInPhyPortVer13 oxmInPhyPortVer13 = new OFOxmInPhyPortVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmInPhyPortVer13);
+            return oxmInPhyPortVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmInPhyPortVer13Funnel FUNNEL = new OFOxmInPhyPortVer13Funnel();
+    static class OFOxmInPhyPortVer13Funnel implements Funnel<OFOxmInPhyPortVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmInPhyPortVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000204L
+            sink.putInt((int) 0x80000204);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmInPhyPortVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmInPhyPortVer13 message) {
+            // fixed value property typeLen = 0x80000204L
+            bb.writeInt((int) 0x80000204);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmInPhyPortVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmInPhyPortVer13 other = (OFOxmInPhyPortVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPortMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPortMaskedVer13.java
new file mode 100644
index 0000000..cdef18a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPortMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmInPortMaskedVer13 implements OFOxmInPortMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmInPortMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+        private final static OFPort DEFAULT_VALUE_MASK = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+    private final OFPort mask;
+//
+    // Immutable default instance
+    final static OFOxmInPortMaskedVer13 DEFAULT = new OFOxmInPortMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmInPortMaskedVer13(OFPort value, OFPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000108L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFPort> getCanonical() {
+        if (OFPort.NO_MASK.equals(mask)) {
+            return new OFOxmInPortVer13(value);
+        } else if(OFPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmInPortMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmInPortMasked.Builder {
+        final OFOxmInPortMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+        private boolean maskSet;
+        private OFPort mask;
+
+        BuilderWithParent(OFOxmInPortMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000108L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPortMasked.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmInPortMasked.Builder setMask(OFPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmInPortMasked build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmInPortMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmInPortMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+        private boolean maskSet;
+        private OFPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000108L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPortMasked.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmInPortMasked.Builder setMask(OFPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmInPortMasked build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmInPortMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmInPortMasked> {
+        @Override
+        public OFOxmInPortMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000108L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000108)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000108L(0x80000108L), got="+typeLen);
+            OFPort value = OFPort.read4Bytes(bb);
+            OFPort mask = OFPort.read4Bytes(bb);
+
+            OFOxmInPortMaskedVer13 oxmInPortMaskedVer13 = new OFOxmInPortMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmInPortMaskedVer13);
+            return oxmInPortMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmInPortMaskedVer13Funnel FUNNEL = new OFOxmInPortMaskedVer13Funnel();
+    static class OFOxmInPortMaskedVer13Funnel implements Funnel<OFOxmInPortMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmInPortMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000108L
+            sink.putInt((int) 0x80000108);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmInPortMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmInPortMaskedVer13 message) {
+            // fixed value property typeLen = 0x80000108L
+            bb.writeInt((int) 0x80000108);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmInPortMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmInPortMaskedVer13 other = (OFOxmInPortMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPortVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPortVer13.java
new file mode 100644
index 0000000..046bdf2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPortVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmInPortVer13 implements OFOxmInPort {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmInPortVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static OFPort DEFAULT_VALUE = OFPort.ANY;
+
+    // OF message fields
+    private final OFPort value;
+//
+    // Immutable default instance
+    final static OFOxmInPortVer13 DEFAULT = new OFOxmInPortVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmInPortVer13(OFPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000004L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmInPort.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmInPort.Builder {
+        final OFOxmInPortVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+        BuilderWithParent(OFOxmInPortVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000004L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmInPort build() {
+                OFPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmInPortVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmInPort.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000004L;
+    }
+
+    @Override
+    public OFPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmInPort.Builder setValue(OFPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFPort> getMatchField() {
+        return MatchField.IN_PORT;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmInPort build() {
+            OFPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmInPortVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmInPort> {
+        @Override
+        public OFOxmInPort readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000004L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000004)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000004L(0x80000004L), got="+typeLen);
+            OFPort value = OFPort.read4Bytes(bb);
+
+            OFOxmInPortVer13 oxmInPortVer13 = new OFOxmInPortVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmInPortVer13);
+            return oxmInPortVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmInPortVer13Funnel FUNNEL = new OFOxmInPortVer13Funnel();
+    static class OFOxmInPortVer13Funnel implements Funnel<OFOxmInPortVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmInPortVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000004L
+            sink.putInt((int) 0x80000004);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmInPortVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmInPortVer13 message) {
+            // fixed value property typeLen = 0x80000004L
+            bb.writeInt((int) 0x80000004);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmInPortVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmInPortVer13 other = (OFOxmInPortVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpDscpMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpDscpMaskedVer13.java
new file mode 100644
index 0000000..f5bffde
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpDscpMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpDscpMaskedVer13 implements OFOxmIpDscpMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpDscpMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static IpDscp DEFAULT_VALUE = IpDscp.NONE;
+        private final static IpDscp DEFAULT_VALUE_MASK = IpDscp.NONE;
+
+    // OF message fields
+    private final IpDscp value;
+    private final IpDscp mask;
+//
+    // Immutable default instance
+    final static OFOxmIpDscpMaskedVer13 DEFAULT = new OFOxmIpDscpMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpDscpMaskedVer13(IpDscp value, IpDscp mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001102L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public IpDscp getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IpDscp> getCanonical() {
+        if (IpDscp.NO_MASK.equals(mask)) {
+            return new OFOxmIpDscpVer13(value);
+        } else if(IpDscp.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpDscpMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpDscpMasked.Builder {
+        final OFOxmIpDscpMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpDscp value;
+        private boolean maskSet;
+        private IpDscp mask;
+
+        BuilderWithParent(OFOxmIpDscpMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001102L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpDscpMasked.Builder setValue(IpDscp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpDscp getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpDscpMasked.Builder setMask(IpDscp mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpDscp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpDscpMasked build() {
+                IpDscp value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IpDscp mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpDscpMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpDscpMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpDscp value;
+        private boolean maskSet;
+        private IpDscp mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001102L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpDscpMasked.Builder setValue(IpDscp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpDscp getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpDscpMasked.Builder setMask(IpDscp mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpDscp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpDscpMasked build() {
+            IpDscp value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IpDscp mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpDscpMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpDscpMasked> {
+        @Override
+        public OFOxmIpDscpMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001102L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001102)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001102L(0x80001102L), got="+typeLen);
+            IpDscp value = IpDscp.readByte(bb);
+            IpDscp mask = IpDscp.readByte(bb);
+
+            OFOxmIpDscpMaskedVer13 oxmIpDscpMaskedVer13 = new OFOxmIpDscpMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpDscpMaskedVer13);
+            return oxmIpDscpMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpDscpMaskedVer13Funnel FUNNEL = new OFOxmIpDscpMaskedVer13Funnel();
+    static class OFOxmIpDscpMaskedVer13Funnel implements Funnel<OFOxmIpDscpMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpDscpMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001102L
+            sink.putInt((int) 0x80001102);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpDscpMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpDscpMaskedVer13 message) {
+            // fixed value property typeLen = 0x80001102L
+            bb.writeInt((int) 0x80001102);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpDscpMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpDscpMaskedVer13 other = (OFOxmIpDscpMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpDscpVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpDscpVer13.java
new file mode 100644
index 0000000..a0b6786
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpDscpVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpDscpVer13 implements OFOxmIpDscp {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpDscpVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static IpDscp DEFAULT_VALUE = IpDscp.NONE;
+
+    // OF message fields
+    private final IpDscp value;
+//
+    // Immutable default instance
+    final static OFOxmIpDscpVer13 DEFAULT = new OFOxmIpDscpVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpDscpVer13(IpDscp value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001001L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IpDscp> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IpDscp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpDscp.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpDscp.Builder {
+        final OFOxmIpDscpVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpDscp value;
+
+        BuilderWithParent(OFOxmIpDscpVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001001L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpDscp.Builder setValue(IpDscp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpDscp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IpDscp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpDscp build() {
+                IpDscp value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpDscpVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpDscp.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpDscp value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001001L;
+    }
+
+    @Override
+    public IpDscp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpDscp.Builder setValue(IpDscp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpDscp> getMatchField() {
+        return MatchField.IP_DSCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpDscp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IpDscp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpDscp build() {
+            IpDscp value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpDscpVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpDscp> {
+        @Override
+        public OFOxmIpDscp readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001001L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001001)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001001L(0x80001001L), got="+typeLen);
+            IpDscp value = IpDscp.readByte(bb);
+
+            OFOxmIpDscpVer13 oxmIpDscpVer13 = new OFOxmIpDscpVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpDscpVer13);
+            return oxmIpDscpVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpDscpVer13Funnel FUNNEL = new OFOxmIpDscpVer13Funnel();
+    static class OFOxmIpDscpVer13Funnel implements Funnel<OFOxmIpDscpVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpDscpVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001001L
+            sink.putInt((int) 0x80001001);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpDscpVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpDscpVer13 message) {
+            // fixed value property typeLen = 0x80001001L
+            bb.writeInt((int) 0x80001001);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpDscpVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpDscpVer13 other = (OFOxmIpDscpVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpEcnMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpEcnMaskedVer13.java
new file mode 100644
index 0000000..0906f6c
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpEcnMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpEcnMaskedVer13 implements OFOxmIpEcnMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpEcnMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static IpEcn DEFAULT_VALUE = IpEcn.NONE;
+        private final static IpEcn DEFAULT_VALUE_MASK = IpEcn.NONE;
+
+    // OF message fields
+    private final IpEcn value;
+    private final IpEcn mask;
+//
+    // Immutable default instance
+    final static OFOxmIpEcnMaskedVer13 DEFAULT = new OFOxmIpEcnMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpEcnMaskedVer13(IpEcn value, IpEcn mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001302L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public IpEcn getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IpEcn> getCanonical() {
+        if (IpEcn.NO_MASK.equals(mask)) {
+            return new OFOxmIpEcnVer13(value);
+        } else if(IpEcn.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpEcnMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpEcnMasked.Builder {
+        final OFOxmIpEcnMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpEcn value;
+        private boolean maskSet;
+        private IpEcn mask;
+
+        BuilderWithParent(OFOxmIpEcnMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001302L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpEcnMasked.Builder setValue(IpEcn value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpEcn getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpEcnMasked.Builder setMask(IpEcn mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpEcn> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpEcnMasked build() {
+                IpEcn value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IpEcn mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpEcnMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpEcnMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpEcn value;
+        private boolean maskSet;
+        private IpEcn mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001302L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpEcnMasked.Builder setValue(IpEcn value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpEcn getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpEcnMasked.Builder setMask(IpEcn mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpEcn> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpEcnMasked build() {
+            IpEcn value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IpEcn mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpEcnMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpEcnMasked> {
+        @Override
+        public OFOxmIpEcnMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001302L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001302)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001302L(0x80001302L), got="+typeLen);
+            IpEcn value = IpEcn.readByte(bb);
+            IpEcn mask = IpEcn.readByte(bb);
+
+            OFOxmIpEcnMaskedVer13 oxmIpEcnMaskedVer13 = new OFOxmIpEcnMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpEcnMaskedVer13);
+            return oxmIpEcnMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpEcnMaskedVer13Funnel FUNNEL = new OFOxmIpEcnMaskedVer13Funnel();
+    static class OFOxmIpEcnMaskedVer13Funnel implements Funnel<OFOxmIpEcnMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpEcnMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001302L
+            sink.putInt((int) 0x80001302);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpEcnMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpEcnMaskedVer13 message) {
+            // fixed value property typeLen = 0x80001302L
+            bb.writeInt((int) 0x80001302);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpEcnMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpEcnMaskedVer13 other = (OFOxmIpEcnMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpEcnVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpEcnVer13.java
new file mode 100644
index 0000000..1389bee
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpEcnVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpEcnVer13 implements OFOxmIpEcn {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpEcnVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static IpEcn DEFAULT_VALUE = IpEcn.NONE;
+
+    // OF message fields
+    private final IpEcn value;
+//
+    // Immutable default instance
+    final static OFOxmIpEcnVer13 DEFAULT = new OFOxmIpEcnVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpEcnVer13(IpEcn value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001201L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IpEcn> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IpEcn getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpEcn.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpEcn.Builder {
+        final OFOxmIpEcnVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpEcn value;
+
+        BuilderWithParent(OFOxmIpEcnVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001201L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpEcn.Builder setValue(IpEcn value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpEcn> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IpEcn getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpEcn build() {
+                IpEcn value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpEcnVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpEcn.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpEcn value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001201L;
+    }
+
+    @Override
+    public IpEcn getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpEcn.Builder setValue(IpEcn value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpEcn> getMatchField() {
+        return MatchField.IP_ECN;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpEcn> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IpEcn getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpEcn build() {
+            IpEcn value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpEcnVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpEcn> {
+        @Override
+        public OFOxmIpEcn readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001201L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001201)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001201L(0x80001201L), got="+typeLen);
+            IpEcn value = IpEcn.readByte(bb);
+
+            OFOxmIpEcnVer13 oxmIpEcnVer13 = new OFOxmIpEcnVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpEcnVer13);
+            return oxmIpEcnVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpEcnVer13Funnel FUNNEL = new OFOxmIpEcnVer13Funnel();
+    static class OFOxmIpEcnVer13Funnel implements Funnel<OFOxmIpEcnVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpEcnVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001201L
+            sink.putInt((int) 0x80001201);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpEcnVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpEcnVer13 message) {
+            // fixed value property typeLen = 0x80001201L
+            bb.writeInt((int) 0x80001201);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpEcnVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpEcnVer13 other = (OFOxmIpEcnVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpProtoMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpProtoMaskedVer13.java
new file mode 100644
index 0000000..a7a3c74
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpProtoMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpProtoMaskedVer13 implements OFOxmIpProtoMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpProtoMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static IpProtocol DEFAULT_VALUE = IpProtocol.NONE;
+        private final static IpProtocol DEFAULT_VALUE_MASK = IpProtocol.NONE;
+
+    // OF message fields
+    private final IpProtocol value;
+    private final IpProtocol mask;
+//
+    // Immutable default instance
+    final static OFOxmIpProtoMaskedVer13 DEFAULT = new OFOxmIpProtoMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpProtoMaskedVer13(IpProtocol value, IpProtocol mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001502L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public IpProtocol getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IpProtocol> getCanonical() {
+        if (IpProtocol.NO_MASK.equals(mask)) {
+            return new OFOxmIpProtoVer13(value);
+        } else if(IpProtocol.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpProtoMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpProtoMasked.Builder {
+        final OFOxmIpProtoMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpProtocol value;
+        private boolean maskSet;
+        private IpProtocol mask;
+
+        BuilderWithParent(OFOxmIpProtoMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001502L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpProtoMasked.Builder setValue(IpProtocol value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpProtocol getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpProtoMasked.Builder setMask(IpProtocol mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpProtocol> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpProtoMasked build() {
+                IpProtocol value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IpProtocol mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpProtoMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpProtoMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpProtocol value;
+        private boolean maskSet;
+        private IpProtocol mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001502L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpProtoMasked.Builder setValue(IpProtocol value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IpProtocol getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpProtoMasked.Builder setMask(IpProtocol mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IpProtocol> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpProtoMasked build() {
+            IpProtocol value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IpProtocol mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpProtoMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpProtoMasked> {
+        @Override
+        public OFOxmIpProtoMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001502L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001502)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001502L(0x80001502L), got="+typeLen);
+            IpProtocol value = IpProtocol.readByte(bb);
+            IpProtocol mask = IpProtocol.readByte(bb);
+
+            OFOxmIpProtoMaskedVer13 oxmIpProtoMaskedVer13 = new OFOxmIpProtoMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpProtoMaskedVer13);
+            return oxmIpProtoMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpProtoMaskedVer13Funnel FUNNEL = new OFOxmIpProtoMaskedVer13Funnel();
+    static class OFOxmIpProtoMaskedVer13Funnel implements Funnel<OFOxmIpProtoMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpProtoMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001502L
+            sink.putInt((int) 0x80001502);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpProtoMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpProtoMaskedVer13 message) {
+            // fixed value property typeLen = 0x80001502L
+            bb.writeInt((int) 0x80001502);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpProtoMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpProtoMaskedVer13 other = (OFOxmIpProtoMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpProtoVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpProtoVer13.java
new file mode 100644
index 0000000..d0354fb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpProtoVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpProtoVer13 implements OFOxmIpProto {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpProtoVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static IpProtocol DEFAULT_VALUE = IpProtocol.NONE;
+
+    // OF message fields
+    private final IpProtocol value;
+//
+    // Immutable default instance
+    final static OFOxmIpProtoVer13 DEFAULT = new OFOxmIpProtoVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpProtoVer13(IpProtocol value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001401L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IpProtocol> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IpProtocol getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpProto.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpProto.Builder {
+        final OFOxmIpProtoVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IpProtocol value;
+
+        BuilderWithParent(OFOxmIpProtoVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001401L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpProto.Builder setValue(IpProtocol value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpProtocol> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IpProtocol getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpProto build() {
+                IpProtocol value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpProtoVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpProto.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IpProtocol value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001401L;
+    }
+
+    @Override
+    public IpProtocol getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpProto.Builder setValue(IpProtocol value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IpProtocol> getMatchField() {
+        return MatchField.IP_PROTO;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IpProtocol> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IpProtocol getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpProto build() {
+            IpProtocol value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpProtoVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpProto> {
+        @Override
+        public OFOxmIpProto readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001401L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001401)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001401L(0x80001401L), got="+typeLen);
+            IpProtocol value = IpProtocol.readByte(bb);
+
+            OFOxmIpProtoVer13 oxmIpProtoVer13 = new OFOxmIpProtoVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpProtoVer13);
+            return oxmIpProtoVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpProtoVer13Funnel FUNNEL = new OFOxmIpProtoVer13Funnel();
+    static class OFOxmIpProtoVer13Funnel implements Funnel<OFOxmIpProtoVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpProtoVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001401L
+            sink.putInt((int) 0x80001401);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpProtoVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpProtoVer13 message) {
+            // fixed value property typeLen = 0x80001401L
+            bb.writeInt((int) 0x80001401);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpProtoVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpProtoVer13 other = (OFOxmIpProtoVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4DstMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4DstMaskedVer13.java
new file mode 100644
index 0000000..e791166
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4DstMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv4DstMaskedVer13 implements OFOxmIpv4DstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv4DstMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_VALUE_MASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+    private final IPv4Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv4DstMaskedVer13 DEFAULT = new OFOxmIpv4DstMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv4DstMaskedVer13(IPv4Address value, IPv4Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001908L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        if (IPv4Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv4DstVer13(value);
+        } else if(IPv4Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv4DstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv4DstMasked.Builder {
+        final OFOxmIpv4DstMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+        BuilderWithParent(OFOxmIpv4DstMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001908L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4DstMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv4DstMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv4DstMasked build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv4Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv4DstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv4DstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001908L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4DstMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv4DstMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv4DstMasked build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv4Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv4DstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv4DstMasked> {
+        @Override
+        public OFOxmIpv4DstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001908L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001908)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001908L(0x80001908L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+            IPv4Address mask = IPv4Address.read4Bytes(bb);
+
+            OFOxmIpv4DstMaskedVer13 oxmIpv4DstMaskedVer13 = new OFOxmIpv4DstMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv4DstMaskedVer13);
+            return oxmIpv4DstMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv4DstMaskedVer13Funnel FUNNEL = new OFOxmIpv4DstMaskedVer13Funnel();
+    static class OFOxmIpv4DstMaskedVer13Funnel implements Funnel<OFOxmIpv4DstMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv4DstMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001908L
+            sink.putInt((int) 0x80001908);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv4DstMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv4DstMaskedVer13 message) {
+            // fixed value property typeLen = 0x80001908L
+            bb.writeInt((int) 0x80001908);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv4DstMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv4DstMaskedVer13 other = (OFOxmIpv4DstMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4DstVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4DstVer13.java
new file mode 100644
index 0000000..d66f14d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4DstVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv4DstVer13 implements OFOxmIpv4Dst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv4DstVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv4DstVer13 DEFAULT = new OFOxmIpv4DstVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv4DstVer13(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001804L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv4Dst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv4Dst.Builder {
+        final OFOxmIpv4DstVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFOxmIpv4DstVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001804L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4Dst.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv4Dst build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv4DstVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv4Dst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001804L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4Dst.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv4Dst build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv4DstVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv4Dst> {
+        @Override
+        public OFOxmIpv4Dst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001804L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001804)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001804L(0x80001804L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFOxmIpv4DstVer13 oxmIpv4DstVer13 = new OFOxmIpv4DstVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv4DstVer13);
+            return oxmIpv4DstVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv4DstVer13Funnel FUNNEL = new OFOxmIpv4DstVer13Funnel();
+    static class OFOxmIpv4DstVer13Funnel implements Funnel<OFOxmIpv4DstVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv4DstVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001804L
+            sink.putInt((int) 0x80001804);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv4DstVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv4DstVer13 message) {
+            // fixed value property typeLen = 0x80001804L
+            bb.writeInt((int) 0x80001804);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv4DstVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv4DstVer13 other = (OFOxmIpv4DstVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4SrcMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4SrcMaskedVer13.java
new file mode 100644
index 0000000..5de3147
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4SrcMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv4SrcMaskedVer13 implements OFOxmIpv4SrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv4SrcMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+        private final static IPv4Address DEFAULT_VALUE_MASK = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+    private final IPv4Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv4SrcMaskedVer13 DEFAULT = new OFOxmIpv4SrcMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv4SrcMaskedVer13(IPv4Address value, IPv4Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001708L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        if (IPv4Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv4SrcVer13(value);
+        } else if(IPv4Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv4SrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv4SrcMasked.Builder {
+        final OFOxmIpv4SrcMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+        BuilderWithParent(OFOxmIpv4SrcMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001708L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4SrcMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv4SrcMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv4SrcMasked build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv4Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv4SrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv4SrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+        private boolean maskSet;
+        private IPv4Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001708L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4SrcMasked.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv4Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv4SrcMasked.Builder setMask(IPv4Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv4SrcMasked build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv4Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv4SrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv4SrcMasked> {
+        @Override
+        public OFOxmIpv4SrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001708L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001708)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001708L(0x80001708L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+            IPv4Address mask = IPv4Address.read4Bytes(bb);
+
+            OFOxmIpv4SrcMaskedVer13 oxmIpv4SrcMaskedVer13 = new OFOxmIpv4SrcMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv4SrcMaskedVer13);
+            return oxmIpv4SrcMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv4SrcMaskedVer13Funnel FUNNEL = new OFOxmIpv4SrcMaskedVer13Funnel();
+    static class OFOxmIpv4SrcMaskedVer13Funnel implements Funnel<OFOxmIpv4SrcMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv4SrcMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001708L
+            sink.putInt((int) 0x80001708);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv4SrcMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv4SrcMaskedVer13 message) {
+            // fixed value property typeLen = 0x80001708L
+            bb.writeInt((int) 0x80001708);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv4SrcMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv4SrcMaskedVer13 other = (OFOxmIpv4SrcMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4SrcVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4SrcVer13.java
new file mode 100644
index 0000000..aae1239
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv4SrcVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv4SrcVer13 implements OFOxmIpv4Src {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv4SrcVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static IPv4Address DEFAULT_VALUE = IPv4Address.NONE;
+
+    // OF message fields
+    private final IPv4Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv4SrcVer13 DEFAULT = new OFOxmIpv4SrcVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv4SrcVer13(IPv4Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001604L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv4Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv4Src.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv4Src.Builder {
+        final OFOxmIpv4SrcVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+        BuilderWithParent(OFOxmIpv4SrcVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001604L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4Src.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv4Src build() {
+                IPv4Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv4SrcVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv4Src.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv4Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001604L;
+    }
+
+    @Override
+    public IPv4Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv4Src.Builder setValue(IPv4Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv4Address> getMatchField() {
+        return MatchField.IPV4_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv4Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv4Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv4Src build() {
+            IPv4Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv4SrcVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv4Src> {
+        @Override
+        public OFOxmIpv4Src readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001604L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001604)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001604L(0x80001604L), got="+typeLen);
+            IPv4Address value = IPv4Address.read4Bytes(bb);
+
+            OFOxmIpv4SrcVer13 oxmIpv4SrcVer13 = new OFOxmIpv4SrcVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv4SrcVer13);
+            return oxmIpv4SrcVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv4SrcVer13Funnel FUNNEL = new OFOxmIpv4SrcVer13Funnel();
+    static class OFOxmIpv4SrcVer13Funnel implements Funnel<OFOxmIpv4SrcVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv4SrcVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001604L
+            sink.putInt((int) 0x80001604);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv4SrcVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv4SrcVer13 message) {
+            // fixed value property typeLen = 0x80001604L
+            bb.writeInt((int) 0x80001604);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv4SrcVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv4SrcVer13 other = (OFOxmIpv4SrcVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstMaskedVer13.java
new file mode 100644
index 0000000..7aaf6a7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6DstMaskedVer13 implements OFOxmIpv6DstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6DstMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 36;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+        private final static IPv6Address DEFAULT_VALUE_MASK = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+    private final IPv6Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6DstMaskedVer13 DEFAULT = new OFOxmIpv6DstMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6DstMaskedVer13(IPv6Address value, IPv6Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003720L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        if (IPv6Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6DstVer13(value);
+        } else if(IPv6Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6DstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6DstMasked.Builder {
+        final OFOxmIpv6DstMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+        BuilderWithParent(OFOxmIpv6DstMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003720L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6DstMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6DstMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6DstMasked build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv6Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6DstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6DstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003720L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6DstMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6DstMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6DstMasked build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv6Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6DstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6DstMasked> {
+        @Override
+        public OFOxmIpv6DstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003720L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003720)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003720L(0x80003720L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+            IPv6Address mask = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6DstMaskedVer13 oxmIpv6DstMaskedVer13 = new OFOxmIpv6DstMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6DstMaskedVer13);
+            return oxmIpv6DstMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6DstMaskedVer13Funnel FUNNEL = new OFOxmIpv6DstMaskedVer13Funnel();
+    static class OFOxmIpv6DstMaskedVer13Funnel implements Funnel<OFOxmIpv6DstMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6DstMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003720L
+            sink.putInt((int) 0x80003720);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6DstMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6DstMaskedVer13 message) {
+            // fixed value property typeLen = 0x80003720L
+            bb.writeInt((int) 0x80003720);
+            message.value.write16Bytes(bb);
+            message.mask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6DstMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6DstMaskedVer13 other = (OFOxmIpv6DstMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstVer13.java
new file mode 100644
index 0000000..148fbd5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6DstVer13 implements OFOxmIpv6Dst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6DstVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6DstVer13 DEFAULT = new OFOxmIpv6DstVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6DstVer13(IPv6Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003610L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6Dst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6Dst.Builder {
+        final OFOxmIpv6DstVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+        BuilderWithParent(OFOxmIpv6DstVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003610L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Dst.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6Dst build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6DstVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6Dst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003610L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Dst.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6Dst build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6DstVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6Dst> {
+        @Override
+        public OFOxmIpv6Dst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003610L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003610)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003610L(0x80003610L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6DstVer13 oxmIpv6DstVer13 = new OFOxmIpv6DstVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6DstVer13);
+            return oxmIpv6DstVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6DstVer13Funnel FUNNEL = new OFOxmIpv6DstVer13Funnel();
+    static class OFOxmIpv6DstVer13Funnel implements Funnel<OFOxmIpv6DstVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6DstVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003610L
+            sink.putInt((int) 0x80003610);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6DstVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6DstVer13 message) {
+            // fixed value property typeLen = 0x80003610L
+            bb.writeInt((int) 0x80003610);
+            message.value.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6DstVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6DstVer13 other = (OFOxmIpv6DstVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6FlabelMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6FlabelMaskedVer13.java
new file mode 100644
index 0000000..2da8bf6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6FlabelMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6FlabelMaskedVer13 implements OFOxmIpv6FlabelMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6FlabelMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static IPv6FlowLabel DEFAULT_VALUE = IPv6FlowLabel.NONE;
+        private final static IPv6FlowLabel DEFAULT_VALUE_MASK = IPv6FlowLabel.NONE;
+
+    // OF message fields
+    private final IPv6FlowLabel value;
+    private final IPv6FlowLabel mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6FlabelMaskedVer13 DEFAULT = new OFOxmIpv6FlabelMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6FlabelMaskedVer13(IPv6FlowLabel value, IPv6FlowLabel mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003908L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv6FlowLabel getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv6FlowLabel> getCanonical() {
+        if (IPv6FlowLabel.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6FlabelVer13(value);
+        } else if(IPv6FlowLabel.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6FlabelMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6FlabelMasked.Builder {
+        final OFOxmIpv6FlabelMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6FlowLabel value;
+        private boolean maskSet;
+        private IPv6FlowLabel mask;
+
+        BuilderWithParent(OFOxmIpv6FlabelMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003908L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6FlabelMasked.Builder setValue(IPv6FlowLabel value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6FlowLabel getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6FlabelMasked.Builder setMask(IPv6FlowLabel mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6FlowLabel> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6FlabelMasked build() {
+                IPv6FlowLabel value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv6FlowLabel mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6FlabelMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6FlabelMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6FlowLabel value;
+        private boolean maskSet;
+        private IPv6FlowLabel mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003908L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6FlabelMasked.Builder setValue(IPv6FlowLabel value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6FlowLabel getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6FlabelMasked.Builder setMask(IPv6FlowLabel mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6FlowLabel> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6FlabelMasked build() {
+            IPv6FlowLabel value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv6FlowLabel mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6FlabelMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6FlabelMasked> {
+        @Override
+        public OFOxmIpv6FlabelMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003908L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003908)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003908L(0x80003908L), got="+typeLen);
+            IPv6FlowLabel value = IPv6FlowLabel.read4Bytes(bb);
+            IPv6FlowLabel mask = IPv6FlowLabel.read4Bytes(bb);
+
+            OFOxmIpv6FlabelMaskedVer13 oxmIpv6FlabelMaskedVer13 = new OFOxmIpv6FlabelMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6FlabelMaskedVer13);
+            return oxmIpv6FlabelMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6FlabelMaskedVer13Funnel FUNNEL = new OFOxmIpv6FlabelMaskedVer13Funnel();
+    static class OFOxmIpv6FlabelMaskedVer13Funnel implements Funnel<OFOxmIpv6FlabelMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6FlabelMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003908L
+            sink.putInt((int) 0x80003908);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6FlabelMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6FlabelMaskedVer13 message) {
+            // fixed value property typeLen = 0x80003908L
+            bb.writeInt((int) 0x80003908);
+            message.value.write4Bytes(bb);
+            message.mask.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6FlabelMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6FlabelMaskedVer13 other = (OFOxmIpv6FlabelMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6FlabelVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6FlabelVer13.java
new file mode 100644
index 0000000..50dbba1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6FlabelVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6FlabelVer13 implements OFOxmIpv6Flabel {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6FlabelVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static IPv6FlowLabel DEFAULT_VALUE = IPv6FlowLabel.NONE;
+
+    // OF message fields
+    private final IPv6FlowLabel value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6FlabelVer13 DEFAULT = new OFOxmIpv6FlabelVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6FlabelVer13(IPv6FlowLabel value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003804L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv6FlowLabel> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv6FlowLabel getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6Flabel.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6Flabel.Builder {
+        final OFOxmIpv6FlabelVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6FlowLabel value;
+
+        BuilderWithParent(OFOxmIpv6FlabelVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003804L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Flabel.Builder setValue(IPv6FlowLabel value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6FlowLabel> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv6FlowLabel getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6Flabel build() {
+                IPv6FlowLabel value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6FlabelVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6Flabel.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6FlowLabel value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003804L;
+    }
+
+    @Override
+    public IPv6FlowLabel getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Flabel.Builder setValue(IPv6FlowLabel value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6FlowLabel> getMatchField() {
+        return MatchField.IPV6_FLABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6FlowLabel> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv6FlowLabel getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6Flabel build() {
+            IPv6FlowLabel value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6FlabelVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6Flabel> {
+        @Override
+        public OFOxmIpv6Flabel readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003804L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003804)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003804L(0x80003804L), got="+typeLen);
+            IPv6FlowLabel value = IPv6FlowLabel.read4Bytes(bb);
+
+            OFOxmIpv6FlabelVer13 oxmIpv6FlabelVer13 = new OFOxmIpv6FlabelVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6FlabelVer13);
+            return oxmIpv6FlabelVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6FlabelVer13Funnel FUNNEL = new OFOxmIpv6FlabelVer13Funnel();
+    static class OFOxmIpv6FlabelVer13Funnel implements Funnel<OFOxmIpv6FlabelVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6FlabelVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003804L
+            sink.putInt((int) 0x80003804);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6FlabelVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6FlabelVer13 message) {
+            // fixed value property typeLen = 0x80003804L
+            bb.writeInt((int) 0x80003804);
+            message.value.write4Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6FlabelVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6FlabelVer13 other = (OFOxmIpv6FlabelVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdSllMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdSllMaskedVer13.java
new file mode 100644
index 0000000..93e8e69
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdSllMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdSllMaskedVer13 implements OFOxmIpv6NdSllMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdSllMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdSllMaskedVer13 DEFAULT = new OFOxmIpv6NdSllMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdSllMaskedVer13(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000410cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6NdSllVer13(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6NdSllMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdSllMasked.Builder {
+        final OFOxmIpv6NdSllMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmIpv6NdSllMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000410cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdSllMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdSllMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdSllMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6NdSllMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdSllMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000410cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdSllMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdSllMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdSllMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6NdSllMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdSllMasked> {
+        @Override
+        public OFOxmIpv6NdSllMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000410cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000410c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000410cL(0x8000410cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmIpv6NdSllMaskedVer13 oxmIpv6NdSllMaskedVer13 = new OFOxmIpv6NdSllMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdSllMaskedVer13);
+            return oxmIpv6NdSllMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdSllMaskedVer13Funnel FUNNEL = new OFOxmIpv6NdSllMaskedVer13Funnel();
+    static class OFOxmIpv6NdSllMaskedVer13Funnel implements Funnel<OFOxmIpv6NdSllMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdSllMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000410cL
+            sink.putInt((int) 0x8000410c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdSllMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdSllMaskedVer13 message) {
+            // fixed value property typeLen = 0x8000410cL
+            bb.writeInt((int) 0x8000410c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdSllMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdSllMaskedVer13 other = (OFOxmIpv6NdSllMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdSllVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdSllVer13.java
new file mode 100644
index 0000000..53b2432
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdSllVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdSllVer13 implements OFOxmIpv6NdSll {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdSllVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdSllVer13 DEFAULT = new OFOxmIpv6NdSllVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdSllVer13(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6NdSll.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdSll.Builder {
+        final OFOxmIpv6NdSllVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmIpv6NdSllVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdSll.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdSll build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6NdSllVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdSll.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004006L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdSll.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_SLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdSll build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6NdSllVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdSll> {
+        @Override
+        public OFOxmIpv6NdSll readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004006L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004006)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004006L(0x80004006L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmIpv6NdSllVer13 oxmIpv6NdSllVer13 = new OFOxmIpv6NdSllVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdSllVer13);
+            return oxmIpv6NdSllVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdSllVer13Funnel FUNNEL = new OFOxmIpv6NdSllVer13Funnel();
+    static class OFOxmIpv6NdSllVer13Funnel implements Funnel<OFOxmIpv6NdSllVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdSllVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004006L
+            sink.putInt((int) 0x80004006);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdSllVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdSllVer13 message) {
+            // fixed value property typeLen = 0x80004006L
+            bb.writeInt((int) 0x80004006);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdSllVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdSllVer13 other = (OFOxmIpv6NdSllVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTargetMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTargetMaskedVer13.java
new file mode 100644
index 0000000..ee92c94
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTargetMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdTargetMaskedVer13 implements OFOxmIpv6NdTargetMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdTargetMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 36;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+        private final static IPv6Address DEFAULT_VALUE_MASK = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+    private final IPv6Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdTargetMaskedVer13 DEFAULT = new OFOxmIpv6NdTargetMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdTargetMaskedVer13(IPv6Address value, IPv6Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003f20L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        if (IPv6Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6NdTargetVer13(value);
+        } else if(IPv6Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6NdTargetMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdTargetMasked.Builder {
+        final OFOxmIpv6NdTargetMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+        BuilderWithParent(OFOxmIpv6NdTargetMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003f20L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTargetMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdTargetMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdTargetMasked build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv6Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6NdTargetMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdTargetMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003f20L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTargetMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdTargetMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdTargetMasked build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv6Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6NdTargetMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdTargetMasked> {
+        @Override
+        public OFOxmIpv6NdTargetMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003f20L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003f20)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003f20L(0x80003f20L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+            IPv6Address mask = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6NdTargetMaskedVer13 oxmIpv6NdTargetMaskedVer13 = new OFOxmIpv6NdTargetMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdTargetMaskedVer13);
+            return oxmIpv6NdTargetMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdTargetMaskedVer13Funnel FUNNEL = new OFOxmIpv6NdTargetMaskedVer13Funnel();
+    static class OFOxmIpv6NdTargetMaskedVer13Funnel implements Funnel<OFOxmIpv6NdTargetMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdTargetMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003f20L
+            sink.putInt((int) 0x80003f20);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdTargetMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdTargetMaskedVer13 message) {
+            // fixed value property typeLen = 0x80003f20L
+            bb.writeInt((int) 0x80003f20);
+            message.value.write16Bytes(bb);
+            message.mask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdTargetMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdTargetMaskedVer13 other = (OFOxmIpv6NdTargetMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTargetVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTargetVer13.java
new file mode 100644
index 0000000..fd5f197
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTargetVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdTargetVer13 implements OFOxmIpv6NdTarget {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdTargetVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdTargetVer13 DEFAULT = new OFOxmIpv6NdTargetVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdTargetVer13(IPv6Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003e10L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6NdTarget.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdTarget.Builder {
+        final OFOxmIpv6NdTargetVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+        BuilderWithParent(OFOxmIpv6NdTargetVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003e10L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTarget.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdTarget build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6NdTargetVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdTarget.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003e10L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTarget.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_ND_TARGET;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdTarget build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6NdTargetVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdTarget> {
+        @Override
+        public OFOxmIpv6NdTarget readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003e10L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003e10)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003e10L(0x80003e10L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6NdTargetVer13 oxmIpv6NdTargetVer13 = new OFOxmIpv6NdTargetVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdTargetVer13);
+            return oxmIpv6NdTargetVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdTargetVer13Funnel FUNNEL = new OFOxmIpv6NdTargetVer13Funnel();
+    static class OFOxmIpv6NdTargetVer13Funnel implements Funnel<OFOxmIpv6NdTargetVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdTargetVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003e10L
+            sink.putInt((int) 0x80003e10);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdTargetVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdTargetVer13 message) {
+            // fixed value property typeLen = 0x80003e10L
+            bb.writeInt((int) 0x80003e10);
+            message.value.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdTargetVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdTargetVer13 other = (OFOxmIpv6NdTargetVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTllMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTllMaskedVer13.java
new file mode 100644
index 0000000..0f4e9fb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTllMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdTllMaskedVer13 implements OFOxmIpv6NdTllMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdTllMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+        private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+    private final MacAddress mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdTllMaskedVer13 DEFAULT = new OFOxmIpv6NdTllMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdTllMaskedVer13(MacAddress value, MacAddress mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x8000430cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        if (MacAddress.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6NdTllVer13(value);
+        } else if(MacAddress.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6NdTllMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdTllMasked.Builder {
+        final OFOxmIpv6NdTllMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+        BuilderWithParent(OFOxmIpv6NdTllMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000430cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTllMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdTllMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdTllMasked build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                MacAddress mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6NdTllMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdTllMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+        private boolean maskSet;
+        private MacAddress mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x8000430cL;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTllMasked.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6NdTllMasked.Builder setMask(MacAddress mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdTllMasked build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6NdTllMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdTllMasked> {
+        @Override
+        public OFOxmIpv6NdTllMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x8000430cL
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x8000430c)
+                throw new OFParseError("Wrong typeLen: Expected=0x8000430cL(0x8000430cL), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+            MacAddress mask = MacAddress.read6Bytes(bb);
+
+            OFOxmIpv6NdTllMaskedVer13 oxmIpv6NdTllMaskedVer13 = new OFOxmIpv6NdTllMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdTllMaskedVer13);
+            return oxmIpv6NdTllMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdTllMaskedVer13Funnel FUNNEL = new OFOxmIpv6NdTllMaskedVer13Funnel();
+    static class OFOxmIpv6NdTllMaskedVer13Funnel implements Funnel<OFOxmIpv6NdTllMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdTllMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x8000430cL
+            sink.putInt((int) 0x8000430c);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdTllMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdTllMaskedVer13 message) {
+            // fixed value property typeLen = 0x8000430cL
+            bb.writeInt((int) 0x8000430c);
+            message.value.write6Bytes(bb);
+            message.mask.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdTllMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdTllMaskedVer13 other = (OFOxmIpv6NdTllMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTllVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTllVer13.java
new file mode 100644
index 0000000..e42cff0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6NdTllVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6NdTllVer13 implements OFOxmIpv6NdTll {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6NdTllVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 10;
+
+        private final static MacAddress DEFAULT_VALUE = MacAddress.NONE;
+
+    // OF message fields
+    private final MacAddress value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6NdTllVer13 DEFAULT = new OFOxmIpv6NdTllVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6NdTllVer13(MacAddress value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<MacAddress> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6NdTll.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6NdTll.Builder {
+        final OFOxmIpv6NdTllVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+        BuilderWithParent(OFOxmIpv6NdTllVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTll.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6NdTll build() {
+                MacAddress value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6NdTllVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6NdTll.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private MacAddress value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004206L;
+    }
+
+    @Override
+    public MacAddress getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6NdTll.Builder setValue(MacAddress value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<MacAddress> getMatchField() {
+        return MatchField.IPV6_ND_TLL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public MacAddress getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6NdTll build() {
+            MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6NdTllVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6NdTll> {
+        @Override
+        public OFOxmIpv6NdTll readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004206L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004206)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004206L(0x80004206L), got="+typeLen);
+            MacAddress value = MacAddress.read6Bytes(bb);
+
+            OFOxmIpv6NdTllVer13 oxmIpv6NdTllVer13 = new OFOxmIpv6NdTllVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6NdTllVer13);
+            return oxmIpv6NdTllVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6NdTllVer13Funnel FUNNEL = new OFOxmIpv6NdTllVer13Funnel();
+    static class OFOxmIpv6NdTllVer13Funnel implements Funnel<OFOxmIpv6NdTllVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6NdTllVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004206L
+            sink.putInt((int) 0x80004206);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6NdTllVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6NdTllVer13 message) {
+            // fixed value property typeLen = 0x80004206L
+            bb.writeInt((int) 0x80004206);
+            message.value.write6Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6NdTllVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6NdTllVer13 other = (OFOxmIpv6NdTllVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6SrcMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6SrcMaskedVer13.java
new file mode 100644
index 0000000..55c238f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6SrcMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6SrcMaskedVer13 implements OFOxmIpv6SrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6SrcMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 36;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+        private final static IPv6Address DEFAULT_VALUE_MASK = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+    private final IPv6Address mask;
+//
+    // Immutable default instance
+    final static OFOxmIpv6SrcMaskedVer13 DEFAULT = new OFOxmIpv6SrcMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6SrcMaskedVer13(IPv6Address value, IPv6Address mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003520L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        if (IPv6Address.NO_MASK.equals(mask)) {
+            return new OFOxmIpv6SrcVer13(value);
+        } else if(IPv6Address.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6SrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6SrcMasked.Builder {
+        final OFOxmIpv6SrcMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+        BuilderWithParent(OFOxmIpv6SrcMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003520L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6SrcMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6SrcMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6SrcMasked build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                IPv6Address mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmIpv6SrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6SrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+        private boolean maskSet;
+        private IPv6Address mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003520L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6SrcMasked.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public IPv6Address getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmIpv6SrcMasked.Builder setMask(IPv6Address mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6SrcMasked build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            IPv6Address mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmIpv6SrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6SrcMasked> {
+        @Override
+        public OFOxmIpv6SrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003520L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003520)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003520L(0x80003520L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+            IPv6Address mask = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6SrcMaskedVer13 oxmIpv6SrcMaskedVer13 = new OFOxmIpv6SrcMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6SrcMaskedVer13);
+            return oxmIpv6SrcMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6SrcMaskedVer13Funnel FUNNEL = new OFOxmIpv6SrcMaskedVer13Funnel();
+    static class OFOxmIpv6SrcMaskedVer13Funnel implements Funnel<OFOxmIpv6SrcMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6SrcMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003520L
+            sink.putInt((int) 0x80003520);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6SrcMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6SrcMaskedVer13 message) {
+            // fixed value property typeLen = 0x80003520L
+            bb.writeInt((int) 0x80003520);
+            message.value.write16Bytes(bb);
+            message.mask.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6SrcMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6SrcMaskedVer13 other = (OFOxmIpv6SrcMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6SrcVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6SrcVer13.java
new file mode 100644
index 0000000..84a242a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6SrcVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmIpv6SrcVer13 implements OFOxmIpv6Src {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmIpv6SrcVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static IPv6Address DEFAULT_VALUE = IPv6Address.NONE;
+
+    // OF message fields
+    private final IPv6Address value;
+//
+    // Immutable default instance
+    final static OFOxmIpv6SrcVer13 DEFAULT = new OFOxmIpv6SrcVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmIpv6SrcVer13(IPv6Address value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80003410L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<IPv6Address> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmIpv6Src.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmIpv6Src.Builder {
+        final OFOxmIpv6SrcVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+        BuilderWithParent(OFOxmIpv6SrcVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003410L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Src.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmIpv6Src build() {
+                IPv6Address value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmIpv6SrcVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmIpv6Src.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private IPv6Address value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80003410L;
+    }
+
+    @Override
+    public IPv6Address getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmIpv6Src.Builder setValue(IPv6Address value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<IPv6Address> getMatchField() {
+        return MatchField.IPV6_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<IPv6Address> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public IPv6Address getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmIpv6Src build() {
+            IPv6Address value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmIpv6SrcVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmIpv6Src> {
+        @Override
+        public OFOxmIpv6Src readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80003410L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80003410)
+                throw new OFParseError("Wrong typeLen: Expected=0x80003410L(0x80003410L), got="+typeLen);
+            IPv6Address value = IPv6Address.read16Bytes(bb);
+
+            OFOxmIpv6SrcVer13 oxmIpv6SrcVer13 = new OFOxmIpv6SrcVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmIpv6SrcVer13);
+            return oxmIpv6SrcVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmIpv6SrcVer13Funnel FUNNEL = new OFOxmIpv6SrcVer13Funnel();
+    static class OFOxmIpv6SrcVer13Funnel implements Funnel<OFOxmIpv6SrcVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmIpv6SrcVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80003410L
+            sink.putInt((int) 0x80003410);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmIpv6SrcVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmIpv6SrcVer13 message) {
+            // fixed value property typeLen = 0x80003410L
+            bb.writeInt((int) 0x80003410);
+            message.value.write16Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmIpv6SrcVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmIpv6SrcVer13 other = (OFOxmIpv6SrcVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMetadataMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMetadataMaskedVer13.java
new file mode 100644
index 0000000..361b7e9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMetadataMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMetadataMaskedVer13 implements OFOxmMetadataMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMetadataMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static OFMetadata DEFAULT_VALUE = OFMetadata.NONE;
+        private final static OFMetadata DEFAULT_VALUE_MASK = OFMetadata.NONE;
+
+    // OF message fields
+    private final OFMetadata value;
+    private final OFMetadata mask;
+//
+    // Immutable default instance
+    final static OFOxmMetadataMaskedVer13 DEFAULT = new OFOxmMetadataMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMetadataMaskedVer13(OFMetadata value, OFMetadata mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000510L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFMetadata getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFMetadata> getCanonical() {
+        if (OFMetadata.NO_MASK.equals(mask)) {
+            return new OFOxmMetadataVer13(value);
+        } else if(OFMetadata.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmMetadataMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMetadataMasked.Builder {
+        final OFOxmMetadataMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFMetadata value;
+        private boolean maskSet;
+        private OFMetadata mask;
+
+        BuilderWithParent(OFOxmMetadataMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000510L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMetadataMasked.Builder setValue(OFMetadata value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFMetadata getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMetadataMasked.Builder setMask(OFMetadata mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFMetadata> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmMetadataMasked build() {
+                OFMetadata value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFMetadata mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmMetadataMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMetadataMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFMetadata value;
+        private boolean maskSet;
+        private OFMetadata mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000510L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMetadataMasked.Builder setValue(OFMetadata value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFMetadata getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMetadataMasked.Builder setMask(OFMetadata mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFMetadata> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmMetadataMasked build() {
+            OFMetadata value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFMetadata mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmMetadataMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMetadataMasked> {
+        @Override
+        public OFOxmMetadataMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000510L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000510)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000510L(0x80000510L), got="+typeLen);
+            OFMetadata value = OFMetadata.read8Bytes(bb);
+            OFMetadata mask = OFMetadata.read8Bytes(bb);
+
+            OFOxmMetadataMaskedVer13 oxmMetadataMaskedVer13 = new OFOxmMetadataMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMetadataMaskedVer13);
+            return oxmMetadataMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMetadataMaskedVer13Funnel FUNNEL = new OFOxmMetadataMaskedVer13Funnel();
+    static class OFOxmMetadataMaskedVer13Funnel implements Funnel<OFOxmMetadataMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMetadataMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000510L
+            sink.putInt((int) 0x80000510);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMetadataMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMetadataMaskedVer13 message) {
+            // fixed value property typeLen = 0x80000510L
+            bb.writeInt((int) 0x80000510);
+            message.value.write8Bytes(bb);
+            message.mask.write8Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMetadataMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMetadataMaskedVer13 other = (OFOxmMetadataMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMetadataVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMetadataVer13.java
new file mode 100644
index 0000000..664abb3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMetadataVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMetadataVer13 implements OFOxmMetadata {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMetadataVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static OFMetadata DEFAULT_VALUE = OFMetadata.NONE;
+
+    // OF message fields
+    private final OFMetadata value;
+//
+    // Immutable default instance
+    final static OFOxmMetadataVer13 DEFAULT = new OFOxmMetadataVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMetadataVer13(OFMetadata value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000408L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFMetadata> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFMetadata getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmMetadata.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMetadata.Builder {
+        final OFOxmMetadataVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFMetadata value;
+
+        BuilderWithParent(OFOxmMetadataVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000408L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMetadata.Builder setValue(OFMetadata value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFMetadata> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFMetadata getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmMetadata build() {
+                OFMetadata value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmMetadataVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMetadata.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFMetadata value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000408L;
+    }
+
+    @Override
+    public OFMetadata getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMetadata.Builder setValue(OFMetadata value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFMetadata> getMatchField() {
+        return MatchField.METADATA;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFMetadata> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFMetadata getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmMetadata build() {
+            OFMetadata value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmMetadataVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMetadata> {
+        @Override
+        public OFOxmMetadata readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000408L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000408)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000408L(0x80000408L), got="+typeLen);
+            OFMetadata value = OFMetadata.read8Bytes(bb);
+
+            OFOxmMetadataVer13 oxmMetadataVer13 = new OFOxmMetadataVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMetadataVer13);
+            return oxmMetadataVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMetadataVer13Funnel FUNNEL = new OFOxmMetadataVer13Funnel();
+    static class OFOxmMetadataVer13Funnel implements Funnel<OFOxmMetadataVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMetadataVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000408L
+            sink.putInt((int) 0x80000408);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMetadataVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMetadataVer13 message) {
+            // fixed value property typeLen = 0x80000408L
+            bb.writeInt((int) 0x80000408);
+            message.value.write8Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMetadataVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMetadataVer13 other = (OFOxmMetadataVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsLabelMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsLabelMaskedVer13.java
new file mode 100644
index 0000000..497a841
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsLabelMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMplsLabelMaskedVer13 implements OFOxmMplsLabelMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMplsLabelMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static U32 DEFAULT_VALUE = U32.ZERO;
+        private final static U32 DEFAULT_VALUE_MASK = U32.ZERO;
+
+    // OF message fields
+    private final U32 value;
+    private final U32 mask;
+//
+    // Immutable default instance
+    final static OFOxmMplsLabelMaskedVer13 DEFAULT = new OFOxmMplsLabelMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMplsLabelMaskedVer13(U32 value, U32 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004508L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public U32 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U32> getCanonical() {
+        if (U32.NO_MASK.equals(mask)) {
+            return new OFOxmMplsLabelVer13(value);
+        } else if(U32.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmMplsLabelMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMplsLabelMasked.Builder {
+        final OFOxmMplsLabelMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U32 value;
+        private boolean maskSet;
+        private U32 mask;
+
+        BuilderWithParent(OFOxmMplsLabelMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004508L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsLabelMasked.Builder setValue(U32 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U32 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMplsLabelMasked.Builder setMask(U32 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U32> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmMplsLabelMasked build() {
+                U32 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U32 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmMplsLabelMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMplsLabelMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U32 value;
+        private boolean maskSet;
+        private U32 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004508L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsLabelMasked.Builder setValue(U32 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U32 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMplsLabelMasked.Builder setMask(U32 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U32> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmMplsLabelMasked build() {
+            U32 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U32 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmMplsLabelMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMplsLabelMasked> {
+        @Override
+        public OFOxmMplsLabelMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004508L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004508)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004508L(0x80004508L), got="+typeLen);
+            U32 value = U32.of(bb.readInt());
+            U32 mask = U32.of(bb.readInt());
+
+            OFOxmMplsLabelMaskedVer13 oxmMplsLabelMaskedVer13 = new OFOxmMplsLabelMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMplsLabelMaskedVer13);
+            return oxmMplsLabelMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMplsLabelMaskedVer13Funnel FUNNEL = new OFOxmMplsLabelMaskedVer13Funnel();
+    static class OFOxmMplsLabelMaskedVer13Funnel implements Funnel<OFOxmMplsLabelMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMplsLabelMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004508L
+            sink.putInt((int) 0x80004508);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMplsLabelMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMplsLabelMaskedVer13 message) {
+            // fixed value property typeLen = 0x80004508L
+            bb.writeInt((int) 0x80004508);
+            bb.writeInt(message.value.getRaw());
+            bb.writeInt(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMplsLabelMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMplsLabelMaskedVer13 other = (OFOxmMplsLabelMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsLabelVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsLabelVer13.java
new file mode 100644
index 0000000..23684b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsLabelVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMplsLabelVer13 implements OFOxmMplsLabel {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMplsLabelVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static U32 DEFAULT_VALUE = U32.ZERO;
+
+    // OF message fields
+    private final U32 value;
+//
+    // Immutable default instance
+    final static OFOxmMplsLabelVer13 DEFAULT = new OFOxmMplsLabelVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMplsLabelVer13(U32 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004404L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U32> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U32 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmMplsLabel.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMplsLabel.Builder {
+        final OFOxmMplsLabelVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U32 value;
+
+        BuilderWithParent(OFOxmMplsLabelVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004404L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsLabel.Builder setValue(U32 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U32> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U32 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmMplsLabel build() {
+                U32 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmMplsLabelVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMplsLabel.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U32 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004404L;
+    }
+
+    @Override
+    public U32 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsLabel.Builder setValue(U32 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U32> getMatchField() {
+        return MatchField.MPLS_LABEL;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U32> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U32 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmMplsLabel build() {
+            U32 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmMplsLabelVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMplsLabel> {
+        @Override
+        public OFOxmMplsLabel readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004404L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004404)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004404L(0x80004404L), got="+typeLen);
+            U32 value = U32.of(bb.readInt());
+
+            OFOxmMplsLabelVer13 oxmMplsLabelVer13 = new OFOxmMplsLabelVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMplsLabelVer13);
+            return oxmMplsLabelVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMplsLabelVer13Funnel FUNNEL = new OFOxmMplsLabelVer13Funnel();
+    static class OFOxmMplsLabelVer13Funnel implements Funnel<OFOxmMplsLabelVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMplsLabelVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004404L
+            sink.putInt((int) 0x80004404);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMplsLabelVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMplsLabelVer13 message) {
+            // fixed value property typeLen = 0x80004404L
+            bb.writeInt((int) 0x80004404);
+            bb.writeInt(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMplsLabelVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMplsLabelVer13 other = (OFOxmMplsLabelVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsTcMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsTcMaskedVer13.java
new file mode 100644
index 0000000..e60efa5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsTcMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMplsTcMaskedVer13 implements OFOxmMplsTcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMplsTcMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+        private final static U8 DEFAULT_VALUE_MASK = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+    private final U8 mask;
+//
+    // Immutable default instance
+    final static OFOxmMplsTcMaskedVer13 DEFAULT = new OFOxmMplsTcMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMplsTcMaskedVer13(U8 value, U8 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004702L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        if (U8.NO_MASK.equals(mask)) {
+            return new OFOxmMplsTcVer13(value);
+        } else if(U8.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmMplsTcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMplsTcMasked.Builder {
+        final OFOxmMplsTcMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+        BuilderWithParent(OFOxmMplsTcMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004702L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsTcMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMplsTcMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmMplsTcMasked build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U8 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmMplsTcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMplsTcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+        private boolean maskSet;
+        private U8 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004702L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsTcMasked.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U8 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmMplsTcMasked.Builder setMask(U8 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmMplsTcMasked build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U8 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmMplsTcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMplsTcMasked> {
+        @Override
+        public OFOxmMplsTcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004702L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004702)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004702L(0x80004702L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+            U8 mask = U8.of(bb.readByte());
+
+            OFOxmMplsTcMaskedVer13 oxmMplsTcMaskedVer13 = new OFOxmMplsTcMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMplsTcMaskedVer13);
+            return oxmMplsTcMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMplsTcMaskedVer13Funnel FUNNEL = new OFOxmMplsTcMaskedVer13Funnel();
+    static class OFOxmMplsTcMaskedVer13Funnel implements Funnel<OFOxmMplsTcMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMplsTcMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004702L
+            sink.putInt((int) 0x80004702);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMplsTcMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMplsTcMaskedVer13 message) {
+            // fixed value property typeLen = 0x80004702L
+            bb.writeInt((int) 0x80004702);
+            bb.writeByte(message.value.getRaw());
+            bb.writeByte(message.mask.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMplsTcMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMplsTcMaskedVer13 other = (OFOxmMplsTcMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsTcVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsTcVer13.java
new file mode 100644
index 0000000..15b685a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmMplsTcVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmMplsTcVer13 implements OFOxmMplsTc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmMplsTcVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static U8 DEFAULT_VALUE = U8.ZERO;
+
+    // OF message fields
+    private final U8 value;
+//
+    // Immutable default instance
+    final static OFOxmMplsTcVer13 DEFAULT = new OFOxmMplsTcVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmMplsTcVer13(U8 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004601L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U8> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmMplsTc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmMplsTc.Builder {
+        final OFOxmMplsTcVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+        BuilderWithParent(OFOxmMplsTcVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004601L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsTc.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmMplsTc build() {
+                U8 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmMplsTcVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmMplsTc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U8 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004601L;
+    }
+
+    @Override
+    public U8 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmMplsTc.Builder setValue(U8 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U8> getMatchField() {
+        return MatchField.MPLS_TC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U8> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U8 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmMplsTc build() {
+            U8 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmMplsTcVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmMplsTc> {
+        @Override
+        public OFOxmMplsTc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004601L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004601)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004601L(0x80004601L), got="+typeLen);
+            U8 value = U8.of(bb.readByte());
+
+            OFOxmMplsTcVer13 oxmMplsTcVer13 = new OFOxmMplsTcVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmMplsTcVer13);
+            return oxmMplsTcVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmMplsTcVer13Funnel FUNNEL = new OFOxmMplsTcVer13Funnel();
+    static class OFOxmMplsTcVer13Funnel implements Funnel<OFOxmMplsTcVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmMplsTcVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004601L
+            sink.putInt((int) 0x80004601);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmMplsTcVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmMplsTcVer13 message) {
+            // fixed value property typeLen = 0x80004601L
+            bb.writeInt((int) 0x80004601);
+            bb.writeByte(message.value.getRaw());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmMplsTcVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmMplsTcVer13 other = (OFOxmMplsTcVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpDstMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpDstMaskedVer13.java
new file mode 100644
index 0000000..03901ed
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpDstMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmSctpDstMaskedVer13 implements OFOxmSctpDstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmSctpDstMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmSctpDstMaskedVer13 DEFAULT = new OFOxmSctpDstMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmSctpDstMaskedVer13(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002504L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmSctpDstVer13(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmSctpDstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmSctpDstMasked.Builder {
+        final OFOxmSctpDstMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmSctpDstMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002504L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmSctpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmSctpDstMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmSctpDstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmSctpDstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002504L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmSctpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmSctpDstMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmSctpDstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmSctpDstMasked> {
+        @Override
+        public OFOxmSctpDstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002504L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002504)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002504L(0x80002504L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmSctpDstMaskedVer13 oxmSctpDstMaskedVer13 = new OFOxmSctpDstMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmSctpDstMaskedVer13);
+            return oxmSctpDstMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmSctpDstMaskedVer13Funnel FUNNEL = new OFOxmSctpDstMaskedVer13Funnel();
+    static class OFOxmSctpDstMaskedVer13Funnel implements Funnel<OFOxmSctpDstMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmSctpDstMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002504L
+            sink.putInt((int) 0x80002504);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmSctpDstMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmSctpDstMaskedVer13 message) {
+            // fixed value property typeLen = 0x80002504L
+            bb.writeInt((int) 0x80002504);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmSctpDstMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmSctpDstMaskedVer13 other = (OFOxmSctpDstMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpDstVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpDstVer13.java
new file mode 100644
index 0000000..955a99d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpDstVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmSctpDstVer13 implements OFOxmSctpDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmSctpDstVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmSctpDstVer13 DEFAULT = new OFOxmSctpDstVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmSctpDstVer13(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002402L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmSctpDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmSctpDst.Builder {
+        final OFOxmSctpDstVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmSctpDstVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002402L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmSctpDst build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmSctpDstVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmSctpDst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002402L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmSctpDst build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmSctpDstVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmSctpDst> {
+        @Override
+        public OFOxmSctpDst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002402L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002402)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002402L(0x80002402L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmSctpDstVer13 oxmSctpDstVer13 = new OFOxmSctpDstVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmSctpDstVer13);
+            return oxmSctpDstVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmSctpDstVer13Funnel FUNNEL = new OFOxmSctpDstVer13Funnel();
+    static class OFOxmSctpDstVer13Funnel implements Funnel<OFOxmSctpDstVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmSctpDstVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002402L
+            sink.putInt((int) 0x80002402);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmSctpDstVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmSctpDstVer13 message) {
+            // fixed value property typeLen = 0x80002402L
+            bb.writeInt((int) 0x80002402);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmSctpDstVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmSctpDstVer13 other = (OFOxmSctpDstVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpSrcMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpSrcMaskedVer13.java
new file mode 100644
index 0000000..a44a994
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpSrcMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmSctpSrcMaskedVer13 implements OFOxmSctpSrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmSctpSrcMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmSctpSrcMaskedVer13 DEFAULT = new OFOxmSctpSrcMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmSctpSrcMaskedVer13(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002304L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmSctpSrcVer13(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmSctpSrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmSctpSrcMasked.Builder {
+        final OFOxmSctpSrcMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmSctpSrcMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002304L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmSctpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmSctpSrcMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmSctpSrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmSctpSrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002304L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmSctpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmSctpSrcMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmSctpSrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmSctpSrcMasked> {
+        @Override
+        public OFOxmSctpSrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002304L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002304)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002304L(0x80002304L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmSctpSrcMaskedVer13 oxmSctpSrcMaskedVer13 = new OFOxmSctpSrcMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmSctpSrcMaskedVer13);
+            return oxmSctpSrcMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmSctpSrcMaskedVer13Funnel FUNNEL = new OFOxmSctpSrcMaskedVer13Funnel();
+    static class OFOxmSctpSrcMaskedVer13Funnel implements Funnel<OFOxmSctpSrcMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmSctpSrcMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002304L
+            sink.putInt((int) 0x80002304);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmSctpSrcMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmSctpSrcMaskedVer13 message) {
+            // fixed value property typeLen = 0x80002304L
+            bb.writeInt((int) 0x80002304);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmSctpSrcMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmSctpSrcMaskedVer13 other = (OFOxmSctpSrcMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpSrcVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpSrcVer13.java
new file mode 100644
index 0000000..631b9b1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmSctpSrcVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmSctpSrcVer13 implements OFOxmSctpSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmSctpSrcVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmSctpSrcVer13 DEFAULT = new OFOxmSctpSrcVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmSctpSrcVer13(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002202L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmSctpSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmSctpSrc.Builder {
+        final OFOxmSctpSrcVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmSctpSrcVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002202L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmSctpSrc build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmSctpSrcVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmSctpSrc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002202L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmSctpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.SCTP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmSctpSrc build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmSctpSrcVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmSctpSrc> {
+        @Override
+        public OFOxmSctpSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002202L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002202)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002202L(0x80002202L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmSctpSrcVer13 oxmSctpSrcVer13 = new OFOxmSctpSrcVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmSctpSrcVer13);
+            return oxmSctpSrcVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmSctpSrcVer13Funnel FUNNEL = new OFOxmSctpSrcVer13Funnel();
+    static class OFOxmSctpSrcVer13Funnel implements Funnel<OFOxmSctpSrcVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmSctpSrcVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002202L
+            sink.putInt((int) 0x80002202);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmSctpSrcVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmSctpSrcVer13 message) {
+            // fixed value property typeLen = 0x80002202L
+            bb.writeInt((int) 0x80002202);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmSctpSrcVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmSctpSrcVer13 other = (OFOxmSctpSrcVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpDstMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpDstMaskedVer13.java
new file mode 100644
index 0000000..264b828
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpDstMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTcpDstMaskedVer13 implements OFOxmTcpDstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTcpDstMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmTcpDstMaskedVer13 DEFAULT = new OFOxmTcpDstMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTcpDstMaskedVer13(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001d04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmTcpDstVer13(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmTcpDstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTcpDstMasked.Builder {
+        final OFOxmTcpDstMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmTcpDstMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001d04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTcpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmTcpDstMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmTcpDstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTcpDstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001d04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTcpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmTcpDstMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmTcpDstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTcpDstMasked> {
+        @Override
+        public OFOxmTcpDstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001d04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001d04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001d04L(0x80001d04L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmTcpDstMaskedVer13 oxmTcpDstMaskedVer13 = new OFOxmTcpDstMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTcpDstMaskedVer13);
+            return oxmTcpDstMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTcpDstMaskedVer13Funnel FUNNEL = new OFOxmTcpDstMaskedVer13Funnel();
+    static class OFOxmTcpDstMaskedVer13Funnel implements Funnel<OFOxmTcpDstMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTcpDstMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001d04L
+            sink.putInt((int) 0x80001d04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTcpDstMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTcpDstMaskedVer13 message) {
+            // fixed value property typeLen = 0x80001d04L
+            bb.writeInt((int) 0x80001d04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTcpDstMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTcpDstMaskedVer13 other = (OFOxmTcpDstMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpDstVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpDstVer13.java
new file mode 100644
index 0000000..b828dd2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpDstVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTcpDstVer13 implements OFOxmTcpDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTcpDstVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmTcpDstVer13 DEFAULT = new OFOxmTcpDstVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTcpDstVer13(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001c02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmTcpDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTcpDst.Builder {
+        final OFOxmTcpDstVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmTcpDstVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001c02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmTcpDst build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmTcpDstVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTcpDst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001c02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmTcpDst build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmTcpDstVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTcpDst> {
+        @Override
+        public OFOxmTcpDst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001c02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001c02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001c02L(0x80001c02L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmTcpDstVer13 oxmTcpDstVer13 = new OFOxmTcpDstVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTcpDstVer13);
+            return oxmTcpDstVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTcpDstVer13Funnel FUNNEL = new OFOxmTcpDstVer13Funnel();
+    static class OFOxmTcpDstVer13Funnel implements Funnel<OFOxmTcpDstVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTcpDstVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001c02L
+            sink.putInt((int) 0x80001c02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTcpDstVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTcpDstVer13 message) {
+            // fixed value property typeLen = 0x80001c02L
+            bb.writeInt((int) 0x80001c02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTcpDstVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTcpDstVer13 other = (OFOxmTcpDstVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpSrcMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpSrcMaskedVer13.java
new file mode 100644
index 0000000..8352fcb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpSrcMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTcpSrcMaskedVer13 implements OFOxmTcpSrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTcpSrcMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmTcpSrcMaskedVer13 DEFAULT = new OFOxmTcpSrcMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTcpSrcMaskedVer13(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001b04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmTcpSrcVer13(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmTcpSrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTcpSrcMasked.Builder {
+        final OFOxmTcpSrcMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmTcpSrcMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001b04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTcpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmTcpSrcMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmTcpSrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTcpSrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001b04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTcpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmTcpSrcMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmTcpSrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTcpSrcMasked> {
+        @Override
+        public OFOxmTcpSrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001b04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001b04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001b04L(0x80001b04L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmTcpSrcMaskedVer13 oxmTcpSrcMaskedVer13 = new OFOxmTcpSrcMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTcpSrcMaskedVer13);
+            return oxmTcpSrcMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTcpSrcMaskedVer13Funnel FUNNEL = new OFOxmTcpSrcMaskedVer13Funnel();
+    static class OFOxmTcpSrcMaskedVer13Funnel implements Funnel<OFOxmTcpSrcMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTcpSrcMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001b04L
+            sink.putInt((int) 0x80001b04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTcpSrcMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTcpSrcMaskedVer13 message) {
+            // fixed value property typeLen = 0x80001b04L
+            bb.writeInt((int) 0x80001b04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTcpSrcMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTcpSrcMaskedVer13 other = (OFOxmTcpSrcMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpSrcVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpSrcVer13.java
new file mode 100644
index 0000000..7ad66bf
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTcpSrcVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTcpSrcVer13 implements OFOxmTcpSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTcpSrcVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmTcpSrcVer13 DEFAULT = new OFOxmTcpSrcVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTcpSrcVer13(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001a02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmTcpSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTcpSrc.Builder {
+        final OFOxmTcpSrcVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmTcpSrcVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001a02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmTcpSrc build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmTcpSrcVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTcpSrc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001a02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTcpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.TCP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmTcpSrc build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmTcpSrcVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTcpSrc> {
+        @Override
+        public OFOxmTcpSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001a02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001a02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001a02L(0x80001a02L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmTcpSrcVer13 oxmTcpSrcVer13 = new OFOxmTcpSrcVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTcpSrcVer13);
+            return oxmTcpSrcVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTcpSrcVer13Funnel FUNNEL = new OFOxmTcpSrcVer13Funnel();
+    static class OFOxmTcpSrcVer13Funnel implements Funnel<OFOxmTcpSrcVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTcpSrcVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001a02L
+            sink.putInt((int) 0x80001a02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTcpSrcVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTcpSrcVer13 message) {
+            // fixed value property typeLen = 0x80001a02L
+            bb.writeInt((int) 0x80001a02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTcpSrcVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTcpSrcVer13 other = (OFOxmTcpSrcVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTunnelIdMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTunnelIdMaskedVer13.java
new file mode 100644
index 0000000..ba550db
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTunnelIdMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTunnelIdMaskedVer13 implements OFOxmTunnelIdMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTunnelIdMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 20;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+        private final static U64 DEFAULT_VALUE_MASK = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+    private final U64 mask;
+//
+    // Immutable default instance
+    final static OFOxmTunnelIdMaskedVer13 DEFAULT = new OFOxmTunnelIdMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTunnelIdMaskedVer13(U64 value, U64 mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004d10L;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public U64 getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<U64> getMatchField() {
+        return MatchField.TUNNEL_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<U64> getCanonical() {
+        if (U64.NO_MASK.equals(mask)) {
+            return new OFOxmTunnelIdVer13(value);
+        } else if(U64.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmTunnelIdMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTunnelIdMasked.Builder {
+        final OFOxmTunnelIdMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+        private boolean maskSet;
+        private U64 mask;
+
+        BuilderWithParent(OFOxmTunnelIdMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004d10L;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTunnelIdMasked.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTunnelIdMasked.Builder setMask(U64 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U64> getMatchField() {
+        return MatchField.TUNNEL_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U64> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmTunnelIdMasked build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                U64 mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmTunnelIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTunnelIdMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+        private boolean maskSet;
+        private U64 mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004d10L;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTunnelIdMasked.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmTunnelIdMasked.Builder setMask(U64 mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U64> getMatchField() {
+        return MatchField.TUNNEL_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<U64> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmTunnelIdMasked build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            U64 mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmTunnelIdMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTunnelIdMasked> {
+        @Override
+        public OFOxmTunnelIdMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004d10L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004d10)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004d10L(0x80004d10L), got="+typeLen);
+            U64 value = U64.ofRaw(bb.readLong());
+            U64 mask = U64.ofRaw(bb.readLong());
+
+            OFOxmTunnelIdMaskedVer13 oxmTunnelIdMaskedVer13 = new OFOxmTunnelIdMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTunnelIdMaskedVer13);
+            return oxmTunnelIdMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTunnelIdMaskedVer13Funnel FUNNEL = new OFOxmTunnelIdMaskedVer13Funnel();
+    static class OFOxmTunnelIdMaskedVer13Funnel implements Funnel<OFOxmTunnelIdMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTunnelIdMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004d10L
+            sink.putInt((int) 0x80004d10);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTunnelIdMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTunnelIdMaskedVer13 message) {
+            // fixed value property typeLen = 0x80004d10L
+            bb.writeInt((int) 0x80004d10);
+            bb.writeLong(message.value.getValue());
+            bb.writeLong(message.mask.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTunnelIdMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTunnelIdMaskedVer13 other = (OFOxmTunnelIdMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTunnelIdVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTunnelIdVer13.java
new file mode 100644
index 0000000..1a7ef01
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmTunnelIdVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmTunnelIdVer13 implements OFOxmTunnelId {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmTunnelIdVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFOxmTunnelIdVer13 DEFAULT = new OFOxmTunnelIdVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmTunnelIdVer13(U64 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80004c08L;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<U64> getMatchField() {
+        return MatchField.TUNNEL_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<U64> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public U64 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmTunnelId.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmTunnelId.Builder {
+        final OFOxmTunnelIdVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFOxmTunnelIdVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004c08L;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTunnelId.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U64> getMatchField() {
+        return MatchField.TUNNEL_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U64> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U64 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmTunnelId build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmTunnelIdVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmTunnelId.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80004c08L;
+    }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmTunnelId.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<U64> getMatchField() {
+        return MatchField.TUNNEL_ID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<U64> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public U64 getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmTunnelId build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmTunnelIdVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmTunnelId> {
+        @Override
+        public OFOxmTunnelId readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80004c08L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80004c08)
+                throw new OFParseError("Wrong typeLen: Expected=0x80004c08L(0x80004c08L), got="+typeLen);
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFOxmTunnelIdVer13 oxmTunnelIdVer13 = new OFOxmTunnelIdVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmTunnelIdVer13);
+            return oxmTunnelIdVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmTunnelIdVer13Funnel FUNNEL = new OFOxmTunnelIdVer13Funnel();
+    static class OFOxmTunnelIdVer13Funnel implements Funnel<OFOxmTunnelIdVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmTunnelIdVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80004c08L
+            sink.putInt((int) 0x80004c08);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmTunnelIdVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmTunnelIdVer13 message) {
+            // fixed value property typeLen = 0x80004c08L
+            bb.writeInt((int) 0x80004c08);
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmTunnelIdVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmTunnelIdVer13 other = (OFOxmTunnelIdVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpDstMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpDstMaskedVer13.java
new file mode 100644
index 0000000..f1cb1ad
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpDstMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmUdpDstMaskedVer13 implements OFOxmUdpDstMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmUdpDstMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmUdpDstMaskedVer13 DEFAULT = new OFOxmUdpDstMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmUdpDstMaskedVer13(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002104L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmUdpDstVer13(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmUdpDstMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmUdpDstMasked.Builder {
+        final OFOxmUdpDstMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmUdpDstMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002104L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmUdpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmUdpDstMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmUdpDstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmUdpDstMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002104L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpDstMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmUdpDstMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmUdpDstMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmUdpDstMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmUdpDstMasked> {
+        @Override
+        public OFOxmUdpDstMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002104L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002104)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002104L(0x80002104L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmUdpDstMaskedVer13 oxmUdpDstMaskedVer13 = new OFOxmUdpDstMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmUdpDstMaskedVer13);
+            return oxmUdpDstMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmUdpDstMaskedVer13Funnel FUNNEL = new OFOxmUdpDstMaskedVer13Funnel();
+    static class OFOxmUdpDstMaskedVer13Funnel implements Funnel<OFOxmUdpDstMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmUdpDstMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002104L
+            sink.putInt((int) 0x80002104);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmUdpDstMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmUdpDstMaskedVer13 message) {
+            // fixed value property typeLen = 0x80002104L
+            bb.writeInt((int) 0x80002104);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmUdpDstMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmUdpDstMaskedVer13 other = (OFOxmUdpDstMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpDstVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpDstVer13.java
new file mode 100644
index 0000000..e1032ce
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpDstVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmUdpDstVer13 implements OFOxmUdpDst {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmUdpDstVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmUdpDstVer13 DEFAULT = new OFOxmUdpDstVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmUdpDstVer13(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80002002L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmUdpDst.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmUdpDst.Builder {
+        final OFOxmUdpDstVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmUdpDstVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002002L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmUdpDst build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmUdpDstVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmUdpDst.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80002002L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpDst.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_DST;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmUdpDst build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmUdpDstVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmUdpDst> {
+        @Override
+        public OFOxmUdpDst readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80002002L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80002002)
+                throw new OFParseError("Wrong typeLen: Expected=0x80002002L(0x80002002L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmUdpDstVer13 oxmUdpDstVer13 = new OFOxmUdpDstVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmUdpDstVer13);
+            return oxmUdpDstVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmUdpDstVer13Funnel FUNNEL = new OFOxmUdpDstVer13Funnel();
+    static class OFOxmUdpDstVer13Funnel implements Funnel<OFOxmUdpDstVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmUdpDstVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80002002L
+            sink.putInt((int) 0x80002002);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmUdpDstVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmUdpDstVer13 message) {
+            // fixed value property typeLen = 0x80002002L
+            bb.writeInt((int) 0x80002002);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmUdpDstVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmUdpDstVer13 other = (OFOxmUdpDstVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpSrcMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpSrcMaskedVer13.java
new file mode 100644
index 0000000..41e1757
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpSrcMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmUdpSrcMaskedVer13 implements OFOxmUdpSrcMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmUdpSrcMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+        private final static TransportPort DEFAULT_VALUE_MASK = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+    private final TransportPort mask;
+//
+    // Immutable default instance
+    final static OFOxmUdpSrcMaskedVer13 DEFAULT = new OFOxmUdpSrcMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmUdpSrcMaskedVer13(TransportPort value, TransportPort mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001f04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        if (TransportPort.NO_MASK.equals(mask)) {
+            return new OFOxmUdpSrcVer13(value);
+        } else if(TransportPort.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmUdpSrcMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmUdpSrcMasked.Builder {
+        final OFOxmUdpSrcMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+        BuilderWithParent(OFOxmUdpSrcMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001f04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmUdpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmUdpSrcMasked build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                TransportPort mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmUdpSrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmUdpSrcMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+        private boolean maskSet;
+        private TransportPort mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001f04L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpSrcMasked.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public TransportPort getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmUdpSrcMasked.Builder setMask(TransportPort mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmUdpSrcMasked build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            TransportPort mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmUdpSrcMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmUdpSrcMasked> {
+        @Override
+        public OFOxmUdpSrcMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001f04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001f04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001f04L(0x80001f04L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+            TransportPort mask = TransportPort.read2Bytes(bb);
+
+            OFOxmUdpSrcMaskedVer13 oxmUdpSrcMaskedVer13 = new OFOxmUdpSrcMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmUdpSrcMaskedVer13);
+            return oxmUdpSrcMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmUdpSrcMaskedVer13Funnel FUNNEL = new OFOxmUdpSrcMaskedVer13Funnel();
+    static class OFOxmUdpSrcMaskedVer13Funnel implements Funnel<OFOxmUdpSrcMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmUdpSrcMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001f04L
+            sink.putInt((int) 0x80001f04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmUdpSrcMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmUdpSrcMaskedVer13 message) {
+            // fixed value property typeLen = 0x80001f04L
+            bb.writeInt((int) 0x80001f04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmUdpSrcMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmUdpSrcMaskedVer13 other = (OFOxmUdpSrcMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpSrcVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpSrcVer13.java
new file mode 100644
index 0000000..98916b0
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmUdpSrcVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmUdpSrcVer13 implements OFOxmUdpSrc {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmUdpSrcVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static TransportPort DEFAULT_VALUE = TransportPort.NONE;
+
+    // OF message fields
+    private final TransportPort value;
+//
+    // Immutable default instance
+    final static OFOxmUdpSrcVer13 DEFAULT = new OFOxmUdpSrcVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmUdpSrcVer13(TransportPort value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80001e02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<TransportPort> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmUdpSrc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmUdpSrc.Builder {
+        final OFOxmUdpSrcVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+        BuilderWithParent(OFOxmUdpSrcVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001e02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmUdpSrc build() {
+                TransportPort value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmUdpSrcVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmUdpSrc.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private TransportPort value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80001e02L;
+    }
+
+    @Override
+    public TransportPort getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmUdpSrc.Builder setValue(TransportPort value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<TransportPort> getMatchField() {
+        return MatchField.UDP_SRC;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<TransportPort> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public TransportPort getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmUdpSrc build() {
+            TransportPort value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmUdpSrcVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmUdpSrc> {
+        @Override
+        public OFOxmUdpSrc readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80001e02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80001e02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80001e02L(0x80001e02L), got="+typeLen);
+            TransportPort value = TransportPort.read2Bytes(bb);
+
+            OFOxmUdpSrcVer13 oxmUdpSrcVer13 = new OFOxmUdpSrcVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmUdpSrcVer13);
+            return oxmUdpSrcVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmUdpSrcVer13Funnel FUNNEL = new OFOxmUdpSrcVer13Funnel();
+    static class OFOxmUdpSrcVer13Funnel implements Funnel<OFOxmUdpSrcVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmUdpSrcVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80001e02L
+            sink.putInt((int) 0x80001e02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmUdpSrcVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmUdpSrcVer13 message) {
+            // fixed value property typeLen = 0x80001e02L
+            bb.writeInt((int) 0x80001e02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmUdpSrcVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmUdpSrcVer13 other = (OFOxmUdpSrcVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVer13.java
new file mode 100644
index 0000000..c8b2e59
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVer13.java
@@ -0,0 +1,380 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFOxmVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFOxmVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFOxm<?>> {
+        @Override
+        public OFOxm<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            int typeLen = bb.readInt();
+            bb.readerIndex(start);
+            switch(typeLen) {
+               case (int) 0x80002a02:
+                   // discriminator value 0x80002a02L=0x80002a02L for class OFOxmArpOpVer13
+                   return OFOxmArpOpVer13.READER.readFrom(bb);
+               case (int) 0x80002b04:
+                   // discriminator value 0x80002b04L=0x80002b04L for class OFOxmArpOpMaskedVer13
+                   return OFOxmArpOpMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80003006:
+                   // discriminator value 0x80003006L=0x80003006L for class OFOxmArpShaVer13
+                   return OFOxmArpShaVer13.READER.readFrom(bb);
+               case (int) 0x8000310c:
+                   // discriminator value 0x8000310cL=0x8000310cL for class OFOxmArpShaMaskedVer13
+                   return OFOxmArpShaMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80002c04:
+                   // discriminator value 0x80002c04L=0x80002c04L for class OFOxmArpSpaVer13
+                   return OFOxmArpSpaVer13.READER.readFrom(bb);
+               case (int) 0x80002d08:
+                   // discriminator value 0x80002d08L=0x80002d08L for class OFOxmArpSpaMaskedVer13
+                   return OFOxmArpSpaMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80003206:
+                   // discriminator value 0x80003206L=0x80003206L for class OFOxmArpThaVer13
+                   return OFOxmArpThaVer13.READER.readFrom(bb);
+               case (int) 0x8000330c:
+                   // discriminator value 0x8000330cL=0x8000330cL for class OFOxmArpThaMaskedVer13
+                   return OFOxmArpThaMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80002e04:
+                   // discriminator value 0x80002e04L=0x80002e04L for class OFOxmArpTpaVer13
+                   return OFOxmArpTpaVer13.READER.readFrom(bb);
+               case (int) 0x80002f08:
+                   // discriminator value 0x80002f08L=0x80002f08L for class OFOxmArpTpaMaskedVer13
+                   return OFOxmArpTpaMaskedVer13.READER.readFrom(bb);
+               case 0x30e04:
+                   // discriminator value 0x30e04L=0x30e04L for class OFOxmBsnEgrPortGroupIdVer13
+                   return OFOxmBsnEgrPortGroupIdVer13.READER.readFrom(bb);
+               case 0x30f08:
+                   // discriminator value 0x30f08L=0x30f08L for class OFOxmBsnEgrPortGroupIdMaskedVer13
+                   return OFOxmBsnEgrPortGroupIdMaskedVer13.READER.readFrom(bb);
+               case 0x30601:
+                   // discriminator value 0x30601L=0x30601L for class OFOxmBsnGlobalVrfAllowedVer13
+                   return OFOxmBsnGlobalVrfAllowedVer13.READER.readFrom(bb);
+               case 0x30702:
+                   // discriminator value 0x30702L=0x30702L for class OFOxmBsnGlobalVrfAllowedMaskedVer13
+                   return OFOxmBsnGlobalVrfAllowedMaskedVer13.READER.readFrom(bb);
+               case 0x30010:
+                   // discriminator value 0x30010L=0x30010L for class OFOxmBsnInPorts128Ver13
+                   return OFOxmBsnInPorts128Ver13.READER.readFrom(bb);
+               case 0x30120:
+                   // discriminator value 0x30120L=0x30120L for class OFOxmBsnInPorts128MaskedVer13
+                   return OFOxmBsnInPorts128MaskedVer13.READER.readFrom(bb);
+               case 0x30c04:
+                   // discriminator value 0x30c04L=0x30c04L for class OFOxmBsnL3DstClassIdVer13
+                   return OFOxmBsnL3DstClassIdVer13.READER.readFrom(bb);
+               case 0x30d08:
+                   // discriminator value 0x30d08L=0x30d08L for class OFOxmBsnL3DstClassIdMaskedVer13
+                   return OFOxmBsnL3DstClassIdMaskedVer13.READER.readFrom(bb);
+               case 0x30804:
+                   // discriminator value 0x30804L=0x30804L for class OFOxmBsnL3InterfaceClassIdVer13
+                   return OFOxmBsnL3InterfaceClassIdVer13.READER.readFrom(bb);
+               case 0x30908:
+                   // discriminator value 0x30908L=0x30908L for class OFOxmBsnL3InterfaceClassIdMaskedVer13
+                   return OFOxmBsnL3InterfaceClassIdMaskedVer13.READER.readFrom(bb);
+               case 0x30a04:
+                   // discriminator value 0x30a04L=0x30a04L for class OFOxmBsnL3SrcClassIdVer13
+                   return OFOxmBsnL3SrcClassIdVer13.READER.readFrom(bb);
+               case 0x30b08:
+                   // discriminator value 0x30b08L=0x30b08L for class OFOxmBsnL3SrcClassIdMaskedVer13
+                   return OFOxmBsnL3SrcClassIdMaskedVer13.READER.readFrom(bb);
+               case 0x30204:
+                   // discriminator value 0x30204L=0x30204L for class OFOxmBsnLagIdVer13
+                   return OFOxmBsnLagIdVer13.READER.readFrom(bb);
+               case 0x30308:
+                   // discriminator value 0x30308L=0x30308L for class OFOxmBsnLagIdMaskedVer13
+                   return OFOxmBsnLagIdMaskedVer13.READER.readFrom(bb);
+               case 0x32002:
+                   // discriminator value 0x32002L=0x32002L for class OFOxmBsnTcpFlagsVer13
+                   return OFOxmBsnTcpFlagsVer13.READER.readFrom(bb);
+               case 0x32104:
+                   // discriminator value 0x32104L=0x32104L for class OFOxmBsnTcpFlagsMaskedVer13
+                   return OFOxmBsnTcpFlagsMaskedVer13.READER.readFrom(bb);
+               case 0x31004:
+                   // discriminator value 0x31004L=0x31004L for class OFOxmBsnUdf0Ver13
+                   return OFOxmBsnUdf0Ver13.READER.readFrom(bb);
+               case 0x31108:
+                   // discriminator value 0x31108L=0x31108L for class OFOxmBsnUdf0MaskedVer13
+                   return OFOxmBsnUdf0MaskedVer13.READER.readFrom(bb);
+               case 0x31204:
+                   // discriminator value 0x31204L=0x31204L for class OFOxmBsnUdf1Ver13
+                   return OFOxmBsnUdf1Ver13.READER.readFrom(bb);
+               case 0x31308:
+                   // discriminator value 0x31308L=0x31308L for class OFOxmBsnUdf1MaskedVer13
+                   return OFOxmBsnUdf1MaskedVer13.READER.readFrom(bb);
+               case 0x31404:
+                   // discriminator value 0x31404L=0x31404L for class OFOxmBsnUdf2Ver13
+                   return OFOxmBsnUdf2Ver13.READER.readFrom(bb);
+               case 0x31508:
+                   // discriminator value 0x31508L=0x31508L for class OFOxmBsnUdf2MaskedVer13
+                   return OFOxmBsnUdf2MaskedVer13.READER.readFrom(bb);
+               case 0x31604:
+                   // discriminator value 0x31604L=0x31604L for class OFOxmBsnUdf3Ver13
+                   return OFOxmBsnUdf3Ver13.READER.readFrom(bb);
+               case 0x31708:
+                   // discriminator value 0x31708L=0x31708L for class OFOxmBsnUdf3MaskedVer13
+                   return OFOxmBsnUdf3MaskedVer13.READER.readFrom(bb);
+               case 0x31804:
+                   // discriminator value 0x31804L=0x31804L for class OFOxmBsnUdf4Ver13
+                   return OFOxmBsnUdf4Ver13.READER.readFrom(bb);
+               case 0x31908:
+                   // discriminator value 0x31908L=0x31908L for class OFOxmBsnUdf4MaskedVer13
+                   return OFOxmBsnUdf4MaskedVer13.READER.readFrom(bb);
+               case 0x31a04:
+                   // discriminator value 0x31a04L=0x31a04L for class OFOxmBsnUdf5Ver13
+                   return OFOxmBsnUdf5Ver13.READER.readFrom(bb);
+               case 0x31b08:
+                   // discriminator value 0x31b08L=0x31b08L for class OFOxmBsnUdf5MaskedVer13
+                   return OFOxmBsnUdf5MaskedVer13.READER.readFrom(bb);
+               case 0x31c04:
+                   // discriminator value 0x31c04L=0x31c04L for class OFOxmBsnUdf6Ver13
+                   return OFOxmBsnUdf6Ver13.READER.readFrom(bb);
+               case 0x31d08:
+                   // discriminator value 0x31d08L=0x31d08L for class OFOxmBsnUdf6MaskedVer13
+                   return OFOxmBsnUdf6MaskedVer13.READER.readFrom(bb);
+               case 0x31e04:
+                   // discriminator value 0x31e04L=0x31e04L for class OFOxmBsnUdf7Ver13
+                   return OFOxmBsnUdf7Ver13.READER.readFrom(bb);
+               case 0x31f08:
+                   // discriminator value 0x31f08L=0x31f08L for class OFOxmBsnUdf7MaskedVer13
+                   return OFOxmBsnUdf7MaskedVer13.READER.readFrom(bb);
+               case 0x32204:
+                   // discriminator value 0x32204L=0x32204L for class OFOxmBsnVlanXlatePortGroupIdVer13
+                   return OFOxmBsnVlanXlatePortGroupIdVer13.READER.readFrom(bb);
+               case 0x32308:
+                   // discriminator value 0x32308L=0x32308L for class OFOxmBsnVlanXlatePortGroupIdMaskedVer13
+                   return OFOxmBsnVlanXlatePortGroupIdMaskedVer13.READER.readFrom(bb);
+               case 0x30404:
+                   // discriminator value 0x30404L=0x30404L for class OFOxmBsnVrfVer13
+                   return OFOxmBsnVrfVer13.READER.readFrom(bb);
+               case 0x30508:
+                   // discriminator value 0x30508L=0x30508L for class OFOxmBsnVrfMaskedVer13
+                   return OFOxmBsnVrfMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80000606:
+                   // discriminator value 0x80000606L=0x80000606L for class OFOxmEthDstVer13
+                   return OFOxmEthDstVer13.READER.readFrom(bb);
+               case (int) 0x8000070c:
+                   // discriminator value 0x8000070cL=0x8000070cL for class OFOxmEthDstMaskedVer13
+                   return OFOxmEthDstMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80000806:
+                   // discriminator value 0x80000806L=0x80000806L for class OFOxmEthSrcVer13
+                   return OFOxmEthSrcVer13.READER.readFrom(bb);
+               case (int) 0x8000090c:
+                   // discriminator value 0x8000090cL=0x8000090cL for class OFOxmEthSrcMaskedVer13
+                   return OFOxmEthSrcMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80000a02:
+                   // discriminator value 0x80000a02L=0x80000a02L for class OFOxmEthTypeVer13
+                   return OFOxmEthTypeVer13.READER.readFrom(bb);
+               case (int) 0x80000b04:
+                   // discriminator value 0x80000b04L=0x80000b04L for class OFOxmEthTypeMaskedVer13
+                   return OFOxmEthTypeMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80002801:
+                   // discriminator value 0x80002801L=0x80002801L for class OFOxmIcmpv4CodeVer13
+                   return OFOxmIcmpv4CodeVer13.READER.readFrom(bb);
+               case (int) 0x80002902:
+                   // discriminator value 0x80002902L=0x80002902L for class OFOxmIcmpv4CodeMaskedVer13
+                   return OFOxmIcmpv4CodeMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80002601:
+                   // discriminator value 0x80002601L=0x80002601L for class OFOxmIcmpv4TypeVer13
+                   return OFOxmIcmpv4TypeVer13.READER.readFrom(bb);
+               case (int) 0x80002702:
+                   // discriminator value 0x80002702L=0x80002702L for class OFOxmIcmpv4TypeMaskedVer13
+                   return OFOxmIcmpv4TypeMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80003c01:
+                   // discriminator value 0x80003c01L=0x80003c01L for class OFOxmIcmpv6CodeVer13
+                   return OFOxmIcmpv6CodeVer13.READER.readFrom(bb);
+               case (int) 0x80003d02:
+                   // discriminator value 0x80003d02L=0x80003d02L for class OFOxmIcmpv6CodeMaskedVer13
+                   return OFOxmIcmpv6CodeMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80003a01:
+                   // discriminator value 0x80003a01L=0x80003a01L for class OFOxmIcmpv6TypeVer13
+                   return OFOxmIcmpv6TypeVer13.READER.readFrom(bb);
+               case (int) 0x80003b02:
+                   // discriminator value 0x80003b02L=0x80003b02L for class OFOxmIcmpv6TypeMaskedVer13
+                   return OFOxmIcmpv6TypeMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80000204:
+                   // discriminator value 0x80000204L=0x80000204L for class OFOxmInPhyPortVer13
+                   return OFOxmInPhyPortVer13.READER.readFrom(bb);
+               case (int) 0x80000308:
+                   // discriminator value 0x80000308L=0x80000308L for class OFOxmInPhyPortMaskedVer13
+                   return OFOxmInPhyPortMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80000004:
+                   // discriminator value 0x80000004L=0x80000004L for class OFOxmInPortVer13
+                   return OFOxmInPortVer13.READER.readFrom(bb);
+               case (int) 0x80000108:
+                   // discriminator value 0x80000108L=0x80000108L for class OFOxmInPortMaskedVer13
+                   return OFOxmInPortMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80001001:
+                   // discriminator value 0x80001001L=0x80001001L for class OFOxmIpDscpVer13
+                   return OFOxmIpDscpVer13.READER.readFrom(bb);
+               case (int) 0x80001102:
+                   // discriminator value 0x80001102L=0x80001102L for class OFOxmIpDscpMaskedVer13
+                   return OFOxmIpDscpMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80001201:
+                   // discriminator value 0x80001201L=0x80001201L for class OFOxmIpEcnVer13
+                   return OFOxmIpEcnVer13.READER.readFrom(bb);
+               case (int) 0x80001302:
+                   // discriminator value 0x80001302L=0x80001302L for class OFOxmIpEcnMaskedVer13
+                   return OFOxmIpEcnMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80001401:
+                   // discriminator value 0x80001401L=0x80001401L for class OFOxmIpProtoVer13
+                   return OFOxmIpProtoVer13.READER.readFrom(bb);
+               case (int) 0x80001502:
+                   // discriminator value 0x80001502L=0x80001502L for class OFOxmIpProtoMaskedVer13
+                   return OFOxmIpProtoMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80001804:
+                   // discriminator value 0x80001804L=0x80001804L for class OFOxmIpv4DstVer13
+                   return OFOxmIpv4DstVer13.READER.readFrom(bb);
+               case (int) 0x80001908:
+                   // discriminator value 0x80001908L=0x80001908L for class OFOxmIpv4DstMaskedVer13
+                   return OFOxmIpv4DstMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80001604:
+                   // discriminator value 0x80001604L=0x80001604L for class OFOxmIpv4SrcVer13
+                   return OFOxmIpv4SrcVer13.READER.readFrom(bb);
+               case (int) 0x80001708:
+                   // discriminator value 0x80001708L=0x80001708L for class OFOxmIpv4SrcMaskedVer13
+                   return OFOxmIpv4SrcMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80003610:
+                   // discriminator value 0x80003610L=0x80003610L for class OFOxmIpv6DstVer13
+                   return OFOxmIpv6DstVer13.READER.readFrom(bb);
+               case (int) 0x80003720:
+                   // discriminator value 0x80003720L=0x80003720L for class OFOxmIpv6DstMaskedVer13
+                   return OFOxmIpv6DstMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80003804:
+                   // discriminator value 0x80003804L=0x80003804L for class OFOxmIpv6FlabelVer13
+                   return OFOxmIpv6FlabelVer13.READER.readFrom(bb);
+               case (int) 0x80003908:
+                   // discriminator value 0x80003908L=0x80003908L for class OFOxmIpv6FlabelMaskedVer13
+                   return OFOxmIpv6FlabelMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80004006:
+                   // discriminator value 0x80004006L=0x80004006L for class OFOxmIpv6NdSllVer13
+                   return OFOxmIpv6NdSllVer13.READER.readFrom(bb);
+               case (int) 0x8000410c:
+                   // discriminator value 0x8000410cL=0x8000410cL for class OFOxmIpv6NdSllMaskedVer13
+                   return OFOxmIpv6NdSllMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80003e10:
+                   // discriminator value 0x80003e10L=0x80003e10L for class OFOxmIpv6NdTargetVer13
+                   return OFOxmIpv6NdTargetVer13.READER.readFrom(bb);
+               case (int) 0x80003f20:
+                   // discriminator value 0x80003f20L=0x80003f20L for class OFOxmIpv6NdTargetMaskedVer13
+                   return OFOxmIpv6NdTargetMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80004206:
+                   // discriminator value 0x80004206L=0x80004206L for class OFOxmIpv6NdTllVer13
+                   return OFOxmIpv6NdTllVer13.READER.readFrom(bb);
+               case (int) 0x8000430c:
+                   // discriminator value 0x8000430cL=0x8000430cL for class OFOxmIpv6NdTllMaskedVer13
+                   return OFOxmIpv6NdTllMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80003410:
+                   // discriminator value 0x80003410L=0x80003410L for class OFOxmIpv6SrcVer13
+                   return OFOxmIpv6SrcVer13.READER.readFrom(bb);
+               case (int) 0x80003520:
+                   // discriminator value 0x80003520L=0x80003520L for class OFOxmIpv6SrcMaskedVer13
+                   return OFOxmIpv6SrcMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80000408:
+                   // discriminator value 0x80000408L=0x80000408L for class OFOxmMetadataVer13
+                   return OFOxmMetadataVer13.READER.readFrom(bb);
+               case (int) 0x80000510:
+                   // discriminator value 0x80000510L=0x80000510L for class OFOxmMetadataMaskedVer13
+                   return OFOxmMetadataMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80004404:
+                   // discriminator value 0x80004404L=0x80004404L for class OFOxmMplsLabelVer13
+                   return OFOxmMplsLabelVer13.READER.readFrom(bb);
+               case (int) 0x80004508:
+                   // discriminator value 0x80004508L=0x80004508L for class OFOxmMplsLabelMaskedVer13
+                   return OFOxmMplsLabelMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80004601:
+                   // discriminator value 0x80004601L=0x80004601L for class OFOxmMplsTcVer13
+                   return OFOxmMplsTcVer13.READER.readFrom(bb);
+               case (int) 0x80004702:
+                   // discriminator value 0x80004702L=0x80004702L for class OFOxmMplsTcMaskedVer13
+                   return OFOxmMplsTcMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80002402:
+                   // discriminator value 0x80002402L=0x80002402L for class OFOxmSctpDstVer13
+                   return OFOxmSctpDstVer13.READER.readFrom(bb);
+               case (int) 0x80002504:
+                   // discriminator value 0x80002504L=0x80002504L for class OFOxmSctpDstMaskedVer13
+                   return OFOxmSctpDstMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80002202:
+                   // discriminator value 0x80002202L=0x80002202L for class OFOxmSctpSrcVer13
+                   return OFOxmSctpSrcVer13.READER.readFrom(bb);
+               case (int) 0x80002304:
+                   // discriminator value 0x80002304L=0x80002304L for class OFOxmSctpSrcMaskedVer13
+                   return OFOxmSctpSrcMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80001c02:
+                   // discriminator value 0x80001c02L=0x80001c02L for class OFOxmTcpDstVer13
+                   return OFOxmTcpDstVer13.READER.readFrom(bb);
+               case (int) 0x80001d04:
+                   // discriminator value 0x80001d04L=0x80001d04L for class OFOxmTcpDstMaskedVer13
+                   return OFOxmTcpDstMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80001a02:
+                   // discriminator value 0x80001a02L=0x80001a02L for class OFOxmTcpSrcVer13
+                   return OFOxmTcpSrcVer13.READER.readFrom(bb);
+               case (int) 0x80001b04:
+                   // discriminator value 0x80001b04L=0x80001b04L for class OFOxmTcpSrcMaskedVer13
+                   return OFOxmTcpSrcMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80002002:
+                   // discriminator value 0x80002002L=0x80002002L for class OFOxmUdpDstVer13
+                   return OFOxmUdpDstVer13.READER.readFrom(bb);
+               case (int) 0x80002104:
+                   // discriminator value 0x80002104L=0x80002104L for class OFOxmUdpDstMaskedVer13
+                   return OFOxmUdpDstMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80001e02:
+                   // discriminator value 0x80001e02L=0x80001e02L for class OFOxmUdpSrcVer13
+                   return OFOxmUdpSrcVer13.READER.readFrom(bb);
+               case (int) 0x80001f04:
+                   // discriminator value 0x80001f04L=0x80001f04L for class OFOxmUdpSrcMaskedVer13
+                   return OFOxmUdpSrcMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80000e01:
+                   // discriminator value 0x80000e01L=0x80000e01L for class OFOxmVlanPcpVer13
+                   return OFOxmVlanPcpVer13.READER.readFrom(bb);
+               case (int) 0x80000f02:
+                   // discriminator value 0x80000f02L=0x80000f02L for class OFOxmVlanPcpMaskedVer13
+                   return OFOxmVlanPcpMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80000c02:
+                   // discriminator value 0x80000c02L=0x80000c02L for class OFOxmVlanVidVer13
+                   return OFOxmVlanVidVer13.READER.readFrom(bb);
+               case (int) 0x80000d04:
+                   // discriminator value 0x80000d04L=0x80000d04L for class OFOxmVlanVidMaskedVer13
+                   return OFOxmVlanVidMaskedVer13.READER.readFrom(bb);
+               case (int) 0x80004c08:
+                   // discriminator value 0x80004c08L=0x80004c08L for class OFOxmTunnelIdVer13
+                   return OFOxmTunnelIdVer13.READER.readFrom(bb);
+               case (int) 0x80004d10:
+                   // discriminator value 0x80004d10L=0x80004d10L for class OFOxmTunnelIdMaskedVer13
+                   return OFOxmTunnelIdMaskedVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator typeLen of class OFOxmVer13: " + typeLen);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanPcpMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanPcpMaskedVer13.java
new file mode 100644
index 0000000..f5e54a4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanPcpMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmVlanPcpMaskedVer13 implements OFOxmVlanPcpMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmVlanPcpMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static VlanPcp DEFAULT_VALUE = VlanPcp.NONE;
+        private final static VlanPcp DEFAULT_VALUE_MASK = VlanPcp.NONE;
+
+    // OF message fields
+    private final VlanPcp value;
+    private final VlanPcp mask;
+//
+    // Immutable default instance
+    final static OFOxmVlanPcpMaskedVer13 DEFAULT = new OFOxmVlanPcpMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmVlanPcpMaskedVer13(VlanPcp value, VlanPcp mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000f02L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public VlanPcp getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<VlanPcp> getCanonical() {
+        if (VlanPcp.NO_MASK.equals(mask)) {
+            return new OFOxmVlanPcpVer13(value);
+        } else if(VlanPcp.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmVlanPcpMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmVlanPcpMasked.Builder {
+        final OFOxmVlanPcpMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VlanPcp value;
+        private boolean maskSet;
+        private VlanPcp mask;
+
+        BuilderWithParent(OFOxmVlanPcpMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000f02L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanPcpMasked.Builder setValue(VlanPcp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public VlanPcp getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmVlanPcpMasked.Builder setMask(VlanPcp mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<VlanPcp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmVlanPcpMasked build() {
+                VlanPcp value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                VlanPcp mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmVlanPcpMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmVlanPcpMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VlanPcp value;
+        private boolean maskSet;
+        private VlanPcp mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000f02L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanPcpMasked.Builder setValue(VlanPcp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public VlanPcp getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmVlanPcpMasked.Builder setMask(VlanPcp mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<VlanPcp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmVlanPcpMasked build() {
+            VlanPcp value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            VlanPcp mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmVlanPcpMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmVlanPcpMasked> {
+        @Override
+        public OFOxmVlanPcpMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000f02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000f02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000f02L(0x80000f02L), got="+typeLen);
+            VlanPcp value = VlanPcp.readByte(bb);
+            VlanPcp mask = VlanPcp.readByte(bb);
+
+            OFOxmVlanPcpMaskedVer13 oxmVlanPcpMaskedVer13 = new OFOxmVlanPcpMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmVlanPcpMaskedVer13);
+            return oxmVlanPcpMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmVlanPcpMaskedVer13Funnel FUNNEL = new OFOxmVlanPcpMaskedVer13Funnel();
+    static class OFOxmVlanPcpMaskedVer13Funnel implements Funnel<OFOxmVlanPcpMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmVlanPcpMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000f02L
+            sink.putInt((int) 0x80000f02);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmVlanPcpMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmVlanPcpMaskedVer13 message) {
+            // fixed value property typeLen = 0x80000f02L
+            bb.writeInt((int) 0x80000f02);
+            message.value.writeByte(bb);
+            message.mask.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmVlanPcpMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmVlanPcpMaskedVer13 other = (OFOxmVlanPcpMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanPcpVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanPcpVer13.java
new file mode 100644
index 0000000..21dcc14
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanPcpVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmVlanPcpVer13 implements OFOxmVlanPcp {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmVlanPcpVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 5;
+
+        private final static VlanPcp DEFAULT_VALUE = VlanPcp.NONE;
+
+    // OF message fields
+    private final VlanPcp value;
+//
+    // Immutable default instance
+    final static OFOxmVlanPcpVer13 DEFAULT = new OFOxmVlanPcpVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmVlanPcpVer13(VlanPcp value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000e01L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<VlanPcp> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public VlanPcp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmVlanPcp.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmVlanPcp.Builder {
+        final OFOxmVlanPcpVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private VlanPcp value;
+
+        BuilderWithParent(OFOxmVlanPcpVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000e01L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanPcp.Builder setValue(VlanPcp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<VlanPcp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public VlanPcp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmVlanPcp build() {
+                VlanPcp value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmVlanPcpVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmVlanPcp.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private VlanPcp value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000e01L;
+    }
+
+    @Override
+    public VlanPcp getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanPcp.Builder setValue(VlanPcp value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<VlanPcp> getMatchField() {
+        return MatchField.VLAN_PCP;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<VlanPcp> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public VlanPcp getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmVlanPcp build() {
+            VlanPcp value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmVlanPcpVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmVlanPcp> {
+        @Override
+        public OFOxmVlanPcp readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000e01L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000e01)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000e01L(0x80000e01L), got="+typeLen);
+            VlanPcp value = VlanPcp.readByte(bb);
+
+            OFOxmVlanPcpVer13 oxmVlanPcpVer13 = new OFOxmVlanPcpVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmVlanPcpVer13);
+            return oxmVlanPcpVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmVlanPcpVer13Funnel FUNNEL = new OFOxmVlanPcpVer13Funnel();
+    static class OFOxmVlanPcpVer13Funnel implements Funnel<OFOxmVlanPcpVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmVlanPcpVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000e01L
+            sink.putInt((int) 0x80000e01);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmVlanPcpVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmVlanPcpVer13 message) {
+            // fixed value property typeLen = 0x80000e01L
+            bb.writeInt((int) 0x80000e01);
+            message.value.writeByte(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmVlanPcpVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmVlanPcpVer13 other = (OFOxmVlanPcpVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanVidMaskedVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanVidMaskedVer13.java
new file mode 100644
index 0000000..58ebd21
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanVidMaskedVer13.java
@@ -0,0 +1,356 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmVlanVidMaskedVer13 implements OFOxmVlanVidMasked {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmVlanVidMaskedVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static OFVlanVidMatch DEFAULT_VALUE = OFVlanVidMatch.NONE;
+        private final static OFVlanVidMatch DEFAULT_VALUE_MASK = OFVlanVidMatch.NONE;
+
+    // OF message fields
+    private final OFVlanVidMatch value;
+    private final OFVlanVidMatch mask;
+//
+    // Immutable default instance
+    final static OFOxmVlanVidMaskedVer13 DEFAULT = new OFOxmVlanVidMaskedVer13(
+        DEFAULT_VALUE, DEFAULT_VALUE_MASK
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmVlanVidMaskedVer13(OFVlanVidMatch value, OFVlanVidMatch mask) {
+        this.value = value;
+        this.mask = mask;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000d04L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVlanVidMatch getMask() {
+        return mask;
+    }
+
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    public OFOxm<OFVlanVidMatch> getCanonical() {
+        if (OFVlanVidMatch.NO_MASK.equals(mask)) {
+            return new OFOxmVlanVidVer13(value);
+        } else if(OFVlanVidMatch.FULL_MASK.equals(mask)) {
+            return null;
+        } else {
+            return this;
+        }
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmVlanVidMasked.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmVlanVidMasked.Builder {
+        final OFOxmVlanVidMaskedVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFVlanVidMatch value;
+        private boolean maskSet;
+        private OFVlanVidMatch mask;
+
+        BuilderWithParent(OFOxmVlanVidMaskedVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000d04L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanVidMasked.Builder setValue(OFVlanVidMatch value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVlanVidMatch getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmVlanVidMasked.Builder setMask(OFVlanVidMatch mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFVlanVidMatch> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmVlanVidMasked build() {
+                OFVlanVidMatch value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+                OFVlanVidMatch mask = this.maskSet ? this.mask : parentMessage.mask;
+                if(mask == null)
+                    throw new NullPointerException("Property mask must not be null");
+
+                //
+                return new OFOxmVlanVidMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmVlanVidMasked.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFVlanVidMatch value;
+        private boolean maskSet;
+        private OFVlanVidMatch mask;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000d04L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanVidMasked.Builder setValue(OFVlanVidMatch value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVlanVidMatch getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFOxmVlanVidMasked.Builder setMask(OFVlanVidMatch mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return true;
+    }
+
+    @Override
+    public OFOxm<OFVlanVidMatch> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmVlanVidMasked build() {
+            OFVlanVidMatch value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+            OFVlanVidMatch mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK;
+            if(mask == null)
+                throw new NullPointerException("Property mask must not be null");
+
+
+            return new OFOxmVlanVidMaskedVer13(
+                    value,
+                    mask
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmVlanVidMasked> {
+        @Override
+        public OFOxmVlanVidMasked readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000d04L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000d04)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000d04L(0x80000d04L), got="+typeLen);
+            OFVlanVidMatch value = OFVlanVidMatch.read2Bytes(bb);
+            OFVlanVidMatch mask = OFVlanVidMatch.read2Bytes(bb);
+
+            OFOxmVlanVidMaskedVer13 oxmVlanVidMaskedVer13 = new OFOxmVlanVidMaskedVer13(
+                    value,
+                      mask
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmVlanVidMaskedVer13);
+            return oxmVlanVidMaskedVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmVlanVidMaskedVer13Funnel FUNNEL = new OFOxmVlanVidMaskedVer13Funnel();
+    static class OFOxmVlanVidMaskedVer13Funnel implements Funnel<OFOxmVlanVidMaskedVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmVlanVidMaskedVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000d04L
+            sink.putInt((int) 0x80000d04);
+            message.value.putTo(sink);
+            message.mask.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmVlanVidMaskedVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmVlanVidMaskedVer13 message) {
+            // fixed value property typeLen = 0x80000d04L
+            bb.writeInt((int) 0x80000d04);
+            message.value.write2Bytes(bb);
+            message.mask.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmVlanVidMaskedVer13(");
+        b.append("value=").append(value);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmVlanVidMaskedVer13 other = (OFOxmVlanVidMaskedVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        if (mask == null) {
+            if (other.mask != null)
+                return false;
+        } else if (!mask.equals(other.mask))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanVidVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanVidVer13.java
new file mode 100644
index 0000000..9d82363
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmVlanVidVer13.java
@@ -0,0 +1,312 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFOxmVlanVidVer13 implements OFOxmVlanVid {
+    private static final Logger logger = LoggerFactory.getLogger(OFOxmVlanVidVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 6;
+
+        private final static OFVlanVidMatch DEFAULT_VALUE = OFVlanVidMatch.NONE;
+
+    // OF message fields
+    private final OFVlanVidMatch value;
+//
+    // Immutable default instance
+    final static OFOxmVlanVidVer13 DEFAULT = new OFOxmVlanVidVer13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFOxmVlanVidVer13(OFVlanVidMatch value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getTypeLen() {
+        return 0x80000c02L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    public OFOxm<OFVlanVidMatch> getCanonical() {
+        // exact match OXM is always canonical
+        return this;
+    }
+
+    @Override
+    public OFVlanVidMatch getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFOxmVlanVid.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFOxmVlanVid.Builder {
+        final OFOxmVlanVidVer13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private OFVlanVidMatch value;
+
+        BuilderWithParent(OFOxmVlanVidVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000c02L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanVid.Builder setValue(OFVlanVidMatch value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFVlanVidMatch> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVlanVidMatch getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFOxmVlanVid build() {
+                OFVlanVidMatch value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFOxmVlanVidVer13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFOxmVlanVid.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private OFVlanVidMatch value;
+
+    @Override
+    public long getTypeLen() {
+        return 0x80000c02L;
+    }
+
+    @Override
+    public OFVlanVidMatch getValue() {
+        return value;
+    }
+
+    @Override
+    public OFOxmVlanVid.Builder setValue(OFVlanVidMatch value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public MatchField<OFVlanVidMatch> getMatchField() {
+        return MatchField.VLAN_VID;
+    }
+
+    @Override
+    public boolean isMasked() {
+        return false;
+    }
+
+    @Override
+    public OFOxm<OFVlanVidMatch> getCanonical()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property canonical not supported in version 1.3");
+    }
+
+    @Override
+    public OFVlanVidMatch getMask()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property mask not supported in version 1.3");
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFOxmVlanVid build() {
+            OFVlanVidMatch value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFOxmVlanVidVer13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFOxmVlanVid> {
+        @Override
+        public OFOxmVlanVid readFrom(ChannelBuffer bb) throws OFParseError {
+            // fixed value property typeLen == 0x80000c02L
+            int typeLen = bb.readInt();
+            if(typeLen != (int) 0x80000c02)
+                throw new OFParseError("Wrong typeLen: Expected=0x80000c02L(0x80000c02L), got="+typeLen);
+            OFVlanVidMatch value = OFVlanVidMatch.read2Bytes(bb);
+
+            OFOxmVlanVidVer13 oxmVlanVidVer13 = new OFOxmVlanVidVer13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", oxmVlanVidVer13);
+            return oxmVlanVidVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFOxmVlanVidVer13Funnel FUNNEL = new OFOxmVlanVidVer13Funnel();
+    static class OFOxmVlanVidVer13Funnel implements Funnel<OFOxmVlanVidVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFOxmVlanVidVer13 message, PrimitiveSink sink) {
+            // fixed value property typeLen = 0x80000c02L
+            sink.putInt((int) 0x80000c02);
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFOxmVlanVidVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFOxmVlanVidVer13 message) {
+            // fixed value property typeLen = 0x80000c02L
+            bb.writeInt((int) 0x80000c02);
+            message.value.write2Bytes(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFOxmVlanVidVer13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFOxmVlanVidVer13 other = (OFOxmVlanVidVer13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmsVer13.java
new file mode 100644
index 0000000..1f2f7b7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmsVer13.java
@@ -0,0 +1,1440 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFOxmsVer13 implements OFOxms {
+    public final static OFOxmsVer13 INSTANCE = new OFOxmsVer13();
+
+
+
+
+    public OFOxmArpOp.Builder buildArpOp() {
+        return new OFOxmArpOpVer13.Builder();
+    }
+    public OFOxmArpOp arpOp(ArpOpcode value) {
+        return new OFOxmArpOpVer13(
+                value
+                    );
+    }
+
+    public OFOxmArpOpMasked.Builder buildArpOpMasked() {
+        return new OFOxmArpOpMaskedVer13.Builder();
+    }
+    public OFOxmArpOpMasked arpOpMasked(ArpOpcode value, ArpOpcode mask) {
+        return new OFOxmArpOpMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmArpSha.Builder buildArpSha() {
+        return new OFOxmArpShaVer13.Builder();
+    }
+    public OFOxmArpSha arpSha(MacAddress value) {
+        return new OFOxmArpShaVer13(
+                value
+                    );
+    }
+
+    public OFOxmArpShaMasked.Builder buildArpShaMasked() {
+        return new OFOxmArpShaMaskedVer13.Builder();
+    }
+    public OFOxmArpShaMasked arpShaMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmArpShaMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmArpSpa.Builder buildArpSpa() {
+        return new OFOxmArpSpaVer13.Builder();
+    }
+    public OFOxmArpSpa arpSpa(IPv4Address value) {
+        return new OFOxmArpSpaVer13(
+                value
+                    );
+    }
+
+    public OFOxmArpSpaMasked.Builder buildArpSpaMasked() {
+        return new OFOxmArpSpaMaskedVer13.Builder();
+    }
+    public OFOxmArpSpaMasked arpSpaMasked(IPv4Address value, IPv4Address mask) {
+        return new OFOxmArpSpaMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmArpTha.Builder buildArpTha() {
+        return new OFOxmArpThaVer13.Builder();
+    }
+    public OFOxmArpTha arpTha(MacAddress value) {
+        return new OFOxmArpThaVer13(
+                value
+                    );
+    }
+
+    public OFOxmArpThaMasked.Builder buildArpThaMasked() {
+        return new OFOxmArpThaMaskedVer13.Builder();
+    }
+    public OFOxmArpThaMasked arpThaMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmArpThaMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmArpTpa.Builder buildArpTpa() {
+        return new OFOxmArpTpaVer13.Builder();
+    }
+    public OFOxmArpTpa arpTpa(IPv4Address value) {
+        return new OFOxmArpTpaVer13(
+                value
+                    );
+    }
+
+    public OFOxmArpTpaMasked.Builder buildArpTpaMasked() {
+        return new OFOxmArpTpaMaskedVer13.Builder();
+    }
+    public OFOxmArpTpaMasked arpTpaMasked(IPv4Address value, IPv4Address mask) {
+        return new OFOxmArpTpaMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnEgrPortGroupId.Builder buildBsnEgrPortGroupId() {
+        return new OFOxmBsnEgrPortGroupIdVer13.Builder();
+    }
+    public OFOxmBsnEgrPortGroupId bsnEgrPortGroupId(ClassId value) {
+        return new OFOxmBsnEgrPortGroupIdVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnEgrPortGroupIdMasked.Builder buildBsnEgrPortGroupIdMasked() {
+        return new OFOxmBsnEgrPortGroupIdMaskedVer13.Builder();
+    }
+    public OFOxmBsnEgrPortGroupIdMasked bsnEgrPortGroupIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnEgrPortGroupIdMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnGlobalVrfAllowed.Builder buildBsnGlobalVrfAllowed() {
+        return new OFOxmBsnGlobalVrfAllowedVer13.Builder();
+    }
+    public OFOxmBsnGlobalVrfAllowed bsnGlobalVrfAllowed(OFBooleanValue value) {
+        return new OFOxmBsnGlobalVrfAllowedVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnGlobalVrfAllowedMasked.Builder buildBsnGlobalVrfAllowedMasked() {
+        return new OFOxmBsnGlobalVrfAllowedMaskedVer13.Builder();
+    }
+    public OFOxmBsnGlobalVrfAllowedMasked bsnGlobalVrfAllowedMasked(OFBooleanValue value, OFBooleanValue mask) {
+        return new OFOxmBsnGlobalVrfAllowedMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnInPorts128.Builder buildBsnInPorts128() {
+        return new OFOxmBsnInPorts128Ver13.Builder();
+    }
+    public OFOxmBsnInPorts128 bsnInPorts128(OFBitMask128 value) {
+        return new OFOxmBsnInPorts128Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnInPorts128Masked.Builder buildBsnInPorts128Masked() {
+        return new OFOxmBsnInPorts128MaskedVer13.Builder();
+    }
+    public OFOxmBsnInPorts128Masked bsnInPorts128Masked(OFBitMask128 value, OFBitMask128 mask) {
+        return new OFOxmBsnInPorts128MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnL3DstClassId.Builder buildBsnL3DstClassId() {
+        return new OFOxmBsnL3DstClassIdVer13.Builder();
+    }
+    public OFOxmBsnL3DstClassId bsnL3DstClassId(ClassId value) {
+        return new OFOxmBsnL3DstClassIdVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnL3DstClassIdMasked.Builder buildBsnL3DstClassIdMasked() {
+        return new OFOxmBsnL3DstClassIdMaskedVer13.Builder();
+    }
+    public OFOxmBsnL3DstClassIdMasked bsnL3DstClassIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnL3DstClassIdMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnL3InterfaceClassId.Builder buildBsnL3InterfaceClassId() {
+        return new OFOxmBsnL3InterfaceClassIdVer13.Builder();
+    }
+    public OFOxmBsnL3InterfaceClassId bsnL3InterfaceClassId(ClassId value) {
+        return new OFOxmBsnL3InterfaceClassIdVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnL3InterfaceClassIdMasked.Builder buildBsnL3InterfaceClassIdMasked() {
+        return new OFOxmBsnL3InterfaceClassIdMaskedVer13.Builder();
+    }
+    public OFOxmBsnL3InterfaceClassIdMasked bsnL3InterfaceClassIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnL3InterfaceClassIdMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnL3SrcClassId.Builder buildBsnL3SrcClassId() {
+        return new OFOxmBsnL3SrcClassIdVer13.Builder();
+    }
+    public OFOxmBsnL3SrcClassId bsnL3SrcClassId(ClassId value) {
+        return new OFOxmBsnL3SrcClassIdVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnL3SrcClassIdMasked.Builder buildBsnL3SrcClassIdMasked() {
+        return new OFOxmBsnL3SrcClassIdMaskedVer13.Builder();
+    }
+    public OFOxmBsnL3SrcClassIdMasked bsnL3SrcClassIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnL3SrcClassIdMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnLagId.Builder buildBsnLagId() {
+        return new OFOxmBsnLagIdVer13.Builder();
+    }
+    public OFOxmBsnLagId bsnLagId(LagId value) {
+        return new OFOxmBsnLagIdVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnLagIdMasked.Builder buildBsnLagIdMasked() {
+        return new OFOxmBsnLagIdMaskedVer13.Builder();
+    }
+    public OFOxmBsnLagIdMasked bsnLagIdMasked(LagId value, LagId mask) {
+        return new OFOxmBsnLagIdMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnTcpFlags.Builder buildBsnTcpFlags() {
+        return new OFOxmBsnTcpFlagsVer13.Builder();
+    }
+    public OFOxmBsnTcpFlags bsnTcpFlags(U16 value) {
+        return new OFOxmBsnTcpFlagsVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnTcpFlagsMasked.Builder buildBsnTcpFlagsMasked() {
+        return new OFOxmBsnTcpFlagsMaskedVer13.Builder();
+    }
+    public OFOxmBsnTcpFlagsMasked bsnTcpFlagsMasked(U16 value, U16 mask) {
+        return new OFOxmBsnTcpFlagsMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf0.Builder buildBsnUdf0() {
+        return new OFOxmBsnUdf0Ver13.Builder();
+    }
+    public OFOxmBsnUdf0 bsnUdf0(UDF value) {
+        return new OFOxmBsnUdf0Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf0Masked.Builder buildBsnUdf0Masked() {
+        return new OFOxmBsnUdf0MaskedVer13.Builder();
+    }
+    public OFOxmBsnUdf0Masked bsnUdf0Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf0MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf1.Builder buildBsnUdf1() {
+        return new OFOxmBsnUdf1Ver13.Builder();
+    }
+    public OFOxmBsnUdf1 bsnUdf1(UDF value) {
+        return new OFOxmBsnUdf1Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf1Masked.Builder buildBsnUdf1Masked() {
+        return new OFOxmBsnUdf1MaskedVer13.Builder();
+    }
+    public OFOxmBsnUdf1Masked bsnUdf1Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf1MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf2.Builder buildBsnUdf2() {
+        return new OFOxmBsnUdf2Ver13.Builder();
+    }
+    public OFOxmBsnUdf2 bsnUdf2(UDF value) {
+        return new OFOxmBsnUdf2Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf2Masked.Builder buildBsnUdf2Masked() {
+        return new OFOxmBsnUdf2MaskedVer13.Builder();
+    }
+    public OFOxmBsnUdf2Masked bsnUdf2Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf2MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf3.Builder buildBsnUdf3() {
+        return new OFOxmBsnUdf3Ver13.Builder();
+    }
+    public OFOxmBsnUdf3 bsnUdf3(UDF value) {
+        return new OFOxmBsnUdf3Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf3Masked.Builder buildBsnUdf3Masked() {
+        return new OFOxmBsnUdf3MaskedVer13.Builder();
+    }
+    public OFOxmBsnUdf3Masked bsnUdf3Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf3MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf4.Builder buildBsnUdf4() {
+        return new OFOxmBsnUdf4Ver13.Builder();
+    }
+    public OFOxmBsnUdf4 bsnUdf4(UDF value) {
+        return new OFOxmBsnUdf4Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf4Masked.Builder buildBsnUdf4Masked() {
+        return new OFOxmBsnUdf4MaskedVer13.Builder();
+    }
+    public OFOxmBsnUdf4Masked bsnUdf4Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf4MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf5.Builder buildBsnUdf5() {
+        return new OFOxmBsnUdf5Ver13.Builder();
+    }
+    public OFOxmBsnUdf5 bsnUdf5(UDF value) {
+        return new OFOxmBsnUdf5Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf5Masked.Builder buildBsnUdf5Masked() {
+        return new OFOxmBsnUdf5MaskedVer13.Builder();
+    }
+    public OFOxmBsnUdf5Masked bsnUdf5Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf5MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf6.Builder buildBsnUdf6() {
+        return new OFOxmBsnUdf6Ver13.Builder();
+    }
+    public OFOxmBsnUdf6 bsnUdf6(UDF value) {
+        return new OFOxmBsnUdf6Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf6Masked.Builder buildBsnUdf6Masked() {
+        return new OFOxmBsnUdf6MaskedVer13.Builder();
+    }
+    public OFOxmBsnUdf6Masked bsnUdf6Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf6MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnUdf7.Builder buildBsnUdf7() {
+        return new OFOxmBsnUdf7Ver13.Builder();
+    }
+    public OFOxmBsnUdf7 bsnUdf7(UDF value) {
+        return new OFOxmBsnUdf7Ver13(
+                value
+                    );
+    }
+
+    public OFOxmBsnUdf7Masked.Builder buildBsnUdf7Masked() {
+        return new OFOxmBsnUdf7MaskedVer13.Builder();
+    }
+    public OFOxmBsnUdf7Masked bsnUdf7Masked(UDF value, UDF mask) {
+        return new OFOxmBsnUdf7MaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnVlanXlatePortGroupId.Builder buildBsnVlanXlatePortGroupId() {
+        return new OFOxmBsnVlanXlatePortGroupIdVer13.Builder();
+    }
+    public OFOxmBsnVlanXlatePortGroupId bsnVlanXlatePortGroupId(ClassId value) {
+        return new OFOxmBsnVlanXlatePortGroupIdVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnVlanXlatePortGroupIdMasked.Builder buildBsnVlanXlatePortGroupIdMasked() {
+        return new OFOxmBsnVlanXlatePortGroupIdMaskedVer13.Builder();
+    }
+    public OFOxmBsnVlanXlatePortGroupIdMasked bsnVlanXlatePortGroupIdMasked(ClassId value, ClassId mask) {
+        return new OFOxmBsnVlanXlatePortGroupIdMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmBsnVrf.Builder buildBsnVrf() {
+        return new OFOxmBsnVrfVer13.Builder();
+    }
+    public OFOxmBsnVrf bsnVrf(VRF value) {
+        return new OFOxmBsnVrfVer13(
+                value
+                    );
+    }
+
+    public OFOxmBsnVrfMasked.Builder buildBsnVrfMasked() {
+        return new OFOxmBsnVrfMaskedVer13.Builder();
+    }
+    public OFOxmBsnVrfMasked bsnVrfMasked(VRF value, VRF mask) {
+        return new OFOxmBsnVrfMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmEthDst.Builder buildEthDst() {
+        return new OFOxmEthDstVer13.Builder();
+    }
+    public OFOxmEthDst ethDst(MacAddress value) {
+        return new OFOxmEthDstVer13(
+                value
+                    );
+    }
+
+    public OFOxmEthDstMasked.Builder buildEthDstMasked() {
+        return new OFOxmEthDstMaskedVer13.Builder();
+    }
+    public OFOxmEthDstMasked ethDstMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmEthDstMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmEthSrc.Builder buildEthSrc() {
+        return new OFOxmEthSrcVer13.Builder();
+    }
+    public OFOxmEthSrc ethSrc(MacAddress value) {
+        return new OFOxmEthSrcVer13(
+                value
+                    );
+    }
+
+    public OFOxmEthSrcMasked.Builder buildEthSrcMasked() {
+        return new OFOxmEthSrcMaskedVer13.Builder();
+    }
+    public OFOxmEthSrcMasked ethSrcMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmEthSrcMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmEthType.Builder buildEthType() {
+        return new OFOxmEthTypeVer13.Builder();
+    }
+    public OFOxmEthType ethType(EthType value) {
+        return new OFOxmEthTypeVer13(
+                value
+                    );
+    }
+
+    public OFOxmEthTypeMasked.Builder buildEthTypeMasked() {
+        return new OFOxmEthTypeMaskedVer13.Builder();
+    }
+    public OFOxmEthTypeMasked ethTypeMasked(EthType value, EthType mask) {
+        return new OFOxmEthTypeMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIcmpv4Code.Builder buildIcmpv4Code() {
+        return new OFOxmIcmpv4CodeVer13.Builder();
+    }
+    public OFOxmIcmpv4Code icmpv4Code(ICMPv4Code value) {
+        return new OFOxmIcmpv4CodeVer13(
+                value
+                    );
+    }
+
+    public OFOxmIcmpv4CodeMasked.Builder buildIcmpv4CodeMasked() {
+        return new OFOxmIcmpv4CodeMaskedVer13.Builder();
+    }
+    public OFOxmIcmpv4CodeMasked icmpv4CodeMasked(ICMPv4Code value, ICMPv4Code mask) {
+        return new OFOxmIcmpv4CodeMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIcmpv4Type.Builder buildIcmpv4Type() {
+        return new OFOxmIcmpv4TypeVer13.Builder();
+    }
+    public OFOxmIcmpv4Type icmpv4Type(ICMPv4Type value) {
+        return new OFOxmIcmpv4TypeVer13(
+                value
+                    );
+    }
+
+    public OFOxmIcmpv4TypeMasked.Builder buildIcmpv4TypeMasked() {
+        return new OFOxmIcmpv4TypeMaskedVer13.Builder();
+    }
+    public OFOxmIcmpv4TypeMasked icmpv4TypeMasked(ICMPv4Type value, ICMPv4Type mask) {
+        return new OFOxmIcmpv4TypeMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIcmpv6Code.Builder buildIcmpv6Code() {
+        return new OFOxmIcmpv6CodeVer13.Builder();
+    }
+    public OFOxmIcmpv6Code icmpv6Code(U8 value) {
+        return new OFOxmIcmpv6CodeVer13(
+                value
+                    );
+    }
+
+    public OFOxmIcmpv6CodeMasked.Builder buildIcmpv6CodeMasked() {
+        return new OFOxmIcmpv6CodeMaskedVer13.Builder();
+    }
+    public OFOxmIcmpv6CodeMasked icmpv6CodeMasked(U8 value, U8 mask) {
+        return new OFOxmIcmpv6CodeMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIcmpv6Type.Builder buildIcmpv6Type() {
+        return new OFOxmIcmpv6TypeVer13.Builder();
+    }
+    public OFOxmIcmpv6Type icmpv6Type(U8 value) {
+        return new OFOxmIcmpv6TypeVer13(
+                value
+                    );
+    }
+
+    public OFOxmIcmpv6TypeMasked.Builder buildIcmpv6TypeMasked() {
+        return new OFOxmIcmpv6TypeMaskedVer13.Builder();
+    }
+    public OFOxmIcmpv6TypeMasked icmpv6TypeMasked(U8 value, U8 mask) {
+        return new OFOxmIcmpv6TypeMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmInPhyPort.Builder buildInPhyPort() {
+        return new OFOxmInPhyPortVer13.Builder();
+    }
+    public OFOxmInPhyPort inPhyPort(OFPort value) {
+        return new OFOxmInPhyPortVer13(
+                value
+                    );
+    }
+
+    public OFOxmInPhyPortMasked.Builder buildInPhyPortMasked() {
+        return new OFOxmInPhyPortMaskedVer13.Builder();
+    }
+    public OFOxmInPhyPortMasked inPhyPortMasked(OFPort value, OFPort mask) {
+        return new OFOxmInPhyPortMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmInPort.Builder buildInPort() {
+        return new OFOxmInPortVer13.Builder();
+    }
+    public OFOxmInPort inPort(OFPort value) {
+        return new OFOxmInPortVer13(
+                value
+                    );
+    }
+
+    public OFOxmInPortMasked.Builder buildInPortMasked() {
+        return new OFOxmInPortMaskedVer13.Builder();
+    }
+    public OFOxmInPortMasked inPortMasked(OFPort value, OFPort mask) {
+        return new OFOxmInPortMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpDscp.Builder buildIpDscp() {
+        return new OFOxmIpDscpVer13.Builder();
+    }
+    public OFOxmIpDscp ipDscp(IpDscp value) {
+        return new OFOxmIpDscpVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpDscpMasked.Builder buildIpDscpMasked() {
+        return new OFOxmIpDscpMaskedVer13.Builder();
+    }
+    public OFOxmIpDscpMasked ipDscpMasked(IpDscp value, IpDscp mask) {
+        return new OFOxmIpDscpMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpEcn.Builder buildIpEcn() {
+        return new OFOxmIpEcnVer13.Builder();
+    }
+    public OFOxmIpEcn ipEcn(IpEcn value) {
+        return new OFOxmIpEcnVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpEcnMasked.Builder buildIpEcnMasked() {
+        return new OFOxmIpEcnMaskedVer13.Builder();
+    }
+    public OFOxmIpEcnMasked ipEcnMasked(IpEcn value, IpEcn mask) {
+        return new OFOxmIpEcnMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpProto.Builder buildIpProto() {
+        return new OFOxmIpProtoVer13.Builder();
+    }
+    public OFOxmIpProto ipProto(IpProtocol value) {
+        return new OFOxmIpProtoVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpProtoMasked.Builder buildIpProtoMasked() {
+        return new OFOxmIpProtoMaskedVer13.Builder();
+    }
+    public OFOxmIpProtoMasked ipProtoMasked(IpProtocol value, IpProtocol mask) {
+        return new OFOxmIpProtoMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv4Dst.Builder buildIpv4Dst() {
+        return new OFOxmIpv4DstVer13.Builder();
+    }
+    public OFOxmIpv4Dst ipv4Dst(IPv4Address value) {
+        return new OFOxmIpv4DstVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpv4DstMasked.Builder buildIpv4DstMasked() {
+        return new OFOxmIpv4DstMaskedVer13.Builder();
+    }
+    public OFOxmIpv4DstMasked ipv4DstMasked(IPv4Address value, IPv4Address mask) {
+        return new OFOxmIpv4DstMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv4Src.Builder buildIpv4Src() {
+        return new OFOxmIpv4SrcVer13.Builder();
+    }
+    public OFOxmIpv4Src ipv4Src(IPv4Address value) {
+        return new OFOxmIpv4SrcVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpv4SrcMasked.Builder buildIpv4SrcMasked() {
+        return new OFOxmIpv4SrcMaskedVer13.Builder();
+    }
+    public OFOxmIpv4SrcMasked ipv4SrcMasked(IPv4Address value, IPv4Address mask) {
+        return new OFOxmIpv4SrcMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6Dst.Builder buildIpv6Dst() {
+        return new OFOxmIpv6DstVer13.Builder();
+    }
+    public OFOxmIpv6Dst ipv6Dst(IPv6Address value) {
+        return new OFOxmIpv6DstVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpv6DstMasked.Builder buildIpv6DstMasked() {
+        return new OFOxmIpv6DstMaskedVer13.Builder();
+    }
+    public OFOxmIpv6DstMasked ipv6DstMasked(IPv6Address value, IPv6Address mask) {
+        return new OFOxmIpv6DstMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6Flabel.Builder buildIpv6Flabel() {
+        return new OFOxmIpv6FlabelVer13.Builder();
+    }
+    public OFOxmIpv6Flabel ipv6Flabel(IPv6FlowLabel value) {
+        return new OFOxmIpv6FlabelVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpv6FlabelMasked.Builder buildIpv6FlabelMasked() {
+        return new OFOxmIpv6FlabelMaskedVer13.Builder();
+    }
+    public OFOxmIpv6FlabelMasked ipv6FlabelMasked(IPv6FlowLabel value, IPv6FlowLabel mask) {
+        return new OFOxmIpv6FlabelMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6NdSll.Builder buildIpv6NdSll() {
+        return new OFOxmIpv6NdSllVer13.Builder();
+    }
+    public OFOxmIpv6NdSll ipv6NdSll(MacAddress value) {
+        return new OFOxmIpv6NdSllVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpv6NdSllMasked.Builder buildIpv6NdSllMasked() {
+        return new OFOxmIpv6NdSllMaskedVer13.Builder();
+    }
+    public OFOxmIpv6NdSllMasked ipv6NdSllMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmIpv6NdSllMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6NdTarget.Builder buildIpv6NdTarget() {
+        return new OFOxmIpv6NdTargetVer13.Builder();
+    }
+    public OFOxmIpv6NdTarget ipv6NdTarget(IPv6Address value) {
+        return new OFOxmIpv6NdTargetVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpv6NdTargetMasked.Builder buildIpv6NdTargetMasked() {
+        return new OFOxmIpv6NdTargetMaskedVer13.Builder();
+    }
+    public OFOxmIpv6NdTargetMasked ipv6NdTargetMasked(IPv6Address value, IPv6Address mask) {
+        return new OFOxmIpv6NdTargetMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6NdTll.Builder buildIpv6NdTll() {
+        return new OFOxmIpv6NdTllVer13.Builder();
+    }
+    public OFOxmIpv6NdTll ipv6NdTll(MacAddress value) {
+        return new OFOxmIpv6NdTllVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpv6NdTllMasked.Builder buildIpv6NdTllMasked() {
+        return new OFOxmIpv6NdTllMaskedVer13.Builder();
+    }
+    public OFOxmIpv6NdTllMasked ipv6NdTllMasked(MacAddress value, MacAddress mask) {
+        return new OFOxmIpv6NdTllMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmIpv6Src.Builder buildIpv6Src() {
+        return new OFOxmIpv6SrcVer13.Builder();
+    }
+    public OFOxmIpv6Src ipv6Src(IPv6Address value) {
+        return new OFOxmIpv6SrcVer13(
+                value
+                    );
+    }
+
+    public OFOxmIpv6SrcMasked.Builder buildIpv6SrcMasked() {
+        return new OFOxmIpv6SrcMaskedVer13.Builder();
+    }
+    public OFOxmIpv6SrcMasked ipv6SrcMasked(IPv6Address value, IPv6Address mask) {
+        return new OFOxmIpv6SrcMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmMetadata.Builder buildMetadata() {
+        return new OFOxmMetadataVer13.Builder();
+    }
+    public OFOxmMetadata metadata(OFMetadata value) {
+        return new OFOxmMetadataVer13(
+                value
+                    );
+    }
+
+    public OFOxmMetadataMasked.Builder buildMetadataMasked() {
+        return new OFOxmMetadataMaskedVer13.Builder();
+    }
+    public OFOxmMetadataMasked metadataMasked(OFMetadata value, OFMetadata mask) {
+        return new OFOxmMetadataMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmMplsLabel.Builder buildMplsLabel() {
+        return new OFOxmMplsLabelVer13.Builder();
+    }
+    public OFOxmMplsLabel mplsLabel(U32 value) {
+        return new OFOxmMplsLabelVer13(
+                value
+                    );
+    }
+
+    public OFOxmMplsLabelMasked.Builder buildMplsLabelMasked() {
+        return new OFOxmMplsLabelMaskedVer13.Builder();
+    }
+    public OFOxmMplsLabelMasked mplsLabelMasked(U32 value, U32 mask) {
+        return new OFOxmMplsLabelMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmMplsTc.Builder buildMplsTc() {
+        return new OFOxmMplsTcVer13.Builder();
+    }
+    public OFOxmMplsTc mplsTc(U8 value) {
+        return new OFOxmMplsTcVer13(
+                value
+                    );
+    }
+
+    public OFOxmMplsTcMasked.Builder buildMplsTcMasked() {
+        return new OFOxmMplsTcMaskedVer13.Builder();
+    }
+    public OFOxmMplsTcMasked mplsTcMasked(U8 value, U8 mask) {
+        return new OFOxmMplsTcMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmSctpDst.Builder buildSctpDst() {
+        return new OFOxmSctpDstVer13.Builder();
+    }
+    public OFOxmSctpDst sctpDst(TransportPort value) {
+        return new OFOxmSctpDstVer13(
+                value
+                    );
+    }
+
+    public OFOxmSctpDstMasked.Builder buildSctpDstMasked() {
+        return new OFOxmSctpDstMaskedVer13.Builder();
+    }
+    public OFOxmSctpDstMasked sctpDstMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmSctpDstMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmSctpSrc.Builder buildSctpSrc() {
+        return new OFOxmSctpSrcVer13.Builder();
+    }
+    public OFOxmSctpSrc sctpSrc(TransportPort value) {
+        return new OFOxmSctpSrcVer13(
+                value
+                    );
+    }
+
+    public OFOxmSctpSrcMasked.Builder buildSctpSrcMasked() {
+        return new OFOxmSctpSrcMaskedVer13.Builder();
+    }
+    public OFOxmSctpSrcMasked sctpSrcMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmSctpSrcMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmTcpDst.Builder buildTcpDst() {
+        return new OFOxmTcpDstVer13.Builder();
+    }
+    public OFOxmTcpDst tcpDst(TransportPort value) {
+        return new OFOxmTcpDstVer13(
+                value
+                    );
+    }
+
+    public OFOxmTcpDstMasked.Builder buildTcpDstMasked() {
+        return new OFOxmTcpDstMaskedVer13.Builder();
+    }
+    public OFOxmTcpDstMasked tcpDstMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmTcpDstMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmTcpSrc.Builder buildTcpSrc() {
+        return new OFOxmTcpSrcVer13.Builder();
+    }
+    public OFOxmTcpSrc tcpSrc(TransportPort value) {
+        return new OFOxmTcpSrcVer13(
+                value
+                    );
+    }
+
+    public OFOxmTcpSrcMasked.Builder buildTcpSrcMasked() {
+        return new OFOxmTcpSrcMaskedVer13.Builder();
+    }
+    public OFOxmTcpSrcMasked tcpSrcMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmTcpSrcMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmUdpDst.Builder buildUdpDst() {
+        return new OFOxmUdpDstVer13.Builder();
+    }
+    public OFOxmUdpDst udpDst(TransportPort value) {
+        return new OFOxmUdpDstVer13(
+                value
+                    );
+    }
+
+    public OFOxmUdpDstMasked.Builder buildUdpDstMasked() {
+        return new OFOxmUdpDstMaskedVer13.Builder();
+    }
+    public OFOxmUdpDstMasked udpDstMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmUdpDstMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmUdpSrc.Builder buildUdpSrc() {
+        return new OFOxmUdpSrcVer13.Builder();
+    }
+    public OFOxmUdpSrc udpSrc(TransportPort value) {
+        return new OFOxmUdpSrcVer13(
+                value
+                    );
+    }
+
+    public OFOxmUdpSrcMasked.Builder buildUdpSrcMasked() {
+        return new OFOxmUdpSrcMaskedVer13.Builder();
+    }
+    public OFOxmUdpSrcMasked udpSrcMasked(TransportPort value, TransportPort mask) {
+        return new OFOxmUdpSrcMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmVlanPcp.Builder buildVlanPcp() {
+        return new OFOxmVlanPcpVer13.Builder();
+    }
+    public OFOxmVlanPcp vlanPcp(VlanPcp value) {
+        return new OFOxmVlanPcpVer13(
+                value
+                    );
+    }
+
+    public OFOxmVlanPcpMasked.Builder buildVlanPcpMasked() {
+        return new OFOxmVlanPcpMaskedVer13.Builder();
+    }
+    public OFOxmVlanPcpMasked vlanPcpMasked(VlanPcp value, VlanPcp mask) {
+        return new OFOxmVlanPcpMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmVlanVid.Builder buildVlanVid() {
+        return new OFOxmVlanVidVer13.Builder();
+    }
+    public OFOxmVlanVid vlanVid(OFVlanVidMatch value) {
+        return new OFOxmVlanVidVer13(
+                value
+                    );
+    }
+
+    public OFOxmVlanVidMasked.Builder buildVlanVidMasked() {
+        return new OFOxmVlanVidMaskedVer13.Builder();
+    }
+    public OFOxmVlanVidMasked vlanVidMasked(OFVlanVidMatch value, OFVlanVidMatch mask) {
+        return new OFOxmVlanVidMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFOxmTunnelId.Builder buildTunnelId() {
+        return new OFOxmTunnelIdVer13.Builder();
+    }
+    public OFOxmTunnelId tunnelId(U64 value) {
+        return new OFOxmTunnelIdVer13(
+                value
+                    );
+    }
+
+    public OFOxmTunnelIdMasked.Builder buildTunnelIdMasked() {
+        return new OFOxmTunnelIdMaskedVer13.Builder();
+    }
+    public OFOxmTunnelIdMasked tunnelIdMasked(U64 value, U64 mask) {
+        return new OFOxmTunnelIdMaskedVer13(
+                value,
+                      mask
+                    );
+    }
+
+    public OFMessageReader<OFOxm<?>> getReader() {
+        return OFOxmVer13.READER;
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromValue(F value, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOp((ArpOpcode)((Object)value)));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpSha((MacAddress)((Object)value)));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpa((IPv4Address)((Object)value)));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpTha((MacAddress)((Object)value)));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpa((IPv4Address)((Object)value)));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupId((ClassId)((Object)value)));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowed((OFBooleanValue)((Object)value)));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128((OFBitMask128)((Object)value)));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassId((ClassId)((Object)value)));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassId((ClassId)((Object)value)));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassId((ClassId)((Object)value)));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagId((LagId)((Object)value)));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlags((U16)((Object)value)));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0((UDF)((Object)value)));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1((UDF)((Object)value)));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2((UDF)((Object)value)));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3((UDF)((Object)value)));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4((UDF)((Object)value)));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5((UDF)((Object)value)));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6((UDF)((Object)value)));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7((UDF)((Object)value)));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupId((ClassId)((Object)value)));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrf((VRF)((Object)value)));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDst((MacAddress)((Object)value)));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrc((MacAddress)((Object)value)));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethType((EthType)((Object)value)));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4Code((ICMPv4Code)((Object)value)));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4Type((ICMPv4Type)((Object)value)));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6Code((U8)((Object)value)));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6Type((U8)((Object)value)));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPort((OFPort)((Object)value)));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPort((OFPort)((Object)value)));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscp((IpDscp)((Object)value)));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcn((IpEcn)((Object)value)));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProto((IpProtocol)((Object)value)));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4Dst((IPv4Address)((Object)value)));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4Src((IPv4Address)((Object)value)));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6Dst((IPv6Address)((Object)value)));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6Flabel((IPv6FlowLabel)((Object)value)));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSll((MacAddress)((Object)value)));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTarget((IPv6Address)((Object)value)));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTll((MacAddress)((Object)value)));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6Src((IPv6Address)((Object)value)));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadata((OFMetadata)((Object)value)));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabel((U32)((Object)value)));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTc((U8)((Object)value)));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDst((TransportPort)((Object)value)));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrc((TransportPort)((Object)value)));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDst((TransportPort)((Object)value)));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrc((TransportPort)((Object)value)));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDst((TransportPort)((Object)value)));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrc((TransportPort)((Object)value)));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcp((VlanPcp)((Object)value)));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVid((OFVlanVidMatch)((Object)value)));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelId((U64)((Object)value)));
+            default:
+                throw new IllegalArgumentException("No OXM known for match field " + field);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromValueAndMask(F value, F mask, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOpMasked((ArpOpcode)((Object)value), (ArpOpcode)((Object)mask)));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpShaMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpaMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpThaMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpaMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowedMasked((OFBooleanValue)((Object)value), (OFBooleanValue)((Object)mask)));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128Masked((OFBitMask128)((Object)value), (OFBitMask128)((Object)mask)));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagIdMasked((LagId)((Object)value), (LagId)((Object)mask)));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlagsMasked((U16)((Object)value), (U16)((Object)mask)));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7Masked((UDF)((Object)value), (UDF)((Object)mask)));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupIdMasked((ClassId)((Object)value), (ClassId)((Object)mask)));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrfMasked((VRF)((Object)value), (VRF)((Object)mask)));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDstMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrcMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethTypeMasked((EthType)((Object)value), (EthType)((Object)mask)));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4CodeMasked((ICMPv4Code)((Object)value), (ICMPv4Code)((Object)mask)));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4TypeMasked((ICMPv4Type)((Object)value), (ICMPv4Type)((Object)mask)));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6CodeMasked((U8)((Object)value), (U8)((Object)mask)));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6TypeMasked((U8)((Object)value), (U8)((Object)mask)));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPortMasked((OFPort)((Object)value), (OFPort)((Object)mask)));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPortMasked((OFPort)((Object)value), (OFPort)((Object)mask)));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscpMasked((IpDscp)((Object)value), (IpDscp)((Object)mask)));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcnMasked((IpEcn)((Object)value), (IpEcn)((Object)mask)));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProtoMasked((IpProtocol)((Object)value), (IpProtocol)((Object)mask)));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4DstMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4SrcMasked((IPv4Address)((Object)value), (IPv4Address)((Object)mask)));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6DstMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6FlabelMasked((IPv6FlowLabel)((Object)value), (IPv6FlowLabel)((Object)mask)));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSllMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTargetMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTllMasked((MacAddress)((Object)value), (MacAddress)((Object)mask)));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6SrcMasked((IPv6Address)((Object)value), (IPv6Address)((Object)mask)));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadataMasked((OFMetadata)((Object)value), (OFMetadata)((Object)mask)));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabelMasked((U32)((Object)value), (U32)((Object)mask)));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTcMasked((U8)((Object)value), (U8)((Object)mask)));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDstMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrcMasked((TransportPort)((Object)value), (TransportPort)((Object)mask)));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcpMasked((VlanPcp)((Object)value), (VlanPcp)((Object)mask)));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVidMasked((OFVlanVidMatch)((Object)value), (OFVlanVidMatch)((Object)mask)));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelIdMasked((U64)((Object)value), (U64)((Object)mask)));
+            default:
+                throw new IllegalArgumentException("No OXM known for match field " + field);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public <F extends OFValueType<F>> OFOxm<F> fromMasked(Masked<F> masked, MatchField<F> field) {
+        switch (field.id) {
+            case ARP_OP:
+                return (OFOxm<F>)((Object)arpOpMasked((ArpOpcode)((Object)(masked.getValue())), (ArpOpcode)((Object)(masked.getMask()))));
+            case ARP_SHA:
+                return (OFOxm<F>)((Object)arpShaMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ARP_SPA:
+                return (OFOxm<F>)((Object)arpSpaMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case ARP_THA:
+                return (OFOxm<F>)((Object)arpThaMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ARP_TPA:
+                return (OFOxm<F>)((Object)arpTpaMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case BSN_EGR_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnEgrPortGroupIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_GLOBAL_VRF_ALLOWED:
+                return (OFOxm<F>)((Object)bsnGlobalVrfAllowedMasked((OFBooleanValue)((Object)(masked.getValue())), (OFBooleanValue)((Object)(masked.getMask()))));
+            case BSN_IN_PORTS_128:
+                return (OFOxm<F>)((Object)bsnInPorts128Masked((OFBitMask128)((Object)(masked.getValue())), (OFBitMask128)((Object)(masked.getMask()))));
+            case BSN_L3_DST_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3DstClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_L3_INTERFACE_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3InterfaceClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_L3_SRC_CLASS_ID:
+                return (OFOxm<F>)((Object)bsnL3SrcClassIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_LAG_ID:
+                return (OFOxm<F>)((Object)bsnLagIdMasked((LagId)((Object)(masked.getValue())), (LagId)((Object)(masked.getMask()))));
+            case BSN_TCP_FLAGS:
+                return (OFOxm<F>)((Object)bsnTcpFlagsMasked((U16)((Object)(masked.getValue())), (U16)((Object)(masked.getMask()))));
+            case BSN_UDF0:
+                return (OFOxm<F>)((Object)bsnUdf0Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF1:
+                return (OFOxm<F>)((Object)bsnUdf1Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF2:
+                return (OFOxm<F>)((Object)bsnUdf2Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF3:
+                return (OFOxm<F>)((Object)bsnUdf3Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF4:
+                return (OFOxm<F>)((Object)bsnUdf4Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF5:
+                return (OFOxm<F>)((Object)bsnUdf5Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF6:
+                return (OFOxm<F>)((Object)bsnUdf6Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_UDF7:
+                return (OFOxm<F>)((Object)bsnUdf7Masked((UDF)((Object)(masked.getValue())), (UDF)((Object)(masked.getMask()))));
+            case BSN_VLAN_XLATE_PORT_GROUP_ID:
+                return (OFOxm<F>)((Object)bsnVlanXlatePortGroupIdMasked((ClassId)((Object)(masked.getValue())), (ClassId)((Object)(masked.getMask()))));
+            case BSN_VRF:
+                return (OFOxm<F>)((Object)bsnVrfMasked((VRF)((Object)(masked.getValue())), (VRF)((Object)(masked.getMask()))));
+            case ETH_DST:
+                return (OFOxm<F>)((Object)ethDstMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ETH_SRC:
+                return (OFOxm<F>)((Object)ethSrcMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case ETH_TYPE:
+                return (OFOxm<F>)((Object)ethTypeMasked((EthType)((Object)(masked.getValue())), (EthType)((Object)(masked.getMask()))));
+            case ICMPV4_CODE:
+                return (OFOxm<F>)((Object)icmpv4CodeMasked((ICMPv4Code)((Object)(masked.getValue())), (ICMPv4Code)((Object)(masked.getMask()))));
+            case ICMPV4_TYPE:
+                return (OFOxm<F>)((Object)icmpv4TypeMasked((ICMPv4Type)((Object)(masked.getValue())), (ICMPv4Type)((Object)(masked.getMask()))));
+            case ICMPV6_CODE:
+                return (OFOxm<F>)((Object)icmpv6CodeMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case ICMPV6_TYPE:
+                return (OFOxm<F>)((Object)icmpv6TypeMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case IN_PHY_PORT:
+                return (OFOxm<F>)((Object)inPhyPortMasked((OFPort)((Object)(masked.getValue())), (OFPort)((Object)(masked.getMask()))));
+            case IN_PORT:
+                return (OFOxm<F>)((Object)inPortMasked((OFPort)((Object)(masked.getValue())), (OFPort)((Object)(masked.getMask()))));
+            case IP_DSCP:
+                return (OFOxm<F>)((Object)ipDscpMasked((IpDscp)((Object)(masked.getValue())), (IpDscp)((Object)(masked.getMask()))));
+            case IP_ECN:
+                return (OFOxm<F>)((Object)ipEcnMasked((IpEcn)((Object)(masked.getValue())), (IpEcn)((Object)(masked.getMask()))));
+            case IP_PROTO:
+                return (OFOxm<F>)((Object)ipProtoMasked((IpProtocol)((Object)(masked.getValue())), (IpProtocol)((Object)(masked.getMask()))));
+            case IPV4_DST:
+                return (OFOxm<F>)((Object)ipv4DstMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case IPV4_SRC:
+                return (OFOxm<F>)((Object)ipv4SrcMasked((IPv4Address)((Object)(masked.getValue())), (IPv4Address)((Object)(masked.getMask()))));
+            case IPV6_DST:
+                return (OFOxm<F>)((Object)ipv6DstMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case IPV6_FLABEL:
+                return (OFOxm<F>)((Object)ipv6FlabelMasked((IPv6FlowLabel)((Object)(masked.getValue())), (IPv6FlowLabel)((Object)(masked.getMask()))));
+            case IPV6_ND_SLL:
+                return (OFOxm<F>)((Object)ipv6NdSllMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case IPV6_ND_TARGET:
+                return (OFOxm<F>)((Object)ipv6NdTargetMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case IPV6_ND_TLL:
+                return (OFOxm<F>)((Object)ipv6NdTllMasked((MacAddress)((Object)(masked.getValue())), (MacAddress)((Object)(masked.getMask()))));
+            case IPV6_SRC:
+                return (OFOxm<F>)((Object)ipv6SrcMasked((IPv6Address)((Object)(masked.getValue())), (IPv6Address)((Object)(masked.getMask()))));
+            case METADATA:
+                return (OFOxm<F>)((Object)metadataMasked((OFMetadata)((Object)(masked.getValue())), (OFMetadata)((Object)(masked.getMask()))));
+            case MPLS_LABEL:
+                return (OFOxm<F>)((Object)mplsLabelMasked((U32)((Object)(masked.getValue())), (U32)((Object)(masked.getMask()))));
+            case MPLS_TC:
+                return (OFOxm<F>)((Object)mplsTcMasked((U8)((Object)(masked.getValue())), (U8)((Object)(masked.getMask()))));
+            case SCTP_DST:
+                return (OFOxm<F>)((Object)sctpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case SCTP_SRC:
+                return (OFOxm<F>)((Object)sctpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case TCP_DST:
+                return (OFOxm<F>)((Object)tcpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case TCP_SRC:
+                return (OFOxm<F>)((Object)tcpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case UDP_DST:
+                return (OFOxm<F>)((Object)udpDstMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case UDP_SRC:
+                return (OFOxm<F>)((Object)udpSrcMasked((TransportPort)((Object)(masked.getValue())), (TransportPort)((Object)(masked.getMask()))));
+            case VLAN_PCP:
+                return (OFOxm<F>)((Object)vlanPcpMasked((VlanPcp)((Object)(masked.getValue())), (VlanPcp)((Object)(masked.getMask()))));
+            case VLAN_VID:
+                return (OFOxm<F>)((Object)vlanVidMasked((OFVlanVidMatch)((Object)(masked.getValue())), (OFVlanVidMatch)((Object)(masked.getMask()))));
+            case TUNNEL_ID:
+                return (OFOxm<F>)((Object)tunnelIdMasked((U64)((Object)(masked.getValue())), (U64)((Object)(masked.getMask()))));
+            default:
+                return null;
+        }
+    }
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInReasonSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInReasonSerializerVer13.java
new file mode 100644
index 0000000..3787e64
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInReasonSerializerVer13.java
@@ -0,0 +1,149 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPacketInReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPacketInReasonSerializerVer13 {
+
+    public final static byte NO_MATCH_VAL = (byte) 0x0;
+    public final static byte ACTION_VAL = (byte) 0x1;
+    public final static byte INVALID_TTL_VAL = (byte) 0x2;
+    public final static byte BSN_NEW_HOST_VAL = (byte) 0x80;
+    public final static byte BSN_STATION_MOVE_VAL = (byte) 0x81;
+    public final static byte BSN_BAD_VLAN_VAL = (byte) 0x82;
+    public final static byte BSN_DESTINATION_LOOKUP_FAILURE_VAL = (byte) 0x83;
+    public final static byte BSN_NO_ROUTE_VAL = (byte) 0x84;
+    public final static byte BSN_ICMP_ECHO_REQUEST_VAL = (byte) 0x85;
+    public final static byte BSN_DEST_NETWORK_UNREACHABLE_VAL = (byte) 0x86;
+    public final static byte BSN_DEST_HOST_UNREACHABLE_VAL = (byte) 0x87;
+    public final static byte BSN_DEST_PORT_UNREACHABLE_VAL = (byte) 0x88;
+    public final static byte BSN_FRAGMENTATION_REQUIRED_VAL = (byte) 0x89;
+    public final static byte BSN_ARP_VAL = (byte) 0x8b;
+    public final static byte BSN_DHCP_VAL = (byte) 0x8c;
+    public final static byte BSN_DEBUG_VAL = (byte) 0x8d;
+    public final static byte BSN_PACKET_OF_DEATH_VAL = (byte) 0x8e;
+
+    public static OFPacketInReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPacketInReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFPacketInReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFPacketInReason ofWireValue(byte val) {
+        switch(val) {
+            case NO_MATCH_VAL:
+                return OFPacketInReason.NO_MATCH;
+            case ACTION_VAL:
+                return OFPacketInReason.ACTION;
+            case INVALID_TTL_VAL:
+                return OFPacketInReason.INVALID_TTL;
+            case BSN_NEW_HOST_VAL:
+                return OFPacketInReason.BSN_NEW_HOST;
+            case BSN_STATION_MOVE_VAL:
+                return OFPacketInReason.BSN_STATION_MOVE;
+            case BSN_BAD_VLAN_VAL:
+                return OFPacketInReason.BSN_BAD_VLAN;
+            case BSN_DESTINATION_LOOKUP_FAILURE_VAL:
+                return OFPacketInReason.BSN_DESTINATION_LOOKUP_FAILURE;
+            case BSN_NO_ROUTE_VAL:
+                return OFPacketInReason.BSN_NO_ROUTE;
+            case BSN_ICMP_ECHO_REQUEST_VAL:
+                return OFPacketInReason.BSN_ICMP_ECHO_REQUEST;
+            case BSN_DEST_NETWORK_UNREACHABLE_VAL:
+                return OFPacketInReason.BSN_DEST_NETWORK_UNREACHABLE;
+            case BSN_DEST_HOST_UNREACHABLE_VAL:
+                return OFPacketInReason.BSN_DEST_HOST_UNREACHABLE;
+            case BSN_DEST_PORT_UNREACHABLE_VAL:
+                return OFPacketInReason.BSN_DEST_PORT_UNREACHABLE;
+            case BSN_FRAGMENTATION_REQUIRED_VAL:
+                return OFPacketInReason.BSN_FRAGMENTATION_REQUIRED;
+            case BSN_ARP_VAL:
+                return OFPacketInReason.BSN_ARP;
+            case BSN_DHCP_VAL:
+                return OFPacketInReason.BSN_DHCP;
+            case BSN_DEBUG_VAL:
+                return OFPacketInReason.BSN_DEBUG;
+            case BSN_PACKET_OF_DEATH_VAL:
+                return OFPacketInReason.BSN_PACKET_OF_DEATH;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPacketInReason in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFPacketInReason e) {
+        switch(e) {
+            case NO_MATCH:
+                return NO_MATCH_VAL;
+            case ACTION:
+                return ACTION_VAL;
+            case INVALID_TTL:
+                return INVALID_TTL_VAL;
+            case BSN_NEW_HOST:
+                return BSN_NEW_HOST_VAL;
+            case BSN_STATION_MOVE:
+                return BSN_STATION_MOVE_VAL;
+            case BSN_BAD_VLAN:
+                return BSN_BAD_VLAN_VAL;
+            case BSN_DESTINATION_LOOKUP_FAILURE:
+                return BSN_DESTINATION_LOOKUP_FAILURE_VAL;
+            case BSN_NO_ROUTE:
+                return BSN_NO_ROUTE_VAL;
+            case BSN_ICMP_ECHO_REQUEST:
+                return BSN_ICMP_ECHO_REQUEST_VAL;
+            case BSN_DEST_NETWORK_UNREACHABLE:
+                return BSN_DEST_NETWORK_UNREACHABLE_VAL;
+            case BSN_DEST_HOST_UNREACHABLE:
+                return BSN_DEST_HOST_UNREACHABLE_VAL;
+            case BSN_DEST_PORT_UNREACHABLE:
+                return BSN_DEST_PORT_UNREACHABLE_VAL;
+            case BSN_FRAGMENTATION_REQUIRED:
+                return BSN_FRAGMENTATION_REQUIRED_VAL;
+            case BSN_ARP:
+                return BSN_ARP_VAL;
+            case BSN_DHCP:
+                return BSN_DHCP_VAL;
+            case BSN_DEBUG:
+                return BSN_DEBUG_VAL;
+            case BSN_PACKET_OF_DEATH:
+                return BSN_PACKET_OF_DEATH_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPacketInReason in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInVer13.java
new file mode 100644
index 0000000..b496100
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInVer13.java
@@ -0,0 +1,689 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFPacketInVer13 implements OFPacketIn {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketInVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 30;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static int DEFAULT_TOTAL_LEN = 0x0;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static U64 DEFAULT_COOKIE = U64.ZERO;
+        private final static Match DEFAULT_MATCH = OFFactoryVer13.MATCH_WILDCARD_ALL;
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final OFBufferId bufferId;
+    private final int totalLen;
+    private final OFPacketInReason reason;
+    private final TableId tableId;
+    private final U64 cookie;
+    private final Match match;
+    private final byte[] data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketInVer13(long xid, OFBufferId bufferId, int totalLen, OFPacketInReason reason, TableId tableId, U64 cookie, Match match, byte[] data) {
+        this.xid = xid;
+        this.bufferId = bufferId;
+        this.totalLen = totalLen;
+        this.reason = reason;
+        this.tableId = tableId;
+        this.cookie = cookie;
+        this.match = match;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPort getInPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPort not supported in version 1.3");
+    }
+
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.3");
+    }
+
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+
+
+    public OFPacketIn.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketIn.Builder {
+        final OFPacketInVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean totalLenSet;
+        private int totalLen;
+        private boolean reasonSet;
+        private OFPacketInReason reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean matchSet;
+        private Match match;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFPacketInVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketIn.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTotalLen(int totalLen) {
+        this.totalLen = totalLen;
+        this.totalLenSet = true;
+        return this;
+    }
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPacketIn.Builder setReason(OFPacketInReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFPacketIn.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketIn.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPort not supported in version 1.3");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPort(OFPort inPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPort not supported in version 1.3");
+    }
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.3");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.3");
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFPacketIn.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPacketIn build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                int totalLen = this.totalLenSet ? this.totalLen : parentMessage.totalLen;
+                OFPacketInReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                U64 cookie = this.cookieSet ? this.cookie : parentMessage.cookie;
+                if(cookie == null)
+                    throw new NullPointerException("Property cookie must not be null");
+                Match match = this.matchSet ? this.match : parentMessage.match;
+                if(match == null)
+                    throw new NullPointerException("Property match must not be null");
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPacketInVer13(
+                    xid,
+                    bufferId,
+                    totalLen,
+                    reason,
+                    tableId,
+                    cookie,
+                    match,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketIn.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean totalLenSet;
+        private int totalLen;
+        private boolean reasonSet;
+        private OFPacketInReason reason;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean cookieSet;
+        private U64 cookie;
+        private boolean matchSet;
+        private Match match;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_IN;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketIn.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public int getTotalLen() {
+        return totalLen;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTotalLen(int totalLen) {
+        this.totalLen = totalLen;
+        this.totalLenSet = true;
+        return this;
+    }
+    @Override
+    public OFPacketInReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPacketIn.Builder setReason(OFPacketInReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFPacketIn.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public Match getMatch() {
+        return match;
+    }
+
+    @Override
+    public OFPacketIn.Builder setMatch(Match match) {
+        this.match = match;
+        this.matchSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketIn.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPort not supported in version 1.3");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPort(OFPort inPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPort not supported in version 1.3");
+    }
+    @Override
+    public OFPort getInPhyPort()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.3");
+    }
+
+    @Override
+    public OFPacketIn.Builder setInPhyPort(OFPort inPhyPort) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property inPhyPort not supported in version 1.3");
+    }
+    @Override
+    public U64 getCookie() {
+        return cookie;
+    }
+
+    @Override
+    public OFPacketIn.Builder setCookie(U64 cookie) {
+        this.cookie = cookie;
+        this.cookieSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPacketIn build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            int totalLen = this.totalLenSet ? this.totalLen : DEFAULT_TOTAL_LEN;
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            U64 cookie = this.cookieSet ? this.cookie : DEFAULT_COOKIE;
+            if(cookie == null)
+                throw new NullPointerException("Property cookie must not be null");
+            Match match = this.matchSet ? this.match : DEFAULT_MATCH;
+            if(match == null)
+                throw new NullPointerException("Property match must not be null");
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPacketInVer13(
+                    xid,
+                    bufferId,
+                    totalLen,
+                    reason,
+                    tableId,
+                    cookie,
+                    match,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketIn> {
+        @Override
+        public OFPacketIn readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 10
+            byte type = bb.readByte();
+            if(type != (byte) 0xa)
+                throw new OFParseError("Wrong type: Expected=OFType.PACKET_IN(10), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            int totalLen = U16.f(bb.readShort());
+            OFPacketInReason reason = OFPacketInReasonSerializerVer13.readFrom(bb);
+            TableId tableId = TableId.readByte(bb);
+            U64 cookie = U64.ofRaw(bb.readLong());
+            Match match = ChannelUtilsVer13.readOFMatch(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFPacketInVer13 packetInVer13 = new OFPacketInVer13(
+                    xid,
+                      bufferId,
+                      totalLen,
+                      reason,
+                      tableId,
+                      cookie,
+                      match,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetInVer13);
+            return packetInVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketInVer13Funnel FUNNEL = new OFPacketInVer13Funnel();
+    static class OFPacketInVer13Funnel implements Funnel<OFPacketInVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketInVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 10
+            sink.putByte((byte) 0xa);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.bufferId.putTo(sink);
+            sink.putInt(message.totalLen);
+            OFPacketInReasonSerializerVer13.putTo(message.reason, sink);
+            message.tableId.putTo(sink);
+            message.cookie.putTo(sink);
+            message.match.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketInVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketInVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 10
+            bb.writeByte((byte) 0xa);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(message.bufferId.getInt());
+            bb.writeShort(U16.t(message.totalLen));
+            OFPacketInReasonSerializerVer13.writeTo(bb, message.reason);
+            message.tableId.writeByte(bb);
+            bb.writeLong(message.cookie.getValue());
+            message.match.writeTo(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketInVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("totalLen=").append(totalLen);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("cookie=").append(cookie);
+        b.append(", ");
+        b.append("match=").append(match);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketInVer13 other = (OFPacketInVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if( totalLen != other.totalLen)
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (cookie == null) {
+            if (other.cookie != null)
+                return false;
+        } else if (!cookie.equals(other.cookie))
+            return false;
+        if (match == null) {
+            if (other.match != null)
+                return false;
+        } else if (!match.equals(other.match))
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + totalLen;
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((cookie == null) ? 0 : cookie.hashCode());
+        result = prime * result + ((match == null) ? 0 : match.hashCode());
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketOutVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketOutVer13.java
new file mode 100644
index 0000000..e4876f9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketOutVer13.java
@@ -0,0 +1,504 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFPacketOutVer13 implements OFPacketOut {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketOutVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFBufferId DEFAULT_BUFFER_ID = OFBufferId.NO_BUFFER;
+        private final static OFPort DEFAULT_IN_PORT = OFPort.ANY;
+        private final static List<OFAction> DEFAULT_ACTIONS = ImmutableList.<OFAction>of();
+        private final static byte[] DEFAULT_DATA = new byte[0];
+
+    // OF message fields
+    private final long xid;
+    private final OFBufferId bufferId;
+    private final OFPort inPort;
+    private final List<OFAction> actions;
+    private final byte[] data;
+//
+    // Immutable default instance
+    final static OFPacketOutVer13 DEFAULT = new OFPacketOutVer13(
+        DEFAULT_XID, DEFAULT_BUFFER_ID, DEFAULT_IN_PORT, DEFAULT_ACTIONS, DEFAULT_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketOutVer13(long xid, OFBufferId bufferId, OFPort inPort, List<OFAction> actions, byte[] data) {
+        this.xid = xid;
+        this.bufferId = bufferId;
+        this.inPort = inPort;
+        this.actions = actions;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+
+
+    public OFPacketOut.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketOut.Builder {
+        final OFPacketOutVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+        private boolean dataSet;
+        private byte[] data;
+
+        BuilderWithParent(OFPacketOutVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketOut.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketOut.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketOut.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFPacketOut.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketOut.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPacketOut build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFBufferId bufferId = this.bufferIdSet ? this.bufferId : parentMessage.bufferId;
+                if(bufferId == null)
+                    throw new NullPointerException("Property bufferId must not be null");
+                OFPort inPort = this.inPortSet ? this.inPort : parentMessage.inPort;
+                if(inPort == null)
+                    throw new NullPointerException("Property inPort must not be null");
+                List<OFAction> actions = this.actionsSet ? this.actions : parentMessage.actions;
+                if(actions == null)
+                    throw new NullPointerException("Property actions must not be null");
+                byte[] data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPacketOutVer13(
+                    xid,
+                    bufferId,
+                    inPort,
+                    actions,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketOut.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean bufferIdSet;
+        private OFBufferId bufferId;
+        private boolean inPortSet;
+        private OFPort inPort;
+        private boolean actionsSet;
+        private List<OFAction> actions;
+        private boolean dataSet;
+        private byte[] data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PACKET_OUT;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPacketOut.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFBufferId getBufferId() {
+        return bufferId;
+    }
+
+    @Override
+    public OFPacketOut.Builder setBufferId(OFBufferId bufferId) {
+        this.bufferId = bufferId;
+        this.bufferIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getInPort() {
+        return inPort;
+    }
+
+    @Override
+    public OFPacketOut.Builder setInPort(OFPort inPort) {
+        this.inPort = inPort;
+        this.inPortSet = true;
+        return this;
+    }
+    @Override
+    public List<OFAction> getActions() {
+        return actions;
+    }
+
+    @Override
+    public OFPacketOut.Builder setActions(List<OFAction> actions) {
+        this.actions = actions;
+        this.actionsSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getData() {
+        return data;
+    }
+
+    @Override
+    public OFPacketOut.Builder setData(byte[] data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPacketOut build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFBufferId bufferId = this.bufferIdSet ? this.bufferId : DEFAULT_BUFFER_ID;
+            if(bufferId == null)
+                throw new NullPointerException("Property bufferId must not be null");
+            OFPort inPort = this.inPortSet ? this.inPort : DEFAULT_IN_PORT;
+            if(inPort == null)
+                throw new NullPointerException("Property inPort must not be null");
+            List<OFAction> actions = this.actionsSet ? this.actions : DEFAULT_ACTIONS;
+            if(actions == null)
+                throw new NullPointerException("Property actions must not be null");
+            byte[] data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPacketOutVer13(
+                    xid,
+                    bufferId,
+                    inPort,
+                    actions,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketOut> {
+        @Override
+        public OFPacketOut readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 13
+            byte type = bb.readByte();
+            if(type != (byte) 0xd)
+                throw new OFParseError("Wrong type: Expected=OFType.PACKET_OUT(13), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFBufferId bufferId = OFBufferId.of(bb.readInt());
+            OFPort inPort = OFPort.read4Bytes(bb);
+            int actionsLen = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            List<OFAction> actions = ChannelUtils.readList(bb, actionsLen, OFActionVer13.READER);
+            byte[] data = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFPacketOutVer13 packetOutVer13 = new OFPacketOutVer13(
+                    xid,
+                      bufferId,
+                      inPort,
+                      actions,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetOutVer13);
+            return packetOutVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketOutVer13Funnel FUNNEL = new OFPacketOutVer13Funnel();
+    static class OFPacketOutVer13Funnel implements Funnel<OFPacketOutVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketOutVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 13
+            sink.putByte((byte) 0xd);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.bufferId.putTo(sink);
+            message.inPort.putTo(sink);
+            // FIXME: skip funnel of actionsLen
+            // skip pad (6 bytes)
+            FunnelUtils.putList(message.actions, sink);
+            sink.putBytes(message.data);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketOutVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketOutVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 13
+            bb.writeByte((byte) 0xd);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            bb.writeInt(message.bufferId.getInt());
+            message.inPort.write4Bytes(bb);
+            // actionsLen is length indicator for actions, will be
+            // udpated when actions has been written
+            int actionsLenIndex = bb.writerIndex();
+            bb.writeShort(0);
+            // pad: 6 bytes
+            bb.writeZero(6);
+            int actionsStartIndex = bb.writerIndex();
+            ChannelUtils.writeList(bb, message.actions);
+            // update field length member actionsLen
+            int actionsLength = bb.writerIndex() - actionsStartIndex;
+            bb.setShort(actionsLenIndex, actionsLength);
+            bb.writeBytes(message.data);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketOutVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("bufferId=").append(bufferId);
+        b.append(", ");
+        b.append("inPort=").append(inPort);
+        b.append(", ");
+        b.append("actions=").append(actions);
+        b.append(", ");
+        b.append("data=").append(Arrays.toString(data));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketOutVer13 other = (OFPacketOutVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (bufferId == null) {
+            if (other.bufferId != null)
+                return false;
+        } else if (!bufferId.equals(other.bufferId))
+            return false;
+        if (inPort == null) {
+            if (other.inPort != null)
+                return false;
+        } else if (!inPort.equals(other.inPort))
+            return false;
+        if (actions == null) {
+            if (other.actions != null)
+                return false;
+        } else if (!actions.equals(other.actions))
+            return false;
+        if (!Arrays.equals(data, other.data))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((bufferId == null) ? 0 : bufferId.hashCode());
+        result = prime * result + ((inPort == null) ? 0 : inPort.hashCode());
+        result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+        result = prime * result + Arrays.hashCode(data);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketQueueVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketQueueVer13.java
new file mode 100644
index 0000000..bc14042
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketQueueVer13.java
@@ -0,0 +1,357 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPacketQueueVer13 implements OFPacketQueue {
+    private static final Logger logger = LoggerFactory.getLogger(OFPacketQueueVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static List<OFQueueProp> DEFAULT_PROPERTIES = ImmutableList.<OFQueueProp>of();
+
+    // OF message fields
+    private final long queueId;
+    private final OFPort port;
+    private final List<OFQueueProp> properties;
+//
+    // Immutable default instance
+    final static OFPacketQueueVer13 DEFAULT = new OFPacketQueueVer13(
+        DEFAULT_QUEUE_ID, DEFAULT_PORT, DEFAULT_PROPERTIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPacketQueueVer13(long queueId, OFPort port, List<OFQueueProp> properties) {
+        this.queueId = queueId;
+        this.port = port;
+        this.properties = properties;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFPacketQueue.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPacketQueue.Builder {
+        final OFPacketQueueVer13 parentMessage;
+
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean portSet;
+        private OFPort port;
+        private boolean propertiesSet;
+        private List<OFQueueProp> properties;
+
+        BuilderWithParent(OFPacketQueueVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setProperties(List<OFQueueProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFPacketQueue build() {
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                List<OFQueueProp> properties = this.propertiesSet ? this.properties : parentMessage.properties;
+                if(properties == null)
+                    throw new NullPointerException("Property properties must not be null");
+
+                //
+                return new OFPacketQueueVer13(
+                    queueId,
+                    port,
+                    properties
+                );
+        }
+
+    }
+
+    static class Builder implements OFPacketQueue.Builder {
+        // OF message fields
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean portSet;
+        private OFPort port;
+        private boolean propertiesSet;
+        private List<OFQueueProp> properties;
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFPacketQueue.Builder setProperties(List<OFQueueProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFPacketQueue build() {
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            List<OFQueueProp> properties = this.propertiesSet ? this.properties : DEFAULT_PROPERTIES;
+            if(properties == null)
+                throw new NullPointerException("Property properties must not be null");
+
+
+            return new OFPacketQueueVer13(
+                    queueId,
+                    port,
+                    properties
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPacketQueue> {
+        @Override
+        public OFPacketQueue readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            long queueId = U32.f(bb.readInt());
+            OFPort port = OFPort.read4Bytes(bb);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 6 bytes
+            bb.skipBytes(6);
+            List<OFQueueProp> properties = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFQueuePropVer13.READER);
+
+            OFPacketQueueVer13 packetQueueVer13 = new OFPacketQueueVer13(
+                    queueId,
+                      port,
+                      properties
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", packetQueueVer13);
+            return packetQueueVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPacketQueueVer13Funnel FUNNEL = new OFPacketQueueVer13Funnel();
+    static class OFPacketQueueVer13Funnel implements Funnel<OFPacketQueueVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPacketQueueVer13 message, PrimitiveSink sink) {
+            sink.putLong(message.queueId);
+            message.port.putTo(sink);
+            // FIXME: skip funnel of length
+            // skip pad (6 bytes)
+            FunnelUtils.putList(message.properties, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPacketQueueVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPacketQueueVer13 message) {
+            int startIndex = bb.writerIndex();
+            bb.writeInt(U32.t(message.queueId));
+            message.port.write4Bytes(bb);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            // pad: 6 bytes
+            bb.writeZero(6);
+            ChannelUtils.writeList(bb, message.properties);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPacketQueueVer13(");
+        b.append("queueId=").append(queueId);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("properties=").append(properties);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPacketQueueVer13 other = (OFPacketQueueVer13) obj;
+
+        if( queueId != other.queueId)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if (properties == null) {
+            if (other.properties != null)
+                return false;
+        } else if (!properties.equals(other.properties))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortConfigSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortConfigSerializerVer13.java
new file mode 100644
index 0000000..3d47d7d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortConfigSerializerVer13.java
@@ -0,0 +1,102 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortConfig;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortConfigSerializerVer13 {
+
+    public final static int PORT_DOWN_VAL = 0x1;
+    public final static int NO_RECV_VAL = 0x4;
+    public final static int NO_FWD_VAL = 0x20;
+    public final static int NO_PACKET_IN_VAL = 0x40;
+    public final static int BSN_MIRROR_DEST_VAL = (int) 0x80000000;
+
+    public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortConfig> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortConfig> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortConfig> ofWireValue(int val) {
+        EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);
+
+        if((val & PORT_DOWN_VAL) != 0)
+            set.add(OFPortConfig.PORT_DOWN);
+        if((val & NO_RECV_VAL) != 0)
+            set.add(OFPortConfig.NO_RECV);
+        if((val & NO_FWD_VAL) != 0)
+            set.add(OFPortConfig.NO_FWD);
+        if((val & NO_PACKET_IN_VAL) != 0)
+            set.add(OFPortConfig.NO_PACKET_IN);
+        if((val & BSN_MIRROR_DEST_VAL) != 0)
+            set.add(OFPortConfig.BSN_MIRROR_DEST);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortConfig> set) {
+        int wireValue = 0;
+
+        for(OFPortConfig e: set) {
+            switch(e) {
+                case PORT_DOWN:
+                    wireValue |= PORT_DOWN_VAL;
+                    break;
+                case NO_RECV:
+                    wireValue |= NO_RECV_VAL;
+                    break;
+                case NO_FWD:
+                    wireValue |= NO_FWD_VAL;
+                    break;
+                case NO_PACKET_IN:
+                    wireValue |= NO_PACKET_IN_VAL;
+                    break;
+                case BSN_MIRROR_DEST:
+                    wireValue |= BSN_MIRROR_DEST_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescStatsReplyVer13.java
new file mode 100644
index 0000000..6834465
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortDescStatsReplyVer13 implements OFPortDescStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortDescStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFPortDesc> DEFAULT_ENTRIES = ImmutableList.<OFPortDesc>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFPortDesc> entries;
+//
+    // Immutable default instance
+    final static OFPortDescStatsReplyVer13 DEFAULT = new OFPortDescStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortDescStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFPortDesc> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFPortDesc> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFPortDescStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortDescStatsReply.Builder {
+        final OFPortDescStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortDesc> entries;
+
+        BuilderWithParent(OFPortDescStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortDesc> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortDescStatsReply.Builder setEntries(List<OFPortDesc> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortDescStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFPortDesc> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFPortDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortDescStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortDesc> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortDescStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT_DESC;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortDesc> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortDescStatsReply.Builder setEntries(List<OFPortDesc> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortDescStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFPortDesc> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFPortDescStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortDescStatsReply> {
+        @Override
+        public OFPortDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 13
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xd)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT_DESC(13), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFPortDesc> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPortDescVer13.READER);
+
+            OFPortDescStatsReplyVer13 portDescStatsReplyVer13 = new OFPortDescStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portDescStatsReplyVer13);
+            return portDescStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortDescStatsReplyVer13Funnel FUNNEL = new OFPortDescStatsReplyVer13Funnel();
+    static class OFPortDescStatsReplyVer13Funnel implements Funnel<OFPortDescStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortDescStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 13
+            sink.putShort((short) 0xd);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortDescStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortDescStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 13
+            bb.writeShort((short) 0xd);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortDescStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortDescStatsReplyVer13 other = (OFPortDescStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescStatsRequestVer13.java
new file mode 100644
index 0000000..903b98b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescStatsRequestVer13.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortDescStatsRequestVer13 implements OFPortDescStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortDescStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFPortDescStatsRequestVer13 DEFAULT = new OFPortDescStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortDescStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFPortDescStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortDescStatsRequest.Builder {
+        final OFPortDescStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFPortDescStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortDescStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFPortDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortDescStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortDescStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT_DESC;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortDescStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortDescStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFPortDescStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortDescStatsRequest> {
+        @Override
+        public OFPortDescStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 13
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xd)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT_DESC(13), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFPortDescStatsRequestVer13 portDescStatsRequestVer13 = new OFPortDescStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portDescStatsRequestVer13);
+            return portDescStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortDescStatsRequestVer13Funnel FUNNEL = new OFPortDescStatsRequestVer13Funnel();
+    static class OFPortDescStatsRequestVer13Funnel implements Funnel<OFPortDescStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortDescStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 13
+            sink.putShort((short) 0xd);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortDescStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortDescStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 13
+            bb.writeShort((short) 0xd);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortDescStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortDescStatsRequestVer13 other = (OFPortDescStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescVer13.java
new file mode 100644
index 0000000..ff92652
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortDescVer13.java
@@ -0,0 +1,766 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortDescVer13 implements OFPortDesc {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortDescVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 64;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static String DEFAULT_NAME = "";
+        private final static Set<OFPortConfig> DEFAULT_CONFIG = ImmutableSet.<OFPortConfig>of();
+        private final static Set<OFPortState> DEFAULT_STATE = ImmutableSet.<OFPortState>of();
+        private final static Set<OFPortFeatures> DEFAULT_CURR = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_ADVERTISED = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_SUPPORTED = ImmutableSet.<OFPortFeatures>of();
+        private final static Set<OFPortFeatures> DEFAULT_PEER = ImmutableSet.<OFPortFeatures>of();
+        private final static long DEFAULT_CURR_SPEED = 0x0L;
+        private final static long DEFAULT_MAX_SPEED = 0x0L;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final MacAddress hwAddr;
+    private final String name;
+    private final Set<OFPortConfig> config;
+    private final Set<OFPortState> state;
+    private final Set<OFPortFeatures> curr;
+    private final Set<OFPortFeatures> advertised;
+    private final Set<OFPortFeatures> supported;
+    private final Set<OFPortFeatures> peer;
+    private final long currSpeed;
+    private final long maxSpeed;
+//
+    // Immutable default instance
+    final static OFPortDescVer13 DEFAULT = new OFPortDescVer13(
+        DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_CONFIG, DEFAULT_STATE, DEFAULT_CURR, DEFAULT_ADVERTISED, DEFAULT_SUPPORTED, DEFAULT_PEER, DEFAULT_CURR_SPEED, DEFAULT_MAX_SPEED
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortDescVer13(OFPort portNo, MacAddress hwAddr, String name, Set<OFPortConfig> config, Set<OFPortState> state, Set<OFPortFeatures> curr, Set<OFPortFeatures> advertised, Set<OFPortFeatures> supported, Set<OFPortFeatures> peer, long currSpeed, long maxSpeed) {
+        this.portNo = portNo;
+        this.hwAddr = hwAddr;
+        this.name = name;
+        this.config = config;
+        this.state = state;
+        this.curr = curr;
+        this.advertised = advertised;
+        this.supported = supported;
+        this.peer = peer;
+        this.currSpeed = currSpeed;
+        this.maxSpeed = maxSpeed;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFPortDesc.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortDesc.Builder {
+        final OFPortDescVer13 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean configSet;
+        private Set<OFPortConfig> config;
+        private boolean stateSet;
+        private Set<OFPortState> state;
+        private boolean currSet;
+        private Set<OFPortFeatures> curr;
+        private boolean advertisedSet;
+        private Set<OFPortFeatures> advertised;
+        private boolean supportedSet;
+        private Set<OFPortFeatures> supported;
+        private boolean peerSet;
+        private Set<OFPortFeatures> peer;
+        private boolean currSpeedSet;
+        private long currSpeed;
+        private boolean maxSpeedSet;
+        private long maxSpeed;
+
+        BuilderWithParent(OFPortDescVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFPortDesc.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public OFPortDesc.Builder setState(Set<OFPortState> state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) {
+        this.curr = curr;
+        this.currSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) {
+        this.advertised = advertised;
+        this.advertisedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) {
+        this.supported = supported;
+        this.supportedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) {
+        this.peer = peer;
+        this.peerSet = true;
+        return this;
+    }
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurrSpeed(long currSpeed) {
+        this.currSpeed = currSpeed;
+        this.currSpeedSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setMaxSpeed(long maxSpeed) {
+        this.maxSpeed = maxSpeed;
+        this.maxSpeedSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFPortDesc build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                Set<OFPortConfig> config = this.configSet ? this.config : parentMessage.config;
+                if(config == null)
+                    throw new NullPointerException("Property config must not be null");
+                Set<OFPortState> state = this.stateSet ? this.state : parentMessage.state;
+                if(state == null)
+                    throw new NullPointerException("Property state must not be null");
+                Set<OFPortFeatures> curr = this.currSet ? this.curr : parentMessage.curr;
+                if(curr == null)
+                    throw new NullPointerException("Property curr must not be null");
+                Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : parentMessage.advertised;
+                if(advertised == null)
+                    throw new NullPointerException("Property advertised must not be null");
+                Set<OFPortFeatures> supported = this.supportedSet ? this.supported : parentMessage.supported;
+                if(supported == null)
+                    throw new NullPointerException("Property supported must not be null");
+                Set<OFPortFeatures> peer = this.peerSet ? this.peer : parentMessage.peer;
+                if(peer == null)
+                    throw new NullPointerException("Property peer must not be null");
+                long currSpeed = this.currSpeedSet ? this.currSpeed : parentMessage.currSpeed;
+                long maxSpeed = this.maxSpeedSet ? this.maxSpeed : parentMessage.maxSpeed;
+
+                //
+                return new OFPortDescVer13(
+                    portNo,
+                    hwAddr,
+                    name,
+                    config,
+                    state,
+                    curr,
+                    advertised,
+                    supported,
+                    peer,
+                    currSpeed,
+                    maxSpeed
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortDesc.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean nameSet;
+        private String name;
+        private boolean configSet;
+        private Set<OFPortConfig> config;
+        private boolean stateSet;
+        private Set<OFPortState> state;
+        private boolean currSet;
+        private Set<OFPortFeatures> curr;
+        private boolean advertisedSet;
+        private Set<OFPortFeatures> advertised;
+        private boolean supportedSet;
+        private Set<OFPortFeatures> supported;
+        private boolean peerSet;
+        private Set<OFPortFeatures> peer;
+        private boolean currSpeedSet;
+        private long currSpeed;
+        private boolean maxSpeedSet;
+        private long maxSpeed;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFPortDesc.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortConfig> getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortDesc.Builder setConfig(Set<OFPortConfig> config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortState> getState() {
+        return state;
+    }
+
+    @Override
+    public OFPortDesc.Builder setState(Set<OFPortState> state) {
+        this.state = state;
+        this.stateSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getCurr() {
+        return curr;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurr(Set<OFPortFeatures> curr) {
+        this.curr = curr;
+        this.currSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getAdvertised() {
+        return advertised;
+    }
+
+    @Override
+    public OFPortDesc.Builder setAdvertised(Set<OFPortFeatures> advertised) {
+        this.advertised = advertised;
+        this.advertisedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getSupported() {
+        return supported;
+    }
+
+    @Override
+    public OFPortDesc.Builder setSupported(Set<OFPortFeatures> supported) {
+        this.supported = supported;
+        this.supportedSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFPortFeatures> getPeer() {
+        return peer;
+    }
+
+    @Override
+    public OFPortDesc.Builder setPeer(Set<OFPortFeatures> peer) {
+        this.peer = peer;
+        this.peerSet = true;
+        return this;
+    }
+    @Override
+    public long getCurrSpeed() {
+        return currSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setCurrSpeed(long currSpeed) {
+        this.currSpeed = currSpeed;
+        this.currSpeedSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxSpeed() {
+        return maxSpeed;
+    }
+
+    @Override
+    public OFPortDesc.Builder setMaxSpeed(long maxSpeed) {
+        this.maxSpeed = maxSpeed;
+        this.maxSpeedSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFPortDesc build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            Set<OFPortConfig> config = this.configSet ? this.config : DEFAULT_CONFIG;
+            if(config == null)
+                throw new NullPointerException("Property config must not be null");
+            Set<OFPortState> state = this.stateSet ? this.state : DEFAULT_STATE;
+            if(state == null)
+                throw new NullPointerException("Property state must not be null");
+            Set<OFPortFeatures> curr = this.currSet ? this.curr : DEFAULT_CURR;
+            if(curr == null)
+                throw new NullPointerException("Property curr must not be null");
+            Set<OFPortFeatures> advertised = this.advertisedSet ? this.advertised : DEFAULT_ADVERTISED;
+            if(advertised == null)
+                throw new NullPointerException("Property advertised must not be null");
+            Set<OFPortFeatures> supported = this.supportedSet ? this.supported : DEFAULT_SUPPORTED;
+            if(supported == null)
+                throw new NullPointerException("Property supported must not be null");
+            Set<OFPortFeatures> peer = this.peerSet ? this.peer : DEFAULT_PEER;
+            if(peer == null)
+                throw new NullPointerException("Property peer must not be null");
+            long currSpeed = this.currSpeedSet ? this.currSpeed : DEFAULT_CURR_SPEED;
+            long maxSpeed = this.maxSpeedSet ? this.maxSpeed : DEFAULT_MAX_SPEED;
+
+
+            return new OFPortDescVer13(
+                    portNo,
+                    hwAddr,
+                    name,
+                    config,
+                    state,
+                    curr,
+                    advertised,
+                    supported,
+                    peer,
+                    currSpeed,
+                    maxSpeed
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortDesc> {
+        @Override
+        public OFPortDesc readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            String name = ChannelUtils.readFixedLengthString(bb, 16);
+            Set<OFPortConfig> config = OFPortConfigSerializerVer13.readFrom(bb);
+            Set<OFPortState> state = OFPortStateSerializerVer13.readFrom(bb);
+            Set<OFPortFeatures> curr = OFPortFeaturesSerializerVer13.readFrom(bb);
+            Set<OFPortFeatures> advertised = OFPortFeaturesSerializerVer13.readFrom(bb);
+            Set<OFPortFeatures> supported = OFPortFeaturesSerializerVer13.readFrom(bb);
+            Set<OFPortFeatures> peer = OFPortFeaturesSerializerVer13.readFrom(bb);
+            long currSpeed = U32.f(bb.readInt());
+            long maxSpeed = U32.f(bb.readInt());
+
+            OFPortDescVer13 portDescVer13 = new OFPortDescVer13(
+                    portNo,
+                      hwAddr,
+                      name,
+                      config,
+                      state,
+                      curr,
+                      advertised,
+                      supported,
+                      peer,
+                      currSpeed,
+                      maxSpeed
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portDescVer13);
+            return portDescVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortDescVer13Funnel FUNNEL = new OFPortDescVer13Funnel();
+    static class OFPortDescVer13Funnel implements Funnel<OFPortDescVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortDescVer13 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putUnencodedChars(message.name);
+            OFPortConfigSerializerVer13.putTo(message.config, sink);
+            OFPortStateSerializerVer13.putTo(message.state, sink);
+            OFPortFeaturesSerializerVer13.putTo(message.curr, sink);
+            OFPortFeaturesSerializerVer13.putTo(message.advertised, sink);
+            OFPortFeaturesSerializerVer13.putTo(message.supported, sink);
+            OFPortFeaturesSerializerVer13.putTo(message.peer, sink);
+            sink.putLong(message.currSpeed);
+            sink.putLong(message.maxSpeed);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortDescVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortDescVer13 message) {
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 16);
+            OFPortConfigSerializerVer13.writeTo(bb, message.config);
+            OFPortStateSerializerVer13.writeTo(bb, message.state);
+            OFPortFeaturesSerializerVer13.writeTo(bb, message.curr);
+            OFPortFeaturesSerializerVer13.writeTo(bb, message.advertised);
+            OFPortFeaturesSerializerVer13.writeTo(bb, message.supported);
+            OFPortFeaturesSerializerVer13.writeTo(bb, message.peer);
+            bb.writeInt(U32.t(message.currSpeed));
+            bb.writeInt(U32.t(message.maxSpeed));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortDescVer13(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("state=").append(state);
+        b.append(", ");
+        b.append("curr=").append(curr);
+        b.append(", ");
+        b.append("advertised=").append(advertised);
+        b.append(", ");
+        b.append("supported=").append(supported);
+        b.append(", ");
+        b.append("peer=").append(peer);
+        b.append(", ");
+        b.append("currSpeed=").append(currSpeed);
+        b.append(", ");
+        b.append("maxSpeed=").append(maxSpeed);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortDescVer13 other = (OFPortDescVer13) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (config == null) {
+            if (other.config != null)
+                return false;
+        } else if (!config.equals(other.config))
+            return false;
+        if (state == null) {
+            if (other.state != null)
+                return false;
+        } else if (!state.equals(other.state))
+            return false;
+        if (curr == null) {
+            if (other.curr != null)
+                return false;
+        } else if (!curr.equals(other.curr))
+            return false;
+        if (advertised == null) {
+            if (other.advertised != null)
+                return false;
+        } else if (!advertised.equals(other.advertised))
+            return false;
+        if (supported == null) {
+            if (other.supported != null)
+                return false;
+        } else if (!supported.equals(other.supported))
+            return false;
+        if (peer == null) {
+            if (other.peer != null)
+                return false;
+        } else if (!peer.equals(other.peer))
+            return false;
+        if( currSpeed != other.currSpeed)
+            return false;
+        if( maxSpeed != other.maxSpeed)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((config == null) ? 0 : config.hashCode());
+        result = prime * result + ((state == null) ? 0 : state.hashCode());
+        result = prime * result + ((curr == null) ? 0 : curr.hashCode());
+        result = prime * result + ((advertised == null) ? 0 : advertised.hashCode());
+        result = prime * result + ((supported == null) ? 0 : supported.hashCode());
+        result = prime * result + ((peer == null) ? 0 : peer.hashCode());
+        result = prime *  (int) (currSpeed ^ (currSpeed >>> 32));
+        result = prime *  (int) (maxSpeed ^ (maxSpeed >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortFeaturesSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortFeaturesSerializerVer13.java
new file mode 100644
index 0000000..58d4204
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortFeaturesSerializerVer13.java
@@ -0,0 +1,168 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortFeatures;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortFeaturesSerializerVer13 {
+
+    public final static int PF_10MB_HD_VAL = 0x1;
+    public final static int PF_10MB_FD_VAL = 0x2;
+    public final static int PF_100MB_HD_VAL = 0x4;
+    public final static int PF_100MB_FD_VAL = 0x8;
+    public final static int PF_1GB_HD_VAL = 0x10;
+    public final static int PF_1GB_FD_VAL = 0x20;
+    public final static int PF_10GB_FD_VAL = 0x40;
+    public final static int PF_COPPER_VAL = 0x800;
+    public final static int PF_FIBER_VAL = 0x1000;
+    public final static int PF_AUTONEG_VAL = 0x2000;
+    public final static int PF_PAUSE_VAL = 0x4000;
+    public final static int PF_PAUSE_ASYM_VAL = 0x8000;
+    public final static int PF_40GB_FD_VAL = 0x80;
+    public final static int PF_100GB_FD_VAL = 0x100;
+    public final static int PF_1TB_FD_VAL = 0x200;
+    public final static int PF_OTHER_VAL = 0x400;
+
+    public static Set<OFPortFeatures> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortFeatures> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortFeatures> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortFeatures> ofWireValue(int val) {
+        EnumSet<OFPortFeatures> set = EnumSet.noneOf(OFPortFeatures.class);
+
+        if((val & PF_10MB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10MB_HD);
+        if((val & PF_10MB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10MB_FD);
+        if((val & PF_100MB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100MB_HD);
+        if((val & PF_100MB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100MB_FD);
+        if((val & PF_1GB_HD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1GB_HD);
+        if((val & PF_1GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1GB_FD);
+        if((val & PF_10GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_10GB_FD);
+        if((val & PF_COPPER_VAL) != 0)
+            set.add(OFPortFeatures.PF_COPPER);
+        if((val & PF_FIBER_VAL) != 0)
+            set.add(OFPortFeatures.PF_FIBER);
+        if((val & PF_AUTONEG_VAL) != 0)
+            set.add(OFPortFeatures.PF_AUTONEG);
+        if((val & PF_PAUSE_VAL) != 0)
+            set.add(OFPortFeatures.PF_PAUSE);
+        if((val & PF_PAUSE_ASYM_VAL) != 0)
+            set.add(OFPortFeatures.PF_PAUSE_ASYM);
+        if((val & PF_40GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_40GB_FD);
+        if((val & PF_100GB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_100GB_FD);
+        if((val & PF_1TB_FD_VAL) != 0)
+            set.add(OFPortFeatures.PF_1TB_FD);
+        if((val & PF_OTHER_VAL) != 0)
+            set.add(OFPortFeatures.PF_OTHER);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortFeatures> set) {
+        int wireValue = 0;
+
+        for(OFPortFeatures e: set) {
+            switch(e) {
+                case PF_10MB_HD:
+                    wireValue |= PF_10MB_HD_VAL;
+                    break;
+                case PF_10MB_FD:
+                    wireValue |= PF_10MB_FD_VAL;
+                    break;
+                case PF_100MB_HD:
+                    wireValue |= PF_100MB_HD_VAL;
+                    break;
+                case PF_100MB_FD:
+                    wireValue |= PF_100MB_FD_VAL;
+                    break;
+                case PF_1GB_HD:
+                    wireValue |= PF_1GB_HD_VAL;
+                    break;
+                case PF_1GB_FD:
+                    wireValue |= PF_1GB_FD_VAL;
+                    break;
+                case PF_10GB_FD:
+                    wireValue |= PF_10GB_FD_VAL;
+                    break;
+                case PF_COPPER:
+                    wireValue |= PF_COPPER_VAL;
+                    break;
+                case PF_FIBER:
+                    wireValue |= PF_FIBER_VAL;
+                    break;
+                case PF_AUTONEG:
+                    wireValue |= PF_AUTONEG_VAL;
+                    break;
+                case PF_PAUSE:
+                    wireValue |= PF_PAUSE_VAL;
+                    break;
+                case PF_PAUSE_ASYM:
+                    wireValue |= PF_PAUSE_ASYM_VAL;
+                    break;
+                case PF_40GB_FD:
+                    wireValue |= PF_40GB_FD_VAL;
+                    break;
+                case PF_100GB_FD:
+                    wireValue |= PF_100GB_FD_VAL;
+                    break;
+                case PF_1TB_FD:
+                    wireValue |= PF_1TB_FD_VAL;
+                    break;
+                case PF_OTHER:
+                    wireValue |= PF_OTHER_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortFeatures in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..75e4b79
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModFailedCodeSerializerVer13.java
@@ -0,0 +1,89 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPortModFailedCodeSerializerVer13 {
+
+    public final static short BAD_PORT_VAL = (short) 0x0;
+    public final static short BAD_HW_ADDR_VAL = (short) 0x1;
+    public final static short BAD_CONFIG_VAL = (short) 0x2;
+    public final static short BAD_ADVERTISE_VAL = (short) 0x3;
+    public final static short EPERM_VAL = (short) 0x4;
+
+    public static OFPortModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPortModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFPortModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFPortModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_PORT_VAL:
+                return OFPortModFailedCode.BAD_PORT;
+            case BAD_HW_ADDR_VAL:
+                return OFPortModFailedCode.BAD_HW_ADDR;
+            case BAD_CONFIG_VAL:
+                return OFPortModFailedCode.BAD_CONFIG;
+            case BAD_ADVERTISE_VAL:
+                return OFPortModFailedCode.BAD_ADVERTISE;
+            case EPERM_VAL:
+                return OFPortModFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPortModFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFPortModFailedCode e) {
+        switch(e) {
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_HW_ADDR:
+                return BAD_HW_ADDR_VAL;
+            case BAD_CONFIG:
+                return BAD_CONFIG_VAL;
+            case BAD_ADVERTISE:
+                return BAD_ADVERTISE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPortModFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModFailedErrorMsgVer13.java
new file mode 100644
index 0000000..83a7169
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortModFailedErrorMsgVer13 implements OFPortModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortModFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFPortModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortModFailedErrorMsgVer13(long xid, OFPortModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFPortModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortModFailedErrorMsg.Builder {
+        final OFPortModFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFPortModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFPortModFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setCode(OFPortModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPortModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFPortModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFPortModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.PORT_MOD_FAILED;
+    }
+
+    @Override
+    public OFPortModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setCode(OFPortModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFPortModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFPortModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortModFailedErrorMsg> {
+        @Override
+        public OFPortModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 7
+            short errType = bb.readShort();
+            if(errType != (short) 0x7)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.PORT_MOD_FAILED(7), got="+errType);
+            OFPortModFailedCode code = OFPortModFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFPortModFailedErrorMsgVer13 portModFailedErrorMsgVer13 = new OFPortModFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portModFailedErrorMsgVer13);
+            return portModFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortModFailedErrorMsgVer13Funnel FUNNEL = new OFPortModFailedErrorMsgVer13Funnel();
+    static class OFPortModFailedErrorMsgVer13Funnel implements Funnel<OFPortModFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortModFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 7
+            sink.putShort((short) 0x7);
+            OFPortModFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortModFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortModFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 7
+            bb.writeShort((short) 0x7);
+            OFPortModFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortModFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortModFailedErrorMsgVer13 other = (OFPortModFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModVer13.java
new file mode 100644
index 0000000..e72ffb7
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortModVer13.java
@@ -0,0 +1,532 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortModVer13 implements OFPortMod {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortModVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 40;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
+        private final static long DEFAULT_CONFIG = 0x0L;
+        private final static long DEFAULT_MASK = 0x0L;
+        private final static long DEFAULT_ADVERTISE = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort portNo;
+    private final MacAddress hwAddr;
+    private final long config;
+    private final long mask;
+    private final long advertise;
+//
+    // Immutable default instance
+    final static OFPortModVer13 DEFAULT = new OFPortModVer13(
+        DEFAULT_XID, DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_CONFIG, DEFAULT_MASK, DEFAULT_ADVERTISE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortModVer13(long xid, OFPort portNo, MacAddress hwAddr, long config, long mask, long advertise) {
+        this.xid = xid;
+        this.portNo = portNo;
+        this.hwAddr = hwAddr;
+        this.config = config;
+        this.mask = mask;
+        this.advertise = advertise;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+
+
+    public OFPortMod.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortMod.Builder {
+        final OFPortModVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean configSet;
+        private long config;
+        private boolean maskSet;
+        private long mask;
+        private boolean advertiseSet;
+        private long advertise;
+
+        BuilderWithParent(OFPortModVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortMod.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortMod.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFPortMod.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+    @Override
+    public OFPortMod.Builder setAdvertise(long advertise) {
+        this.advertise = advertise;
+        this.advertiseSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortMod build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
+                if(hwAddr == null)
+                    throw new NullPointerException("Property hwAddr must not be null");
+                long config = this.configSet ? this.config : parentMessage.config;
+                long mask = this.maskSet ? this.mask : parentMessage.mask;
+                long advertise = this.advertiseSet ? this.advertise : parentMessage.advertise;
+
+                //
+                return new OFPortModVer13(
+                    xid,
+                    portNo,
+                    hwAddr,
+                    config,
+                    mask,
+                    advertise
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortMod.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean hwAddrSet;
+        private MacAddress hwAddr;
+        private boolean configSet;
+        private long config;
+        private boolean maskSet;
+        private long mask;
+        private boolean advertiseSet;
+        private long advertise;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortMod.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public MacAddress getHwAddr() {
+        return hwAddr;
+    }
+
+    @Override
+    public OFPortMod.Builder setHwAddr(MacAddress hwAddr) {
+        this.hwAddr = hwAddr;
+        this.hwAddrSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFPortMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMask() {
+        return mask;
+    }
+
+    @Override
+    public OFPortMod.Builder setMask(long mask) {
+        this.mask = mask;
+        this.maskSet = true;
+        return this;
+    }
+    @Override
+    public long getAdvertise() {
+        return advertise;
+    }
+
+    @Override
+    public OFPortMod.Builder setAdvertise(long advertise) {
+        this.advertise = advertise;
+        this.advertiseSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortMod build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
+            if(hwAddr == null)
+                throw new NullPointerException("Property hwAddr must not be null");
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+            long mask = this.maskSet ? this.mask : DEFAULT_MASK;
+            long advertise = this.advertiseSet ? this.advertise : DEFAULT_ADVERTISE;
+
+
+            return new OFPortModVer13(
+                    xid,
+                    portNo,
+                    hwAddr,
+                    config,
+                    mask,
+                    advertise
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortMod> {
+        @Override
+        public OFPortMod readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 16
+            byte type = bb.readByte();
+            if(type != (byte) 0x10)
+                throw new OFParseError("Wrong type: Expected=OFType.PORT_MOD(16), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 40)
+                throw new OFParseError("Wrong length: Expected=40(40), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            MacAddress hwAddr = MacAddress.read6Bytes(bb);
+            // pad: 2 bytes
+            bb.skipBytes(2);
+            long config = U32.f(bb.readInt());
+            long mask = U32.f(bb.readInt());
+            long advertise = U32.f(bb.readInt());
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFPortModVer13 portModVer13 = new OFPortModVer13(
+                    xid,
+                      portNo,
+                      hwAddr,
+                      config,
+                      mask,
+                      advertise
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portModVer13);
+            return portModVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortModVer13Funnel FUNNEL = new OFPortModVer13Funnel();
+    static class OFPortModVer13Funnel implements Funnel<OFPortModVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortModVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 16
+            sink.putByte((byte) 0x10);
+            // fixed value property length = 40
+            sink.putShort((short) 0x28);
+            sink.putLong(message.xid);
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.hwAddr.putTo(sink);
+            // skip pad (2 bytes)
+            sink.putLong(message.config);
+            sink.putLong(message.mask);
+            sink.putLong(message.advertise);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortModVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortModVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 16
+            bb.writeByte((byte) 0x10);
+            // fixed value property length = 40
+            bb.writeShort((short) 0x28);
+            bb.writeInt(U32.t(message.xid));
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.hwAddr.write6Bytes(bb);
+            // pad: 2 bytes
+            bb.writeZero(2);
+            bb.writeInt(U32.t(message.config));
+            bb.writeInt(U32.t(message.mask));
+            bb.writeInt(U32.t(message.advertise));
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortModVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("hwAddr=").append(hwAddr);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("mask=").append(mask);
+        b.append(", ");
+        b.append("advertise=").append(advertise);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortModVer13 other = (OFPortModVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (hwAddr == null) {
+            if (other.hwAddr != null)
+                return false;
+        } else if (!hwAddr.equals(other.hwAddr))
+            return false;
+        if( config != other.config)
+            return false;
+        if( mask != other.mask)
+            return false;
+        if( advertise != other.advertise)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
+        result = prime *  (int) (config ^ (config >>> 32));
+        result = prime *  (int) (mask ^ (mask >>> 32));
+        result = prime *  (int) (advertise ^ (advertise >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortReasonSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortReasonSerializerVer13.java
new file mode 100644
index 0000000..1794800
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortReasonSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortReason;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFPortReasonSerializerVer13 {
+
+    public final static byte ADD_VAL = (byte) 0x0;
+    public final static byte DELETE_VAL = (byte) 0x1;
+    public final static byte MODIFY_VAL = (byte) 0x2;
+
+    public static OFPortReason readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFPortReason e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFPortReason e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFPortReason ofWireValue(byte val) {
+        switch(val) {
+            case ADD_VAL:
+                return OFPortReason.ADD;
+            case DELETE_VAL:
+                return OFPortReason.DELETE;
+            case MODIFY_VAL:
+                return OFPortReason.MODIFY;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFPortReason in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFPortReason e) {
+        switch(e) {
+            case ADD:
+                return ADD_VAL;
+            case DELETE:
+                return DELETE_VAL;
+            case MODIFY:
+                return MODIFY_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFPortReason in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStateSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStateSerializerVer13.java
new file mode 100644
index 0000000..b7cc4c5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStateSerializerVer13.java
@@ -0,0 +1,90 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFPortState;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFPortStateSerializerVer13 {
+
+    public final static int LINK_DOWN_VAL = 0x1;
+    public final static int BLOCKED_VAL = 0x2;
+    public final static int LIVE_VAL = 0x4;
+
+    public static Set<OFPortState> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFPortState> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFPortState> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFPortState> ofWireValue(int val) {
+        EnumSet<OFPortState> set = EnumSet.noneOf(OFPortState.class);
+
+        if((val & LINK_DOWN_VAL) != 0)
+            set.add(OFPortState.LINK_DOWN);
+        if((val & BLOCKED_VAL) != 0)
+            set.add(OFPortState.BLOCKED);
+        if((val & LIVE_VAL) != 0)
+            set.add(OFPortState.LIVE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFPortState> set) {
+        int wireValue = 0;
+
+        for(OFPortState e: set) {
+            switch(e) {
+                case LINK_DOWN:
+                    wireValue |= LINK_DOWN_VAL;
+                    break;
+                case BLOCKED:
+                    wireValue |= BLOCKED_VAL;
+                    break;
+                case LIVE:
+                    wireValue |= LIVE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFPortState in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsEntryVer13.java
new file mode 100644
index 0000000..3fd23aa
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsEntryVer13.java
@@ -0,0 +1,976 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsEntryVer13 implements OFPortStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 112;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static U64 DEFAULT_RX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_RX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_RX_DROPPED = U64.ZERO;
+        private final static U64 DEFAULT_TX_DROPPED = U64.ZERO;
+        private final static U64 DEFAULT_RX_ERRORS = U64.ZERO;
+        private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
+        private final static U64 DEFAULT_RX_FRAME_ERR = U64.ZERO;
+        private final static U64 DEFAULT_RX_OVER_ERR = U64.ZERO;
+        private final static U64 DEFAULT_RX_CRC_ERR = U64.ZERO;
+        private final static U64 DEFAULT_COLLISIONS = U64.ZERO;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final U64 rxPackets;
+    private final U64 txPackets;
+    private final U64 rxBytes;
+    private final U64 txBytes;
+    private final U64 rxDropped;
+    private final U64 txDropped;
+    private final U64 rxErrors;
+    private final U64 txErrors;
+    private final U64 rxFrameErr;
+    private final U64 rxOverErr;
+    private final U64 rxCrcErr;
+    private final U64 collisions;
+    private final long durationSec;
+    private final long durationNsec;
+//
+    // Immutable default instance
+    final static OFPortStatsEntryVer13 DEFAULT = new OFPortStatsEntryVer13(
+        DEFAULT_PORT_NO, DEFAULT_RX_PACKETS, DEFAULT_TX_PACKETS, DEFAULT_RX_BYTES, DEFAULT_TX_BYTES, DEFAULT_RX_DROPPED, DEFAULT_TX_DROPPED, DEFAULT_RX_ERRORS, DEFAULT_TX_ERRORS, DEFAULT_RX_FRAME_ERR, DEFAULT_RX_OVER_ERR, DEFAULT_RX_CRC_ERR, DEFAULT_COLLISIONS, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsEntryVer13(OFPort portNo, U64 rxPackets, U64 txPackets, U64 rxBytes, U64 txBytes, U64 rxDropped, U64 txDropped, U64 rxErrors, U64 txErrors, U64 rxFrameErr, U64 rxOverErr, U64 rxCrcErr, U64 collisions, long durationSec, long durationNsec) {
+        this.portNo = portNo;
+        this.rxPackets = rxPackets;
+        this.txPackets = txPackets;
+        this.rxBytes = rxBytes;
+        this.txBytes = txBytes;
+        this.rxDropped = rxDropped;
+        this.txDropped = txDropped;
+        this.rxErrors = rxErrors;
+        this.txErrors = txErrors;
+        this.rxFrameErr = rxFrameErr;
+        this.rxOverErr = rxOverErr;
+        this.rxCrcErr = rxCrcErr;
+        this.collisions = collisions;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFPortStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsEntry.Builder {
+        final OFPortStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean rxPacketsSet;
+        private U64 rxPackets;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean rxBytesSet;
+        private U64 rxBytes;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean rxDroppedSet;
+        private U64 rxDropped;
+        private boolean txDroppedSet;
+        private U64 txDropped;
+        private boolean rxErrorsSet;
+        private U64 rxErrors;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean rxFrameErrSet;
+        private U64 rxFrameErr;
+        private boolean rxOverErrSet;
+        private U64 rxOverErr;
+        private boolean rxCrcErrSet;
+        private U64 rxCrcErr;
+        private boolean collisionsSet;
+        private U64 collisions;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+
+        BuilderWithParent(OFPortStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxPackets(U64 rxPackets) {
+        this.rxPackets = rxPackets;
+        this.rxPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxBytes(U64 rxBytes) {
+        this.rxBytes = rxBytes;
+        this.rxBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxDropped(U64 rxDropped) {
+        this.rxDropped = rxDropped;
+        this.rxDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxDropped(U64 txDropped) {
+        this.txDropped = txDropped;
+        this.txDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxErrors(U64 rxErrors) {
+        this.rxErrors = rxErrors;
+        this.rxErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxFrameErr(U64 rxFrameErr) {
+        this.rxFrameErr = rxFrameErr;
+        this.rxFrameErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxOverErr(U64 rxOverErr) {
+        this.rxOverErr = rxOverErr;
+        this.rxOverErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxCrcErr(U64 rxCrcErr) {
+        this.rxCrcErr = rxCrcErr;
+        this.rxCrcErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setCollisions(U64 collisions) {
+        this.collisions = collisions;
+        this.collisionsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFPortStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                U64 rxPackets = this.rxPacketsSet ? this.rxPackets : parentMessage.rxPackets;
+                if(rxPackets == null)
+                    throw new NullPointerException("Property rxPackets must not be null");
+                U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
+                if(txPackets == null)
+                    throw new NullPointerException("Property txPackets must not be null");
+                U64 rxBytes = this.rxBytesSet ? this.rxBytes : parentMessage.rxBytes;
+                if(rxBytes == null)
+                    throw new NullPointerException("Property rxBytes must not be null");
+                U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
+                if(txBytes == null)
+                    throw new NullPointerException("Property txBytes must not be null");
+                U64 rxDropped = this.rxDroppedSet ? this.rxDropped : parentMessage.rxDropped;
+                if(rxDropped == null)
+                    throw new NullPointerException("Property rxDropped must not be null");
+                U64 txDropped = this.txDroppedSet ? this.txDropped : parentMessage.txDropped;
+                if(txDropped == null)
+                    throw new NullPointerException("Property txDropped must not be null");
+                U64 rxErrors = this.rxErrorsSet ? this.rxErrors : parentMessage.rxErrors;
+                if(rxErrors == null)
+                    throw new NullPointerException("Property rxErrors must not be null");
+                U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
+                if(txErrors == null)
+                    throw new NullPointerException("Property txErrors must not be null");
+                U64 rxFrameErr = this.rxFrameErrSet ? this.rxFrameErr : parentMessage.rxFrameErr;
+                if(rxFrameErr == null)
+                    throw new NullPointerException("Property rxFrameErr must not be null");
+                U64 rxOverErr = this.rxOverErrSet ? this.rxOverErr : parentMessage.rxOverErr;
+                if(rxOverErr == null)
+                    throw new NullPointerException("Property rxOverErr must not be null");
+                U64 rxCrcErr = this.rxCrcErrSet ? this.rxCrcErr : parentMessage.rxCrcErr;
+                if(rxCrcErr == null)
+                    throw new NullPointerException("Property rxCrcErr must not be null");
+                U64 collisions = this.collisionsSet ? this.collisions : parentMessage.collisions;
+                if(collisions == null)
+                    throw new NullPointerException("Property collisions must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+
+                //
+                return new OFPortStatsEntryVer13(
+                    portNo,
+                    rxPackets,
+                    txPackets,
+                    rxBytes,
+                    txBytes,
+                    rxDropped,
+                    txDropped,
+                    rxErrors,
+                    txErrors,
+                    rxFrameErr,
+                    rxOverErr,
+                    rxCrcErr,
+                    collisions,
+                    durationSec,
+                    durationNsec
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean rxPacketsSet;
+        private U64 rxPackets;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean rxBytesSet;
+        private U64 rxBytes;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean rxDroppedSet;
+        private U64 rxDropped;
+        private boolean txDroppedSet;
+        private U64 txDropped;
+        private boolean rxErrorsSet;
+        private U64 rxErrors;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean rxFrameErrSet;
+        private U64 rxFrameErr;
+        private boolean rxOverErrSet;
+        private U64 rxOverErr;
+        private boolean rxCrcErrSet;
+        private U64 rxCrcErr;
+        private boolean collisionsSet;
+        private U64 collisions;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxPackets() {
+        return rxPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxPackets(U64 rxPackets) {
+        this.rxPackets = rxPackets;
+        this.rxPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxBytes() {
+        return rxBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxBytes(U64 rxBytes) {
+        this.rxBytes = rxBytes;
+        this.rxBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxDropped() {
+        return rxDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxDropped(U64 rxDropped) {
+        this.rxDropped = rxDropped;
+        this.rxDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxDropped() {
+        return txDropped;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxDropped(U64 txDropped) {
+        this.txDropped = txDropped;
+        this.txDroppedSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxErrors() {
+        return rxErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxErrors(U64 rxErrors) {
+        this.rxErrors = rxErrors;
+        this.rxErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxFrameErr() {
+        return rxFrameErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxFrameErr(U64 rxFrameErr) {
+        this.rxFrameErr = rxFrameErr;
+        this.rxFrameErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxOverErr() {
+        return rxOverErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxOverErr(U64 rxOverErr) {
+        this.rxOverErr = rxOverErr;
+        this.rxOverErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getRxCrcErr() {
+        return rxCrcErr;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setRxCrcErr(U64 rxCrcErr) {
+        this.rxCrcErr = rxCrcErr;
+        this.rxCrcErrSet = true;
+        return this;
+    }
+    @Override
+    public U64 getCollisions() {
+        return collisions;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setCollisions(U64 collisions) {
+        this.collisions = collisions;
+        this.collisionsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFPortStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFPortStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            U64 rxPackets = this.rxPacketsSet ? this.rxPackets : DEFAULT_RX_PACKETS;
+            if(rxPackets == null)
+                throw new NullPointerException("Property rxPackets must not be null");
+            U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
+            if(txPackets == null)
+                throw new NullPointerException("Property txPackets must not be null");
+            U64 rxBytes = this.rxBytesSet ? this.rxBytes : DEFAULT_RX_BYTES;
+            if(rxBytes == null)
+                throw new NullPointerException("Property rxBytes must not be null");
+            U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
+            if(txBytes == null)
+                throw new NullPointerException("Property txBytes must not be null");
+            U64 rxDropped = this.rxDroppedSet ? this.rxDropped : DEFAULT_RX_DROPPED;
+            if(rxDropped == null)
+                throw new NullPointerException("Property rxDropped must not be null");
+            U64 txDropped = this.txDroppedSet ? this.txDropped : DEFAULT_TX_DROPPED;
+            if(txDropped == null)
+                throw new NullPointerException("Property txDropped must not be null");
+            U64 rxErrors = this.rxErrorsSet ? this.rxErrors : DEFAULT_RX_ERRORS;
+            if(rxErrors == null)
+                throw new NullPointerException("Property rxErrors must not be null");
+            U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
+            if(txErrors == null)
+                throw new NullPointerException("Property txErrors must not be null");
+            U64 rxFrameErr = this.rxFrameErrSet ? this.rxFrameErr : DEFAULT_RX_FRAME_ERR;
+            if(rxFrameErr == null)
+                throw new NullPointerException("Property rxFrameErr must not be null");
+            U64 rxOverErr = this.rxOverErrSet ? this.rxOverErr : DEFAULT_RX_OVER_ERR;
+            if(rxOverErr == null)
+                throw new NullPointerException("Property rxOverErr must not be null");
+            U64 rxCrcErr = this.rxCrcErrSet ? this.rxCrcErr : DEFAULT_RX_CRC_ERR;
+            if(rxCrcErr == null)
+                throw new NullPointerException("Property rxCrcErr must not be null");
+            U64 collisions = this.collisionsSet ? this.collisions : DEFAULT_COLLISIONS;
+            if(collisions == null)
+                throw new NullPointerException("Property collisions must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+
+
+            return new OFPortStatsEntryVer13(
+                    portNo,
+                    rxPackets,
+                    txPackets,
+                    rxBytes,
+                    txBytes,
+                    rxDropped,
+                    txDropped,
+                    rxErrors,
+                    txErrors,
+                    rxFrameErr,
+                    rxOverErr,
+                    rxCrcErr,
+                    collisions,
+                    durationSec,
+                    durationNsec
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsEntry> {
+        @Override
+        public OFPortStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 rxPackets = U64.ofRaw(bb.readLong());
+            U64 txPackets = U64.ofRaw(bb.readLong());
+            U64 rxBytes = U64.ofRaw(bb.readLong());
+            U64 txBytes = U64.ofRaw(bb.readLong());
+            U64 rxDropped = U64.ofRaw(bb.readLong());
+            U64 txDropped = U64.ofRaw(bb.readLong());
+            U64 rxErrors = U64.ofRaw(bb.readLong());
+            U64 txErrors = U64.ofRaw(bb.readLong());
+            U64 rxFrameErr = U64.ofRaw(bb.readLong());
+            U64 rxOverErr = U64.ofRaw(bb.readLong());
+            U64 rxCrcErr = U64.ofRaw(bb.readLong());
+            U64 collisions = U64.ofRaw(bb.readLong());
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+
+            OFPortStatsEntryVer13 portStatsEntryVer13 = new OFPortStatsEntryVer13(
+                    portNo,
+                      rxPackets,
+                      txPackets,
+                      rxBytes,
+                      txBytes,
+                      rxDropped,
+                      txDropped,
+                      rxErrors,
+                      txErrors,
+                      rxFrameErr,
+                      rxOverErr,
+                      rxCrcErr,
+                      collisions,
+                      durationSec,
+                      durationNsec
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsEntryVer13);
+            return portStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsEntryVer13Funnel FUNNEL = new OFPortStatsEntryVer13Funnel();
+    static class OFPortStatsEntryVer13Funnel implements Funnel<OFPortStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsEntryVer13 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+            message.rxPackets.putTo(sink);
+            message.txPackets.putTo(sink);
+            message.rxBytes.putTo(sink);
+            message.txBytes.putTo(sink);
+            message.rxDropped.putTo(sink);
+            message.txDropped.putTo(sink);
+            message.rxErrors.putTo(sink);
+            message.txErrors.putTo(sink);
+            message.rxFrameErr.putTo(sink);
+            message.rxOverErr.putTo(sink);
+            message.rxCrcErr.putTo(sink);
+            message.collisions.putTo(sink);
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsEntryVer13 message) {
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.rxPackets.getValue());
+            bb.writeLong(message.txPackets.getValue());
+            bb.writeLong(message.rxBytes.getValue());
+            bb.writeLong(message.txBytes.getValue());
+            bb.writeLong(message.rxDropped.getValue());
+            bb.writeLong(message.txDropped.getValue());
+            bb.writeLong(message.rxErrors.getValue());
+            bb.writeLong(message.txErrors.getValue());
+            bb.writeLong(message.rxFrameErr.getValue());
+            bb.writeLong(message.rxOverErr.getValue());
+            bb.writeLong(message.rxCrcErr.getValue());
+            bb.writeLong(message.collisions.getValue());
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsEntryVer13(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("rxPackets=").append(rxPackets);
+        b.append(", ");
+        b.append("txPackets=").append(txPackets);
+        b.append(", ");
+        b.append("rxBytes=").append(rxBytes);
+        b.append(", ");
+        b.append("txBytes=").append(txBytes);
+        b.append(", ");
+        b.append("rxDropped=").append(rxDropped);
+        b.append(", ");
+        b.append("txDropped=").append(txDropped);
+        b.append(", ");
+        b.append("rxErrors=").append(rxErrors);
+        b.append(", ");
+        b.append("txErrors=").append(txErrors);
+        b.append(", ");
+        b.append("rxFrameErr=").append(rxFrameErr);
+        b.append(", ");
+        b.append("rxOverErr=").append(rxOverErr);
+        b.append(", ");
+        b.append("rxCrcErr=").append(rxCrcErr);
+        b.append(", ");
+        b.append("collisions=").append(collisions);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsEntryVer13 other = (OFPortStatsEntryVer13) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if (rxPackets == null) {
+            if (other.rxPackets != null)
+                return false;
+        } else if (!rxPackets.equals(other.rxPackets))
+            return false;
+        if (txPackets == null) {
+            if (other.txPackets != null)
+                return false;
+        } else if (!txPackets.equals(other.txPackets))
+            return false;
+        if (rxBytes == null) {
+            if (other.rxBytes != null)
+                return false;
+        } else if (!rxBytes.equals(other.rxBytes))
+            return false;
+        if (txBytes == null) {
+            if (other.txBytes != null)
+                return false;
+        } else if (!txBytes.equals(other.txBytes))
+            return false;
+        if (rxDropped == null) {
+            if (other.rxDropped != null)
+                return false;
+        } else if (!rxDropped.equals(other.rxDropped))
+            return false;
+        if (txDropped == null) {
+            if (other.txDropped != null)
+                return false;
+        } else if (!txDropped.equals(other.txDropped))
+            return false;
+        if (rxErrors == null) {
+            if (other.rxErrors != null)
+                return false;
+        } else if (!rxErrors.equals(other.rxErrors))
+            return false;
+        if (txErrors == null) {
+            if (other.txErrors != null)
+                return false;
+        } else if (!txErrors.equals(other.txErrors))
+            return false;
+        if (rxFrameErr == null) {
+            if (other.rxFrameErr != null)
+                return false;
+        } else if (!rxFrameErr.equals(other.rxFrameErr))
+            return false;
+        if (rxOverErr == null) {
+            if (other.rxOverErr != null)
+                return false;
+        } else if (!rxOverErr.equals(other.rxOverErr))
+            return false;
+        if (rxCrcErr == null) {
+            if (other.rxCrcErr != null)
+                return false;
+        } else if (!rxCrcErr.equals(other.rxCrcErr))
+            return false;
+        if (collisions == null) {
+            if (other.collisions != null)
+                return false;
+        } else if (!collisions.equals(other.collisions))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime * result + ((rxPackets == null) ? 0 : rxPackets.hashCode());
+        result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
+        result = prime * result + ((rxBytes == null) ? 0 : rxBytes.hashCode());
+        result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
+        result = prime * result + ((rxDropped == null) ? 0 : rxDropped.hashCode());
+        result = prime * result + ((txDropped == null) ? 0 : txDropped.hashCode());
+        result = prime * result + ((rxErrors == null) ? 0 : rxErrors.hashCode());
+        result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
+        result = prime * result + ((rxFrameErr == null) ? 0 : rxFrameErr.hashCode());
+        result = prime * result + ((rxOverErr == null) ? 0 : rxOverErr.hashCode());
+        result = prime * result + ((rxCrcErr == null) ? 0 : rxCrcErr.hashCode());
+        result = prime * result + ((collisions == null) ? 0 : collisions.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsReplyVer13.java
new file mode 100644
index 0000000..b71da30
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsReplyVer13 implements OFPortStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFPortStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFPortStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFPortStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFPortStatsReplyVer13 DEFAULT = new OFPortStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFPortStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFPortStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsReply.Builder {
+        final OFPortStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortStatsEntry> entries;
+
+        BuilderWithParent(OFPortStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setEntries(List<OFPortStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFPortStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFPortStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFPortStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPortStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFPortStatsReply.Builder setEntries(List<OFPortStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFPortStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFPortStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsReply> {
+        @Override
+        public OFPortStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 4
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x4)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFPortStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPortStatsEntryVer13.READER);
+
+            OFPortStatsReplyVer13 portStatsReplyVer13 = new OFPortStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsReplyVer13);
+            return portStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsReplyVer13Funnel FUNNEL = new OFPortStatsReplyVer13Funnel();
+    static class OFPortStatsReplyVer13Funnel implements Funnel<OFPortStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 4
+            sink.putShort((short) 0x4);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 4
+            bb.writeShort((short) 0x4);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsReplyVer13 other = (OFPortStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsRequestVer13.java
new file mode 100644
index 0000000..276b8e6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatsRequestVer13.java
@@ -0,0 +1,410 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatsRequestVer13 implements OFPortStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+//
+    // Immutable default instance
+    final static OFPortStatsRequestVer13 DEFAULT = new OFPortStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+
+
+    public OFPortStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatsRequest.Builder {
+        final OFPortStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+        BuilderWithParent(OFPortStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+
+                //
+                return new OFPortStatsRequestVer13(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.PORT;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFPortStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+
+
+            return new OFPortStatsRequestVer13(
+                    xid,
+                    flags,
+                    portNo
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatsRequest> {
+        @Override
+        public OFPortStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 4
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x4)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.PORT(4), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFPortStatsRequestVer13 portStatsRequestVer13 = new OFPortStatsRequestVer13(
+                    xid,
+                      flags,
+                      portNo
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatsRequestVer13);
+            return portStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatsRequestVer13Funnel FUNNEL = new OFPortStatsRequestVer13Funnel();
+    static class OFPortStatsRequestVer13Funnel implements Funnel<OFPortStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 4
+            sink.putShort((short) 0x4);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.portNo.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 4
+            bb.writeShort((short) 0x4);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.portNo.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatsRequestVer13 other = (OFPortStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatusVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatusVer13.java
new file mode 100644
index 0000000..a671c49
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatusVer13.java
@@ -0,0 +1,377 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFPortStatusVer13 implements OFPortStatus {
+    private static final Logger logger = LoggerFactory.getLogger(OFPortStatusVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 80;
+
+        private final static long DEFAULT_XID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final OFPortReason reason;
+    private final OFPortDesc desc;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFPortStatusVer13(long xid, OFPortReason reason, OFPortDesc desc) {
+        this.xid = xid;
+        this.reason = reason;
+        this.desc = desc;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+
+
+    public OFPortStatus.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFPortStatus.Builder {
+        final OFPortStatusVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reasonSet;
+        private OFPortReason reason;
+        private boolean descSet;
+        private OFPortDesc desc;
+
+        BuilderWithParent(OFPortStatusVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortStatus.Builder setReason(OFPortReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+    @Override
+    public OFPortStatus.Builder setDesc(OFPortDesc desc) {
+        this.desc = desc;
+        this.descSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFPortStatus build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPortReason reason = this.reasonSet ? this.reason : parentMessage.reason;
+                if(reason == null)
+                    throw new NullPointerException("Property reason must not be null");
+                OFPortDesc desc = this.descSet ? this.desc : parentMessage.desc;
+                if(desc == null)
+                    throw new NullPointerException("Property desc must not be null");
+
+                //
+                return new OFPortStatusVer13(
+                    xid,
+                    reason,
+                    desc
+                );
+        }
+
+    }
+
+    static class Builder implements OFPortStatus.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean reasonSet;
+        private OFPortReason reason;
+        private boolean descSet;
+        private OFPortDesc desc;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.PORT_STATUS;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPortStatus.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPortReason getReason() {
+        return reason;
+    }
+
+    @Override
+    public OFPortStatus.Builder setReason(OFPortReason reason) {
+        this.reason = reason;
+        this.reasonSet = true;
+        return this;
+    }
+    @Override
+    public OFPortDesc getDesc() {
+        return desc;
+    }
+
+    @Override
+    public OFPortStatus.Builder setDesc(OFPortDesc desc) {
+        this.desc = desc;
+        this.descSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFPortStatus build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.reasonSet)
+                throw new IllegalStateException("Property reason doesn't have default value -- must be set");
+            if(reason == null)
+                throw new NullPointerException("Property reason must not be null");
+            if(!this.descSet)
+                throw new IllegalStateException("Property desc doesn't have default value -- must be set");
+            if(desc == null)
+                throw new NullPointerException("Property desc must not be null");
+
+
+            return new OFPortStatusVer13(
+                    xid,
+                    reason,
+                    desc
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFPortStatus> {
+        @Override
+        public OFPortStatus readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 12
+            byte type = bb.readByte();
+            if(type != (byte) 0xc)
+                throw new OFParseError("Wrong type: Expected=OFType.PORT_STATUS(12), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 80)
+                throw new OFParseError("Wrong length: Expected=80(80), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPortReason reason = OFPortReasonSerializerVer13.readFrom(bb);
+            // pad: 7 bytes
+            bb.skipBytes(7);
+            OFPortDesc desc = OFPortDescVer13.READER.readFrom(bb);
+
+            OFPortStatusVer13 portStatusVer13 = new OFPortStatusVer13(
+                    xid,
+                      reason,
+                      desc
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", portStatusVer13);
+            return portStatusVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFPortStatusVer13Funnel FUNNEL = new OFPortStatusVer13Funnel();
+    static class OFPortStatusVer13Funnel implements Funnel<OFPortStatusVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFPortStatusVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 12
+            sink.putByte((byte) 0xc);
+            // fixed value property length = 80
+            sink.putShort((short) 0x50);
+            sink.putLong(message.xid);
+            OFPortReasonSerializerVer13.putTo(message.reason, sink);
+            // skip pad (7 bytes)
+            message.desc.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFPortStatusVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFPortStatusVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 12
+            bb.writeByte((byte) 0xc);
+            // fixed value property length = 80
+            bb.writeShort((short) 0x50);
+            bb.writeInt(U32.t(message.xid));
+            OFPortReasonSerializerVer13.writeTo(bb, message.reason);
+            // pad: 7 bytes
+            bb.writeZero(7);
+            message.desc.writeTo(bb);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFPortStatusVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("reason=").append(reason);
+        b.append(", ");
+        b.append("desc=").append(desc);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFPortStatusVer13 other = (OFPortStatusVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (reason == null) {
+            if (other.reason != null)
+                return false;
+        } else if (!reason.equals(other.reason))
+            return false;
+        if (desc == null) {
+            if (other.desc != null)
+                return false;
+        } else if (!desc.equals(other.desc))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((reason == null) ? 0 : reason.hashCode());
+        result = prime * result + ((desc == null) ? 0 : desc.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueGetConfigReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueGetConfigReplyVer13.java
new file mode 100644
index 0000000..72f9e32
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueGetConfigReplyVer13.java
@@ -0,0 +1,388 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueGetConfigReplyVer13 implements OFQueueGetConfigReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueGetConfigReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+        private final static List<OFPacketQueue> DEFAULT_QUEUES = ImmutableList.<OFPacketQueue>of();
+
+    // OF message fields
+    private final long xid;
+    private final OFPort port;
+    private final List<OFPacketQueue> queues;
+//
+    // Immutable default instance
+    final static OFQueueGetConfigReplyVer13 DEFAULT = new OFQueueGetConfigReplyVer13(
+        DEFAULT_XID, DEFAULT_PORT, DEFAULT_QUEUES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueGetConfigReplyVer13(long xid, OFPort port, List<OFPacketQueue> queues) {
+        this.xid = xid;
+        this.port = port;
+        this.queues = queues;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+
+
+    public OFQueueGetConfigReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueGetConfigReply.Builder {
+        final OFQueueGetConfigReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+        private boolean queuesSet;
+        private List<OFPacketQueue> queues;
+
+        BuilderWithParent(OFQueueGetConfigReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setQueues(List<OFPacketQueue> queues) {
+        this.queues = queues;
+        this.queuesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueGetConfigReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+                List<OFPacketQueue> queues = this.queuesSet ? this.queues : parentMessage.queues;
+                if(queues == null)
+                    throw new NullPointerException("Property queues must not be null");
+
+                //
+                return new OFQueueGetConfigReplyVer13(
+                    xid,
+                    port,
+                    queues
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueGetConfigReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+        private boolean queuesSet;
+        private List<OFPacketQueue> queues;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+    @Override
+    public List<OFPacketQueue> getQueues() {
+        return queues;
+    }
+
+    @Override
+    public OFQueueGetConfigReply.Builder setQueues(List<OFPacketQueue> queues) {
+        this.queues = queues;
+        this.queuesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueGetConfigReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+            List<OFPacketQueue> queues = this.queuesSet ? this.queues : DEFAULT_QUEUES;
+            if(queues == null)
+                throw new NullPointerException("Property queues must not be null");
+
+
+            return new OFQueueGetConfigReplyVer13(
+                    xid,
+                    port,
+                    queues
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueGetConfigReply> {
+        @Override
+        public OFQueueGetConfigReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 23
+            byte type = bb.readByte();
+            if(type != (byte) 0x17)
+                throw new OFParseError("Wrong type: Expected=OFType.QUEUE_GET_CONFIG_REPLY(23), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort port = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFPacketQueue> queues = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFPacketQueueVer13.READER);
+
+            OFQueueGetConfigReplyVer13 queueGetConfigReplyVer13 = new OFQueueGetConfigReplyVer13(
+                    xid,
+                      port,
+                      queues
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueGetConfigReplyVer13);
+            return queueGetConfigReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueGetConfigReplyVer13Funnel FUNNEL = new OFQueueGetConfigReplyVer13Funnel();
+    static class OFQueueGetConfigReplyVer13Funnel implements Funnel<OFQueueGetConfigReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueGetConfigReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 23
+            sink.putByte((byte) 0x17);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            message.port.putTo(sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.queues, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueGetConfigReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueGetConfigReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 23
+            bb.writeByte((byte) 0x17);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            message.port.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.queues);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueGetConfigReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(", ");
+        b.append("queues=").append(queues);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueGetConfigReplyVer13 other = (OFQueueGetConfigReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        if (queues == null) {
+            if (other.queues != null)
+                return false;
+        } else if (!queues.equals(other.queues))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        result = prime * result + ((queues == null) ? 0 : queues.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueGetConfigRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueGetConfigRequestVer13.java
new file mode 100644
index 0000000..91613ea
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueGetConfigRequestVer13.java
@@ -0,0 +1,327 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueGetConfigRequestVer13 implements OFQueueGetConfigRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueGetConfigRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFPort DEFAULT_PORT = OFPort.ANY;
+
+    // OF message fields
+    private final long xid;
+    private final OFPort port;
+//
+    // Immutable default instance
+    final static OFQueueGetConfigRequestVer13 DEFAULT = new OFQueueGetConfigRequestVer13(
+        DEFAULT_XID, DEFAULT_PORT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueGetConfigRequestVer13(long xid, OFPort port) {
+        this.xid = xid;
+        this.port = port;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+
+
+    public OFQueueGetConfigRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueGetConfigRequest.Builder {
+        final OFQueueGetConfigRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+
+        BuilderWithParent(OFQueueGetConfigRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueGetConfigRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFPort port = this.portSet ? this.port : parentMessage.port;
+                if(port == null)
+                    throw new NullPointerException("Property port must not be null");
+
+                //
+                return new OFQueueGetConfigRequestVer13(
+                    xid,
+                    port
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueGetConfigRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean portSet;
+        private OFPort port;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.QUEUE_GET_CONFIG_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPort() {
+        return port;
+    }
+
+    @Override
+    public OFQueueGetConfigRequest.Builder setPort(OFPort port) {
+        this.port = port;
+        this.portSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueGetConfigRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            OFPort port = this.portSet ? this.port : DEFAULT_PORT;
+            if(port == null)
+                throw new NullPointerException("Property port must not be null");
+
+
+            return new OFQueueGetConfigRequestVer13(
+                    xid,
+                    port
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueGetConfigRequest> {
+        @Override
+        public OFQueueGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 22
+            byte type = bb.readByte();
+            if(type != (byte) 0x16)
+                throw new OFParseError("Wrong type: Expected=OFType.QUEUE_GET_CONFIG_REQUEST(22), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFPort port = OFPort.read4Bytes(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFQueueGetConfigRequestVer13 queueGetConfigRequestVer13 = new OFQueueGetConfigRequestVer13(
+                    xid,
+                      port
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueGetConfigRequestVer13);
+            return queueGetConfigRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueGetConfigRequestVer13Funnel FUNNEL = new OFQueueGetConfigRequestVer13Funnel();
+    static class OFQueueGetConfigRequestVer13Funnel implements Funnel<OFQueueGetConfigRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueGetConfigRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 22
+            sink.putByte((byte) 0x16);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            message.port.putTo(sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueGetConfigRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueGetConfigRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 22
+            bb.writeByte((byte) 0x16);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            message.port.write4Bytes(bb);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueGetConfigRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("port=").append(port);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueGetConfigRequestVer13 other = (OFQueueGetConfigRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (port == null) {
+            if (other.port != null)
+                return false;
+        } else if (!port.equals(other.port))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((port == null) ? 0 : port.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueOpFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueOpFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..621e5f4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueOpFailedCodeSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFQueueOpFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFQueueOpFailedCodeSerializerVer13 {
+
+    public final static short BAD_PORT_VAL = (short) 0x0;
+    public final static short BAD_QUEUE_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+
+    public static OFQueueOpFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFQueueOpFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFQueueOpFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFQueueOpFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_PORT_VAL:
+                return OFQueueOpFailedCode.BAD_PORT;
+            case BAD_QUEUE_VAL:
+                return OFQueueOpFailedCode.BAD_QUEUE;
+            case EPERM_VAL:
+                return OFQueueOpFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFQueueOpFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFQueueOpFailedCode e) {
+        switch(e) {
+            case BAD_PORT:
+                return BAD_PORT_VAL;
+            case BAD_QUEUE:
+                return BAD_QUEUE_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFQueueOpFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueOpFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueOpFailedErrorMsgVer13.java
new file mode 100644
index 0000000..7d71584
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueOpFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueOpFailedErrorMsgVer13 implements OFQueueOpFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueOpFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFQueueOpFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueOpFailedErrorMsgVer13(long xid, OFQueueOpFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFQueueOpFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueOpFailedErrorMsg.Builder {
+        final OFQueueOpFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFQueueOpFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFQueueOpFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setCode(OFQueueOpFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueOpFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFQueueOpFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFQueueOpFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueOpFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFQueueOpFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.QUEUE_OP_FAILED;
+    }
+
+    @Override
+    public OFQueueOpFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setCode(OFQueueOpFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFQueueOpFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueOpFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFQueueOpFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueOpFailedErrorMsg> {
+        @Override
+        public OFQueueOpFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 9
+            short errType = bb.readShort();
+            if(errType != (short) 0x9)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.QUEUE_OP_FAILED(9), got="+errType);
+            OFQueueOpFailedCode code = OFQueueOpFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFQueueOpFailedErrorMsgVer13 queueOpFailedErrorMsgVer13 = new OFQueueOpFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueOpFailedErrorMsgVer13);
+            return queueOpFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueOpFailedErrorMsgVer13Funnel FUNNEL = new OFQueueOpFailedErrorMsgVer13Funnel();
+    static class OFQueueOpFailedErrorMsgVer13Funnel implements Funnel<OFQueueOpFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueOpFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 9
+            sink.putShort((short) 0x9);
+            OFQueueOpFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueOpFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueOpFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 9
+            bb.writeShort((short) 0x9);
+            OFQueueOpFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueOpFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueOpFailedErrorMsgVer13 other = (OFQueueOpFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropExperimenterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropExperimenterVer13.java
new file mode 100644
index 0000000..2add383
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropExperimenterVer13.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFQueuePropExperimenterVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFQueuePropExperimenterVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFQueuePropExperimenter> {
+        @Override
+        public OFQueuePropExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property type == 0xffff
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=0xffff(0xffff), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int experimenter = bb.readInt();
+            bb.readerIndex(start);
+            switch(experimenter) {
+               default:
+                   throw new OFParseError("Unknown value for discriminator experimenter of class OFQueuePropExperimenterVer13: " + experimenter);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropMaxRateVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropMaxRateVer13.java
new file mode 100644
index 0000000..9f4b824
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropMaxRateVer13.java
@@ -0,0 +1,270 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueuePropMaxRateVer13 implements OFQueuePropMaxRate {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueuePropMaxRateVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static int DEFAULT_RATE = 0x0;
+
+    // OF message fields
+    private final int rate;
+//
+    // Immutable default instance
+    final static OFQueuePropMaxRateVer13 DEFAULT = new OFQueuePropMaxRateVer13(
+        DEFAULT_RATE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueuePropMaxRateVer13(int rate) {
+        this.rate = rate;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFQueuePropMaxRate.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueuePropMaxRate.Builder {
+        final OFQueuePropMaxRateVer13 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+        BuilderWithParent(OFQueuePropMaxRateVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMaxRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFQueuePropMaxRate build() {
+                int rate = this.rateSet ? this.rate : parentMessage.rate;
+
+                //
+                return new OFQueuePropMaxRateVer13(
+                    rate
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueuePropMaxRate.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMaxRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFQueuePropMaxRate build() {
+            int rate = this.rateSet ? this.rate : DEFAULT_RATE;
+
+
+            return new OFQueuePropMaxRateVer13(
+                    rate
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueuePropMaxRate> {
+        @Override
+        public OFQueuePropMaxRate readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=0x2(0x2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int rate = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFQueuePropMaxRateVer13 queuePropMaxRateVer13 = new OFQueuePropMaxRateVer13(
+                    rate
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queuePropMaxRateVer13);
+            return queuePropMaxRateVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueuePropMaxRateVer13Funnel FUNNEL = new OFQueuePropMaxRateVer13Funnel();
+    static class OFQueuePropMaxRateVer13Funnel implements Funnel<OFQueuePropMaxRateVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueuePropMaxRateVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x2
+            sink.putShort((short) 0x2);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // skip pad (4 bytes)
+            sink.putInt(message.rate);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueuePropMaxRateVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueuePropMaxRateVer13 message) {
+            // fixed value property type = 0x2
+            bb.writeShort((short) 0x2);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeShort(U16.t(message.rate));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueuePropMaxRateVer13(");
+        b.append("rate=").append(rate);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueuePropMaxRateVer13 other = (OFQueuePropMaxRateVer13) obj;
+
+        if( rate != other.rate)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + rate;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropMinRateVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropMinRateVer13.java
new file mode 100644
index 0000000..c0730c4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropMinRateVer13.java
@@ -0,0 +1,270 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueuePropMinRateVer13 implements OFQueuePropMinRate {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueuePropMinRateVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static int DEFAULT_RATE = 0x0;
+
+    // OF message fields
+    private final int rate;
+//
+    // Immutable default instance
+    final static OFQueuePropMinRateVer13 DEFAULT = new OFQueuePropMinRateVer13(
+        DEFAULT_RATE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueuePropMinRateVer13(int rate) {
+        this.rate = rate;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFQueuePropMinRate.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueuePropMinRate.Builder {
+        final OFQueuePropMinRateVer13 parentMessage;
+
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+        BuilderWithParent(OFQueuePropMinRateVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMinRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFQueuePropMinRate build() {
+                int rate = this.rateSet ? this.rate : parentMessage.rate;
+
+                //
+                return new OFQueuePropMinRateVer13(
+                    rate
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueuePropMinRate.Builder {
+        // OF message fields
+        private boolean rateSet;
+        private int rate;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public int getRate() {
+        return rate;
+    }
+
+    @Override
+    public OFQueuePropMinRate.Builder setRate(int rate) {
+        this.rate = rate;
+        this.rateSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFQueuePropMinRate build() {
+            int rate = this.rateSet ? this.rate : DEFAULT_RATE;
+
+
+            return new OFQueuePropMinRateVer13(
+                    rate
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueuePropMinRate> {
+        @Override
+        public OFQueuePropMinRate readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            int rate = U16.f(bb.readShort());
+            // pad: 6 bytes
+            bb.skipBytes(6);
+
+            OFQueuePropMinRateVer13 queuePropMinRateVer13 = new OFQueuePropMinRateVer13(
+                    rate
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queuePropMinRateVer13);
+            return queuePropMinRateVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueuePropMinRateVer13Funnel FUNNEL = new OFQueuePropMinRateVer13Funnel();
+    static class OFQueuePropMinRateVer13Funnel implements Funnel<OFQueuePropMinRateVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueuePropMinRateVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            // skip pad (4 bytes)
+            sink.putInt(message.rate);
+            // skip pad (6 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueuePropMinRateVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueuePropMinRateVer13 message) {
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeShort(U16.t(message.rate));
+            // pad: 6 bytes
+            bb.writeZero(6);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueuePropMinRateVer13(");
+        b.append("rate=").append(rate);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueuePropMinRateVer13 other = (OFQueuePropMinRateVer13) obj;
+
+        if( rate != other.rate)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + rate;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropVer13.java
new file mode 100644
index 0000000..1d9abc8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropVer13.java
@@ -0,0 +1,59 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFQueuePropVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 8;
+
+
+    public final static OFQueuePropVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFQueueProp> {
+        @Override
+        public OFQueueProp readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFQueuePropMinRateVer13
+                   return OFQueuePropMinRateVer13.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value 0xffff=0xffff for class OFQueuePropExperimenterVer13
+                   return OFQueuePropExperimenterVer13.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value 0x2=0x2 for class OFQueuePropMaxRateVer13
+                   return OFQueuePropMaxRateVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFQueuePropVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropertiesSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropertiesSerializerVer13.java
new file mode 100644
index 0000000..b2899a4
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropertiesSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFQueueProperties;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFQueuePropertiesSerializerVer13 {
+
+    public final static short MIN_RATE_VAL = (short) 0x1;
+    public final static short MAX_RATE_VAL = (short) 0x2;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFQueueProperties readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFQueueProperties e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFQueueProperties e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFQueueProperties ofWireValue(short val) {
+        switch(val) {
+            case MIN_RATE_VAL:
+                return OFQueueProperties.MIN_RATE;
+            case MAX_RATE_VAL:
+                return OFQueueProperties.MAX_RATE;
+            case EXPERIMENTER_VAL:
+                return OFQueueProperties.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFQueueProperties in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFQueueProperties e) {
+        switch(e) {
+            case MIN_RATE:
+                return MIN_RATE_VAL;
+            case MAX_RATE:
+                return MAX_RATE_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFQueueProperties in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropsVer13.java
new file mode 100644
index 0000000..96f1b3e
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueuePropsVer13.java
@@ -0,0 +1,60 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_factory_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+
+
+public class OFQueuePropsVer13 implements OFQueueProps {
+    public final static OFQueuePropsVer13 INSTANCE = new OFQueuePropsVer13();
+
+
+
+
+    public OFQueuePropMinRate.Builder buildMinRate() {
+        return new OFQueuePropMinRateVer13.Builder();
+    }
+    public OFQueuePropMinRate minRate(int rate) {
+        return new OFQueuePropMinRateVer13(
+                rate
+                    );
+    }
+
+    public OFQueuePropMaxRate.Builder buildMaxRate() {
+        return new OFQueuePropMaxRateVer13.Builder();
+    }
+    public OFQueuePropMaxRate maxRate(int rate) {
+        return new OFQueuePropMaxRateVer13(
+                rate
+                    );
+    }
+
+    public OFMessageReader<OFQueueProp> getReader() {
+        return OFQueuePropVer13.READER;
+    }
+
+
+    public OFVersion getVersion() {
+            return OFVersion.OF_13;
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsEntryVer13.java
new file mode 100644
index 0000000..10b9c3a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsEntryVer13.java
@@ -0,0 +1,532 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsEntryVer13 implements OFQueueStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 40;
+
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+        private final static U64 DEFAULT_TX_BYTES = U64.ZERO;
+        private final static U64 DEFAULT_TX_PACKETS = U64.ZERO;
+        private final static U64 DEFAULT_TX_ERRORS = U64.ZERO;
+        private final static long DEFAULT_DURATION_SEC = 0x0L;
+        private final static long DEFAULT_DURATION_NSEC = 0x0L;
+
+    // OF message fields
+    private final OFPort portNo;
+    private final long queueId;
+    private final U64 txBytes;
+    private final U64 txPackets;
+    private final U64 txErrors;
+    private final long durationSec;
+    private final long durationNsec;
+//
+    // Immutable default instance
+    final static OFQueueStatsEntryVer13 DEFAULT = new OFQueueStatsEntryVer13(
+        DEFAULT_PORT_NO, DEFAULT_QUEUE_ID, DEFAULT_TX_BYTES, DEFAULT_TX_PACKETS, DEFAULT_TX_ERRORS, DEFAULT_DURATION_SEC, DEFAULT_DURATION_NSEC
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsEntryVer13(OFPort portNo, long queueId, U64 txBytes, U64 txPackets, U64 txErrors, long durationSec, long durationNsec) {
+        this.portNo = portNo;
+        this.queueId = queueId;
+        this.txBytes = txBytes;
+        this.txPackets = txPackets;
+        this.txErrors = txErrors;
+        this.durationSec = durationSec;
+        this.durationNsec = durationNsec;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFQueueStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsEntry.Builder {
+        final OFQueueStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+
+        BuilderWithParent(OFQueueStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFQueueStatsEntry build() {
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+                U64 txBytes = this.txBytesSet ? this.txBytes : parentMessage.txBytes;
+                if(txBytes == null)
+                    throw new NullPointerException("Property txBytes must not be null");
+                U64 txPackets = this.txPacketsSet ? this.txPackets : parentMessage.txPackets;
+                if(txPackets == null)
+                    throw new NullPointerException("Property txPackets must not be null");
+                U64 txErrors = this.txErrorsSet ? this.txErrors : parentMessage.txErrors;
+                if(txErrors == null)
+                    throw new NullPointerException("Property txErrors must not be null");
+                long durationSec = this.durationSecSet ? this.durationSec : parentMessage.durationSec;
+                long durationNsec = this.durationNsecSet ? this.durationNsec : parentMessage.durationNsec;
+
+                //
+                return new OFQueueStatsEntryVer13(
+                    portNo,
+                    queueId,
+                    txBytes,
+                    txPackets,
+                    txErrors,
+                    durationSec,
+                    durationNsec
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsEntry.Builder {
+        // OF message fields
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+        private boolean txBytesSet;
+        private U64 txBytes;
+        private boolean txPacketsSet;
+        private U64 txPackets;
+        private boolean txErrorsSet;
+        private U64 txErrors;
+        private boolean durationSecSet;
+        private long durationSec;
+        private boolean durationNsecSet;
+        private long durationNsec;
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxBytes() {
+        return txBytes;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxBytes(U64 txBytes) {
+        this.txBytes = txBytes;
+        this.txBytesSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxPackets() {
+        return txPackets;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxPackets(U64 txPackets) {
+        this.txPackets = txPackets;
+        this.txPacketsSet = true;
+        return this;
+    }
+    @Override
+    public U64 getTxErrors() {
+        return txErrors;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setTxErrors(U64 txErrors) {
+        this.txErrors = txErrors;
+        this.txErrorsSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationSec() {
+        return durationSec;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationSec(long durationSec) {
+        this.durationSec = durationSec;
+        this.durationSecSet = true;
+        return this;
+    }
+    @Override
+    public long getDurationNsec() {
+        return durationNsec;
+    }
+
+    @Override
+    public OFQueueStatsEntry.Builder setDurationNsec(long durationNsec) {
+        this.durationNsec = durationNsec;
+        this.durationNsecSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFQueueStatsEntry build() {
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+            U64 txBytes = this.txBytesSet ? this.txBytes : DEFAULT_TX_BYTES;
+            if(txBytes == null)
+                throw new NullPointerException("Property txBytes must not be null");
+            U64 txPackets = this.txPacketsSet ? this.txPackets : DEFAULT_TX_PACKETS;
+            if(txPackets == null)
+                throw new NullPointerException("Property txPackets must not be null");
+            U64 txErrors = this.txErrorsSet ? this.txErrors : DEFAULT_TX_ERRORS;
+            if(txErrors == null)
+                throw new NullPointerException("Property txErrors must not be null");
+            long durationSec = this.durationSecSet ? this.durationSec : DEFAULT_DURATION_SEC;
+            long durationNsec = this.durationNsecSet ? this.durationNsec : DEFAULT_DURATION_NSEC;
+
+
+            return new OFQueueStatsEntryVer13(
+                    portNo,
+                    queueId,
+                    txBytes,
+                    txPackets,
+                    txErrors,
+                    durationSec,
+                    durationNsec
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsEntry> {
+        @Override
+        public OFQueueStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            OFPort portNo = OFPort.read4Bytes(bb);
+            long queueId = U32.f(bb.readInt());
+            U64 txBytes = U64.ofRaw(bb.readLong());
+            U64 txPackets = U64.ofRaw(bb.readLong());
+            U64 txErrors = U64.ofRaw(bb.readLong());
+            long durationSec = U32.f(bb.readInt());
+            long durationNsec = U32.f(bb.readInt());
+
+            OFQueueStatsEntryVer13 queueStatsEntryVer13 = new OFQueueStatsEntryVer13(
+                    portNo,
+                      queueId,
+                      txBytes,
+                      txPackets,
+                      txErrors,
+                      durationSec,
+                      durationNsec
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsEntryVer13);
+            return queueStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsEntryVer13Funnel FUNNEL = new OFQueueStatsEntryVer13Funnel();
+    static class OFQueueStatsEntryVer13Funnel implements Funnel<OFQueueStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsEntryVer13 message, PrimitiveSink sink) {
+            message.portNo.putTo(sink);
+            sink.putLong(message.queueId);
+            message.txBytes.putTo(sink);
+            message.txPackets.putTo(sink);
+            message.txErrors.putTo(sink);
+            sink.putLong(message.durationSec);
+            sink.putLong(message.durationNsec);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsEntryVer13 message) {
+            message.portNo.write4Bytes(bb);
+            bb.writeInt(U32.t(message.queueId));
+            bb.writeLong(message.txBytes.getValue());
+            bb.writeLong(message.txPackets.getValue());
+            bb.writeLong(message.txErrors.getValue());
+            bb.writeInt(U32.t(message.durationSec));
+            bb.writeInt(U32.t(message.durationNsec));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsEntryVer13(");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(", ");
+        b.append("txBytes=").append(txBytes);
+        b.append(", ");
+        b.append("txPackets=").append(txPackets);
+        b.append(", ");
+        b.append("txErrors=").append(txErrors);
+        b.append(", ");
+        b.append("durationSec=").append(durationSec);
+        b.append(", ");
+        b.append("durationNsec=").append(durationNsec);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsEntryVer13 other = (OFQueueStatsEntryVer13) obj;
+
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        if (txBytes == null) {
+            if (other.txBytes != null)
+                return false;
+        } else if (!txBytes.equals(other.txBytes))
+            return false;
+        if (txPackets == null) {
+            if (other.txPackets != null)
+                return false;
+        } else if (!txPackets.equals(other.txPackets))
+            return false;
+        if (txErrors == null) {
+            if (other.txErrors != null)
+                return false;
+        } else if (!txErrors.equals(other.txErrors))
+            return false;
+        if( durationSec != other.durationSec)
+            return false;
+        if( durationNsec != other.durationNsec)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        result = prime * result + ((txBytes == null) ? 0 : txBytes.hashCode());
+        result = prime * result + ((txPackets == null) ? 0 : txPackets.hashCode());
+        result = prime * result + ((txErrors == null) ? 0 : txErrors.hashCode());
+        result = prime *  (int) (durationSec ^ (durationSec >>> 32));
+        result = prime *  (int) (durationNsec ^ (durationNsec >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsReplyVer13.java
new file mode 100644
index 0000000..c9353be
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsReplyVer13 implements OFQueueStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFQueueStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFQueueStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFQueueStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFQueueStatsReplyVer13 DEFAULT = new OFQueueStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFQueueStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFQueueStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsReply.Builder {
+        final OFQueueStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFQueueStatsEntry> entries;
+
+        BuilderWithParent(OFQueueStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setEntries(List<OFQueueStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFQueueStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFQueueStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFQueueStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFQueueStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFQueueStatsReply.Builder setEntries(List<OFQueueStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFQueueStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFQueueStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsReply> {
+        @Override
+        public OFQueueStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 5
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x5)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.QUEUE(5), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFQueueStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFQueueStatsEntryVer13.READER);
+
+            OFQueueStatsReplyVer13 queueStatsReplyVer13 = new OFQueueStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsReplyVer13);
+            return queueStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsReplyVer13Funnel FUNNEL = new OFQueueStatsReplyVer13Funnel();
+    static class OFQueueStatsReplyVer13Funnel implements Funnel<OFQueueStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 5
+            sink.putShort((short) 0x5);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 5
+            bb.writeShort((short) 0x5);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsReplyVer13 other = (OFQueueStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsRequestVer13.java
new file mode 100644
index 0000000..c7c6829
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFQueueStatsRequestVer13.java
@@ -0,0 +1,452 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFQueueStatsRequestVer13 implements OFQueueStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFQueueStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
+        private final static long DEFAULT_QUEUE_ID = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final OFPort portNo;
+    private final long queueId;
+//
+    // Immutable default instance
+    final static OFQueueStatsRequestVer13 DEFAULT = new OFQueueStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_PORT_NO, DEFAULT_QUEUE_ID
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFQueueStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, OFPort portNo, long queueId) {
+        this.xid = xid;
+        this.flags = flags;
+        this.portNo = portNo;
+        this.queueId = queueId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+
+
+    public OFQueueStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFQueueStatsRequest.Builder {
+        final OFQueueStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+
+        BuilderWithParent(OFQueueStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFQueueStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
+                if(portNo == null)
+                    throw new NullPointerException("Property portNo must not be null");
+                long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
+
+                //
+                return new OFQueueStatsRequestVer13(
+                    xid,
+                    flags,
+                    portNo,
+                    queueId
+                );
+        }
+
+    }
+
+    static class Builder implements OFQueueStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean portNoSet;
+        private OFPort portNo;
+        private boolean queueIdSet;
+        private long queueId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.QUEUE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public OFPort getPortNo() {
+        return portNo;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setPortNo(OFPort portNo) {
+        this.portNo = portNo;
+        this.portNoSet = true;
+        return this;
+    }
+    @Override
+    public long getQueueId() {
+        return queueId;
+    }
+
+    @Override
+    public OFQueueStatsRequest.Builder setQueueId(long queueId) {
+        this.queueId = queueId;
+        this.queueIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFQueueStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
+            if(portNo == null)
+                throw new NullPointerException("Property portNo must not be null");
+            long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
+
+
+            return new OFQueueStatsRequestVer13(
+                    xid,
+                    flags,
+                    portNo,
+                    queueId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFQueueStatsRequest> {
+        @Override
+        public OFQueueStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 5
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x5)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.QUEUE(5), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            OFPort portNo = OFPort.read4Bytes(bb);
+            long queueId = U32.f(bb.readInt());
+
+            OFQueueStatsRequestVer13 queueStatsRequestVer13 = new OFQueueStatsRequestVer13(
+                    xid,
+                      flags,
+                      portNo,
+                      queueId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", queueStatsRequestVer13);
+            return queueStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFQueueStatsRequestVer13Funnel FUNNEL = new OFQueueStatsRequestVer13Funnel();
+    static class OFQueueStatsRequestVer13Funnel implements Funnel<OFQueueStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFQueueStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 5
+            sink.putShort((short) 0x5);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            message.portNo.putTo(sink);
+            sink.putLong(message.queueId);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFQueueStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFQueueStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 5
+            bb.writeShort((short) 0x5);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            message.portNo.write4Bytes(bb);
+            bb.writeInt(U32.t(message.queueId));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFQueueStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("portNo=").append(portNo);
+        b.append(", ");
+        b.append("queueId=").append(queueId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFQueueStatsRequestVer13 other = (OFQueueStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (portNo == null) {
+            if (other.portNo != null)
+                return false;
+        } else if (!portNo.equals(other.portNo))
+            return false;
+        if( queueId != other.queueId)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
+        result = prime *  (int) (queueId ^ (queueId >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleReplyVer13.java
new file mode 100644
index 0000000..a04b292
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleReplyVer13.java
@@ -0,0 +1,377 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFRoleReplyVer13 implements OFRoleReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFRoleReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_GENERATION_ID = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final OFControllerRole role;
+    private final U64 generationId;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFRoleReplyVer13(long xid, OFControllerRole role, U64 generationId) {
+        this.xid = xid;
+        this.role = role;
+        this.generationId = generationId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+
+
+    public OFRoleReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFRoleReply.Builder {
+        final OFRoleReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+        BuilderWithParent(OFRoleReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFRoleReply.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFRoleReply.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFRoleReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFControllerRole role = this.roleSet ? this.role : parentMessage.role;
+                if(role == null)
+                    throw new NullPointerException("Property role must not be null");
+                U64 generationId = this.generationIdSet ? this.generationId : parentMessage.generationId;
+                if(generationId == null)
+                    throw new NullPointerException("Property generationId must not be null");
+
+                //
+                return new OFRoleReplyVer13(
+                    xid,
+                    role,
+                    generationId
+                );
+        }
+
+    }
+
+    static class Builder implements OFRoleReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFRoleReply.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFRoleReply.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFRoleReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.roleSet)
+                throw new IllegalStateException("Property role doesn't have default value -- must be set");
+            if(role == null)
+                throw new NullPointerException("Property role must not be null");
+            U64 generationId = this.generationIdSet ? this.generationId : DEFAULT_GENERATION_ID;
+            if(generationId == null)
+                throw new NullPointerException("Property generationId must not be null");
+
+
+            return new OFRoleReplyVer13(
+                    xid,
+                    role,
+                    generationId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFRoleReply> {
+        @Override
+        public OFRoleReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 25
+            byte type = bb.readByte();
+            if(type != (byte) 0x19)
+                throw new OFParseError("Wrong type: Expected=OFType.ROLE_REPLY(25), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFControllerRole role = OFControllerRoleSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 generationId = U64.ofRaw(bb.readLong());
+
+            OFRoleReplyVer13 roleReplyVer13 = new OFRoleReplyVer13(
+                    xid,
+                      role,
+                      generationId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", roleReplyVer13);
+            return roleReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFRoleReplyVer13Funnel FUNNEL = new OFRoleReplyVer13Funnel();
+    static class OFRoleReplyVer13Funnel implements Funnel<OFRoleReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFRoleReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 25
+            sink.putByte((byte) 0x19);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            OFControllerRoleSerializerVer13.putTo(message.role, sink);
+            // skip pad (4 bytes)
+            message.generationId.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFRoleReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFRoleReplyVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 25
+            bb.writeByte((byte) 0x19);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            OFControllerRoleSerializerVer13.writeTo(bb, message.role);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.generationId.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFRoleReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("role=").append(role);
+        b.append(", ");
+        b.append("generationId=").append(generationId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFRoleReplyVer13 other = (OFRoleReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (role == null) {
+            if (other.role != null)
+                return false;
+        } else if (!role.equals(other.role))
+            return false;
+        if (generationId == null) {
+            if (other.generationId != null)
+                return false;
+        } else if (!generationId.equals(other.generationId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((role == null) ? 0 : role.hashCode());
+        result = prime * result + ((generationId == null) ? 0 : generationId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..bd07134
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestFailedCodeSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFRoleRequestFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFRoleRequestFailedCodeSerializerVer13 {
+
+    public final static short STALE_VAL = (short) 0x0;
+    public final static short UNSUP_VAL = (short) 0x1;
+    public final static short BAD_ROLE_VAL = (short) 0x2;
+
+    public static OFRoleRequestFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFRoleRequestFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFRoleRequestFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFRoleRequestFailedCode ofWireValue(short val) {
+        switch(val) {
+            case STALE_VAL:
+                return OFRoleRequestFailedCode.STALE;
+            case UNSUP_VAL:
+                return OFRoleRequestFailedCode.UNSUP;
+            case BAD_ROLE_VAL:
+                return OFRoleRequestFailedCode.BAD_ROLE;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFRoleRequestFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFRoleRequestFailedCode e) {
+        switch(e) {
+            case STALE:
+                return STALE_VAL;
+            case UNSUP:
+                return UNSUP_VAL;
+            case BAD_ROLE:
+                return BAD_ROLE_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFRoleRequestFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestFailedErrorMsgVer13.java
new file mode 100644
index 0000000..8456374
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFRoleRequestFailedErrorMsgVer13 implements OFRoleRequestFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFRoleRequestFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFRoleRequestFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFRoleRequestFailedErrorMsgVer13(long xid, OFRoleRequestFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.ROLE_REQUEST_FAILED;
+    }
+
+    @Override
+    public OFRoleRequestFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFRoleRequestFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFRoleRequestFailedErrorMsg.Builder {
+        final OFRoleRequestFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFRoleRequestFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFRoleRequestFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.ROLE_REQUEST_FAILED;
+    }
+
+    @Override
+    public OFRoleRequestFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setCode(OFRoleRequestFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFRoleRequestFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFRoleRequestFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFRoleRequestFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFRoleRequestFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFRoleRequestFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.ROLE_REQUEST_FAILED;
+    }
+
+    @Override
+    public OFRoleRequestFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setCode(OFRoleRequestFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFRoleRequestFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFRoleRequestFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFRoleRequestFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFRoleRequestFailedErrorMsg> {
+        @Override
+        public OFRoleRequestFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 11
+            short errType = bb.readShort();
+            if(errType != (short) 0xb)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.ROLE_REQUEST_FAILED(11), got="+errType);
+            OFRoleRequestFailedCode code = OFRoleRequestFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFRoleRequestFailedErrorMsgVer13 roleRequestFailedErrorMsgVer13 = new OFRoleRequestFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", roleRequestFailedErrorMsgVer13);
+            return roleRequestFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFRoleRequestFailedErrorMsgVer13Funnel FUNNEL = new OFRoleRequestFailedErrorMsgVer13Funnel();
+    static class OFRoleRequestFailedErrorMsgVer13Funnel implements Funnel<OFRoleRequestFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFRoleRequestFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 11
+            sink.putShort((short) 0xb);
+            OFRoleRequestFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFRoleRequestFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFRoleRequestFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 11
+            bb.writeShort((short) 0xb);
+            OFRoleRequestFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFRoleRequestFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFRoleRequestFailedErrorMsgVer13 other = (OFRoleRequestFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestVer13.java
new file mode 100644
index 0000000..b864496
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFRoleRequestVer13.java
@@ -0,0 +1,377 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFRoleRequestVer13 implements OFRoleRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFRoleRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static U64 DEFAULT_GENERATION_ID = U64.ZERO;
+
+    // OF message fields
+    private final long xid;
+    private final OFControllerRole role;
+    private final U64 generationId;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFRoleRequestVer13(long xid, OFControllerRole role, U64 generationId) {
+        this.xid = xid;
+        this.role = role;
+        this.generationId = generationId;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+
+
+    public OFRoleRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFRoleRequest.Builder {
+        final OFRoleRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+        BuilderWithParent(OFRoleRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFRoleRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFControllerRole role = this.roleSet ? this.role : parentMessage.role;
+                if(role == null)
+                    throw new NullPointerException("Property role must not be null");
+                U64 generationId = this.generationIdSet ? this.generationId : parentMessage.generationId;
+                if(generationId == null)
+                    throw new NullPointerException("Property generationId must not be null");
+
+                //
+                return new OFRoleRequestVer13(
+                    xid,
+                    role,
+                    generationId
+                );
+        }
+
+    }
+
+    static class Builder implements OFRoleRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean roleSet;
+        private OFControllerRole role;
+        private boolean generationIdSet;
+        private U64 generationId;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ROLE_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFControllerRole getRole() {
+        return role;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setRole(OFControllerRole role) {
+        this.role = role;
+        this.roleSet = true;
+        return this;
+    }
+    @Override
+    public U64 getGenerationId() {
+        return generationId;
+    }
+
+    @Override
+    public OFRoleRequest.Builder setGenerationId(U64 generationId) {
+        this.generationId = generationId;
+        this.generationIdSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFRoleRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.roleSet)
+                throw new IllegalStateException("Property role doesn't have default value -- must be set");
+            if(role == null)
+                throw new NullPointerException("Property role must not be null");
+            U64 generationId = this.generationIdSet ? this.generationId : DEFAULT_GENERATION_ID;
+            if(generationId == null)
+                throw new NullPointerException("Property generationId must not be null");
+
+
+            return new OFRoleRequestVer13(
+                    xid,
+                    role,
+                    generationId
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFRoleRequest> {
+        @Override
+        public OFRoleRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 24
+            byte type = bb.readByte();
+            if(type != (byte) 0x18)
+                throw new OFParseError("Wrong type: Expected=OFType.ROLE_REQUEST(24), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 24)
+                throw new OFParseError("Wrong length: Expected=24(24), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            OFControllerRole role = OFControllerRoleSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            U64 generationId = U64.ofRaw(bb.readLong());
+
+            OFRoleRequestVer13 roleRequestVer13 = new OFRoleRequestVer13(
+                    xid,
+                      role,
+                      generationId
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", roleRequestVer13);
+            return roleRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFRoleRequestVer13Funnel FUNNEL = new OFRoleRequestVer13Funnel();
+    static class OFRoleRequestVer13Funnel implements Funnel<OFRoleRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFRoleRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 24
+            sink.putByte((byte) 0x18);
+            // fixed value property length = 24
+            sink.putShort((short) 0x18);
+            sink.putLong(message.xid);
+            OFControllerRoleSerializerVer13.putTo(message.role, sink);
+            // skip pad (4 bytes)
+            message.generationId.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFRoleRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFRoleRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 24
+            bb.writeByte((byte) 0x18);
+            // fixed value property length = 24
+            bb.writeShort((short) 0x18);
+            bb.writeInt(U32.t(message.xid));
+            OFControllerRoleSerializerVer13.writeTo(bb, message.role);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            bb.writeLong(message.generationId.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFRoleRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("role=").append(role);
+        b.append(", ");
+        b.append("generationId=").append(generationId);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFRoleRequestVer13 other = (OFRoleRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (role == null) {
+            if (other.role != null)
+                return false;
+        } else if (!role.equals(other.role))
+            return false;
+        if (generationId == null) {
+            if (other.generationId != null)
+                return false;
+        } else if (!generationId.equals(other.generationId))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((role == null) ? 0 : role.hashCode());
+        result = prime * result + ((generationId == null) ? 0 : generationId.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSetConfigVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSetConfigVer13.java
new file mode 100644
index 0000000..49a1cb3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSetConfigVer13.java
@@ -0,0 +1,370 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFSetConfigVer13 implements OFSetConfig {
+    private static final Logger logger = LoggerFactory.getLogger(OFSetConfigVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFConfigFlags> DEFAULT_FLAGS = ImmutableSet.<OFConfigFlags>of();
+        private final static int DEFAULT_MISS_SEND_LEN = 0x0;
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFConfigFlags> flags;
+    private final int missSendLen;
+//
+    // Immutable default instance
+    final static OFSetConfigVer13 DEFAULT = new OFSetConfigVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MISS_SEND_LEN
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFSetConfigVer13(long xid, Set<OFConfigFlags> flags, int missSendLen) {
+        this.xid = xid;
+        this.flags = flags;
+        this.missSendLen = missSendLen;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+
+
+    public OFSetConfig.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFSetConfig.Builder {
+        final OFSetConfigVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+        BuilderWithParent(OFSetConfigVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSetConfig.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFSetConfig.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFSetConfig.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFSetConfig build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFConfigFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                int missSendLen = this.missSendLenSet ? this.missSendLen : parentMessage.missSendLen;
+
+                //
+                return new OFSetConfigVer13(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+    static class Builder implements OFSetConfig.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFConfigFlags> flags;
+        private boolean missSendLenSet;
+        private int missSendLen;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.SET_CONFIG;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSetConfig.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public Set<OFConfigFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFSetConfig.Builder setFlags(Set<OFConfigFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public int getMissSendLen() {
+        return missSendLen;
+    }
+
+    @Override
+    public OFSetConfig.Builder setMissSendLen(int missSendLen) {
+        this.missSendLen = missSendLen;
+        this.missSendLenSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFSetConfig build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFConfigFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            int missSendLen = this.missSendLenSet ? this.missSendLen : DEFAULT_MISS_SEND_LEN;
+
+
+            return new OFSetConfigVer13(
+                    xid,
+                    flags,
+                    missSendLen
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFSetConfig> {
+        @Override
+        public OFSetConfig readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 9
+            byte type = bb.readByte();
+            if(type != (byte) 0x9)
+                throw new OFParseError("Wrong type: Expected=OFType.SET_CONFIG(9), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 12)
+                throw new OFParseError("Wrong length: Expected=12(12), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            Set<OFConfigFlags> flags = OFConfigFlagsSerializerVer13.readFrom(bb);
+            int missSendLen = U16.f(bb.readShort());
+
+            OFSetConfigVer13 setConfigVer13 = new OFSetConfigVer13(
+                    xid,
+                      flags,
+                      missSendLen
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", setConfigVer13);
+            return setConfigVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFSetConfigVer13Funnel FUNNEL = new OFSetConfigVer13Funnel();
+    static class OFSetConfigVer13Funnel implements Funnel<OFSetConfigVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFSetConfigVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 9
+            sink.putByte((byte) 0x9);
+            // fixed value property length = 12
+            sink.putShort((short) 0xc);
+            sink.putLong(message.xid);
+            OFConfigFlagsSerializerVer13.putTo(message.flags, sink);
+            sink.putInt(message.missSendLen);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFSetConfigVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFSetConfigVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 9
+            bb.writeByte((byte) 0x9);
+            // fixed value property length = 12
+            bb.writeShort((short) 0xc);
+            bb.writeInt(U32.t(message.xid));
+            OFConfigFlagsSerializerVer13.writeTo(bb, message.flags);
+            bb.writeShort(U16.t(message.missSendLen));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFSetConfigVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("missSendLen=").append(missSendLen);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFSetConfigVer13 other = (OFSetConfigVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if( missSendLen != other.missSendLen)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + missSendLen;
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsReplyFlagsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsReplyFlagsSerializerVer13.java
new file mode 100644
index 0000000..d4b5972
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsReplyFlagsSerializerVer13.java
@@ -0,0 +1,78 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFStatsReplyFlagsSerializerVer13 {
+
+    public final static short REPLY_MORE_VAL = (short) 0x1;
+
+    public static Set<OFStatsReplyFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFStatsReplyFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFStatsReplyFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFStatsReplyFlags> ofWireValue(short val) {
+        EnumSet<OFStatsReplyFlags> set = EnumSet.noneOf(OFStatsReplyFlags.class);
+
+        if((val & REPLY_MORE_VAL) != 0)
+            set.add(OFStatsReplyFlags.REPLY_MORE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFStatsReplyFlags> set) {
+        short wireValue = 0;
+
+        for(OFStatsReplyFlags e: set) {
+            switch(e) {
+                case REPLY_MORE:
+                    wireValue |= REPLY_MORE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFStatsReplyFlags in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsReplyVer13.java
new file mode 100644
index 0000000..89368bd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsReplyVer13.java
@@ -0,0 +1,107 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFStatsReplyVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFStatsReplyVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFStatsReply> {
+        @Override
+        public OFStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short statsType = bb.readShort();
+            bb.readerIndex(start);
+            switch(statsType) {
+               case (short) 0x2:
+                   // discriminator value OFStatsType.AGGREGATE=2 for class OFAggregateStatsReplyVer13
+                   return OFAggregateStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFStatsType.EXPERIMENTER=65535 for class OFExperimenterStatsReplyVer13
+                   return OFExperimenterStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFStatsType.DESC=0 for class OFDescStatsReplyVer13
+                   return OFDescStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFStatsType.FLOW=1 for class OFFlowStatsReplyVer13
+                   return OFFlowStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFStatsType.PORT=4 for class OFPortStatsReplyVer13
+                   return OFPortStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFStatsType.QUEUE=5 for class OFQueueStatsReplyVer13
+                   return OFQueueStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFStatsType.TABLE=3 for class OFTableStatsReplyVer13
+                   return OFTableStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFStatsType.GROUP_DESC=7 for class OFGroupDescStatsReplyVer13
+                   return OFGroupDescStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFStatsType.GROUP=6 for class OFGroupStatsReplyVer13
+                   return OFGroupStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFStatsType.GROUP_FEATURES=8 for class OFGroupFeaturesStatsReplyVer13
+                   return OFGroupFeaturesStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0xa:
+                   // discriminator value OFStatsType.METER_CONFIG=10 for class OFMeterConfigStatsReplyVer13
+                   return OFMeterConfigStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFStatsType.METER_FEATURES=11 for class OFMeterFeaturesStatsReplyVer13
+                   return OFMeterFeaturesStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0x9:
+                   // discriminator value OFStatsType.METER=9 for class OFMeterStatsReplyVer13
+                   return OFMeterStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0xd:
+                   // discriminator value OFStatsType.PORT_DESC=13 for class OFPortDescStatsReplyVer13
+                   return OFPortDescStatsReplyVer13.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value OFStatsType.TABLE_FEATURES=12 for class OFTableFeaturesStatsReplyVer13
+                   return OFTableFeaturesStatsReplyVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator statsType of class OFStatsReplyVer13: " + statsType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsRequestFlagsSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsRequestFlagsSerializerVer13.java
new file mode 100644
index 0000000..a00082f
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsRequestFlagsSerializerVer13.java
@@ -0,0 +1,78 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsRequestFlags;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFStatsRequestFlagsSerializerVer13 {
+
+    public final static short REQ_MORE_VAL = (short) 0x1;
+
+    public static Set<OFStatsRequestFlags> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFStatsRequestFlags> set) {
+        bb.writeShort(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFStatsRequestFlags> set, PrimitiveSink sink) {
+        sink.putShort(toWireValue(set));
+    }
+
+
+    public static Set<OFStatsRequestFlags> ofWireValue(short val) {
+        EnumSet<OFStatsRequestFlags> set = EnumSet.noneOf(OFStatsRequestFlags.class);
+
+        if((val & REQ_MORE_VAL) != 0)
+            set.add(OFStatsRequestFlags.REQ_MORE);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static short toWireValue(Set<OFStatsRequestFlags> set) {
+        short wireValue = 0;
+
+        for(OFStatsRequestFlags e: set) {
+            switch(e) {
+                case REQ_MORE:
+                    wireValue |= REQ_MORE_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFStatsRequestFlags in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsRequestVer13.java
new file mode 100644
index 0000000..e532526
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsRequestVer13.java
@@ -0,0 +1,107 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+
+abstract class OFStatsRequestVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+
+    public final static OFStatsRequestVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFStatsRequest<?>> {
+        @Override
+        public OFStatsRequest<?> readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            U32.f(bb.readInt());
+            short statsType = bb.readShort();
+            bb.readerIndex(start);
+            switch(statsType) {
+               case (short) 0x2:
+                   // discriminator value OFStatsType.AGGREGATE=2 for class OFAggregateStatsRequestVer13
+                   return OFAggregateStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value OFStatsType.EXPERIMENTER=65535 for class OFExperimenterStatsRequestVer13
+                   return OFExperimenterStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value OFStatsType.DESC=0 for class OFDescStatsRequestVer13
+                   return OFDescStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value OFStatsType.FLOW=1 for class OFFlowStatsRequestVer13
+                   return OFFlowStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value OFStatsType.PORT=4 for class OFPortStatsRequestVer13
+                   return OFPortStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value OFStatsType.QUEUE=5 for class OFQueueStatsRequestVer13
+                   return OFQueueStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value OFStatsType.TABLE=3 for class OFTableStatsRequestVer13
+                   return OFTableStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value OFStatsType.GROUP_DESC=7 for class OFGroupDescStatsRequestVer13
+                   return OFGroupDescStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x6:
+                   // discriminator value OFStatsType.GROUP=6 for class OFGroupStatsRequestVer13
+                   return OFGroupStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value OFStatsType.GROUP_FEATURES=8 for class OFGroupFeaturesStatsRequestVer13
+                   return OFGroupFeaturesStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0xa:
+                   // discriminator value OFStatsType.METER_CONFIG=10 for class OFMeterConfigStatsRequestVer13
+                   return OFMeterConfigStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0xb:
+                   // discriminator value OFStatsType.METER_FEATURES=11 for class OFMeterFeaturesStatsRequestVer13
+                   return OFMeterFeaturesStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0x9:
+                   // discriminator value OFStatsType.METER=9 for class OFMeterStatsRequestVer13
+                   return OFMeterStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0xd:
+                   // discriminator value OFStatsType.PORT_DESC=13 for class OFPortDescStatsRequestVer13
+                   return OFPortDescStatsRequestVer13.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value OFStatsType.TABLE_FEATURES=12 for class OFTableFeaturesStatsRequestVer13
+                   return OFTableFeaturesStatsRequestVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator statsType of class OFStatsRequestVer13: " + statsType);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsTypeSerializerVer13.java
new file mode 100644
index 0000000..d979ecd
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFStatsTypeSerializerVer13.java
@@ -0,0 +1,139 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFStatsTypeSerializerVer13 {
+
+    public final static short DESC_VAL = (short) 0x0;
+    public final static short FLOW_VAL = (short) 0x1;
+    public final static short AGGREGATE_VAL = (short) 0x2;
+    public final static short TABLE_VAL = (short) 0x3;
+    public final static short PORT_VAL = (short) 0x4;
+    public final static short QUEUE_VAL = (short) 0x5;
+    public final static short GROUP_VAL = (short) 0x6;
+    public final static short GROUP_DESC_VAL = (short) 0x7;
+    public final static short GROUP_FEATURES_VAL = (short) 0x8;
+    public final static short METER_VAL = (short) 0x9;
+    public final static short METER_CONFIG_VAL = (short) 0xa;
+    public final static short METER_FEATURES_VAL = (short) 0xb;
+    public final static short TABLE_FEATURES_VAL = (short) 0xc;
+    public final static short PORT_DESC_VAL = (short) 0xd;
+    public final static short EXPERIMENTER_VAL = (short) 0xffff;
+
+    public static OFStatsType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFStatsType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFStatsType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFStatsType ofWireValue(short val) {
+        switch(val) {
+            case DESC_VAL:
+                return OFStatsType.DESC;
+            case FLOW_VAL:
+                return OFStatsType.FLOW;
+            case AGGREGATE_VAL:
+                return OFStatsType.AGGREGATE;
+            case TABLE_VAL:
+                return OFStatsType.TABLE;
+            case PORT_VAL:
+                return OFStatsType.PORT;
+            case QUEUE_VAL:
+                return OFStatsType.QUEUE;
+            case GROUP_VAL:
+                return OFStatsType.GROUP;
+            case GROUP_DESC_VAL:
+                return OFStatsType.GROUP_DESC;
+            case GROUP_FEATURES_VAL:
+                return OFStatsType.GROUP_FEATURES;
+            case METER_VAL:
+                return OFStatsType.METER;
+            case METER_CONFIG_VAL:
+                return OFStatsType.METER_CONFIG;
+            case METER_FEATURES_VAL:
+                return OFStatsType.METER_FEATURES;
+            case TABLE_FEATURES_VAL:
+                return OFStatsType.TABLE_FEATURES;
+            case PORT_DESC_VAL:
+                return OFStatsType.PORT_DESC;
+            case EXPERIMENTER_VAL:
+                return OFStatsType.EXPERIMENTER;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFStatsType e) {
+        switch(e) {
+            case DESC:
+                return DESC_VAL;
+            case FLOW:
+                return FLOW_VAL;
+            case AGGREGATE:
+                return AGGREGATE_VAL;
+            case TABLE:
+                return TABLE_VAL;
+            case PORT:
+                return PORT_VAL;
+            case QUEUE:
+                return QUEUE_VAL;
+            case GROUP:
+                return GROUP_VAL;
+            case GROUP_DESC:
+                return GROUP_DESC_VAL;
+            case GROUP_FEATURES:
+                return GROUP_FEATURES_VAL;
+            case METER:
+                return METER_VAL;
+            case METER_CONFIG:
+                return METER_CONFIG_VAL;
+            case METER_FEATURES:
+                return METER_FEATURES_VAL;
+            case TABLE_FEATURES:
+                return TABLE_FEATURES_VAL;
+            case PORT_DESC:
+                return PORT_DESC_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSwitchConfigFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSwitchConfigFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..efd303a
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSwitchConfigFailedCodeSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFSwitchConfigFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFSwitchConfigFailedCodeSerializerVer13 {
+
+    public final static short BAD_FLAGS_VAL = (short) 0x0;
+    public final static short BAD_LEN_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+
+    public static OFSwitchConfigFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFSwitchConfigFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFSwitchConfigFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFSwitchConfigFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_FLAGS_VAL:
+                return OFSwitchConfigFailedCode.BAD_FLAGS;
+            case BAD_LEN_VAL:
+                return OFSwitchConfigFailedCode.BAD_LEN;
+            case EPERM_VAL:
+                return OFSwitchConfigFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFSwitchConfigFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFSwitchConfigFailedCode e) {
+        switch(e) {
+            case BAD_FLAGS:
+                return BAD_FLAGS_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFSwitchConfigFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSwitchConfigFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSwitchConfigFailedErrorMsgVer13.java
new file mode 100644
index 0000000..6c065d1
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFSwitchConfigFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFSwitchConfigFailedErrorMsgVer13 implements OFSwitchConfigFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFSwitchConfigFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFSwitchConfigFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFSwitchConfigFailedErrorMsgVer13(long xid, OFSwitchConfigFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFSwitchConfigFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFSwitchConfigFailedErrorMsg.Builder {
+        final OFSwitchConfigFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFSwitchConfigFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFSwitchConfigFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setCode(OFSwitchConfigFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFSwitchConfigFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFSwitchConfigFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFSwitchConfigFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFSwitchConfigFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFSwitchConfigFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.SWITCH_CONFIG_FAILED;
+    }
+
+    @Override
+    public OFSwitchConfigFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setCode(OFSwitchConfigFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFSwitchConfigFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFSwitchConfigFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFSwitchConfigFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFSwitchConfigFailedErrorMsg> {
+        @Override
+        public OFSwitchConfigFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 10
+            short errType = bb.readShort();
+            if(errType != (short) 0xa)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.SWITCH_CONFIG_FAILED(10), got="+errType);
+            OFSwitchConfigFailedCode code = OFSwitchConfigFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFSwitchConfigFailedErrorMsgVer13 switchConfigFailedErrorMsgVer13 = new OFSwitchConfigFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", switchConfigFailedErrorMsgVer13);
+            return switchConfigFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFSwitchConfigFailedErrorMsgVer13Funnel FUNNEL = new OFSwitchConfigFailedErrorMsgVer13Funnel();
+    static class OFSwitchConfigFailedErrorMsgVer13Funnel implements Funnel<OFSwitchConfigFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFSwitchConfigFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 10
+            sink.putShort((short) 0xa);
+            OFSwitchConfigFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFSwitchConfigFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFSwitchConfigFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 10
+            bb.writeShort((short) 0xa);
+            OFSwitchConfigFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFSwitchConfigFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFSwitchConfigFailedErrorMsgVer13 other = (OFSwitchConfigFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableConfigSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableConfigSerializerVer13.java
new file mode 100644
index 0000000..3e47912
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableConfigSerializerVer13.java
@@ -0,0 +1,78 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_set_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTableConfig;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import java.util.EnumSet;
+import java.util.Collections;
+
+
+public class OFTableConfigSerializerVer13 {
+
+    public final static int DEPRECATED_MASK_VAL = 0x3;
+
+    public static Set<OFTableConfig> readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readInt());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, Set<OFTableConfig> set) {
+        bb.writeInt(toWireValue(set));
+    }
+
+    public static void putTo(Set<OFTableConfig> set, PrimitiveSink sink) {
+        sink.putInt(toWireValue(set));
+    }
+
+
+    public static Set<OFTableConfig> ofWireValue(int val) {
+        EnumSet<OFTableConfig> set = EnumSet.noneOf(OFTableConfig.class);
+
+        if((val & DEPRECATED_MASK_VAL) != 0)
+            set.add(OFTableConfig.DEPRECATED_MASK);
+        return Collections.unmodifiableSet(set);
+    }
+
+    public static int toWireValue(Set<OFTableConfig> set) {
+        int wireValue = 0;
+
+        for(OFTableConfig e: set) {
+            switch(e) {
+                case DEPRECATED_MASK:
+                    wireValue |= DEPRECATED_MASK_VAL;
+                    break;
+                default:
+                    throw new IllegalArgumentException("Illegal enum value for type OFTableConfig in version 1.3: " + e);
+            }
+        }
+        return wireValue;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplyActionsMissVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplyActionsMissVer13.java
new file mode 100644
index 0000000..5fd08ec
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplyActionsMissVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropApplyActionsMissVer13 implements OFTableFeaturePropApplyActionsMiss {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropApplyActionsMissVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<OFActionId> DEFAULT_ACTION_IDS = ImmutableList.<OFActionId>of();
+
+    // OF message fields
+    private final List<OFActionId> actionIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropApplyActionsMissVer13 DEFAULT = new OFTableFeaturePropApplyActionsMissVer13(
+        DEFAULT_ACTION_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropApplyActionsMissVer13(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x7;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropApplyActionsMiss.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropApplyActionsMiss.Builder {
+        final OFTableFeaturePropApplyActionsMissVer13 parentMessage;
+
+        // OF message fields
+        private boolean actionIdsSet;
+        private List<OFActionId> actionIds;
+
+        BuilderWithParent(OFTableFeaturePropApplyActionsMissVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x7;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropApplyActionsMiss.Builder setActionIds(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+        this.actionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropApplyActionsMiss build() {
+                List<OFActionId> actionIds = this.actionIdsSet ? this.actionIds : parentMessage.actionIds;
+                if(actionIds == null)
+                    throw new NullPointerException("Property actionIds must not be null");
+
+                //
+                return new OFTableFeaturePropApplyActionsMissVer13(
+                    actionIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropApplyActionsMiss.Builder {
+        // OF message fields
+        private boolean actionIdsSet;
+        private List<OFActionId> actionIds;
+
+    @Override
+    public int getType() {
+        return 0x7;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropApplyActionsMiss.Builder setActionIds(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+        this.actionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropApplyActionsMiss build() {
+            List<OFActionId> actionIds = this.actionIdsSet ? this.actionIds : DEFAULT_ACTION_IDS;
+            if(actionIds == null)
+                throw new NullPointerException("Property actionIds must not be null");
+
+
+            return new OFTableFeaturePropApplyActionsMissVer13(
+                    actionIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropApplyActionsMiss> {
+        @Override
+        public OFTableFeaturePropApplyActionsMiss readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x7
+            short type = bb.readShort();
+            if(type != (short) 0x7)
+                throw new OFParseError("Wrong type: Expected=0x7(0x7), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<OFActionId> actionIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionIdVer13.READER);
+
+            OFTableFeaturePropApplyActionsMissVer13 tableFeaturePropApplyActionsMissVer13 = new OFTableFeaturePropApplyActionsMissVer13(
+                    actionIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropApplyActionsMissVer13);
+            return tableFeaturePropApplyActionsMissVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropApplyActionsMissVer13Funnel FUNNEL = new OFTableFeaturePropApplyActionsMissVer13Funnel();
+    static class OFTableFeaturePropApplyActionsMissVer13Funnel implements Funnel<OFTableFeaturePropApplyActionsMissVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropApplyActionsMissVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x7
+            sink.putShort((short) 0x7);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.actionIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropApplyActionsMissVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropApplyActionsMissVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x7
+            bb.writeShort((short) 0x7);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.actionIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropApplyActionsMissVer13(");
+        b.append("actionIds=").append(actionIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropApplyActionsMissVer13 other = (OFTableFeaturePropApplyActionsMissVer13) obj;
+
+        if (actionIds == null) {
+            if (other.actionIds != null)
+                return false;
+        } else if (!actionIds.equals(other.actionIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actionIds == null) ? 0 : actionIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplyActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplyActionsVer13.java
new file mode 100644
index 0000000..a2f9c46
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplyActionsVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropApplyActionsVer13 implements OFTableFeaturePropApplyActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropApplyActionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<OFActionId> DEFAULT_ACTION_IDS = ImmutableList.<OFActionId>of();
+
+    // OF message fields
+    private final List<OFActionId> actionIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropApplyActionsVer13 DEFAULT = new OFTableFeaturePropApplyActionsVer13(
+        DEFAULT_ACTION_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropApplyActionsVer13(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x6;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropApplyActions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropApplyActions.Builder {
+        final OFTableFeaturePropApplyActionsVer13 parentMessage;
+
+        // OF message fields
+        private boolean actionIdsSet;
+        private List<OFActionId> actionIds;
+
+        BuilderWithParent(OFTableFeaturePropApplyActionsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x6;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropApplyActions.Builder setActionIds(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+        this.actionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropApplyActions build() {
+                List<OFActionId> actionIds = this.actionIdsSet ? this.actionIds : parentMessage.actionIds;
+                if(actionIds == null)
+                    throw new NullPointerException("Property actionIds must not be null");
+
+                //
+                return new OFTableFeaturePropApplyActionsVer13(
+                    actionIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropApplyActions.Builder {
+        // OF message fields
+        private boolean actionIdsSet;
+        private List<OFActionId> actionIds;
+
+    @Override
+    public int getType() {
+        return 0x6;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropApplyActions.Builder setActionIds(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+        this.actionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropApplyActions build() {
+            List<OFActionId> actionIds = this.actionIdsSet ? this.actionIds : DEFAULT_ACTION_IDS;
+            if(actionIds == null)
+                throw new NullPointerException("Property actionIds must not be null");
+
+
+            return new OFTableFeaturePropApplyActionsVer13(
+                    actionIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropApplyActions> {
+        @Override
+        public OFTableFeaturePropApplyActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x6
+            short type = bb.readShort();
+            if(type != (short) 0x6)
+                throw new OFParseError("Wrong type: Expected=0x6(0x6), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<OFActionId> actionIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionIdVer13.READER);
+
+            OFTableFeaturePropApplyActionsVer13 tableFeaturePropApplyActionsVer13 = new OFTableFeaturePropApplyActionsVer13(
+                    actionIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropApplyActionsVer13);
+            return tableFeaturePropApplyActionsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropApplyActionsVer13Funnel FUNNEL = new OFTableFeaturePropApplyActionsVer13Funnel();
+    static class OFTableFeaturePropApplyActionsVer13Funnel implements Funnel<OFTableFeaturePropApplyActionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropApplyActionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x6
+            sink.putShort((short) 0x6);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.actionIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropApplyActionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropApplyActionsVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x6
+            bb.writeShort((short) 0x6);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.actionIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropApplyActionsVer13(");
+        b.append("actionIds=").append(actionIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropApplyActionsVer13 other = (OFTableFeaturePropApplyActionsVer13) obj;
+
+        if (actionIds == null) {
+            if (other.actionIds != null)
+                return false;
+        } else if (!actionIds.equals(other.actionIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actionIds == null) ? 0 : actionIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplySetfieldMissVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplySetfieldMissVer13.java
new file mode 100644
index 0000000..6ca4d56
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplySetfieldMissVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropApplySetfieldMissVer13 implements OFTableFeaturePropApplySetfieldMiss {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropApplySetfieldMissVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U32> DEFAULT_OXM_IDS = ImmutableList.<U32>of();
+
+    // OF message fields
+    private final List<U32> oxmIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropApplySetfieldMissVer13 DEFAULT = new OFTableFeaturePropApplySetfieldMissVer13(
+        DEFAULT_OXM_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropApplySetfieldMissVer13(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xf;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropApplySetfieldMiss.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropApplySetfieldMiss.Builder {
+        final OFTableFeaturePropApplySetfieldMissVer13 parentMessage;
+
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+        BuilderWithParent(OFTableFeaturePropApplySetfieldMissVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xf;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropApplySetfieldMiss.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropApplySetfieldMiss build() {
+                List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : parentMessage.oxmIds;
+                if(oxmIds == null)
+                    throw new NullPointerException("Property oxmIds must not be null");
+
+                //
+                return new OFTableFeaturePropApplySetfieldMissVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropApplySetfieldMiss.Builder {
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+    @Override
+    public int getType() {
+        return 0xf;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropApplySetfieldMiss.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropApplySetfieldMiss build() {
+            List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : DEFAULT_OXM_IDS;
+            if(oxmIds == null)
+                throw new NullPointerException("Property oxmIds must not be null");
+
+
+            return new OFTableFeaturePropApplySetfieldMissVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropApplySetfieldMiss> {
+        @Override
+        public OFTableFeaturePropApplySetfieldMiss readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xf
+            short type = bb.readShort();
+            if(type != (short) 0xf)
+                throw new OFParseError("Wrong type: Expected=0xf(0xf), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U32> oxmIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U32.READER);
+
+            OFTableFeaturePropApplySetfieldMissVer13 tableFeaturePropApplySetfieldMissVer13 = new OFTableFeaturePropApplySetfieldMissVer13(
+                    oxmIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropApplySetfieldMissVer13);
+            return tableFeaturePropApplySetfieldMissVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropApplySetfieldMissVer13Funnel FUNNEL = new OFTableFeaturePropApplySetfieldMissVer13Funnel();
+    static class OFTableFeaturePropApplySetfieldMissVer13Funnel implements Funnel<OFTableFeaturePropApplySetfieldMissVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropApplySetfieldMissVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xf
+            sink.putShort((short) 0xf);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.oxmIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropApplySetfieldMissVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropApplySetfieldMissVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0xf
+            bb.writeShort((short) 0xf);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.oxmIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropApplySetfieldMissVer13(");
+        b.append("oxmIds=").append(oxmIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropApplySetfieldMissVer13 other = (OFTableFeaturePropApplySetfieldMissVer13) obj;
+
+        if (oxmIds == null) {
+            if (other.oxmIds != null)
+                return false;
+        } else if (!oxmIds.equals(other.oxmIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((oxmIds == null) ? 0 : oxmIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplySetfieldVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplySetfieldVer13.java
new file mode 100644
index 0000000..b0b49dc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropApplySetfieldVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropApplySetfieldVer13 implements OFTableFeaturePropApplySetfield {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropApplySetfieldVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U32> DEFAULT_OXM_IDS = ImmutableList.<U32>of();
+
+    // OF message fields
+    private final List<U32> oxmIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropApplySetfieldVer13 DEFAULT = new OFTableFeaturePropApplySetfieldVer13(
+        DEFAULT_OXM_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropApplySetfieldVer13(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xe;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropApplySetfield.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropApplySetfield.Builder {
+        final OFTableFeaturePropApplySetfieldVer13 parentMessage;
+
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+        BuilderWithParent(OFTableFeaturePropApplySetfieldVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xe;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropApplySetfield.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropApplySetfield build() {
+                List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : parentMessage.oxmIds;
+                if(oxmIds == null)
+                    throw new NullPointerException("Property oxmIds must not be null");
+
+                //
+                return new OFTableFeaturePropApplySetfieldVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropApplySetfield.Builder {
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+    @Override
+    public int getType() {
+        return 0xe;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropApplySetfield.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropApplySetfield build() {
+            List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : DEFAULT_OXM_IDS;
+            if(oxmIds == null)
+                throw new NullPointerException("Property oxmIds must not be null");
+
+
+            return new OFTableFeaturePropApplySetfieldVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropApplySetfield> {
+        @Override
+        public OFTableFeaturePropApplySetfield readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xe
+            short type = bb.readShort();
+            if(type != (short) 0xe)
+                throw new OFParseError("Wrong type: Expected=0xe(0xe), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U32> oxmIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U32.READER);
+
+            OFTableFeaturePropApplySetfieldVer13 tableFeaturePropApplySetfieldVer13 = new OFTableFeaturePropApplySetfieldVer13(
+                    oxmIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropApplySetfieldVer13);
+            return tableFeaturePropApplySetfieldVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropApplySetfieldVer13Funnel FUNNEL = new OFTableFeaturePropApplySetfieldVer13Funnel();
+    static class OFTableFeaturePropApplySetfieldVer13Funnel implements Funnel<OFTableFeaturePropApplySetfieldVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropApplySetfieldVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xe
+            sink.putShort((short) 0xe);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.oxmIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropApplySetfieldVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropApplySetfieldVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0xe
+            bb.writeShort((short) 0xe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.oxmIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropApplySetfieldVer13(");
+        b.append("oxmIds=").append(oxmIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropApplySetfieldVer13 other = (OFTableFeaturePropApplySetfieldVer13) obj;
+
+        if (oxmIds == null) {
+            if (other.oxmIds != null)
+                return false;
+        } else if (!oxmIds.equals(other.oxmIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((oxmIds == null) ? 0 : oxmIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropExperimenterMissVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropExperimenterMissVer13.java
new file mode 100644
index 0000000..e5685cc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropExperimenterMissVer13.java
@@ -0,0 +1,364 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFTableFeaturePropExperimenterMissVer13 implements OFTableFeaturePropExperimenterMiss {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropExperimenterMissVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_EXPERIMENTER = 0x0L;
+        private final static long DEFAULT_SUBTYPE = 0x0L;
+        private final static byte[] DEFAULT_EXPERIMENTER_DATA = new byte[0];
+
+    // OF message fields
+    private final long experimenter;
+    private final long subtype;
+    private final byte[] experimenterData;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropExperimenterMissVer13 DEFAULT = new OFTableFeaturePropExperimenterMissVer13(
+        DEFAULT_EXPERIMENTER, DEFAULT_SUBTYPE, DEFAULT_EXPERIMENTER_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropExperimenterMissVer13(long experimenter, long subtype, byte[] experimenterData) {
+        this.experimenter = experimenter;
+        this.subtype = subtype;
+        this.experimenterData = experimenterData;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xffff;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public long getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public byte[] getExperimenterData() {
+        return experimenterData;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropExperimenterMiss.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropExperimenterMiss.Builder {
+        final OFTableFeaturePropExperimenterMissVer13 parentMessage;
+
+        // OF message fields
+        private boolean experimenterSet;
+        private long experimenter;
+        private boolean subtypeSet;
+        private long subtype;
+        private boolean experimenterDataSet;
+        private byte[] experimenterData;
+
+        BuilderWithParent(OFTableFeaturePropExperimenterMissVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xffff;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenterMiss.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public long getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenterMiss.Builder setSubtype(long subtype) {
+        this.subtype = subtype;
+        this.subtypeSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getExperimenterData() {
+        return experimenterData;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenterMiss.Builder setExperimenterData(byte[] experimenterData) {
+        this.experimenterData = experimenterData;
+        this.experimenterDataSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropExperimenterMiss build() {
+                long experimenter = this.experimenterSet ? this.experimenter : parentMessage.experimenter;
+                long subtype = this.subtypeSet ? this.subtype : parentMessage.subtype;
+                byte[] experimenterData = this.experimenterDataSet ? this.experimenterData : parentMessage.experimenterData;
+                if(experimenterData == null)
+                    throw new NullPointerException("Property experimenterData must not be null");
+
+                //
+                return new OFTableFeaturePropExperimenterMissVer13(
+                    experimenter,
+                    subtype,
+                    experimenterData
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropExperimenterMiss.Builder {
+        // OF message fields
+        private boolean experimenterSet;
+        private long experimenter;
+        private boolean subtypeSet;
+        private long subtype;
+        private boolean experimenterDataSet;
+        private byte[] experimenterData;
+
+    @Override
+    public int getType() {
+        return 0xffff;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenterMiss.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public long getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenterMiss.Builder setSubtype(long subtype) {
+        this.subtype = subtype;
+        this.subtypeSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getExperimenterData() {
+        return experimenterData;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenterMiss.Builder setExperimenterData(byte[] experimenterData) {
+        this.experimenterData = experimenterData;
+        this.experimenterDataSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropExperimenterMiss build() {
+            long experimenter = this.experimenterSet ? this.experimenter : DEFAULT_EXPERIMENTER;
+            long subtype = this.subtypeSet ? this.subtype : DEFAULT_SUBTYPE;
+            byte[] experimenterData = this.experimenterDataSet ? this.experimenterData : DEFAULT_EXPERIMENTER_DATA;
+            if(experimenterData == null)
+                throw new NullPointerException("Property experimenterData must not be null");
+
+
+            return new OFTableFeaturePropExperimenterMissVer13(
+                    experimenter,
+                    subtype,
+                    experimenterData
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropExperimenterMiss> {
+        @Override
+        public OFTableFeaturePropExperimenterMiss readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xffff
+            short type = bb.readShort();
+            if(type != (short) 0xffff)
+                throw new OFParseError("Wrong type: Expected=0xffff(0xffff), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long experimenter = U32.f(bb.readInt());
+            long subtype = U32.f(bb.readInt());
+            byte[] experimenterData = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFTableFeaturePropExperimenterMissVer13 tableFeaturePropExperimenterMissVer13 = new OFTableFeaturePropExperimenterMissVer13(
+                    experimenter,
+                      subtype,
+                      experimenterData
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropExperimenterMissVer13);
+            return tableFeaturePropExperimenterMissVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropExperimenterMissVer13Funnel FUNNEL = new OFTableFeaturePropExperimenterMissVer13Funnel();
+    static class OFTableFeaturePropExperimenterMissVer13Funnel implements Funnel<OFTableFeaturePropExperimenterMissVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropExperimenterMissVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xffff
+            sink.putShort((short) 0xffff);
+            // FIXME: skip funnel of length
+            sink.putLong(message.experimenter);
+            sink.putLong(message.subtype);
+            sink.putBytes(message.experimenterData);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropExperimenterMissVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropExperimenterMissVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0xffff
+            bb.writeShort((short) 0xffff);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.experimenter));
+            bb.writeInt(U32.t(message.subtype));
+            bb.writeBytes(message.experimenterData);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropExperimenterMissVer13(");
+        b.append("experimenter=").append(experimenter);
+        b.append(", ");
+        b.append("subtype=").append(subtype);
+        b.append(", ");
+        b.append("experimenterData=").append(Arrays.toString(experimenterData));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropExperimenterMissVer13 other = (OFTableFeaturePropExperimenterMissVer13) obj;
+
+        if( experimenter != other.experimenter)
+            return false;
+        if( subtype != other.subtype)
+            return false;
+        if (!Arrays.equals(experimenterData, other.experimenterData))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (experimenter ^ (experimenter >>> 32));
+        result = prime *  (int) (subtype ^ (subtype >>> 32));
+        result = prime * result + Arrays.hashCode(experimenterData);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropExperimenterVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropExperimenterVer13.java
new file mode 100644
index 0000000..056b550
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropExperimenterVer13.java
@@ -0,0 +1,364 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+import java.util.Arrays;
+
+class OFTableFeaturePropExperimenterVer13 implements OFTableFeaturePropExperimenter {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropExperimenterVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_EXPERIMENTER = 0x0L;
+        private final static long DEFAULT_SUBTYPE = 0x0L;
+        private final static byte[] DEFAULT_EXPERIMENTER_DATA = new byte[0];
+
+    // OF message fields
+    private final long experimenter;
+    private final long subtype;
+    private final byte[] experimenterData;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropExperimenterVer13 DEFAULT = new OFTableFeaturePropExperimenterVer13(
+        DEFAULT_EXPERIMENTER, DEFAULT_SUBTYPE, DEFAULT_EXPERIMENTER_DATA
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropExperimenterVer13(long experimenter, long subtype, byte[] experimenterData) {
+        this.experimenter = experimenter;
+        this.subtype = subtype;
+        this.experimenterData = experimenterData;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xfffe;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public long getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public byte[] getExperimenterData() {
+        return experimenterData;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropExperimenter.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropExperimenter.Builder {
+        final OFTableFeaturePropExperimenterVer13 parentMessage;
+
+        // OF message fields
+        private boolean experimenterSet;
+        private long experimenter;
+        private boolean subtypeSet;
+        private long subtype;
+        private boolean experimenterDataSet;
+        private byte[] experimenterData;
+
+        BuilderWithParent(OFTableFeaturePropExperimenterVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xfffe;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenter.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public long getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenter.Builder setSubtype(long subtype) {
+        this.subtype = subtype;
+        this.subtypeSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getExperimenterData() {
+        return experimenterData;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenter.Builder setExperimenterData(byte[] experimenterData) {
+        this.experimenterData = experimenterData;
+        this.experimenterDataSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropExperimenter build() {
+                long experimenter = this.experimenterSet ? this.experimenter : parentMessage.experimenter;
+                long subtype = this.subtypeSet ? this.subtype : parentMessage.subtype;
+                byte[] experimenterData = this.experimenterDataSet ? this.experimenterData : parentMessage.experimenterData;
+                if(experimenterData == null)
+                    throw new NullPointerException("Property experimenterData must not be null");
+
+                //
+                return new OFTableFeaturePropExperimenterVer13(
+                    experimenter,
+                    subtype,
+                    experimenterData
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropExperimenter.Builder {
+        // OF message fields
+        private boolean experimenterSet;
+        private long experimenter;
+        private boolean subtypeSet;
+        private long subtype;
+        private boolean experimenterDataSet;
+        private byte[] experimenterData;
+
+    @Override
+    public int getType() {
+        return 0xfffe;
+    }
+
+    @Override
+    public long getExperimenter() {
+        return experimenter;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenter.Builder setExperimenter(long experimenter) {
+        this.experimenter = experimenter;
+        this.experimenterSet = true;
+        return this;
+    }
+    @Override
+    public long getSubtype() {
+        return subtype;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenter.Builder setSubtype(long subtype) {
+        this.subtype = subtype;
+        this.subtypeSet = true;
+        return this;
+    }
+    @Override
+    public byte[] getExperimenterData() {
+        return experimenterData;
+    }
+
+    @Override
+    public OFTableFeaturePropExperimenter.Builder setExperimenterData(byte[] experimenterData) {
+        this.experimenterData = experimenterData;
+        this.experimenterDataSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropExperimenter build() {
+            long experimenter = this.experimenterSet ? this.experimenter : DEFAULT_EXPERIMENTER;
+            long subtype = this.subtypeSet ? this.subtype : DEFAULT_SUBTYPE;
+            byte[] experimenterData = this.experimenterDataSet ? this.experimenterData : DEFAULT_EXPERIMENTER_DATA;
+            if(experimenterData == null)
+                throw new NullPointerException("Property experimenterData must not be null");
+
+
+            return new OFTableFeaturePropExperimenterVer13(
+                    experimenter,
+                    subtype,
+                    experimenterData
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropExperimenter> {
+        @Override
+        public OFTableFeaturePropExperimenter readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xfffe
+            short type = bb.readShort();
+            if(type != (short) 0xfffe)
+                throw new OFParseError("Wrong type: Expected=0xfffe(0xfffe), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long experimenter = U32.f(bb.readInt());
+            long subtype = U32.f(bb.readInt());
+            byte[] experimenterData = ChannelUtils.readBytes(bb, length - (bb.readerIndex() - start));
+
+            OFTableFeaturePropExperimenterVer13 tableFeaturePropExperimenterVer13 = new OFTableFeaturePropExperimenterVer13(
+                    experimenter,
+                      subtype,
+                      experimenterData
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropExperimenterVer13);
+            return tableFeaturePropExperimenterVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropExperimenterVer13Funnel FUNNEL = new OFTableFeaturePropExperimenterVer13Funnel();
+    static class OFTableFeaturePropExperimenterVer13Funnel implements Funnel<OFTableFeaturePropExperimenterVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropExperimenterVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xfffe
+            sink.putShort((short) 0xfffe);
+            // FIXME: skip funnel of length
+            sink.putLong(message.experimenter);
+            sink.putLong(message.subtype);
+            sink.putBytes(message.experimenterData);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropExperimenterVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropExperimenterVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0xfffe
+            bb.writeShort((short) 0xfffe);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.experimenter));
+            bb.writeInt(U32.t(message.subtype));
+            bb.writeBytes(message.experimenterData);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropExperimenterVer13(");
+        b.append("experimenter=").append(experimenter);
+        b.append(", ");
+        b.append("subtype=").append(subtype);
+        b.append(", ");
+        b.append("experimenterData=").append(Arrays.toString(experimenterData));
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropExperimenterVer13 other = (OFTableFeaturePropExperimenterVer13) obj;
+
+        if( experimenter != other.experimenter)
+            return false;
+        if( subtype != other.subtype)
+            return false;
+        if (!Arrays.equals(experimenterData, other.experimenterData))
+                return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (experimenter ^ (experimenter >>> 32));
+        result = prime *  (int) (subtype ^ (subtype >>> 32));
+        result = prime * result + Arrays.hashCode(experimenterData);
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropInstructionsMissVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropInstructionsMissVer13.java
new file mode 100644
index 0000000..a7785e2
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropInstructionsMissVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropInstructionsMissVer13 implements OFTableFeaturePropInstructionsMiss {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropInstructionsMissVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<OFInstructionId> DEFAULT_INSTRUCTION_IDS = ImmutableList.<OFInstructionId>of();
+
+    // OF message fields
+    private final List<OFInstructionId> instructionIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropInstructionsMissVer13 DEFAULT = new OFTableFeaturePropInstructionsMissVer13(
+        DEFAULT_INSTRUCTION_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropInstructionsMissVer13(List<OFInstructionId> instructionIds) {
+        this.instructionIds = instructionIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public List<OFInstructionId> getInstructionIds() {
+        return instructionIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropInstructionsMiss.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropInstructionsMiss.Builder {
+        final OFTableFeaturePropInstructionsMissVer13 parentMessage;
+
+        // OF message fields
+        private boolean instructionIdsSet;
+        private List<OFInstructionId> instructionIds;
+
+        BuilderWithParent(OFTableFeaturePropInstructionsMissVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public List<OFInstructionId> getInstructionIds() {
+        return instructionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropInstructionsMiss.Builder setInstructionIds(List<OFInstructionId> instructionIds) {
+        this.instructionIds = instructionIds;
+        this.instructionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropInstructionsMiss build() {
+                List<OFInstructionId> instructionIds = this.instructionIdsSet ? this.instructionIds : parentMessage.instructionIds;
+                if(instructionIds == null)
+                    throw new NullPointerException("Property instructionIds must not be null");
+
+                //
+                return new OFTableFeaturePropInstructionsMissVer13(
+                    instructionIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropInstructionsMiss.Builder {
+        // OF message fields
+        private boolean instructionIdsSet;
+        private List<OFInstructionId> instructionIds;
+
+    @Override
+    public int getType() {
+        return 0x1;
+    }
+
+    @Override
+    public List<OFInstructionId> getInstructionIds() {
+        return instructionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropInstructionsMiss.Builder setInstructionIds(List<OFInstructionId> instructionIds) {
+        this.instructionIds = instructionIds;
+        this.instructionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropInstructionsMiss build() {
+            List<OFInstructionId> instructionIds = this.instructionIdsSet ? this.instructionIds : DEFAULT_INSTRUCTION_IDS;
+            if(instructionIds == null)
+                throw new NullPointerException("Property instructionIds must not be null");
+
+
+            return new OFTableFeaturePropInstructionsMissVer13(
+                    instructionIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropInstructionsMiss> {
+        @Override
+        public OFTableFeaturePropInstructionsMiss readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x1
+            short type = bb.readShort();
+            if(type != (short) 0x1)
+                throw new OFParseError("Wrong type: Expected=0x1(0x1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<OFInstructionId> instructionIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionIdVer13.READER);
+
+            OFTableFeaturePropInstructionsMissVer13 tableFeaturePropInstructionsMissVer13 = new OFTableFeaturePropInstructionsMissVer13(
+                    instructionIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropInstructionsMissVer13);
+            return tableFeaturePropInstructionsMissVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropInstructionsMissVer13Funnel FUNNEL = new OFTableFeaturePropInstructionsMissVer13Funnel();
+    static class OFTableFeaturePropInstructionsMissVer13Funnel implements Funnel<OFTableFeaturePropInstructionsMissVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropInstructionsMissVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x1
+            sink.putShort((short) 0x1);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.instructionIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropInstructionsMissVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropInstructionsMissVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x1
+            bb.writeShort((short) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.instructionIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropInstructionsMissVer13(");
+        b.append("instructionIds=").append(instructionIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropInstructionsMissVer13 other = (OFTableFeaturePropInstructionsMissVer13) obj;
+
+        if (instructionIds == null) {
+            if (other.instructionIds != null)
+                return false;
+        } else if (!instructionIds.equals(other.instructionIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((instructionIds == null) ? 0 : instructionIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropInstructionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropInstructionsVer13.java
new file mode 100644
index 0000000..829f553
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropInstructionsVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropInstructionsVer13 implements OFTableFeaturePropInstructions {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropInstructionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<OFInstructionId> DEFAULT_INSTRUCTION_IDS = ImmutableList.<OFInstructionId>of();
+
+    // OF message fields
+    private final List<OFInstructionId> instructionIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropInstructionsVer13 DEFAULT = new OFTableFeaturePropInstructionsVer13(
+        DEFAULT_INSTRUCTION_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropInstructionsVer13(List<OFInstructionId> instructionIds) {
+        this.instructionIds = instructionIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public List<OFInstructionId> getInstructionIds() {
+        return instructionIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropInstructions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropInstructions.Builder {
+        final OFTableFeaturePropInstructionsVer13 parentMessage;
+
+        // OF message fields
+        private boolean instructionIdsSet;
+        private List<OFInstructionId> instructionIds;
+
+        BuilderWithParent(OFTableFeaturePropInstructionsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public List<OFInstructionId> getInstructionIds() {
+        return instructionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropInstructions.Builder setInstructionIds(List<OFInstructionId> instructionIds) {
+        this.instructionIds = instructionIds;
+        this.instructionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropInstructions build() {
+                List<OFInstructionId> instructionIds = this.instructionIdsSet ? this.instructionIds : parentMessage.instructionIds;
+                if(instructionIds == null)
+                    throw new NullPointerException("Property instructionIds must not be null");
+
+                //
+                return new OFTableFeaturePropInstructionsVer13(
+                    instructionIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropInstructions.Builder {
+        // OF message fields
+        private boolean instructionIdsSet;
+        private List<OFInstructionId> instructionIds;
+
+    @Override
+    public int getType() {
+        return 0x0;
+    }
+
+    @Override
+    public List<OFInstructionId> getInstructionIds() {
+        return instructionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropInstructions.Builder setInstructionIds(List<OFInstructionId> instructionIds) {
+        this.instructionIds = instructionIds;
+        this.instructionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropInstructions build() {
+            List<OFInstructionId> instructionIds = this.instructionIdsSet ? this.instructionIds : DEFAULT_INSTRUCTION_IDS;
+            if(instructionIds == null)
+                throw new NullPointerException("Property instructionIds must not be null");
+
+
+            return new OFTableFeaturePropInstructionsVer13(
+                    instructionIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropInstructions> {
+        @Override
+        public OFTableFeaturePropInstructions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x0
+            short type = bb.readShort();
+            if(type != (short) 0x0)
+                throw new OFParseError("Wrong type: Expected=0x0(0x0), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<OFInstructionId> instructionIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFInstructionIdVer13.READER);
+
+            OFTableFeaturePropInstructionsVer13 tableFeaturePropInstructionsVer13 = new OFTableFeaturePropInstructionsVer13(
+                    instructionIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropInstructionsVer13);
+            return tableFeaturePropInstructionsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropInstructionsVer13Funnel FUNNEL = new OFTableFeaturePropInstructionsVer13Funnel();
+    static class OFTableFeaturePropInstructionsVer13Funnel implements Funnel<OFTableFeaturePropInstructionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropInstructionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x0
+            sink.putShort((short) 0x0);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.instructionIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropInstructionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropInstructionsVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x0
+            bb.writeShort((short) 0x0);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.instructionIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropInstructionsVer13(");
+        b.append("instructionIds=").append(instructionIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropInstructionsVer13 other = (OFTableFeaturePropInstructionsVer13) obj;
+
+        if (instructionIds == null) {
+            if (other.instructionIds != null)
+                return false;
+        } else if (!instructionIds.equals(other.instructionIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((instructionIds == null) ? 0 : instructionIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropMatchVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropMatchVer13.java
new file mode 100644
index 0000000..ab2cbe8
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropMatchVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropMatchVer13 implements OFTableFeaturePropMatch {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropMatchVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U32> DEFAULT_OXM_IDS = ImmutableList.<U32>of();
+
+    // OF message fields
+    private final List<U32> oxmIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropMatchVer13 DEFAULT = new OFTableFeaturePropMatchVer13(
+        DEFAULT_OXM_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropMatchVer13(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x8;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropMatch.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropMatch.Builder {
+        final OFTableFeaturePropMatchVer13 parentMessage;
+
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+        BuilderWithParent(OFTableFeaturePropMatchVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x8;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropMatch.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropMatch build() {
+                List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : parentMessage.oxmIds;
+                if(oxmIds == null)
+                    throw new NullPointerException("Property oxmIds must not be null");
+
+                //
+                return new OFTableFeaturePropMatchVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropMatch.Builder {
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+    @Override
+    public int getType() {
+        return 0x8;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropMatch.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropMatch build() {
+            List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : DEFAULT_OXM_IDS;
+            if(oxmIds == null)
+                throw new NullPointerException("Property oxmIds must not be null");
+
+
+            return new OFTableFeaturePropMatchVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropMatch> {
+        @Override
+        public OFTableFeaturePropMatch readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x8
+            short type = bb.readShort();
+            if(type != (short) 0x8)
+                throw new OFParseError("Wrong type: Expected=0x8(0x8), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U32> oxmIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U32.READER);
+
+            OFTableFeaturePropMatchVer13 tableFeaturePropMatchVer13 = new OFTableFeaturePropMatchVer13(
+                    oxmIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropMatchVer13);
+            return tableFeaturePropMatchVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropMatchVer13Funnel FUNNEL = new OFTableFeaturePropMatchVer13Funnel();
+    static class OFTableFeaturePropMatchVer13Funnel implements Funnel<OFTableFeaturePropMatchVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropMatchVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x8
+            sink.putShort((short) 0x8);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.oxmIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropMatchVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropMatchVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x8
+            bb.writeShort((short) 0x8);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.oxmIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropMatchVer13(");
+        b.append("oxmIds=").append(oxmIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropMatchVer13 other = (OFTableFeaturePropMatchVer13) obj;
+
+        if (oxmIds == null) {
+            if (other.oxmIds != null)
+                return false;
+        } else if (!oxmIds.equals(other.oxmIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((oxmIds == null) ? 0 : oxmIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropNextTablesMissVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropNextTablesMissVer13.java
new file mode 100644
index 0000000..150bd06
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropNextTablesMissVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropNextTablesMissVer13 implements OFTableFeaturePropNextTablesMiss {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropNextTablesMissVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U8> DEFAULT_NEXT_TABLE_IDS = ImmutableList.<U8>of();
+
+    // OF message fields
+    private final List<U8> nextTableIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropNextTablesMissVer13 DEFAULT = new OFTableFeaturePropNextTablesMissVer13(
+        DEFAULT_NEXT_TABLE_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropNextTablesMissVer13(List<U8> nextTableIds) {
+        this.nextTableIds = nextTableIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x3;
+    }
+
+    @Override
+    public List<U8> getNextTableIds() {
+        return nextTableIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropNextTablesMiss.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropNextTablesMiss.Builder {
+        final OFTableFeaturePropNextTablesMissVer13 parentMessage;
+
+        // OF message fields
+        private boolean nextTableIdsSet;
+        private List<U8> nextTableIds;
+
+        BuilderWithParent(OFTableFeaturePropNextTablesMissVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x3;
+    }
+
+    @Override
+    public List<U8> getNextTableIds() {
+        return nextTableIds;
+    }
+
+    @Override
+    public OFTableFeaturePropNextTablesMiss.Builder setNextTableIds(List<U8> nextTableIds) {
+        this.nextTableIds = nextTableIds;
+        this.nextTableIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropNextTablesMiss build() {
+                List<U8> nextTableIds = this.nextTableIdsSet ? this.nextTableIds : parentMessage.nextTableIds;
+                if(nextTableIds == null)
+                    throw new NullPointerException("Property nextTableIds must not be null");
+
+                //
+                return new OFTableFeaturePropNextTablesMissVer13(
+                    nextTableIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropNextTablesMiss.Builder {
+        // OF message fields
+        private boolean nextTableIdsSet;
+        private List<U8> nextTableIds;
+
+    @Override
+    public int getType() {
+        return 0x3;
+    }
+
+    @Override
+    public List<U8> getNextTableIds() {
+        return nextTableIds;
+    }
+
+    @Override
+    public OFTableFeaturePropNextTablesMiss.Builder setNextTableIds(List<U8> nextTableIds) {
+        this.nextTableIds = nextTableIds;
+        this.nextTableIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropNextTablesMiss build() {
+            List<U8> nextTableIds = this.nextTableIdsSet ? this.nextTableIds : DEFAULT_NEXT_TABLE_IDS;
+            if(nextTableIds == null)
+                throw new NullPointerException("Property nextTableIds must not be null");
+
+
+            return new OFTableFeaturePropNextTablesMissVer13(
+                    nextTableIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropNextTablesMiss> {
+        @Override
+        public OFTableFeaturePropNextTablesMiss readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x3
+            short type = bb.readShort();
+            if(type != (short) 0x3)
+                throw new OFParseError("Wrong type: Expected=0x3(0x3), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U8> nextTableIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U8.READER);
+
+            OFTableFeaturePropNextTablesMissVer13 tableFeaturePropNextTablesMissVer13 = new OFTableFeaturePropNextTablesMissVer13(
+                    nextTableIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropNextTablesMissVer13);
+            return tableFeaturePropNextTablesMissVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropNextTablesMissVer13Funnel FUNNEL = new OFTableFeaturePropNextTablesMissVer13Funnel();
+    static class OFTableFeaturePropNextTablesMissVer13Funnel implements Funnel<OFTableFeaturePropNextTablesMissVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropNextTablesMissVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x3
+            sink.putShort((short) 0x3);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.nextTableIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropNextTablesMissVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropNextTablesMissVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x3
+            bb.writeShort((short) 0x3);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.nextTableIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropNextTablesMissVer13(");
+        b.append("nextTableIds=").append(nextTableIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropNextTablesMissVer13 other = (OFTableFeaturePropNextTablesMissVer13) obj;
+
+        if (nextTableIds == null) {
+            if (other.nextTableIds != null)
+                return false;
+        } else if (!nextTableIds.equals(other.nextTableIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((nextTableIds == null) ? 0 : nextTableIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropNextTablesVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropNextTablesVer13.java
new file mode 100644
index 0000000..6bb6d93
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropNextTablesVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropNextTablesVer13 implements OFTableFeaturePropNextTables {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropNextTablesVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U8> DEFAULT_NEXT_TABLE_IDS = ImmutableList.<U8>of();
+
+    // OF message fields
+    private final List<U8> nextTableIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropNextTablesVer13 DEFAULT = new OFTableFeaturePropNextTablesVer13(
+        DEFAULT_NEXT_TABLE_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropNextTablesVer13(List<U8> nextTableIds) {
+        this.nextTableIds = nextTableIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public List<U8> getNextTableIds() {
+        return nextTableIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropNextTables.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropNextTables.Builder {
+        final OFTableFeaturePropNextTablesVer13 parentMessage;
+
+        // OF message fields
+        private boolean nextTableIdsSet;
+        private List<U8> nextTableIds;
+
+        BuilderWithParent(OFTableFeaturePropNextTablesVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public List<U8> getNextTableIds() {
+        return nextTableIds;
+    }
+
+    @Override
+    public OFTableFeaturePropNextTables.Builder setNextTableIds(List<U8> nextTableIds) {
+        this.nextTableIds = nextTableIds;
+        this.nextTableIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropNextTables build() {
+                List<U8> nextTableIds = this.nextTableIdsSet ? this.nextTableIds : parentMessage.nextTableIds;
+                if(nextTableIds == null)
+                    throw new NullPointerException("Property nextTableIds must not be null");
+
+                //
+                return new OFTableFeaturePropNextTablesVer13(
+                    nextTableIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropNextTables.Builder {
+        // OF message fields
+        private boolean nextTableIdsSet;
+        private List<U8> nextTableIds;
+
+    @Override
+    public int getType() {
+        return 0x2;
+    }
+
+    @Override
+    public List<U8> getNextTableIds() {
+        return nextTableIds;
+    }
+
+    @Override
+    public OFTableFeaturePropNextTables.Builder setNextTableIds(List<U8> nextTableIds) {
+        this.nextTableIds = nextTableIds;
+        this.nextTableIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropNextTables build() {
+            List<U8> nextTableIds = this.nextTableIdsSet ? this.nextTableIds : DEFAULT_NEXT_TABLE_IDS;
+            if(nextTableIds == null)
+                throw new NullPointerException("Property nextTableIds must not be null");
+
+
+            return new OFTableFeaturePropNextTablesVer13(
+                    nextTableIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropNextTables> {
+        @Override
+        public OFTableFeaturePropNextTables readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x2
+            short type = bb.readShort();
+            if(type != (short) 0x2)
+                throw new OFParseError("Wrong type: Expected=0x2(0x2), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U8> nextTableIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U8.READER);
+
+            OFTableFeaturePropNextTablesVer13 tableFeaturePropNextTablesVer13 = new OFTableFeaturePropNextTablesVer13(
+                    nextTableIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropNextTablesVer13);
+            return tableFeaturePropNextTablesVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropNextTablesVer13Funnel FUNNEL = new OFTableFeaturePropNextTablesVer13Funnel();
+    static class OFTableFeaturePropNextTablesVer13Funnel implements Funnel<OFTableFeaturePropNextTablesVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropNextTablesVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x2
+            sink.putShort((short) 0x2);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.nextTableIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropNextTablesVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropNextTablesVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x2
+            bb.writeShort((short) 0x2);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.nextTableIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropNextTablesVer13(");
+        b.append("nextTableIds=").append(nextTableIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropNextTablesVer13 other = (OFTableFeaturePropNextTablesVer13) obj;
+
+        if (nextTableIds == null) {
+            if (other.nextTableIds != null)
+                return false;
+        } else if (!nextTableIds.equals(other.nextTableIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((nextTableIds == null) ? 0 : nextTableIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropTypeSerializerVer13.java
new file mode 100644
index 0000000..a3524f5
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropTypeSerializerVer13.java
@@ -0,0 +1,144 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTableFeaturePropType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTableFeaturePropTypeSerializerVer13 {
+
+    public final static short INSTRUCTIONS_VAL = (short) 0x0;
+    public final static short INSTRUCTIONS_MISS_VAL = (short) 0x1;
+    public final static short NEXT_TABLES_VAL = (short) 0x2;
+    public final static short NEXT_TABLES_MISS_VAL = (short) 0x3;
+    public final static short WRITE_ACTIONS_VAL = (short) 0x4;
+    public final static short WRITE_ACTIONS_MISS_VAL = (short) 0x5;
+    public final static short APPLY_ACTIONS_VAL = (short) 0x6;
+    public final static short APPLY_ACTIONS_MISS_VAL = (short) 0x7;
+    public final static short MATCH_VAL = (short) 0x8;
+    public final static short WILDCARDS_VAL = (short) 0xa;
+    public final static short WRITE_SETFIELD_VAL = (short) 0xc;
+    public final static short WRITE_SETFIELD_MISS_VAL = (short) 0xd;
+    public final static short APPLY_SETFIELD_VAL = (short) 0xe;
+    public final static short APPLY_SETFIELD_MISS_VAL = (short) 0xf;
+    public final static short EXPERIMENTER_VAL = (short) 0xfffe;
+    public final static short EXPERIMENTER_MISS_VAL = (short) 0xffff;
+
+    public static OFTableFeaturePropType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFTableFeaturePropType e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFTableFeaturePropType e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFTableFeaturePropType ofWireValue(short val) {
+        switch(val) {
+            case INSTRUCTIONS_VAL:
+                return OFTableFeaturePropType.INSTRUCTIONS;
+            case INSTRUCTIONS_MISS_VAL:
+                return OFTableFeaturePropType.INSTRUCTIONS_MISS;
+            case NEXT_TABLES_VAL:
+                return OFTableFeaturePropType.NEXT_TABLES;
+            case NEXT_TABLES_MISS_VAL:
+                return OFTableFeaturePropType.NEXT_TABLES_MISS;
+            case WRITE_ACTIONS_VAL:
+                return OFTableFeaturePropType.WRITE_ACTIONS;
+            case WRITE_ACTIONS_MISS_VAL:
+                return OFTableFeaturePropType.WRITE_ACTIONS_MISS;
+            case APPLY_ACTIONS_VAL:
+                return OFTableFeaturePropType.APPLY_ACTIONS;
+            case APPLY_ACTIONS_MISS_VAL:
+                return OFTableFeaturePropType.APPLY_ACTIONS_MISS;
+            case MATCH_VAL:
+                return OFTableFeaturePropType.MATCH;
+            case WILDCARDS_VAL:
+                return OFTableFeaturePropType.WILDCARDS;
+            case WRITE_SETFIELD_VAL:
+                return OFTableFeaturePropType.WRITE_SETFIELD;
+            case WRITE_SETFIELD_MISS_VAL:
+                return OFTableFeaturePropType.WRITE_SETFIELD_MISS;
+            case APPLY_SETFIELD_VAL:
+                return OFTableFeaturePropType.APPLY_SETFIELD;
+            case APPLY_SETFIELD_MISS_VAL:
+                return OFTableFeaturePropType.APPLY_SETFIELD_MISS;
+            case EXPERIMENTER_VAL:
+                return OFTableFeaturePropType.EXPERIMENTER;
+            case EXPERIMENTER_MISS_VAL:
+                return OFTableFeaturePropType.EXPERIMENTER_MISS;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFTableFeaturePropType in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFTableFeaturePropType e) {
+        switch(e) {
+            case INSTRUCTIONS:
+                return INSTRUCTIONS_VAL;
+            case INSTRUCTIONS_MISS:
+                return INSTRUCTIONS_MISS_VAL;
+            case NEXT_TABLES:
+                return NEXT_TABLES_VAL;
+            case NEXT_TABLES_MISS:
+                return NEXT_TABLES_MISS_VAL;
+            case WRITE_ACTIONS:
+                return WRITE_ACTIONS_VAL;
+            case WRITE_ACTIONS_MISS:
+                return WRITE_ACTIONS_MISS_VAL;
+            case APPLY_ACTIONS:
+                return APPLY_ACTIONS_VAL;
+            case APPLY_ACTIONS_MISS:
+                return APPLY_ACTIONS_MISS_VAL;
+            case MATCH:
+                return MATCH_VAL;
+            case WILDCARDS:
+                return WILDCARDS_VAL;
+            case WRITE_SETFIELD:
+                return WRITE_SETFIELD_VAL;
+            case WRITE_SETFIELD_MISS:
+                return WRITE_SETFIELD_MISS_VAL;
+            case APPLY_SETFIELD:
+                return APPLY_SETFIELD_VAL;
+            case APPLY_SETFIELD_MISS:
+                return APPLY_SETFIELD_MISS_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            case EXPERIMENTER_MISS:
+                return EXPERIMENTER_MISS_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFTableFeaturePropType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropVer13.java
new file mode 100644
index 0000000..833639b
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropVer13.java
@@ -0,0 +1,99 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_virtual_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.jboss.netty.buffer.ChannelBuffer;
+import java.util.Set;
+
+abstract class OFTableFeaturePropVer13 {
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+
+    public final static OFTableFeaturePropVer13.Reader READER = new Reader();
+
+    static class Reader implements OFMessageReader<OFTableFeatureProp> {
+        @Override
+        public OFTableFeatureProp readFrom(ChannelBuffer bb) throws OFParseError {
+            if(bb.readableBytes() < MINIMUM_LENGTH)
+                return null;
+            int start = bb.readerIndex();
+            short type = bb.readShort();
+            bb.readerIndex(start);
+            switch(type) {
+               case (short) 0x6:
+                   // discriminator value 0x6=0x6 for class OFTableFeaturePropApplyActionsVer13
+                   return OFTableFeaturePropApplyActionsVer13.READER.readFrom(bb);
+               case (short) 0x7:
+                   // discriminator value 0x7=0x7 for class OFTableFeaturePropApplyActionsMissVer13
+                   return OFTableFeaturePropApplyActionsMissVer13.READER.readFrom(bb);
+               case (short) 0xe:
+                   // discriminator value 0xe=0xe for class OFTableFeaturePropApplySetfieldVer13
+                   return OFTableFeaturePropApplySetfieldVer13.READER.readFrom(bb);
+               case (short) 0xf:
+                   // discriminator value 0xf=0xf for class OFTableFeaturePropApplySetfieldMissVer13
+                   return OFTableFeaturePropApplySetfieldMissVer13.READER.readFrom(bb);
+               case (short) 0xfffe:
+                   // discriminator value 0xfffe=0xfffe for class OFTableFeaturePropExperimenterVer13
+                   return OFTableFeaturePropExperimenterVer13.READER.readFrom(bb);
+               case (short) 0xffff:
+                   // discriminator value 0xffff=0xffff for class OFTableFeaturePropExperimenterMissVer13
+                   return OFTableFeaturePropExperimenterMissVer13.READER.readFrom(bb);
+               case (short) 0x0:
+                   // discriminator value 0x0=0x0 for class OFTableFeaturePropInstructionsVer13
+                   return OFTableFeaturePropInstructionsVer13.READER.readFrom(bb);
+               case (short) 0x1:
+                   // discriminator value 0x1=0x1 for class OFTableFeaturePropInstructionsMissVer13
+                   return OFTableFeaturePropInstructionsMissVer13.READER.readFrom(bb);
+               case (short) 0x8:
+                   // discriminator value 0x8=0x8 for class OFTableFeaturePropMatchVer13
+                   return OFTableFeaturePropMatchVer13.READER.readFrom(bb);
+               case (short) 0x2:
+                   // discriminator value 0x2=0x2 for class OFTableFeaturePropNextTablesVer13
+                   return OFTableFeaturePropNextTablesVer13.READER.readFrom(bb);
+               case (short) 0x3:
+                   // discriminator value 0x3=0x3 for class OFTableFeaturePropNextTablesMissVer13
+                   return OFTableFeaturePropNextTablesMissVer13.READER.readFrom(bb);
+               case (short) 0xa:
+                   // discriminator value 0xa=0xa for class OFTableFeaturePropWildcardsVer13
+                   return OFTableFeaturePropWildcardsVer13.READER.readFrom(bb);
+               case (short) 0x4:
+                   // discriminator value 0x4=0x4 for class OFTableFeaturePropWriteActionsVer13
+                   return OFTableFeaturePropWriteActionsVer13.READER.readFrom(bb);
+               case (short) 0x5:
+                   // discriminator value 0x5=0x5 for class OFTableFeaturePropWriteActionsMissVer13
+                   return OFTableFeaturePropWriteActionsMissVer13.READER.readFrom(bb);
+               case (short) 0xc:
+                   // discriminator value 0xc=0xc for class OFTableFeaturePropWriteSetfieldVer13
+                   return OFTableFeaturePropWriteSetfieldVer13.READER.readFrom(bb);
+               case (short) 0xd:
+                   // discriminator value 0xd=0xd for class OFTableFeaturePropWriteSetfieldMissVer13
+                   return OFTableFeaturePropWriteSetfieldMissVer13.READER.readFrom(bb);
+               default:
+                   throw new OFParseError("Unknown value for discriminator type of class OFTableFeaturePropVer13: " + type);
+            }
+        }
+    }
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWildcardsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWildcardsVer13.java
new file mode 100644
index 0000000..66db46d
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWildcardsVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropWildcardsVer13 implements OFTableFeaturePropWildcards {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropWildcardsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U32> DEFAULT_OXM_IDS = ImmutableList.<U32>of();
+
+    // OF message fields
+    private final List<U32> oxmIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropWildcardsVer13 DEFAULT = new OFTableFeaturePropWildcardsVer13(
+        DEFAULT_OXM_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropWildcardsVer13(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xa;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropWildcards.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropWildcards.Builder {
+        final OFTableFeaturePropWildcardsVer13 parentMessage;
+
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+        BuilderWithParent(OFTableFeaturePropWildcardsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xa;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWildcards.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropWildcards build() {
+                List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : parentMessage.oxmIds;
+                if(oxmIds == null)
+                    throw new NullPointerException("Property oxmIds must not be null");
+
+                //
+                return new OFTableFeaturePropWildcardsVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropWildcards.Builder {
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+    @Override
+    public int getType() {
+        return 0xa;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWildcards.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropWildcards build() {
+            List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : DEFAULT_OXM_IDS;
+            if(oxmIds == null)
+                throw new NullPointerException("Property oxmIds must not be null");
+
+
+            return new OFTableFeaturePropWildcardsVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropWildcards> {
+        @Override
+        public OFTableFeaturePropWildcards readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xa
+            short type = bb.readShort();
+            if(type != (short) 0xa)
+                throw new OFParseError("Wrong type: Expected=0xa(0xa), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U32> oxmIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U32.READER);
+
+            OFTableFeaturePropWildcardsVer13 tableFeaturePropWildcardsVer13 = new OFTableFeaturePropWildcardsVer13(
+                    oxmIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropWildcardsVer13);
+            return tableFeaturePropWildcardsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropWildcardsVer13Funnel FUNNEL = new OFTableFeaturePropWildcardsVer13Funnel();
+    static class OFTableFeaturePropWildcardsVer13Funnel implements Funnel<OFTableFeaturePropWildcardsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropWildcardsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xa
+            sink.putShort((short) 0xa);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.oxmIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropWildcardsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropWildcardsVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0xa
+            bb.writeShort((short) 0xa);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.oxmIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropWildcardsVer13(");
+        b.append("oxmIds=").append(oxmIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropWildcardsVer13 other = (OFTableFeaturePropWildcardsVer13) obj;
+
+        if (oxmIds == null) {
+            if (other.oxmIds != null)
+                return false;
+        } else if (!oxmIds.equals(other.oxmIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((oxmIds == null) ? 0 : oxmIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteActionsMissVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteActionsMissVer13.java
new file mode 100644
index 0000000..ce905bc
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteActionsMissVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropWriteActionsMissVer13 implements OFTableFeaturePropWriteActionsMiss {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropWriteActionsMissVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<OFActionId> DEFAULT_ACTION_IDS = ImmutableList.<OFActionId>of();
+
+    // OF message fields
+    private final List<OFActionId> actionIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropWriteActionsMissVer13 DEFAULT = new OFTableFeaturePropWriteActionsMissVer13(
+        DEFAULT_ACTION_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropWriteActionsMissVer13(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x5;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropWriteActionsMiss.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropWriteActionsMiss.Builder {
+        final OFTableFeaturePropWriteActionsMissVer13 parentMessage;
+
+        // OF message fields
+        private boolean actionIdsSet;
+        private List<OFActionId> actionIds;
+
+        BuilderWithParent(OFTableFeaturePropWriteActionsMissVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x5;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWriteActionsMiss.Builder setActionIds(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+        this.actionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropWriteActionsMiss build() {
+                List<OFActionId> actionIds = this.actionIdsSet ? this.actionIds : parentMessage.actionIds;
+                if(actionIds == null)
+                    throw new NullPointerException("Property actionIds must not be null");
+
+                //
+                return new OFTableFeaturePropWriteActionsMissVer13(
+                    actionIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropWriteActionsMiss.Builder {
+        // OF message fields
+        private boolean actionIdsSet;
+        private List<OFActionId> actionIds;
+
+    @Override
+    public int getType() {
+        return 0x5;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWriteActionsMiss.Builder setActionIds(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+        this.actionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropWriteActionsMiss build() {
+            List<OFActionId> actionIds = this.actionIdsSet ? this.actionIds : DEFAULT_ACTION_IDS;
+            if(actionIds == null)
+                throw new NullPointerException("Property actionIds must not be null");
+
+
+            return new OFTableFeaturePropWriteActionsMissVer13(
+                    actionIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropWriteActionsMiss> {
+        @Override
+        public OFTableFeaturePropWriteActionsMiss readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x5
+            short type = bb.readShort();
+            if(type != (short) 0x5)
+                throw new OFParseError("Wrong type: Expected=0x5(0x5), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<OFActionId> actionIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionIdVer13.READER);
+
+            OFTableFeaturePropWriteActionsMissVer13 tableFeaturePropWriteActionsMissVer13 = new OFTableFeaturePropWriteActionsMissVer13(
+                    actionIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropWriteActionsMissVer13);
+            return tableFeaturePropWriteActionsMissVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropWriteActionsMissVer13Funnel FUNNEL = new OFTableFeaturePropWriteActionsMissVer13Funnel();
+    static class OFTableFeaturePropWriteActionsMissVer13Funnel implements Funnel<OFTableFeaturePropWriteActionsMissVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropWriteActionsMissVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x5
+            sink.putShort((short) 0x5);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.actionIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropWriteActionsMissVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropWriteActionsMissVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x5
+            bb.writeShort((short) 0x5);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.actionIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropWriteActionsMissVer13(");
+        b.append("actionIds=").append(actionIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropWriteActionsMissVer13 other = (OFTableFeaturePropWriteActionsMissVer13) obj;
+
+        if (actionIds == null) {
+            if (other.actionIds != null)
+                return false;
+        } else if (!actionIds.equals(other.actionIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actionIds == null) ? 0 : actionIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteActionsVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteActionsVer13.java
new file mode 100644
index 0000000..54a2130
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteActionsVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropWriteActionsVer13 implements OFTableFeaturePropWriteActions {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropWriteActionsVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<OFActionId> DEFAULT_ACTION_IDS = ImmutableList.<OFActionId>of();
+
+    // OF message fields
+    private final List<OFActionId> actionIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropWriteActionsVer13 DEFAULT = new OFTableFeaturePropWriteActionsVer13(
+        DEFAULT_ACTION_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropWriteActionsVer13(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0x4;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropWriteActions.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropWriteActions.Builder {
+        final OFTableFeaturePropWriteActionsVer13 parentMessage;
+
+        // OF message fields
+        private boolean actionIdsSet;
+        private List<OFActionId> actionIds;
+
+        BuilderWithParent(OFTableFeaturePropWriteActionsVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0x4;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWriteActions.Builder setActionIds(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+        this.actionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropWriteActions build() {
+                List<OFActionId> actionIds = this.actionIdsSet ? this.actionIds : parentMessage.actionIds;
+                if(actionIds == null)
+                    throw new NullPointerException("Property actionIds must not be null");
+
+                //
+                return new OFTableFeaturePropWriteActionsVer13(
+                    actionIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropWriteActions.Builder {
+        // OF message fields
+        private boolean actionIdsSet;
+        private List<OFActionId> actionIds;
+
+    @Override
+    public int getType() {
+        return 0x4;
+    }
+
+    @Override
+    public List<OFActionId> getActionIds() {
+        return actionIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWriteActions.Builder setActionIds(List<OFActionId> actionIds) {
+        this.actionIds = actionIds;
+        this.actionIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropWriteActions build() {
+            List<OFActionId> actionIds = this.actionIdsSet ? this.actionIds : DEFAULT_ACTION_IDS;
+            if(actionIds == null)
+                throw new NullPointerException("Property actionIds must not be null");
+
+
+            return new OFTableFeaturePropWriteActionsVer13(
+                    actionIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropWriteActions> {
+        @Override
+        public OFTableFeaturePropWriteActions readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0x4
+            short type = bb.readShort();
+            if(type != (short) 0x4)
+                throw new OFParseError("Wrong type: Expected=0x4(0x4), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<OFActionId> actionIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFActionIdVer13.READER);
+
+            OFTableFeaturePropWriteActionsVer13 tableFeaturePropWriteActionsVer13 = new OFTableFeaturePropWriteActionsVer13(
+                    actionIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropWriteActionsVer13);
+            return tableFeaturePropWriteActionsVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropWriteActionsVer13Funnel FUNNEL = new OFTableFeaturePropWriteActionsVer13Funnel();
+    static class OFTableFeaturePropWriteActionsVer13Funnel implements Funnel<OFTableFeaturePropWriteActionsVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropWriteActionsVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0x4
+            sink.putShort((short) 0x4);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.actionIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropWriteActionsVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropWriteActionsVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0x4
+            bb.writeShort((short) 0x4);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.actionIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropWriteActionsVer13(");
+        b.append("actionIds=").append(actionIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropWriteActionsVer13 other = (OFTableFeaturePropWriteActionsVer13) obj;
+
+        if (actionIds == null) {
+            if (other.actionIds != null)
+                return false;
+        } else if (!actionIds.equals(other.actionIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((actionIds == null) ? 0 : actionIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteSetfieldMissVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteSetfieldMissVer13.java
new file mode 100644
index 0000000..6c87079
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteSetfieldMissVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropWriteSetfieldMissVer13 implements OFTableFeaturePropWriteSetfieldMiss {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropWriteSetfieldMissVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U32> DEFAULT_OXM_IDS = ImmutableList.<U32>of();
+
+    // OF message fields
+    private final List<U32> oxmIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropWriteSetfieldMissVer13 DEFAULT = new OFTableFeaturePropWriteSetfieldMissVer13(
+        DEFAULT_OXM_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropWriteSetfieldMissVer13(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xd;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropWriteSetfieldMiss.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropWriteSetfieldMiss.Builder {
+        final OFTableFeaturePropWriteSetfieldMissVer13 parentMessage;
+
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+        BuilderWithParent(OFTableFeaturePropWriteSetfieldMissVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xd;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWriteSetfieldMiss.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropWriteSetfieldMiss build() {
+                List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : parentMessage.oxmIds;
+                if(oxmIds == null)
+                    throw new NullPointerException("Property oxmIds must not be null");
+
+                //
+                return new OFTableFeaturePropWriteSetfieldMissVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropWriteSetfieldMiss.Builder {
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+    @Override
+    public int getType() {
+        return 0xd;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWriteSetfieldMiss.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropWriteSetfieldMiss build() {
+            List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : DEFAULT_OXM_IDS;
+            if(oxmIds == null)
+                throw new NullPointerException("Property oxmIds must not be null");
+
+
+            return new OFTableFeaturePropWriteSetfieldMissVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropWriteSetfieldMiss> {
+        @Override
+        public OFTableFeaturePropWriteSetfieldMiss readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xd
+            short type = bb.readShort();
+            if(type != (short) 0xd)
+                throw new OFParseError("Wrong type: Expected=0xd(0xd), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U32> oxmIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U32.READER);
+
+            OFTableFeaturePropWriteSetfieldMissVer13 tableFeaturePropWriteSetfieldMissVer13 = new OFTableFeaturePropWriteSetfieldMissVer13(
+                    oxmIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropWriteSetfieldMissVer13);
+            return tableFeaturePropWriteSetfieldMissVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropWriteSetfieldMissVer13Funnel FUNNEL = new OFTableFeaturePropWriteSetfieldMissVer13Funnel();
+    static class OFTableFeaturePropWriteSetfieldMissVer13Funnel implements Funnel<OFTableFeaturePropWriteSetfieldMissVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropWriteSetfieldMissVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xd
+            sink.putShort((short) 0xd);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.oxmIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropWriteSetfieldMissVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropWriteSetfieldMissVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0xd
+            bb.writeShort((short) 0xd);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.oxmIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropWriteSetfieldMissVer13(");
+        b.append("oxmIds=").append(oxmIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropWriteSetfieldMissVer13 other = (OFTableFeaturePropWriteSetfieldMissVer13) obj;
+
+        if (oxmIds == null) {
+            if (other.oxmIds != null)
+                return false;
+        } else if (!oxmIds.equals(other.oxmIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((oxmIds == null) ? 0 : oxmIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteSetfieldVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteSetfieldVer13.java
new file mode 100644
index 0000000..4990b30
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturePropWriteSetfieldVer13.java
@@ -0,0 +1,274 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturePropWriteSetfieldVer13 implements OFTableFeaturePropWriteSetfield {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturePropWriteSetfieldVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 4;
+
+        private final static List<U32> DEFAULT_OXM_IDS = ImmutableList.<U32>of();
+
+    // OF message fields
+    private final List<U32> oxmIds;
+//
+    // Immutable default instance
+    final static OFTableFeaturePropWriteSetfieldVer13 DEFAULT = new OFTableFeaturePropWriteSetfieldVer13(
+        DEFAULT_OXM_IDS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturePropWriteSetfieldVer13(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public int getType() {
+        return 0xc;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeaturePropWriteSetfield.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturePropWriteSetfield.Builder {
+        final OFTableFeaturePropWriteSetfieldVer13 parentMessage;
+
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+        BuilderWithParent(OFTableFeaturePropWriteSetfieldVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public int getType() {
+        return 0xc;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWriteSetfield.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeaturePropWriteSetfield build() {
+                List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : parentMessage.oxmIds;
+                if(oxmIds == null)
+                    throw new NullPointerException("Property oxmIds must not be null");
+
+                //
+                return new OFTableFeaturePropWriteSetfieldVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturePropWriteSetfield.Builder {
+        // OF message fields
+        private boolean oxmIdsSet;
+        private List<U32> oxmIds;
+
+    @Override
+    public int getType() {
+        return 0xc;
+    }
+
+    @Override
+    public List<U32> getOxmIds() {
+        return oxmIds;
+    }
+
+    @Override
+    public OFTableFeaturePropWriteSetfield.Builder setOxmIds(List<U32> oxmIds) {
+        this.oxmIds = oxmIds;
+        this.oxmIdsSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeaturePropWriteSetfield build() {
+            List<U32> oxmIds = this.oxmIdsSet ? this.oxmIds : DEFAULT_OXM_IDS;
+            if(oxmIds == null)
+                throw new NullPointerException("Property oxmIds must not be null");
+
+
+            return new OFTableFeaturePropWriteSetfieldVer13(
+                    oxmIds
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturePropWriteSetfield> {
+        @Override
+        public OFTableFeaturePropWriteSetfield readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property type == 0xc
+            short type = bb.readShort();
+            if(type != (short) 0xc)
+                throw new OFParseError("Wrong type: Expected=0xc(0xc), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            List<U32> oxmIds = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), U32.READER);
+
+            OFTableFeaturePropWriteSetfieldVer13 tableFeaturePropWriteSetfieldVer13 = new OFTableFeaturePropWriteSetfieldVer13(
+                    oxmIds
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturePropWriteSetfieldVer13);
+            return tableFeaturePropWriteSetfieldVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturePropWriteSetfieldVer13Funnel FUNNEL = new OFTableFeaturePropWriteSetfieldVer13Funnel();
+    static class OFTableFeaturePropWriteSetfieldVer13Funnel implements Funnel<OFTableFeaturePropWriteSetfieldVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturePropWriteSetfieldVer13 message, PrimitiveSink sink) {
+            // fixed value property type = 0xc
+            sink.putShort((short) 0xc);
+            // FIXME: skip funnel of length
+            FunnelUtils.putList(message.oxmIds, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturePropWriteSetfieldVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturePropWriteSetfieldVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property type = 0xc
+            bb.writeShort((short) 0xc);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            ChannelUtils.writeList(bb, message.oxmIds);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturePropWriteSetfieldVer13(");
+        b.append("oxmIds=").append(oxmIds);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturePropWriteSetfieldVer13 other = (OFTableFeaturePropWriteSetfieldVer13) obj;
+
+        if (oxmIds == null) {
+            if (other.oxmIds != null)
+                return false;
+        } else if (!oxmIds.equals(other.oxmIds))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((oxmIds == null) ? 0 : oxmIds.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..8026d95
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesFailedCodeSerializerVer13.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTableFeaturesFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTableFeaturesFailedCodeSerializerVer13 {
+
+    public final static short BAD_TABLE_VAL = (short) 0x0;
+    public final static short BAD_METADATA_VAL = (short) 0x1;
+    public final static short BAD_TYPE_VAL = (short) 0x2;
+    public final static short BAD_LEN_VAL = (short) 0x3;
+    public final static short BAD_ARGUMENT_VAL = (short) 0x4;
+    public final static short EPERM_VAL = (short) 0x5;
+
+    public static OFTableFeaturesFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFTableFeaturesFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFTableFeaturesFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFTableFeaturesFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TABLE_VAL:
+                return OFTableFeaturesFailedCode.BAD_TABLE;
+            case BAD_METADATA_VAL:
+                return OFTableFeaturesFailedCode.BAD_METADATA;
+            case BAD_TYPE_VAL:
+                return OFTableFeaturesFailedCode.BAD_TYPE;
+            case BAD_LEN_VAL:
+                return OFTableFeaturesFailedCode.BAD_LEN;
+            case BAD_ARGUMENT_VAL:
+                return OFTableFeaturesFailedCode.BAD_ARGUMENT;
+            case EPERM_VAL:
+                return OFTableFeaturesFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFTableFeaturesFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFTableFeaturesFailedCode e) {
+        switch(e) {
+            case BAD_TABLE:
+                return BAD_TABLE_VAL;
+            case BAD_METADATA:
+                return BAD_METADATA_VAL;
+            case BAD_TYPE:
+                return BAD_TYPE_VAL;
+            case BAD_LEN:
+                return BAD_LEN_VAL;
+            case BAD_ARGUMENT:
+                return BAD_ARGUMENT_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFTableFeaturesFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesFailedErrorMsgVer13.java
new file mode 100644
index 0000000..27d3ba9
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturesFailedErrorMsgVer13 implements OFTableFeaturesFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturesFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFTableFeaturesFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturesFailedErrorMsgVer13(long xid, OFTableFeaturesFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_FEATURES_FAILED;
+    }
+
+    @Override
+    public OFTableFeaturesFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFTableFeaturesFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturesFailedErrorMsg.Builder {
+        final OFTableFeaturesFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFTableFeaturesFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFTableFeaturesFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableFeaturesFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_FEATURES_FAILED;
+    }
+
+    @Override
+    public OFTableFeaturesFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFTableFeaturesFailedErrorMsg.Builder setCode(OFTableFeaturesFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFTableFeaturesFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableFeaturesFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFTableFeaturesFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFTableFeaturesFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturesFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFTableFeaturesFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableFeaturesFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_FEATURES_FAILED;
+    }
+
+    @Override
+    public OFTableFeaturesFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFTableFeaturesFailedErrorMsg.Builder setCode(OFTableFeaturesFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFTableFeaturesFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableFeaturesFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFTableFeaturesFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturesFailedErrorMsg> {
+        @Override
+        public OFTableFeaturesFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 13
+            short errType = bb.readShort();
+            if(errType != (short) 0xd)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.TABLE_FEATURES_FAILED(13), got="+errType);
+            OFTableFeaturesFailedCode code = OFTableFeaturesFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFTableFeaturesFailedErrorMsgVer13 tableFeaturesFailedErrorMsgVer13 = new OFTableFeaturesFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturesFailedErrorMsgVer13);
+            return tableFeaturesFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturesFailedErrorMsgVer13Funnel FUNNEL = new OFTableFeaturesFailedErrorMsgVer13Funnel();
+    static class OFTableFeaturesFailedErrorMsgVer13Funnel implements Funnel<OFTableFeaturesFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturesFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 13
+            sink.putShort((short) 0xd);
+            OFTableFeaturesFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturesFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturesFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 13
+            bb.writeShort((short) 0xd);
+            OFTableFeaturesFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturesFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturesFailedErrorMsgVer13 other = (OFTableFeaturesFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesStatsReplyVer13.java
new file mode 100644
index 0000000..3bcb7b3
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturesStatsReplyVer13 implements OFTableFeaturesStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturesStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFTableFeatures> DEFAULT_ENTRIES = ImmutableList.<OFTableFeatures>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFTableFeatures> entries;
+//
+    // Immutable default instance
+    final static OFTableFeaturesStatsReplyVer13 DEFAULT = new OFTableFeaturesStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturesStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFTableFeatures> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFTableFeatures> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFTableFeaturesStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturesStatsReply.Builder {
+        final OFTableFeaturesStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableFeatures> entries;
+
+        BuilderWithParent(OFTableFeaturesStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableFeaturesStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableFeaturesStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableFeatures> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableFeaturesStatsReply.Builder setEntries(List<OFTableFeatures> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableFeaturesStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFTableFeatures> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFTableFeaturesStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturesStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableFeatures> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableFeaturesStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableFeaturesStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableFeatures> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableFeaturesStatsReply.Builder setEntries(List<OFTableFeatures> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableFeaturesStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFTableFeatures> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFTableFeaturesStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturesStatsReply> {
+        @Override
+        public OFTableFeaturesStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 12
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xc)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE_FEATURES(12), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFTableFeatures> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFTableFeaturesVer13.READER);
+
+            OFTableFeaturesStatsReplyVer13 tableFeaturesStatsReplyVer13 = new OFTableFeaturesStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturesStatsReplyVer13);
+            return tableFeaturesStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturesStatsReplyVer13Funnel FUNNEL = new OFTableFeaturesStatsReplyVer13Funnel();
+    static class OFTableFeaturesStatsReplyVer13Funnel implements Funnel<OFTableFeaturesStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturesStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 12
+            sink.putShort((short) 0xc);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturesStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturesStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 12
+            bb.writeShort((short) 0xc);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturesStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturesStatsReplyVer13 other = (OFTableFeaturesStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesStatsRequestVer13.java
new file mode 100644
index 0000000..7981631
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesStatsRequestVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturesStatsRequestVer13 implements OFTableFeaturesStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturesStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+        private final static List<OFTableFeatures> DEFAULT_ENTRIES = ImmutableList.<OFTableFeatures>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+    private final List<OFTableFeatures> entries;
+//
+    // Immutable default instance
+    final static OFTableFeaturesStatsRequestVer13 DEFAULT = new OFTableFeaturesStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturesStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags, List<OFTableFeatures> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFTableFeatures> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFTableFeaturesStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeaturesStatsRequest.Builder {
+        final OFTableFeaturesStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableFeatures> entries;
+
+        BuilderWithParent(OFTableFeaturesStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableFeaturesStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableFeaturesStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableFeatures> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableFeaturesStatsRequest.Builder setEntries(List<OFTableFeatures> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableFeaturesStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFTableFeatures> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFTableFeaturesStatsRequestVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeaturesStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableFeatures> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableFeaturesStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE_FEATURES;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableFeaturesStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableFeatures> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableFeaturesStatsRequest.Builder setEntries(List<OFTableFeatures> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableFeaturesStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFTableFeatures> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFTableFeaturesStatsRequestVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeaturesStatsRequest> {
+        @Override
+        public OFTableFeaturesStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 12
+            short statsType = bb.readShort();
+            if(statsType != (short) 0xc)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE_FEATURES(12), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFTableFeatures> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFTableFeaturesVer13.READER);
+
+            OFTableFeaturesStatsRequestVer13 tableFeaturesStatsRequestVer13 = new OFTableFeaturesStatsRequestVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturesStatsRequestVer13);
+            return tableFeaturesStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturesStatsRequestVer13Funnel FUNNEL = new OFTableFeaturesStatsRequestVer13Funnel();
+    static class OFTableFeaturesStatsRequestVer13Funnel implements Funnel<OFTableFeaturesStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturesStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 12
+            sink.putShort((short) 0xc);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturesStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturesStatsRequestVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 12
+            bb.writeShort((short) 0xc);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturesStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturesStatsRequestVer13 other = (OFTableFeaturesStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesVer13.java
new file mode 100644
index 0000000..c5064e6
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableFeaturesVer13.java
@@ -0,0 +1,566 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableFeaturesVer13 implements OFTableFeatures {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableFeaturesVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 64;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static String DEFAULT_NAME = "";
+        private final static U64 DEFAULT_METADATA_MATCH = U64.ZERO;
+        private final static U64 DEFAULT_METADATA_WRITE = U64.ZERO;
+        private final static long DEFAULT_CONFIG = 0x0L;
+        private final static long DEFAULT_MAX_ENTRIES = 0x0L;
+        private final static List<OFTableFeatureProp> DEFAULT_PROPERTIES = ImmutableList.<OFTableFeatureProp>of();
+
+    // OF message fields
+    private final TableId tableId;
+    private final String name;
+    private final U64 metadataMatch;
+    private final U64 metadataWrite;
+    private final long config;
+    private final long maxEntries;
+    private final List<OFTableFeatureProp> properties;
+//
+    // Immutable default instance
+    final static OFTableFeaturesVer13 DEFAULT = new OFTableFeaturesVer13(
+        DEFAULT_TABLE_ID, DEFAULT_NAME, DEFAULT_METADATA_MATCH, DEFAULT_METADATA_WRITE, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES, DEFAULT_PROPERTIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableFeaturesVer13(TableId tableId, String name, U64 metadataMatch, U64 metadataWrite, long config, long maxEntries, List<OFTableFeatureProp> properties) {
+        this.tableId = tableId;
+        this.name = name;
+        this.metadataMatch = metadataMatch;
+        this.metadataWrite = metadataWrite;
+        this.config = config;
+        this.maxEntries = maxEntries;
+        this.properties = properties;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public U64 getMetadataMatch() {
+        return metadataMatch;
+    }
+
+    @Override
+    public U64 getMetadataWrite() {
+        return metadataWrite;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public List<OFTableFeatureProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableFeatures.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableFeatures.Builder {
+        final OFTableFeaturesVer13 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean metadataMatchSet;
+        private U64 metadataMatch;
+        private boolean metadataWriteSet;
+        private U64 metadataWrite;
+        private boolean configSet;
+        private long config;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+        private boolean propertiesSet;
+        private List<OFTableFeatureProp> properties;
+
+        BuilderWithParent(OFTableFeaturesVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMatch() {
+        return metadataMatch;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setMetadataMatch(U64 metadataMatch) {
+        this.metadataMatch = metadataMatch;
+        this.metadataMatchSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataWrite() {
+        return metadataWrite;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setMetadataWrite(U64 metadataWrite) {
+        this.metadataWrite = metadataWrite;
+        this.metadataWriteSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableFeatureProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setProperties(List<OFTableFeatureProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableFeatures build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                String name = this.nameSet ? this.name : parentMessage.name;
+                if(name == null)
+                    throw new NullPointerException("Property name must not be null");
+                U64 metadataMatch = this.metadataMatchSet ? this.metadataMatch : parentMessage.metadataMatch;
+                if(metadataMatch == null)
+                    throw new NullPointerException("Property metadataMatch must not be null");
+                U64 metadataWrite = this.metadataWriteSet ? this.metadataWrite : parentMessage.metadataWrite;
+                if(metadataWrite == null)
+                    throw new NullPointerException("Property metadataWrite must not be null");
+                long config = this.configSet ? this.config : parentMessage.config;
+                long maxEntries = this.maxEntriesSet ? this.maxEntries : parentMessage.maxEntries;
+                List<OFTableFeatureProp> properties = this.propertiesSet ? this.properties : parentMessage.properties;
+                if(properties == null)
+                    throw new NullPointerException("Property properties must not be null");
+
+                //
+                return new OFTableFeaturesVer13(
+                    tableId,
+                    name,
+                    metadataMatch,
+                    metadataWrite,
+                    config,
+                    maxEntries,
+                    properties
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableFeatures.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean nameSet;
+        private String name;
+        private boolean metadataMatchSet;
+        private U64 metadataMatch;
+        private boolean metadataWriteSet;
+        private U64 metadataWrite;
+        private boolean configSet;
+        private long config;
+        private boolean maxEntriesSet;
+        private long maxEntries;
+        private boolean propertiesSet;
+        private List<OFTableFeatureProp> properties;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setName(String name) {
+        this.name = name;
+        this.nameSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataMatch() {
+        return metadataMatch;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setMetadataMatch(U64 metadataMatch) {
+        this.metadataMatch = metadataMatch;
+        this.metadataMatchSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMetadataWrite() {
+        return metadataWrite;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setMetadataWrite(U64 metadataWrite) {
+        this.metadataWrite = metadataWrite;
+        this.metadataWriteSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+    @Override
+    public long getMaxEntries() {
+        return maxEntries;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setMaxEntries(long maxEntries) {
+        this.maxEntries = maxEntries;
+        this.maxEntriesSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableFeatureProp> getProperties() {
+        return properties;
+    }
+
+    @Override
+    public OFTableFeatures.Builder setProperties(List<OFTableFeatureProp> properties) {
+        this.properties = properties;
+        this.propertiesSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableFeatures build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            String name = this.nameSet ? this.name : DEFAULT_NAME;
+            if(name == null)
+                throw new NullPointerException("Property name must not be null");
+            U64 metadataMatch = this.metadataMatchSet ? this.metadataMatch : DEFAULT_METADATA_MATCH;
+            if(metadataMatch == null)
+                throw new NullPointerException("Property metadataMatch must not be null");
+            U64 metadataWrite = this.metadataWriteSet ? this.metadataWrite : DEFAULT_METADATA_WRITE;
+            if(metadataWrite == null)
+                throw new NullPointerException("Property metadataWrite must not be null");
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+            long maxEntries = this.maxEntriesSet ? this.maxEntries : DEFAULT_MAX_ENTRIES;
+            List<OFTableFeatureProp> properties = this.propertiesSet ? this.properties : DEFAULT_PROPERTIES;
+            if(properties == null)
+                throw new NullPointerException("Property properties must not be null");
+
+
+            return new OFTableFeaturesVer13(
+                    tableId,
+                    name,
+                    metadataMatch,
+                    metadataWrite,
+                    config,
+                    maxEntries,
+                    properties
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableFeatures> {
+        @Override
+        public OFTableFeatures readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            TableId tableId = TableId.readByte(bb);
+            // pad: 5 bytes
+            bb.skipBytes(5);
+            String name = ChannelUtils.readFixedLengthString(bb, 32);
+            U64 metadataMatch = U64.ofRaw(bb.readLong());
+            U64 metadataWrite = U64.ofRaw(bb.readLong());
+            long config = U32.f(bb.readInt());
+            long maxEntries = U32.f(bb.readInt());
+            List<OFTableFeatureProp> properties = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFTableFeaturePropVer13.READER);
+
+            OFTableFeaturesVer13 tableFeaturesVer13 = new OFTableFeaturesVer13(
+                    tableId,
+                      name,
+                      metadataMatch,
+                      metadataWrite,
+                      config,
+                      maxEntries,
+                      properties
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableFeaturesVer13);
+            return tableFeaturesVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableFeaturesVer13Funnel FUNNEL = new OFTableFeaturesVer13Funnel();
+    static class OFTableFeaturesVer13Funnel implements Funnel<OFTableFeaturesVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableFeaturesVer13 message, PrimitiveSink sink) {
+            // FIXME: skip funnel of length
+            message.tableId.putTo(sink);
+            // skip pad (5 bytes)
+            sink.putUnencodedChars(message.name);
+            message.metadataMatch.putTo(sink);
+            message.metadataWrite.putTo(sink);
+            sink.putLong(message.config);
+            sink.putLong(message.maxEntries);
+            FunnelUtils.putList(message.properties, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableFeaturesVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableFeaturesVer13 message) {
+            int startIndex = bb.writerIndex();
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            message.tableId.writeByte(bb);
+            // pad: 5 bytes
+            bb.writeZero(5);
+            ChannelUtils.writeFixedLengthString(bb, message.name, 32);
+            bb.writeLong(message.metadataMatch.getValue());
+            bb.writeLong(message.metadataWrite.getValue());
+            bb.writeInt(U32.t(message.config));
+            bb.writeInt(U32.t(message.maxEntries));
+            ChannelUtils.writeList(bb, message.properties);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableFeaturesVer13(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("name=").append(name);
+        b.append(", ");
+        b.append("metadataMatch=").append(metadataMatch);
+        b.append(", ");
+        b.append("metadataWrite=").append(metadataWrite);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(", ");
+        b.append("maxEntries=").append(maxEntries);
+        b.append(", ");
+        b.append("properties=").append(properties);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableFeaturesVer13 other = (OFTableFeaturesVer13) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if (name == null) {
+            if (other.name != null)
+                return false;
+        } else if (!name.equals(other.name))
+            return false;
+        if (metadataMatch == null) {
+            if (other.metadataMatch != null)
+                return false;
+        } else if (!metadataMatch.equals(other.metadataMatch))
+            return false;
+        if (metadataWrite == null) {
+            if (other.metadataWrite != null)
+                return false;
+        } else if (!metadataWrite.equals(other.metadataWrite))
+            return false;
+        if( config != other.config)
+            return false;
+        if( maxEntries != other.maxEntries)
+            return false;
+        if (properties == null) {
+            if (other.properties != null)
+                return false;
+        } else if (!properties.equals(other.properties))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result + ((metadataMatch == null) ? 0 : metadataMatch.hashCode());
+        result = prime * result + ((metadataWrite == null) ? 0 : metadataWrite.hashCode());
+        result = prime *  (int) (config ^ (config >>> 32));
+        result = prime *  (int) (maxEntries ^ (maxEntries >>> 32));
+        result = prime * result + ((properties == null) ? 0 : properties.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModFailedCodeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModFailedCodeSerializerVer13.java
new file mode 100644
index 0000000..d869bef
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModFailedCodeSerializerVer13.java
@@ -0,0 +1,79 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTableModFailedCode;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTableModFailedCodeSerializerVer13 {
+
+    public final static short BAD_TABLE_VAL = (short) 0x0;
+    public final static short BAD_CONFIG_VAL = (short) 0x1;
+    public final static short EPERM_VAL = (short) 0x2;
+
+    public static OFTableModFailedCode readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readShort());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFTableModFailedCode e) {
+        bb.writeShort(toWireValue(e));
+    }
+
+    public static void putTo(OFTableModFailedCode e, PrimitiveSink sink) {
+        sink.putShort(toWireValue(e));
+    }
+
+    public static OFTableModFailedCode ofWireValue(short val) {
+        switch(val) {
+            case BAD_TABLE_VAL:
+                return OFTableModFailedCode.BAD_TABLE;
+            case BAD_CONFIG_VAL:
+                return OFTableModFailedCode.BAD_CONFIG;
+            case EPERM_VAL:
+                return OFTableModFailedCode.EPERM;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFTableModFailedCode in version 1.3: " + val);
+        }
+    }
+
+
+    public static short toWireValue(OFTableModFailedCode e) {
+        switch(e) {
+            case BAD_TABLE:
+                return BAD_TABLE_VAL;
+            case BAD_CONFIG:
+                return BAD_CONFIG_VAL;
+            case EPERM:
+                return EPERM_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFTableModFailedCode in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModFailedErrorMsgVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModFailedErrorMsgVer13.java
new file mode 100644
index 0000000..929eefb
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModFailedErrorMsgVer13.java
@@ -0,0 +1,400 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableModFailedErrorMsgVer13 implements OFTableModFailedErrorMsg {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableModFailedErrorMsgVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 12;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
+
+    // OF message fields
+    private final long xid;
+    private final OFTableModFailedCode code;
+    private final OFErrorCauseData data;
+//
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableModFailedErrorMsgVer13(long xid, OFTableModFailedCode code, OFErrorCauseData data) {
+        this.xid = xid;
+        this.code = code;
+        this.data = data;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+
+
+    public OFTableModFailedErrorMsg.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableModFailedErrorMsg.Builder {
+        final OFTableModFailedErrorMsgVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFTableModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+        BuilderWithParent(OFTableModFailedErrorMsgVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setCode(OFTableModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableModFailedErrorMsg build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                OFTableModFailedCode code = this.codeSet ? this.code : parentMessage.code;
+                if(code == null)
+                    throw new NullPointerException("Property code must not be null");
+                OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
+                if(data == null)
+                    throw new NullPointerException("Property data must not be null");
+
+                //
+                return new OFTableModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableModFailedErrorMsg.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean codeSet;
+        private OFTableModFailedCode code;
+        private boolean dataSet;
+        private OFErrorCauseData data;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.ERROR;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorType getErrType() {
+        return OFErrorType.TABLE_MOD_FAILED;
+    }
+
+    @Override
+    public OFTableModFailedCode getCode() {
+        return code;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setCode(OFTableModFailedCode code) {
+        this.code = code;
+        this.codeSet = true;
+        return this;
+    }
+    @Override
+    public OFErrorCauseData getData() {
+        return data;
+    }
+
+    @Override
+    public OFTableModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
+        this.data = data;
+        this.dataSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableModFailedErrorMsg build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            if(!this.codeSet)
+                throw new IllegalStateException("Property code doesn't have default value -- must be set");
+            if(code == null)
+                throw new NullPointerException("Property code must not be null");
+            OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
+            if(data == null)
+                throw new NullPointerException("Property data must not be null");
+
+
+            return new OFTableModFailedErrorMsgVer13(
+                    xid,
+                    code,
+                    data
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableModFailedErrorMsg> {
+        @Override
+        public OFTableModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 1
+            byte type = bb.readByte();
+            if(type != (byte) 0x1)
+                throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property errType == 8
+            short errType = bb.readShort();
+            if(errType != (short) 0x8)
+                throw new OFParseError("Wrong errType: Expected=OFErrorType.TABLE_MOD_FAILED(8), got="+errType);
+            OFTableModFailedCode code = OFTableModFailedCodeSerializerVer13.readFrom(bb);
+            OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_13);
+
+            OFTableModFailedErrorMsgVer13 tableModFailedErrorMsgVer13 = new OFTableModFailedErrorMsgVer13(
+                    xid,
+                      code,
+                      data
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableModFailedErrorMsgVer13);
+            return tableModFailedErrorMsgVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableModFailedErrorMsgVer13Funnel FUNNEL = new OFTableModFailedErrorMsgVer13Funnel();
+    static class OFTableModFailedErrorMsgVer13Funnel implements Funnel<OFTableModFailedErrorMsgVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableModFailedErrorMsgVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 1
+            sink.putByte((byte) 0x1);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property errType = 8
+            sink.putShort((short) 0x8);
+            OFTableModFailedCodeSerializerVer13.putTo(message.code, sink);
+            message.data.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableModFailedErrorMsgVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableModFailedErrorMsgVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 1
+            bb.writeByte((byte) 0x1);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property errType = 8
+            bb.writeShort((short) 0x8);
+            OFTableModFailedCodeSerializerVer13.writeTo(bb, message.code);
+            message.data.writeTo(bb);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableModFailedErrorMsgVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("code=").append(code);
+        b.append(", ");
+        b.append("data=").append(data);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableModFailedErrorMsgVer13 other = (OFTableModFailedErrorMsgVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (code == null) {
+            if (other.code != null)
+                return false;
+        } else if (!code.equals(other.code))
+            return false;
+        if (data == null) {
+            if (other.data != null)
+                return false;
+        } else if (!data.equals(other.data))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((code == null) ? 0 : code.hashCode());
+        result = prime * result + ((data == null) ? 0 : data.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModVer13.java
new file mode 100644
index 0000000..f6db229
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableModVer13.java
@@ -0,0 +1,374 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableModVer13 implements OFTableMod {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableModVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_CONFIG = 0x0L;
+
+    // OF message fields
+    private final long xid;
+    private final TableId tableId;
+    private final long config;
+//
+    // Immutable default instance
+    final static OFTableModVer13 DEFAULT = new OFTableModVer13(
+        DEFAULT_XID, DEFAULT_TABLE_ID, DEFAULT_CONFIG
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableModVer13(long xid, TableId tableId, long config) {
+        this.xid = xid;
+        this.tableId = tableId;
+        this.config = config;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+
+
+    public OFTableMod.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableMod.Builder {
+        final OFTableModVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean configSet;
+        private long config;
+
+        BuilderWithParent(OFTableModVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableMod.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableMod build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long config = this.configSet ? this.config : parentMessage.config;
+
+                //
+                return new OFTableModVer13(
+                    xid,
+                    tableId,
+                    config
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableMod.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean configSet;
+        private long config;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.TABLE_MOD;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableMod.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableMod.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public long getConfig() {
+        return config;
+    }
+
+    @Override
+    public OFTableMod.Builder setConfig(long config) {
+        this.config = config;
+        this.configSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableMod build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long config = this.configSet ? this.config : DEFAULT_CONFIG;
+
+
+            return new OFTableModVer13(
+                    xid,
+                    tableId,
+                    config
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableMod> {
+        @Override
+        public OFTableMod readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 17
+            byte type = bb.readByte();
+            if(type != (byte) 0x11)
+                throw new OFParseError("Wrong type: Expected=OFType.TABLE_MOD(17), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            long config = U32.f(bb.readInt());
+
+            OFTableModVer13 tableModVer13 = new OFTableModVer13(
+                    xid,
+                      tableId,
+                      config
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableModVer13);
+            return tableModVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableModVer13Funnel FUNNEL = new OFTableModVer13Funnel();
+    static class OFTableModVer13Funnel implements Funnel<OFTableModVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableModVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 17
+            sink.putByte((byte) 0x11);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            sink.putLong(message.config);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableModVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableModVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 17
+            bb.writeByte((byte) 0x11);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeInt(U32.t(message.config));
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableModVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("config=").append(config);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableModVer13 other = (OFTableModVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( config != other.config)
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (config ^ (config >>> 32));
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableSerializerVer13.java
new file mode 100644
index 0000000..f5b8a63
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableSerializerVer13.java
@@ -0,0 +1,74 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFTable;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTableSerializerVer13 {
+
+    public final static byte MAX_VAL = (byte) 0xfe;
+    public final static byte ALL_VAL = (byte) 0xff;
+
+    public static OFTable readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFTable e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFTable e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFTable ofWireValue(byte val) {
+        switch(val) {
+            case MAX_VAL:
+                return OFTable.MAX;
+            case ALL_VAL:
+                return OFTable.ALL;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFTable in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFTable e) {
+        switch(e) {
+            case MAX:
+                return MAX_VAL;
+            case ALL:
+                return ALL_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFTable in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsEntryVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsEntryVer13.java
new file mode 100644
index 0000000..25bc571
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsEntryVer13.java
@@ -0,0 +1,665 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsEntryVer13 implements OFTableStatsEntry {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsEntryVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 24;
+
+        private final static TableId DEFAULT_TABLE_ID = TableId.ALL;
+        private final static long DEFAULT_ACTIVE_COUNT = 0x0L;
+        private final static U64 DEFAULT_LOOKUP_COUNT = U64.ZERO;
+        private final static U64 DEFAULT_MATCHED_COUNT = U64.ZERO;
+
+    // OF message fields
+    private final TableId tableId;
+    private final long activeCount;
+    private final U64 lookupCount;
+    private final U64 matchedCount;
+//
+    // Immutable default instance
+    final static OFTableStatsEntryVer13 DEFAULT = new OFTableStatsEntryVer13(
+        DEFAULT_TABLE_ID, DEFAULT_ACTIVE_COUNT, DEFAULT_LOOKUP_COUNT, DEFAULT_MATCHED_COUNT
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsEntryVer13(TableId tableId, long activeCount, U64 lookupCount, U64 matchedCount) {
+        this.tableId = tableId;
+        this.activeCount = activeCount;
+        this.lookupCount = lookupCount;
+        this.matchedCount = matchedCount;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public String getName()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property name not supported in version 1.3");
+    }
+
+    @Override
+    public OFMatchBmap getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.3");
+    }
+
+    @Override
+    public int getWildcards()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property wildcards not supported in version 1.3");
+    }
+
+    @Override
+    public long getWriteActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeActions not supported in version 1.3");
+    }
+
+    @Override
+    public long getApplyActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applyActions not supported in version 1.3");
+    }
+
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.3");
+    }
+
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.3");
+    }
+
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.3");
+    }
+
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.3");
+    }
+
+    @Override
+    public long getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.3");
+    }
+
+    @Override
+    public long getConfig()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property config not supported in version 1.3");
+    }
+
+    @Override
+    public long getMaxEntries()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property maxEntries not supported in version 1.3");
+    }
+
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFTableStatsEntry.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsEntry.Builder {
+        final OFTableStatsEntryVer13 parentMessage;
+
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean activeCountSet;
+        private long activeCount;
+        private boolean lookupCountSet;
+        private U64 lookupCount;
+        private boolean matchedCountSet;
+        private U64 matchedCount;
+
+        BuilderWithParent(OFTableStatsEntryVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property name not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setName(String name) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property name not supported in version 1.3");
+    }
+    @Override
+    public OFMatchBmap getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatch(OFMatchBmap match) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property match not supported in version 1.3");
+    }
+    @Override
+    public int getWildcards()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property wildcards not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWildcards(int wildcards) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property wildcards not supported in version 1.3");
+    }
+    @Override
+    public long getWriteActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeActions not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteActions(long writeActions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeActions not supported in version 1.3");
+    }
+    @Override
+    public long getApplyActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applyActions not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplyActions(long applyActions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applyActions not supported in version 1.3");
+    }
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteSetfields(U64 writeSetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.3");
+    }
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplySetfields(U64 applySetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applySetfields not supported in version 1.3");
+    }
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataMatch(U64 metadataMatch) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.3");
+    }
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataWrite(U64 metadataWrite) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.3");
+    }
+    @Override
+    public long getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setInstructions(long instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.3");
+    }
+    @Override
+    public long getConfig()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property config not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setConfig(long config) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property config not supported in version 1.3");
+    }
+    @Override
+    public long getMaxEntries()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property maxEntries not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMaxEntries(long maxEntries) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property maxEntries not supported in version 1.3");
+    }
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setActiveCount(long activeCount) {
+        this.activeCount = activeCount;
+        this.activeCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setLookupCount(U64 lookupCount) {
+        this.lookupCount = lookupCount;
+        this.lookupCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatchedCount(U64 matchedCount) {
+        this.matchedCount = matchedCount;
+        this.matchedCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFTableStatsEntry build() {
+                TableId tableId = this.tableIdSet ? this.tableId : parentMessage.tableId;
+                if(tableId == null)
+                    throw new NullPointerException("Property tableId must not be null");
+                long activeCount = this.activeCountSet ? this.activeCount : parentMessage.activeCount;
+                U64 lookupCount = this.lookupCountSet ? this.lookupCount : parentMessage.lookupCount;
+                if(lookupCount == null)
+                    throw new NullPointerException("Property lookupCount must not be null");
+                U64 matchedCount = this.matchedCountSet ? this.matchedCount : parentMessage.matchedCount;
+                if(matchedCount == null)
+                    throw new NullPointerException("Property matchedCount must not be null");
+
+                //
+                return new OFTableStatsEntryVer13(
+                    tableId,
+                    activeCount,
+                    lookupCount,
+                    matchedCount
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsEntry.Builder {
+        // OF message fields
+        private boolean tableIdSet;
+        private TableId tableId;
+        private boolean activeCountSet;
+        private long activeCount;
+        private boolean lookupCountSet;
+        private U64 lookupCount;
+        private boolean matchedCountSet;
+        private U64 matchedCount;
+
+    @Override
+    public TableId getTableId() {
+        return tableId;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setTableId(TableId tableId) {
+        this.tableId = tableId;
+        this.tableIdSet = true;
+        return this;
+    }
+    @Override
+    public String getName()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property name not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setName(String name) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property name not supported in version 1.3");
+    }
+    @Override
+    public OFMatchBmap getMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property match not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatch(OFMatchBmap match) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property match not supported in version 1.3");
+    }
+    @Override
+    public int getWildcards()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property wildcards not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWildcards(int wildcards) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property wildcards not supported in version 1.3");
+    }
+    @Override
+    public long getWriteActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeActions not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteActions(long writeActions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeActions not supported in version 1.3");
+    }
+    @Override
+    public long getApplyActions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applyActions not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplyActions(long applyActions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applyActions not supported in version 1.3");
+    }
+    @Override
+    public U64 getWriteSetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setWriteSetfields(U64 writeSetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property writeSetfields not supported in version 1.3");
+    }
+    @Override
+    public U64 getApplySetfields()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property applySetfields not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setApplySetfields(U64 applySetfields) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property applySetfields not supported in version 1.3");
+    }
+    @Override
+    public U64 getMetadataMatch()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataMatch(U64 metadataMatch) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataMatch not supported in version 1.3");
+    }
+    @Override
+    public U64 getMetadataWrite()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMetadataWrite(U64 metadataWrite) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property metadataWrite not supported in version 1.3");
+    }
+    @Override
+    public long getInstructions()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property instructions not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setInstructions(long instructions) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property instructions not supported in version 1.3");
+    }
+    @Override
+    public long getConfig()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property config not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setConfig(long config) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property config not supported in version 1.3");
+    }
+    @Override
+    public long getMaxEntries()throws UnsupportedOperationException {
+        throw new UnsupportedOperationException("Property maxEntries not supported in version 1.3");
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMaxEntries(long maxEntries) throws UnsupportedOperationException {
+            throw new UnsupportedOperationException("Property maxEntries not supported in version 1.3");
+    }
+    @Override
+    public long getActiveCount() {
+        return activeCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setActiveCount(long activeCount) {
+        this.activeCount = activeCount;
+        this.activeCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getLookupCount() {
+        return lookupCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setLookupCount(U64 lookupCount) {
+        this.lookupCount = lookupCount;
+        this.lookupCountSet = true;
+        return this;
+    }
+    @Override
+    public U64 getMatchedCount() {
+        return matchedCount;
+    }
+
+    @Override
+    public OFTableStatsEntry.Builder setMatchedCount(U64 matchedCount) {
+        this.matchedCount = matchedCount;
+        this.matchedCountSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFTableStatsEntry build() {
+            TableId tableId = this.tableIdSet ? this.tableId : DEFAULT_TABLE_ID;
+            if(tableId == null)
+                throw new NullPointerException("Property tableId must not be null");
+            long activeCount = this.activeCountSet ? this.activeCount : DEFAULT_ACTIVE_COUNT;
+            U64 lookupCount = this.lookupCountSet ? this.lookupCount : DEFAULT_LOOKUP_COUNT;
+            if(lookupCount == null)
+                throw new NullPointerException("Property lookupCount must not be null");
+            U64 matchedCount = this.matchedCountSet ? this.matchedCount : DEFAULT_MATCHED_COUNT;
+            if(matchedCount == null)
+                throw new NullPointerException("Property matchedCount must not be null");
+
+
+            return new OFTableStatsEntryVer13(
+                    tableId,
+                    activeCount,
+                    lookupCount,
+                    matchedCount
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsEntry> {
+        @Override
+        public OFTableStatsEntry readFrom(ChannelBuffer bb) throws OFParseError {
+            TableId tableId = TableId.readByte(bb);
+            // pad: 3 bytes
+            bb.skipBytes(3);
+            long activeCount = U32.f(bb.readInt());
+            U64 lookupCount = U64.ofRaw(bb.readLong());
+            U64 matchedCount = U64.ofRaw(bb.readLong());
+
+            OFTableStatsEntryVer13 tableStatsEntryVer13 = new OFTableStatsEntryVer13(
+                    tableId,
+                      activeCount,
+                      lookupCount,
+                      matchedCount
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsEntryVer13);
+            return tableStatsEntryVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsEntryVer13Funnel FUNNEL = new OFTableStatsEntryVer13Funnel();
+    static class OFTableStatsEntryVer13Funnel implements Funnel<OFTableStatsEntryVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsEntryVer13 message, PrimitiveSink sink) {
+            message.tableId.putTo(sink);
+            // skip pad (3 bytes)
+            sink.putLong(message.activeCount);
+            message.lookupCount.putTo(sink);
+            message.matchedCount.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsEntryVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsEntryVer13 message) {
+            message.tableId.writeByte(bb);
+            // pad: 3 bytes
+            bb.writeZero(3);
+            bb.writeInt(U32.t(message.activeCount));
+            bb.writeLong(message.lookupCount.getValue());
+            bb.writeLong(message.matchedCount.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsEntryVer13(");
+        b.append("tableId=").append(tableId);
+        b.append(", ");
+        b.append("activeCount=").append(activeCount);
+        b.append(", ");
+        b.append("lookupCount=").append(lookupCount);
+        b.append(", ");
+        b.append("matchedCount=").append(matchedCount);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsEntryVer13 other = (OFTableStatsEntryVer13) obj;
+
+        if (tableId == null) {
+            if (other.tableId != null)
+                return false;
+        } else if (!tableId.equals(other.tableId))
+            return false;
+        if( activeCount != other.activeCount)
+            return false;
+        if (lookupCount == null) {
+            if (other.lookupCount != null)
+                return false;
+        } else if (!lookupCount.equals(other.lookupCount))
+            return false;
+        if (matchedCount == null) {
+            if (other.matchedCount != null)
+                return false;
+        } else if (!matchedCount.equals(other.matchedCount))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((tableId == null) ? 0 : tableId.hashCode());
+        result = prime *  (int) (activeCount ^ (activeCount >>> 32));
+        result = prime * result + ((lookupCount == null) ? 0 : lookupCount.hashCode());
+        result = prime * result + ((matchedCount == null) ? 0 : matchedCount.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsReplyVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsReplyVer13.java
new file mode 100644
index 0000000..c6e6fbe
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsReplyVer13.java
@@ -0,0 +1,412 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsReplyVer13 implements OFTableStatsReply {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsReplyVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int MINIMUM_LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
+        private final static List<OFTableStatsEntry> DEFAULT_ENTRIES = ImmutableList.<OFTableStatsEntry>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsReplyFlags> flags;
+    private final List<OFTableStatsEntry> entries;
+//
+    // Immutable default instance
+    final static OFTableStatsReplyVer13 DEFAULT = new OFTableStatsReplyVer13(
+        DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_ENTRIES
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, List<OFTableStatsEntry> entries) {
+        this.xid = xid;
+        this.flags = flags;
+        this.entries = entries;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+
+
+    public OFTableStatsReply.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsReply.Builder {
+        final OFTableStatsReplyVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableStatsEntry> entries;
+
+        BuilderWithParent(OFTableStatsReplyVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setEntries(List<OFTableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableStatsReply build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+                List<OFTableStatsEntry> entries = this.entriesSet ? this.entries : parentMessage.entries;
+                if(entries == null)
+                    throw new NullPointerException("Property entries must not be null");
+
+                //
+                return new OFTableStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsReply.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsReplyFlags> flags;
+        private boolean entriesSet;
+        private List<OFTableStatsEntry> entries;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REPLY;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsReplyFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+    @Override
+    public List<OFTableStatsEntry> getEntries() {
+        return entries;
+    }
+
+    @Override
+    public OFTableStatsReply.Builder setEntries(List<OFTableStatsEntry> entries) {
+        this.entries = entries;
+        this.entriesSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableStatsReply build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+            List<OFTableStatsEntry> entries = this.entriesSet ? this.entries : DEFAULT_ENTRIES;
+            if(entries == null)
+                throw new NullPointerException("Property entries must not be null");
+
+
+            return new OFTableStatsReplyVer13(
+                    xid,
+                    flags,
+                    entries
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsReply> {
+        @Override
+        public OFTableStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 19
+            byte type = bb.readByte();
+            if(type != (byte) 0x13)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length < MINIMUM_LENGTH)
+                throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 3
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x3)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType);
+            Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+            List<OFTableStatsEntry> entries = ChannelUtils.readList(bb, length - (bb.readerIndex() - start), OFTableStatsEntryVer13.READER);
+
+            OFTableStatsReplyVer13 tableStatsReplyVer13 = new OFTableStatsReplyVer13(
+                    xid,
+                      flags,
+                      entries
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsReplyVer13);
+            return tableStatsReplyVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsReplyVer13Funnel FUNNEL = new OFTableStatsReplyVer13Funnel();
+    static class OFTableStatsReplyVer13Funnel implements Funnel<OFTableStatsReplyVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsReplyVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 19
+            sink.putByte((byte) 0x13);
+            // FIXME: skip funnel of length
+            sink.putLong(message.xid);
+            // fixed value property statsType = 3
+            sink.putShort((short) 0x3);
+            OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+            FunnelUtils.putList(message.entries, sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsReplyVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsReplyVer13 message) {
+            int startIndex = bb.writerIndex();
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 19
+            bb.writeByte((byte) 0x13);
+            // length is length of variable message, will be updated at the end
+            int lengthIndex = bb.writerIndex();
+            bb.writeShort(U16.t(0));
+
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 3
+            bb.writeShort((short) 0x3);
+            OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+            ChannelUtils.writeList(bb, message.entries);
+
+            // update length field
+            int length = bb.writerIndex() - startIndex;
+            bb.setShort(lengthIndex, length);
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsReplyVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(", ");
+        b.append("entries=").append(entries);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsReplyVer13 other = (OFTableStatsReplyVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        if (entries == null) {
+            if (other.entries != null)
+                return false;
+        } else if (!entries.equals(other.entries))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        result = prime * result + ((entries == null) ? 0 : entries.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsRequestVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsRequestVer13.java
new file mode 100644
index 0000000..63bceee
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTableStatsRequestVer13.java
@@ -0,0 +1,351 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFTableStatsRequestVer13 implements OFTableStatsRequest {
+    private static final Logger logger = LoggerFactory.getLogger(OFTableStatsRequestVer13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 16;
+
+        private final static long DEFAULT_XID = 0x0L;
+        private final static Set<OFStatsRequestFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsRequestFlags>of();
+
+    // OF message fields
+    private final long xid;
+    private final Set<OFStatsRequestFlags> flags;
+//
+    // Immutable default instance
+    final static OFTableStatsRequestVer13 DEFAULT = new OFTableStatsRequestVer13(
+        DEFAULT_XID, DEFAULT_FLAGS
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFTableStatsRequestVer13(long xid, Set<OFStatsRequestFlags> flags) {
+        this.xid = xid;
+        this.flags = flags;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+
+
+    public OFTableStatsRequest.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFTableStatsRequest.Builder {
+        final OFTableStatsRequestVer13 parentMessage;
+
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+        BuilderWithParent(OFTableStatsRequestVer13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+
+
+        @Override
+        public OFTableStatsRequest build() {
+                long xid = this.xidSet ? this.xid : parentMessage.xid;
+                Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
+                if(flags == null)
+                    throw new NullPointerException("Property flags must not be null");
+
+                //
+                return new OFTableStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+    static class Builder implements OFTableStatsRequest.Builder {
+        // OF message fields
+        private boolean xidSet;
+        private long xid;
+        private boolean flagsSet;
+        private Set<OFStatsRequestFlags> flags;
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+    @Override
+    public OFType getType() {
+        return OFType.STATS_REQUEST;
+    }
+
+    @Override
+    public long getXid() {
+        return xid;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setXid(long xid) {
+        this.xid = xid;
+        this.xidSet = true;
+        return this;
+    }
+    @Override
+    public OFStatsType getStatsType() {
+        return OFStatsType.TABLE;
+    }
+
+    @Override
+    public Set<OFStatsRequestFlags> getFlags() {
+        return flags;
+    }
+
+    @Override
+    public OFTableStatsRequest.Builder setFlags(Set<OFStatsRequestFlags> flags) {
+        this.flags = flags;
+        this.flagsSet = true;
+        return this;
+    }
+//
+        @Override
+        public OFTableStatsRequest build() {
+            long xid = this.xidSet ? this.xid : DEFAULT_XID;
+            Set<OFStatsRequestFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
+            if(flags == null)
+                throw new NullPointerException("Property flags must not be null");
+
+
+            return new OFTableStatsRequestVer13(
+                    xid,
+                    flags
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFTableStatsRequest> {
+        @Override
+        public OFTableStatsRequest readFrom(ChannelBuffer bb) throws OFParseError {
+            int start = bb.readerIndex();
+            // fixed value property version == 4
+            byte version = bb.readByte();
+            if(version != (byte) 0x4)
+                throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
+            // fixed value property type == 18
+            byte type = bb.readByte();
+            if(type != (byte) 0x12)
+                throw new OFParseError("Wrong type: Expected=OFType.STATS_REQUEST(18), got="+type);
+            int length = U16.f(bb.readShort());
+            if(length != 16)
+                throw new OFParseError("Wrong length: Expected=16(16), got="+length);
+            if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
+                // Buffer does not have all data yet
+                bb.readerIndex(start);
+                return null;
+            }
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - length={}", length);
+            long xid = U32.f(bb.readInt());
+            // fixed value property statsType == 3
+            short statsType = bb.readShort();
+            if(statsType != (short) 0x3)
+                throw new OFParseError("Wrong statsType: Expected=OFStatsType.TABLE(3), got="+statsType);
+            Set<OFStatsRequestFlags> flags = OFStatsRequestFlagsSerializerVer13.readFrom(bb);
+            // pad: 4 bytes
+            bb.skipBytes(4);
+
+            OFTableStatsRequestVer13 tableStatsRequestVer13 = new OFTableStatsRequestVer13(
+                    xid,
+                      flags
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", tableStatsRequestVer13);
+            return tableStatsRequestVer13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFTableStatsRequestVer13Funnel FUNNEL = new OFTableStatsRequestVer13Funnel();
+    static class OFTableStatsRequestVer13Funnel implements Funnel<OFTableStatsRequestVer13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFTableStatsRequestVer13 message, PrimitiveSink sink) {
+            // fixed value property version = 4
+            sink.putByte((byte) 0x4);
+            // fixed value property type = 18
+            sink.putByte((byte) 0x12);
+            // fixed value property length = 16
+            sink.putShort((short) 0x10);
+            sink.putLong(message.xid);
+            // fixed value property statsType = 3
+            sink.putShort((short) 0x3);
+            OFStatsRequestFlagsSerializerVer13.putTo(message.flags, sink);
+            // skip pad (4 bytes)
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFTableStatsRequestVer13> {
+        @Override
+        public void write(ChannelBuffer bb, OFTableStatsRequestVer13 message) {
+            // fixed value property version = 4
+            bb.writeByte((byte) 0x4);
+            // fixed value property type = 18
+            bb.writeByte((byte) 0x12);
+            // fixed value property length = 16
+            bb.writeShort((short) 0x10);
+            bb.writeInt(U32.t(message.xid));
+            // fixed value property statsType = 3
+            bb.writeShort((short) 0x3);
+            OFStatsRequestFlagsSerializerVer13.writeTo(bb, message.flags);
+            // pad: 4 bytes
+            bb.writeZero(4);
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFTableStatsRequestVer13(");
+        b.append("xid=").append(xid);
+        b.append(", ");
+        b.append("flags=").append(flags);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFTableStatsRequestVer13 other = (OFTableStatsRequestVer13) obj;
+
+        if( xid != other.xid)
+            return false;
+        if (flags == null) {
+            if (other.flags != null)
+                return false;
+        } else if (!flags.equals(other.flags))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime *  (int) (xid ^ (xid >>> 32));
+        result = prime * result + ((flags == null) ? 0 : flags.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTypeSerializerVer13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTypeSerializerVer13.java
new file mode 100644
index 0000000..2047f98
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFTypeSerializerVer13.java
@@ -0,0 +1,214 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template const_serializer.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+
+public class OFTypeSerializerVer13 {
+
+    public final static byte HELLO_VAL = (byte) 0x0;
+    public final static byte ERROR_VAL = (byte) 0x1;
+    public final static byte ECHO_REQUEST_VAL = (byte) 0x2;
+    public final static byte ECHO_REPLY_VAL = (byte) 0x3;
+    public final static byte EXPERIMENTER_VAL = (byte) 0x4;
+    public final static byte FEATURES_REQUEST_VAL = (byte) 0x5;
+    public final static byte FEATURES_REPLY_VAL = (byte) 0x6;
+    public final static byte GET_CONFIG_REQUEST_VAL = (byte) 0x7;
+    public final static byte GET_CONFIG_REPLY_VAL = (byte) 0x8;
+    public final static byte SET_CONFIG_VAL = (byte) 0x9;
+    public final static byte PACKET_IN_VAL = (byte) 0xa;
+    public final static byte FLOW_REMOVED_VAL = (byte) 0xb;
+    public final static byte PORT_STATUS_VAL = (byte) 0xc;
+    public final static byte PACKET_OUT_VAL = (byte) 0xd;
+    public final static byte FLOW_MOD_VAL = (byte) 0xe;
+    public final static byte GROUP_MOD_VAL = (byte) 0xf;
+    public final static byte PORT_MOD_VAL = (byte) 0x10;
+    public final static byte TABLE_MOD_VAL = (byte) 0x11;
+    public final static byte STATS_REQUEST_VAL = (byte) 0x12;
+    public final static byte STATS_REPLY_VAL = (byte) 0x13;
+    public final static byte BARRIER_REQUEST_VAL = (byte) 0x14;
+    public final static byte BARRIER_REPLY_VAL = (byte) 0x15;
+    public final static byte QUEUE_GET_CONFIG_REQUEST_VAL = (byte) 0x16;
+    public final static byte QUEUE_GET_CONFIG_REPLY_VAL = (byte) 0x17;
+    public final static byte ROLE_REQUEST_VAL = (byte) 0x18;
+    public final static byte ROLE_REPLY_VAL = (byte) 0x19;
+    public final static byte GET_ASYNC_REQUEST_VAL = (byte) 0x1a;
+    public final static byte GET_ASYNC_REPLY_VAL = (byte) 0x1b;
+    public final static byte SET_ASYNC_VAL = (byte) 0x1c;
+    public final static byte METER_MOD_VAL = (byte) 0x1d;
+
+    public static OFType readFrom(ChannelBuffer bb) throws OFParseError {
+        try {
+            return ofWireValue(bb.readByte());
+        } catch (IllegalArgumentException e) {
+            throw new OFParseError(e);
+        }
+    }
+
+    public static void writeTo(ChannelBuffer bb, OFType e) {
+        bb.writeByte(toWireValue(e));
+    }
+
+    public static void putTo(OFType e, PrimitiveSink sink) {
+        sink.putByte(toWireValue(e));
+    }
+
+    public static OFType ofWireValue(byte val) {
+        switch(val) {
+            case HELLO_VAL:
+                return OFType.HELLO;
+            case ERROR_VAL:
+                return OFType.ERROR;
+            case ECHO_REQUEST_VAL:
+                return OFType.ECHO_REQUEST;
+            case ECHO_REPLY_VAL:
+                return OFType.ECHO_REPLY;
+            case EXPERIMENTER_VAL:
+                return OFType.EXPERIMENTER;
+            case FEATURES_REQUEST_VAL:
+                return OFType.FEATURES_REQUEST;
+            case FEATURES_REPLY_VAL:
+                return OFType.FEATURES_REPLY;
+            case GET_CONFIG_REQUEST_VAL:
+                return OFType.GET_CONFIG_REQUEST;
+            case GET_CONFIG_REPLY_VAL:
+                return OFType.GET_CONFIG_REPLY;
+            case SET_CONFIG_VAL:
+                return OFType.SET_CONFIG;
+            case PACKET_IN_VAL:
+                return OFType.PACKET_IN;
+            case FLOW_REMOVED_VAL:
+                return OFType.FLOW_REMOVED;
+            case PORT_STATUS_VAL:
+                return OFType.PORT_STATUS;
+            case PACKET_OUT_VAL:
+                return OFType.PACKET_OUT;
+            case FLOW_MOD_VAL:
+                return OFType.FLOW_MOD;
+            case GROUP_MOD_VAL:
+                return OFType.GROUP_MOD;
+            case PORT_MOD_VAL:
+                return OFType.PORT_MOD;
+            case TABLE_MOD_VAL:
+                return OFType.TABLE_MOD;
+            case STATS_REQUEST_VAL:
+                return OFType.STATS_REQUEST;
+            case STATS_REPLY_VAL:
+                return OFType.STATS_REPLY;
+            case BARRIER_REQUEST_VAL:
+                return OFType.BARRIER_REQUEST;
+            case BARRIER_REPLY_VAL:
+                return OFType.BARRIER_REPLY;
+            case QUEUE_GET_CONFIG_REQUEST_VAL:
+                return OFType.QUEUE_GET_CONFIG_REQUEST;
+            case QUEUE_GET_CONFIG_REPLY_VAL:
+                return OFType.QUEUE_GET_CONFIG_REPLY;
+            case ROLE_REQUEST_VAL:
+                return OFType.ROLE_REQUEST;
+            case ROLE_REPLY_VAL:
+                return OFType.ROLE_REPLY;
+            case GET_ASYNC_REQUEST_VAL:
+                return OFType.GET_ASYNC_REQUEST;
+            case GET_ASYNC_REPLY_VAL:
+                return OFType.GET_ASYNC_REPLY;
+            case SET_ASYNC_VAL:
+                return OFType.SET_ASYNC;
+            case METER_MOD_VAL:
+                return OFType.METER_MOD;
+            default:
+                throw new IllegalArgumentException("Illegal wire value for type OFType in version 1.3: " + val);
+        }
+    }
+
+
+    public static byte toWireValue(OFType e) {
+        switch(e) {
+            case HELLO:
+                return HELLO_VAL;
+            case ERROR:
+                return ERROR_VAL;
+            case ECHO_REQUEST:
+                return ECHO_REQUEST_VAL;
+            case ECHO_REPLY:
+                return ECHO_REPLY_VAL;
+            case EXPERIMENTER:
+                return EXPERIMENTER_VAL;
+            case FEATURES_REQUEST:
+                return FEATURES_REQUEST_VAL;
+            case FEATURES_REPLY:
+                return FEATURES_REPLY_VAL;
+            case GET_CONFIG_REQUEST:
+                return GET_CONFIG_REQUEST_VAL;
+            case GET_CONFIG_REPLY:
+                return GET_CONFIG_REPLY_VAL;
+            case SET_CONFIG:
+                return SET_CONFIG_VAL;
+            case PACKET_IN:
+                return PACKET_IN_VAL;
+            case FLOW_REMOVED:
+                return FLOW_REMOVED_VAL;
+            case PORT_STATUS:
+                return PORT_STATUS_VAL;
+            case PACKET_OUT:
+                return PACKET_OUT_VAL;
+            case FLOW_MOD:
+                return FLOW_MOD_VAL;
+            case GROUP_MOD:
+                return GROUP_MOD_VAL;
+            case PORT_MOD:
+                return PORT_MOD_VAL;
+            case TABLE_MOD:
+                return TABLE_MOD_VAL;
+            case STATS_REQUEST:
+                return STATS_REQUEST_VAL;
+            case STATS_REPLY:
+                return STATS_REPLY_VAL;
+            case BARRIER_REQUEST:
+                return BARRIER_REQUEST_VAL;
+            case BARRIER_REPLY:
+                return BARRIER_REPLY_VAL;
+            case QUEUE_GET_CONFIG_REQUEST:
+                return QUEUE_GET_CONFIG_REQUEST_VAL;
+            case QUEUE_GET_CONFIG_REPLY:
+                return QUEUE_GET_CONFIG_REPLY_VAL;
+            case ROLE_REQUEST:
+                return ROLE_REQUEST_VAL;
+            case ROLE_REPLY:
+                return ROLE_REPLY_VAL;
+            case GET_ASYNC_REQUEST:
+                return GET_ASYNC_REQUEST_VAL;
+            case GET_ASYNC_REPLY:
+                return GET_ASYNC_REPLY_VAL;
+            case SET_ASYNC:
+                return SET_ASYNC_VAL;
+            case METER_MOD:
+                return METER_MOD_VAL;
+            default:
+                throw new IllegalArgumentException("Illegal enum value for type OFType in version 1.3: " + e);
+        }
+    }
+
+}
diff --git a/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFUint64Ver13.java b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFUint64Ver13.java
new file mode 100644
index 0000000..c8b14ee
--- /dev/null
+++ b/of/lib/gen-src/main/java/org/projectfloodlight/openflow/protocol/ver13/OFUint64Ver13.java
@@ -0,0 +1,229 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template of_class.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.Set;
+import org.jboss.netty.buffer.ChannelBuffer;
+import com.google.common.hash.PrimitiveSink;
+import com.google.common.hash.Funnel;
+
+class OFUint64Ver13 implements OFUint64 {
+    private static final Logger logger = LoggerFactory.getLogger(OFUint64Ver13.class);
+    // version: 1.3
+    final static byte WIRE_VERSION = 4;
+    final static int LENGTH = 8;
+
+        private final static U64 DEFAULT_VALUE = U64.ZERO;
+
+    // OF message fields
+    private final U64 value;
+//
+    // Immutable default instance
+    final static OFUint64Ver13 DEFAULT = new OFUint64Ver13(
+        DEFAULT_VALUE
+    );
+
+    // package private constructor - used by readers, builders, and factory
+    OFUint64Ver13(U64 value) {
+        this.value = value;
+    }
+
+    // Accessors for OF message fields
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+    public OFUint64.Builder createBuilder() {
+        return new BuilderWithParent(this);
+    }
+
+    static class BuilderWithParent implements OFUint64.Builder {
+        final OFUint64Ver13 parentMessage;
+
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+        BuilderWithParent(OFUint64Ver13 parentMessage) {
+            this.parentMessage = parentMessage;
+        }
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFUint64.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+
+
+        @Override
+        public OFUint64 build() {
+                U64 value = this.valueSet ? this.value : parentMessage.value;
+                if(value == null)
+                    throw new NullPointerException("Property value must not be null");
+
+                //
+                return new OFUint64Ver13(
+                    value
+                );
+        }
+
+    }
+
+    static class Builder implements OFUint64.Builder {
+        // OF message fields
+        private boolean valueSet;
+        private U64 value;
+
+    @Override
+    public U64 getValue() {
+        return value;
+    }
+
+    @Override
+    public OFUint64.Builder setValue(U64 value) {
+        this.value = value;
+        this.valueSet = true;
+        return this;
+    }
+    @Override
+    public OFVersion getVersion() {
+        return OFVersion.OF_13;
+    }
+
+//
+        @Override
+        public OFUint64 build() {
+            U64 value = this.valueSet ? this.value : DEFAULT_VALUE;
+            if(value == null)
+                throw new NullPointerException("Property value must not be null");
+
+
+            return new OFUint64Ver13(
+                    value
+                );
+        }
+
+    }
+
+
+    final static Reader READER = new Reader();
+    static class Reader implements OFMessageReader<OFUint64> {
+        @Override
+        public OFUint64 readFrom(ChannelBuffer bb) throws OFParseError {
+            U64 value = U64.ofRaw(bb.readLong());
+
+            OFUint64Ver13 uint64Ver13 = new OFUint64Ver13(
+                    value
+                    );
+            if(logger.isTraceEnabled())
+                logger.trace("readFrom - read={}", uint64Ver13);
+            return uint64Ver13;
+        }
+    }
+
+    public void putTo(PrimitiveSink sink) {
+        FUNNEL.funnel(this, sink);
+    }
+
+    final static OFUint64Ver13Funnel FUNNEL = new OFUint64Ver13Funnel();
+    static class OFUint64Ver13Funnel implements Funnel<OFUint64Ver13> {
+        private static final long serialVersionUID = 1L;
+        @Override
+        public void funnel(OFUint64Ver13 message, PrimitiveSink sink) {
+            message.value.putTo(sink);
+        }
+    }
+
+
+    public void writeTo(ChannelBuffer bb) {
+        WRITER.write(bb, this);
+    }
+
+    final static Writer WRITER = new Writer();
+    static class Writer implements OFMessageWriter<OFUint64Ver13> {
+        @Override
+        public void write(ChannelBuffer bb, OFUint64Ver13 message) {
+            bb.writeLong(message.value.getValue());
+
+
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder b = new StringBuilder("OFUint64Ver13(");
+        b.append("value=").append(value);
+        b.append(")");
+        return b.toString();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        OFUint64Ver13 other = (OFUint64Ver13) obj;
+
+        if (value == null) {
+            if (other.value != null)
+                return false;
+        } else if (!value.equals(other.value))
+            return false;
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+
+        result = prime * result + ((value == null) ? 0 : value.hashCode());
+        return result;
+    }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnSetTunnelDstVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnSetTunnelDstVer10Test.java
new file mode 100644
index 0000000..328d5b7
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFActionBsnSetTunnelDstVer10Test.java
@@ -0,0 +1,66 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFActionBsnSetTunnelDstVer10Test {
+    OFActions factory;
+
+    final static byte[] ACTION_BSN_SET_TUNNEL_DST_SERIALIZED =
+        new byte[] { (byte) 0xff, (byte) 0xff, 0x0, 0x10, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2, 0x12, 0x34, 0x56, 0x78 };
+
+    @Before
+    public void setup() {
+        factory = OFActionsVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_BSN_SET_TUNNEL_DST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFActionBsnSetTunnelDst actionBsnSetTunnelDst = OFActionBsnSetTunnelDstVer10.READER.readFrom(input);
+       assertEquals(ACTION_BSN_SET_TUNNEL_DST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       actionBsnSetTunnelDst.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ACTION_BSN_SET_TUNNEL_DST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsReplyVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsReplyVer10Test.java
new file mode 100644
index 0000000..8b95216
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFDescStatsReplyVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFDescStatsReplyVer10Test {
+    OFFactory factory;
+
+    final static byte[] DESC_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x1, 0x11, 0x4, 0x2c, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x1, 0x54, 0x68, 0x65, 0x20, 0x49, 0x6e, 0x64, 0x69, 0x67, 0x6f, 0x2d, 0x32, 0x20, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x49, 0x6e, 0x64, 0x69, 0x67, 0x6f, 0x2d, 0x32, 0x20, 0x4c, 0x52, 0x49, 0x20, 0x70, 0x72, 0x65, 0x2d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x31, 0x31, 0x32, 0x33, 0x35, 0x38, 0x31, 0x33, 0x32, 0x31, 0x33, 0x34, 0x35, 0x35, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x49, 0x6e, 0x64, 0x69, 0x67, 0x6f, 0x2d, 0x32, 0x20, 0x4c, 0x52, 0x49, 0x20, 0x66, 0x6f, 0x72, 0x77, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x67, 0x20, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(DESC_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFDescStatsReply descStatsReply = OFDescStatsReplyVer10.READER.readFrom(input);
+       assertEquals(DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       descStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(DESC_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoRequestVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoRequestVer10Test.java
new file mode 100644
index 0000000..1619f47
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFEchoRequestVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFEchoRequestVer10Test {
+    OFFactory factory;
+
+    final static byte[] ECHO_REQUEST_SERIALIZED =
+        new byte[] { 0x1, 0x2, 0x0, 0xb, 0x12, 0x34, 0x56, 0x78, 0x61, 0x62, 0x1 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ECHO_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFEchoRequest echoRequest = OFEchoRequestVer10.READER.readFrom(input);
+       assertEquals(ECHO_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       echoRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ECHO_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowAddVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowAddVer10Test.java
new file mode 100644
index 0000000..730f325
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowAddVer10Test.java
@@ -0,0 +1,138 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.EnumSet;
+import java.util.Set;
+import com.google.common.collect.Sets;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowAddVer10Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_ADD_SERIALIZED =
+        new byte[] { 0x1, 0xe, 0x0, 0x70, 0x12, 0x34, 0x56, 0x78, 0x0, 0x30, 0x0, (byte) 0xe2, 0x0, 0x3, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef, 0x1, 0x23, 0x45, 0x67, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xc0, (byte) 0xa8, 0x3, 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x8, (byte) 0xff, (byte) 0xfb, 0x0, 0x0, (byte) 0xff, (byte) 0xff, 0x0, 0x10, 0x0, 0x0, 0x23, 0x20, 0x0, 0x12, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xff, (byte) 0xff, 0x0, 0x10, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFFlowAdd.Builder builder = factory.buildFlowAdd();
+        builder.setXid(0x12345678)
+    .setMatch(
+        factory.buildMatch()
+            .setExact(MatchField.IN_PORT, OFPort.of(3))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv4)
+            .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
+            .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
+            .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
+            .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
+            .build()
+    )
+    .setIdleTimeout(5)
+    .setFlags(Sets.immutableEnumSet(OFFlowModFlags.CHECK_OVERLAP))
+    .setBufferId(OFBufferId.of(0))
+    .setOutPort(OFPort.of(0)) // doesn't make that much sense, but is in the example
+    .setActions(
+        ImmutableList.of(
+            factory.actions().output(OFPort.FLOOD, 0),
+            factory.actions().niciraDecTtl(),
+            factory.actions().bsnSetTunnelDst(0)
+        )
+    );;
+        OFFlowAdd flowAdd = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        flowAdd.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(FLOW_ADD_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFFlowAdd.Builder builder = factory.buildFlowAdd();
+        builder.setXid(0x12345678)
+    .setMatch(
+        factory.buildMatch()
+            .setExact(MatchField.IN_PORT, OFPort.of(3))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv4)
+            .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
+            .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
+            .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
+            .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
+            .build()
+    )
+    .setIdleTimeout(5)
+    .setFlags(Sets.immutableEnumSet(OFFlowModFlags.CHECK_OVERLAP))
+    .setBufferId(OFBufferId.of(0))
+    .setOutPort(OFPort.of(0)) // doesn't make that much sense, but is in the example
+    .setActions(
+        ImmutableList.of(
+            factory.actions().output(OFPort.FLOOD, 0),
+            factory.actions().niciraDecTtl(),
+            factory.actions().bsnSetTunnelDst(0)
+        )
+    );;
+        OFFlowAdd flowAddBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_ADD_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFFlowAdd flowAddRead = OFFlowAddVer10.READER.readFrom(input);
+        assertEquals(FLOW_ADD_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(flowAddBuilt, flowAddRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_ADD_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowAdd flowAdd = OFFlowAddVer10.READER.readFrom(input);
+       assertEquals(FLOW_ADD_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowAdd.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_ADD_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsEntryVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsEntryVer10Test.java
new file mode 100644
index 0000000..3710ef8
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsEntryVer10Test.java
@@ -0,0 +1,143 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowStatsEntryVer10Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_STATS_ENTRY_SERIALIZED =
+        new byte[] { 0x0, 0x68, 0x3, 0x0, 0x0, 0x30, 0x0, (byte) 0xe2, 0x0, 0x3, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef, 0x1, 0x23, 0x45, 0x67, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xc0, (byte) 0xa8, 0x3, 0x7f, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x64, 0x0, 0x5, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, (byte) 0xe8, 0x0, 0x0, 0x0, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x2, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFFlowStatsEntry.Builder builder = factory.buildFlowStatsEntry();
+            builder
+      .setTableId(TableId.of(3))
+      .setMatch(
+        factory.buildMatch()
+            .setExact(MatchField.IN_PORT, OFPort.of(3))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv4)
+            .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
+            .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
+            .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
+            .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
+            .build()
+      )
+      .setDurationSec(1)
+      .setDurationNsec(2)
+      .setPriority(100)
+      .setIdleTimeout(5)
+      .setHardTimeout(10)
+      .setCookie(U64.of(0x0123456789abcdefL))
+      .setPacketCount(U64.of(10))
+      .setByteCount(U64.of(1000))
+      .setActions(
+            ImmutableList.<OFAction>of(
+                   factory.actions().output(OFPort.of(1), 0),
+                   factory.actions().output(OFPort.of(2), 0)
+                   )
+      );;
+        OFFlowStatsEntry flowStatsEntry = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        flowStatsEntry.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(FLOW_STATS_ENTRY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFFlowStatsEntry.Builder builder = factory.buildFlowStatsEntry();
+            builder
+      .setTableId(TableId.of(3))
+      .setMatch(
+        factory.buildMatch()
+            .setExact(MatchField.IN_PORT, OFPort.of(3))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv4)
+            .setExact(MatchField.IPV4_SRC, IPv4Address.of(0xc0a8037f))
+            .setExact(MatchField.IPV4_DST, IPv4Address.of(0xffffffff))
+            .setExact(MatchField.ETH_SRC, MacAddress.of("01:23:45:67:89:ab"))
+            .setExact(MatchField.ETH_DST, MacAddress.of("cd:ef:01:23:45:67"))
+            .build()
+      )
+      .setDurationSec(1)
+      .setDurationNsec(2)
+      .setPriority(100)
+      .setIdleTimeout(5)
+      .setHardTimeout(10)
+      .setCookie(U64.of(0x0123456789abcdefL))
+      .setPacketCount(U64.of(10))
+      .setByteCount(U64.of(1000))
+      .setActions(
+            ImmutableList.<OFAction>of(
+                   factory.actions().output(OFPort.of(1), 0),
+                   factory.actions().output(OFPort.of(2), 0)
+                   )
+      );;
+        OFFlowStatsEntry flowStatsEntryBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_STATS_ENTRY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFFlowStatsEntry flowStatsEntryRead = OFFlowStatsEntryVer10.READER.readFrom(input);
+        assertEquals(FLOW_STATS_ENTRY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(flowStatsEntryBuilt, flowStatsEntryRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_STATS_ENTRY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowStatsEntry flowStatsEntry = OFFlowStatsEntryVer10.READER.readFrom(input);
+       assertEquals(FLOW_STATS_ENTRY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowStatsEntry.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_STATS_ENTRY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsReplyVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsReplyVer10Test.java
new file mode 100644
index 0000000..f4d6539
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFFlowStatsReplyVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowStatsReplyVer10Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x1, 0x11, 0x0, (byte) 0xe4, 0x0, 0x0, 0x0, 0x6, 0x0, 0x1, 0x0, 0x0, 0x0, 0x68, 0x3, 0x0, 0x0, 0x3f, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x64, 0x0, 0x5, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, (byte) 0xe8, 0x0, 0x0, 0x0, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x70, 0x4, 0x0, 0x0, 0x3f, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x64, 0x0, 0x5, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, (byte) 0xe8, 0x0, 0x0, 0x0, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x3, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowStatsReply flowStatsReply = OFFlowStatsReplyVer10.READER.readFrom(input);
+       assertEquals(FLOW_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloVer10Test.java
new file mode 100644
index 0000000..f2bc4af
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFHelloVer10Test.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFHelloVer10Test {
+    OFFactory factory;
+
+    final static byte[] HELLO_SERIALIZED =
+        new byte[] { 0x1, 0x0, 0x0, 0x8, 0x12, 0x34, 0x56, 0x78 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFHello.Builder builder = factory.buildHello();
+        builder.setXid(0x12345678);
+        OFHello hello = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        hello.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(HELLO_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFHello.Builder builder = factory.buildHello();
+        builder.setXid(0x12345678);
+        OFHello helloBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(HELLO_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFHello helloRead = OFHelloVer10.READER.readFrom(input);
+        assertEquals(HELLO_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(helloBuilt, helloRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(HELLO_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFHello hello = OFHelloVer10.READER.readFrom(input);
+       assertEquals(HELLO_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       hello.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(HELLO_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInVer10Test.java
new file mode 100644
index 0000000..288dcd4
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketInVer10Test.java
@@ -0,0 +1,103 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPacketInVer10Test {
+    OFFactory factory;
+
+    final static byte[] PACKET_IN_SERIALIZED =
+        new byte[] { 0x1, 0xa, 0x0, 0x15, 0x12, 0x34, 0x56, 0x78, (byte) 0xab, (byte) 0xcd, (byte) 0xef, 0x1, 0x0, 0x9, (byte) 0xff, (byte) 0xfe, 0x1, 0x0, 0x61, 0x62, 0x63 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFPacketIn.Builder builder = factory.buildPacketIn();
+        builder
+   .setXid(0x12345678)
+   .setBufferId(OFBufferId.of(0xabcdef01))
+   .setTotalLen(9)
+   .setInPort(OFPort.LOCAL)
+   .setReason(OFPacketInReason.ACTION)
+   .setData(new byte[] { 0x61, 0x62, 0x63 } );;
+        OFPacketIn packetIn = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        packetIn.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(PACKET_IN_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFPacketIn.Builder builder = factory.buildPacketIn();
+        builder
+   .setXid(0x12345678)
+   .setBufferId(OFBufferId.of(0xabcdef01))
+   .setTotalLen(9)
+   .setInPort(OFPort.LOCAL)
+   .setReason(OFPacketInReason.ACTION)
+   .setData(new byte[] { 0x61, 0x62, 0x63 } );;
+        OFPacketIn packetInBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(PACKET_IN_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFPacketIn packetInRead = OFPacketInVer10.READER.readFrom(input);
+        assertEquals(PACKET_IN_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(packetInBuilt, packetInRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PACKET_IN_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPacketIn packetIn = OFPacketInVer10.READER.readFrom(input);
+       assertEquals(PACKET_IN_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       packetIn.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PACKET_IN_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketOutVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketOutVer10Test.java
new file mode 100644
index 0000000..b8d5074
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPacketOutVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPacketOutVer10Test {
+    OFFactory factory;
+
+    final static byte[] PACKET_OUT_SERIALIZED =
+        new byte[] { 0x1, 0xd, 0x0, 0x23, 0x12, 0x34, 0x56, 0x78, (byte) 0xab, (byte) 0xcd, (byte) 0xef, 0x1, (byte) 0xff, (byte) 0xfe, 0x0, 0x10, 0x0, 0x0, 0x0, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x2, 0x0, 0x0, 0x61, 0x62, 0x63 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PACKET_OUT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPacketOut packetOut = OFPacketOutVer10.READER.readFrom(input);
+       assertEquals(PACKET_OUT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       packetOut.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PACKET_OUT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortDescVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortDescVer10Test.java
new file mode 100644
index 0000000..9d6378b
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortDescVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPortDescVer10Test {
+    OFFactory factory;
+
+    final static byte[] PORT_DESC_SERIALIZED =
+        new byte[] { (byte) 0xff, (byte) 0xfd, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x66, 0x6f, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x8, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PORT_DESC_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPortDesc portDesc = OFPortDescVer10.READER.readFrom(input);
+       assertEquals(PORT_DESC_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       portDesc.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PORT_DESC_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModVer10Test.java
new file mode 100644
index 0000000..7ccbc4b
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortModVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPortModVer10Test {
+    OFFactory factory;
+
+    final static byte[] PORT_MOD_SERIALIZED =
+        new byte[] { 0x1, 0xf, 0x0, 0x20, 0x0, 0x0, 0x0, 0x2, (byte) 0xff, (byte) 0xfd, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, (byte) 0x90, (byte) 0xab, (byte) 0xcd, (byte) 0xef, (byte) 0xff, 0x11, (byte) 0xff, 0x11, (byte) 0xca, (byte) 0xfe, 0x67, (byte) 0x89, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PORT_MOD_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPortMod portMod = OFPortModVer10.READER.readFrom(input);
+       assertEquals(PORT_MOD_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       portMod.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PORT_MOD_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsReplyVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsReplyVer10Test.java
new file mode 100644
index 0000000..03fa8b2
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatsReplyVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPortStatsReplyVer10Test {
+    OFFactory factory;
+
+    final static byte[] PORT_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x1, 0x11, 0x0, (byte) 0xdc, 0x0, 0x0, 0x0, 0x5, 0x0, 0x4, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, (byte) 0xff, (byte) 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PORT_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPortStatsReply portStatsReply = OFPortStatsReplyVer10.READER.readFrom(input);
+       assertEquals(PORT_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       portStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PORT_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatusVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatusVer10Test.java
new file mode 100644
index 0000000..798c65d
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFPortStatusVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPortStatusVer10Test {
+    OFFactory factory;
+
+    final static byte[] PORT_STATUS_SERIALIZED =
+        new byte[] { 0x1, 0xc, 0x0, 0x40, 0x0, 0x0, 0x0, 0x4, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xff, (byte) 0xfd, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x66, 0x6f, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x8, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PORT_STATUS_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPortStatus portStatus = OFPortStatusVer10.READER.readFrom(input);
+       assertEquals(PORT_STATUS_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       portStatus.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PORT_STATUS_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigReplyVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigReplyVer10Test.java
new file mode 100644
index 0000000..da60313
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFQueueGetConfigReplyVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFQueueGetConfigReplyVer10Test {
+    OFFactory factory;
+
+    final static byte[] QUEUE_GET_CONFIG_REPLY_SERIALIZED =
+        new byte[] { 0x1, 0x15, 0x0, 0x50, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xfe, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x18, 0x0, 0x0, 0x0, 0x1, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x28, 0x0, 0x0, 0x0, 0x1, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(QUEUE_GET_CONFIG_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFQueueGetConfigReply queueGetConfigReply = OFQueueGetConfigReplyVer10.READER.readFrom(input);
+       assertEquals(QUEUE_GET_CONFIG_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       queueGetConfigReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(QUEUE_GET_CONFIG_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsEntryVer10Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsEntryVer10Test.java
new file mode 100644
index 0000000..3eb91bf
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver10/OFTableStatsEntryVer10Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver10;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFTableStatsEntryVer10Test {
+    OFFactory factory;
+
+    final static byte[] TABLE_STATS_ENTRY_SERIALIZED =
+        new byte[] { 0x3, 0x0, 0x0, 0x0, 0x66, 0x6f, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x81, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer10.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(TABLE_STATS_ENTRY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFTableStatsEntry tableStatsEntry = OFTableStatsEntryVer10.READER.readFrom(input);
+       assertEquals(TABLE_STATS_ENTRY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       tableStatsEntry.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(TABLE_STATS_ENTRY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortMaskedVer12Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortMaskedVer12Test.java
new file mode 100644
index 0000000..59f6f2e
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortMaskedVer12Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmInPhyPortMaskedVer12Test {
+    OFOxms factory;
+
+    final static byte[] OXM_IN_PHY_PORT_MASKED_SERIALIZED =
+        new byte[] { (byte) 0x80, 0x0, 0x3, 0x8, 0x0, 0x0, 0x0, 0x2a, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xdd };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer12.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_IN_PHY_PORT_MASKED_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmInPhyPortMasked oxmInPhyPortMasked = OFOxmInPhyPortMaskedVer12.READER.readFrom(input);
+       assertEquals(OXM_IN_PHY_PORT_MASKED_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmInPhyPortMasked.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_IN_PHY_PORT_MASKED_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortVer12Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortVer12Test.java
new file mode 100644
index 0000000..9d55855
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmInPhyPortVer12Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmInPhyPortVer12Test {
+    OFOxms factory;
+
+    final static byte[] OXM_IN_PHY_PORT_SERIALIZED =
+        new byte[] { (byte) 0x80, 0x0, 0x2, 0x4, 0x0, 0x0, 0x0, 0x2a };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer12.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_IN_PHY_PORT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmInPhyPort oxmInPhyPort = OFOxmInPhyPortVer12.READER.readFrom(input);
+       assertEquals(OXM_IN_PHY_PORT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmInPhyPort.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_IN_PHY_PORT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstVer12Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstVer12Test.java
new file mode 100644
index 0000000..1be7fbc
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver12/OFOxmIpv6DstVer12Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver12;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmIpv6DstVer12Test {
+    OFOxms factory;
+
+    final static byte[] OXM_IPV6_DST_SERIALIZED =
+        new byte[] { (byte) 0x80, 0x0, 0x36, 0x10, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer12.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_IPV6_DST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmIpv6Dst oxmIpv6Dst = OFOxmIpv6DstVer12.READER.readFrom(input);
+       assertEquals(OXM_IPV6_DST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmIpv6Dst.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_IPV6_DST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdOutputVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdOutputVer13Test.java
new file mode 100644
index 0000000..a43d1d8
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionIdOutputVer13Test.java
@@ -0,0 +1,87 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFActionIdOutputVer13Test {
+    OFActionIds factory;
+
+    final static byte[] ACTION_ID_OUTPUT_SERIALIZED =
+        new byte[] { 0x0, 0x0, 0x0, 0x4 };
+
+    @Before
+    public void setup() {
+        factory = OFActionIdsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFActionIdOutput actionIdOutput = factory.output();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        actionIdOutput.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(ACTION_ID_OUTPUT_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFActionIdOutput actionIdOutputBuilt = factory.output();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_ID_OUTPUT_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFActionIdOutput actionIdOutputRead = OFActionIdOutputVer13.READER.readFrom(input);
+        assertEquals(ACTION_ID_OUTPUT_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(actionIdOutputBuilt, actionIdOutputRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_ID_OUTPUT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFActionIdOutput actionIdOutput = OFActionIdOutputVer13.READER.readFrom(input);
+       assertEquals(ACTION_ID_OUTPUT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       actionIdOutput.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ACTION_ID_OUTPUT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionOutputVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionOutputVer13Test.java
new file mode 100644
index 0000000..321df67
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionOutputVer13Test.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFActionOutputVer13Test {
+    OFActions factory;
+
+    final static byte[] ACTION_OUTPUT_SERIALIZED =
+        new byte[] { 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x32, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFActionsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFActionOutput.Builder builder = factory.buildOutput();
+        builder.setPort(OFPort.of(50)).setMaxLen(65535);
+        OFActionOutput actionOutput = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        actionOutput.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(ACTION_OUTPUT_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFActionOutput.Builder builder = factory.buildOutput();
+        builder.setPort(OFPort.of(50)).setMaxLen(65535);
+        OFActionOutput actionOutputBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_OUTPUT_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFActionOutput actionOutputRead = OFActionOutputVer13.READER.readFrom(input);
+        assertEquals(ACTION_OUTPUT_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(actionOutputBuilt, actionOutputRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_OUTPUT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFActionOutput actionOutput = OFActionOutputVer13.READER.readFrom(input);
+       assertEquals(ACTION_OUTPUT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       actionOutput.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ACTION_OUTPUT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13BsnLagIdTest.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13BsnLagIdTest.java
new file mode 100644
index 0000000..00313fb
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13BsnLagIdTest.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFActionSetFieldVer13BsnLagIdTest {
+    OFActions factory;
+
+    final static byte[] ACTION_SET_FIELD_SERIALIZED =
+        new byte[] { 0x0, 0x19, 0x0, 0x10, 0x0, 0x3, 0x2, 0x4, 0x12, 0x34, 0x56, 0x78, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFActionsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFActionSetField.Builder builder = factory.buildSetField();
+        OFOxms oxms = OFFactories.getFactory(OFVersion.OF_13).oxms();
+builder.setField(oxms.bsnLagId(LagId.of(0x12345678)));
+        OFActionSetField actionSetField = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        actionSetField.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(ACTION_SET_FIELD_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFActionSetField.Builder builder = factory.buildSetField();
+        OFOxms oxms = OFFactories.getFactory(OFVersion.OF_13).oxms();
+builder.setField(oxms.bsnLagId(LagId.of(0x12345678)));
+        OFActionSetField actionSetFieldBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_SET_FIELD_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFActionSetField actionSetFieldRead = OFActionSetFieldVer13.READER.readFrom(input);
+        assertEquals(ACTION_SET_FIELD_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(actionSetFieldBuilt, actionSetFieldRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_SET_FIELD_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFActionSetField actionSetField = OFActionSetFieldVer13.READER.readFrom(input);
+       assertEquals(ACTION_SET_FIELD_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       actionSetField.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ACTION_SET_FIELD_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13EthDstTest.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13EthDstTest.java
new file mode 100644
index 0000000..8cc7e76
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13EthDstTest.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFActionSetFieldVer13EthDstTest {
+    OFActions factory;
+
+    final static byte[] ACTION_SET_FIELD_SERIALIZED =
+        new byte[] { 0x0, 0x19, 0x0, 0x10, (byte) 0x80, 0x0, 0x6, 0x6, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFActionsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFActionSetField.Builder builder = factory.buildSetField();
+        OFOxms oxms = OFFactories.getFactory(OFVersion.OF_13).oxms();
+builder.setField(oxms.ethDst(MacAddress.of("00:01:02:03:04:05")));
+        OFActionSetField actionSetField = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        actionSetField.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(ACTION_SET_FIELD_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFActionSetField.Builder builder = factory.buildSetField();
+        OFOxms oxms = OFFactories.getFactory(OFVersion.OF_13).oxms();
+builder.setField(oxms.ethDst(MacAddress.of("00:01:02:03:04:05")));
+        OFActionSetField actionSetFieldBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_SET_FIELD_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFActionSetField actionSetFieldRead = OFActionSetFieldVer13.READER.readFrom(input);
+        assertEquals(ACTION_SET_FIELD_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(actionSetFieldBuilt, actionSetFieldRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_SET_FIELD_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFActionSetField actionSetField = OFActionSetFieldVer13.READER.readFrom(input);
+       assertEquals(ACTION_SET_FIELD_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       actionSetField.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ACTION_SET_FIELD_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13Ipv6SrcTest.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13Ipv6SrcTest.java
new file mode 100644
index 0000000..342663d
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13Ipv6SrcTest.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFActionSetFieldVer13Ipv6SrcTest {
+    OFActions factory;
+
+    final static byte[] ACTION_SET_FIELD_SERIALIZED =
+        new byte[] { 0x0, 0x19, 0x0, 0x18, (byte) 0x80, 0x0, 0x34, 0x10, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf };
+
+    @Before
+    public void setup() {
+        factory = OFActionsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFActionSetField.Builder builder = factory.buildSetField();
+        OFOxms oxms = OFFactories.getFactory(OFVersion.OF_13).oxms();
+builder.setField(oxms.ipv6Src(IPv6Address.of("0001:0203:0405:0607:0809:0a0b:0c0d:0e0f")));
+        OFActionSetField actionSetField = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        actionSetField.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(ACTION_SET_FIELD_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFActionSetField.Builder builder = factory.buildSetField();
+        OFOxms oxms = OFFactories.getFactory(OFVersion.OF_13).oxms();
+builder.setField(oxms.ipv6Src(IPv6Address.of("0001:0203:0405:0607:0809:0a0b:0c0d:0e0f")));
+        OFActionSetField actionSetFieldBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_SET_FIELD_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFActionSetField actionSetFieldRead = OFActionSetFieldVer13.READER.readFrom(input);
+        assertEquals(ACTION_SET_FIELD_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(actionSetFieldBuilt, actionSetFieldRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_SET_FIELD_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFActionSetField actionSetField = OFActionSetFieldVer13.READER.readFrom(input);
+       assertEquals(ACTION_SET_FIELD_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       actionSetField.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ACTION_SET_FIELD_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13TcpSrcTest.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13TcpSrcTest.java
new file mode 100644
index 0000000..b01a93a
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFActionSetFieldVer13TcpSrcTest.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFActionSetFieldVer13TcpSrcTest {
+    OFActions factory;
+
+    final static byte[] ACTION_SET_FIELD_SERIALIZED =
+        new byte[] { 0x0, 0x19, 0x0, 0x10, (byte) 0x80, 0x0, 0x1a, 0x2, 0x0, 0x32, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFActionsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFActionSetField.Builder builder = factory.buildSetField();
+        OFOxms oxms = OFFactories.getFactory(OFVersion.OF_13).oxms();
+builder.setField(oxms.tcpSrc(TransportPort.of(50)));
+        OFActionSetField actionSetField = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        actionSetField.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(ACTION_SET_FIELD_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFActionSetField.Builder builder = factory.buildSetField();
+        OFOxms oxms = OFFactories.getFactory(OFVersion.OF_13).oxms();
+builder.setField(oxms.tcpSrc(TransportPort.of(50)));
+        OFActionSetField actionSetFieldBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_SET_FIELD_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFActionSetField actionSetFieldRead = OFActionSetFieldVer13.READER.readFrom(input);
+        assertEquals(ACTION_SET_FIELD_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(actionSetFieldBuilt, actionSetFieldRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ACTION_SET_FIELD_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFActionSetField actionSetField = OFActionSetFieldVer13.READER.readFrom(input);
+       assertEquals(ACTION_SET_FIELD_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       actionSetField.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ACTION_SET_FIELD_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchErrorMsgVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchErrorMsgVer13Test.java
new file mode 100644
index 0000000..9ccbe31
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBadMatchErrorMsgVer13Test.java
@@ -0,0 +1,95 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBadMatchErrorMsgVer13Test {
+    OFErrorMsgs factory;
+
+    final static byte[] BAD_MATCH_ERROR_MSG_SERIALIZED =
+        new byte[] { 0x4, 0x1, 0x0, 0xf, 0x12, 0x34, 0x56, 0x78, 0x0, 0x4, 0x0, 0x8, 0x61, 0x62, 0x63 };
+
+    @Before
+    public void setup() {
+        factory = OFErrorMsgsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBadMatchErrorMsg.Builder builder = factory.buildBadMatchErrorMsg();
+        builder.setXid(0x12345678)
+    .setCode(OFBadMatchCode.BAD_MASK)
+    .setData(OFErrorCauseData.of(new byte[] { 0x61, 0x62, 0x63 }, OFVersion.OF_13));;
+        OFBadMatchErrorMsg badMatchErrorMsg = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        badMatchErrorMsg.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BAD_MATCH_ERROR_MSG_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBadMatchErrorMsg.Builder builder = factory.buildBadMatchErrorMsg();
+        builder.setXid(0x12345678)
+    .setCode(OFBadMatchCode.BAD_MASK)
+    .setData(OFErrorCauseData.of(new byte[] { 0x61, 0x62, 0x63 }, OFVersion.OF_13));;
+        OFBadMatchErrorMsg badMatchErrorMsgBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BAD_MATCH_ERROR_MSG_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBadMatchErrorMsg badMatchErrorMsgRead = OFBadMatchErrorMsgVer13.READER.readFrom(input);
+        assertEquals(BAD_MATCH_ERROR_MSG_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(badMatchErrorMsgBuilt, badMatchErrorMsgRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BAD_MATCH_ERROR_MSG_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBadMatchErrorMsg badMatchErrorMsg = OFBadMatchErrorMsgVer13.READER.readFrom(input);
+       assertEquals(BAD_MATCH_ERROR_MSG_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       badMatchErrorMsg.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BAD_MATCH_ERROR_MSG_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestErrorMsgVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestErrorMsgVer13Test.java
new file mode 100644
index 0000000..08b0a77
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBadRequestErrorMsgVer13Test.java
@@ -0,0 +1,95 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBadRequestErrorMsgVer13Test {
+    OFErrorMsgs factory;
+
+    final static byte[] BAD_REQUEST_ERROR_MSG_SERIALIZED =
+        new byte[] { 0x4, 0x1, 0x0, 0xf, 0x12, 0x34, 0x56, 0x78, 0x0, 0x1, 0x0, 0x8, 0x61, 0x62, 0x63 };
+
+    @Before
+    public void setup() {
+        factory = OFErrorMsgsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBadRequestErrorMsg.Builder builder = factory.buildBadRequestErrorMsg();
+        builder.setXid(0x12345678)
+    .setCode(OFBadRequestCode.BUFFER_UNKNOWN)
+    .setData(OFErrorCauseData.of(new byte[] { 0x61, 0x62, 0x63 }, OFVersion.OF_13));;
+        OFBadRequestErrorMsg badRequestErrorMsg = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        badRequestErrorMsg.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BAD_REQUEST_ERROR_MSG_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBadRequestErrorMsg.Builder builder = factory.buildBadRequestErrorMsg();
+        builder.setXid(0x12345678)
+    .setCode(OFBadRequestCode.BUFFER_UNKNOWN)
+    .setData(OFErrorCauseData.of(new byte[] { 0x61, 0x62, 0x63 }, OFVersion.OF_13));;
+        OFBadRequestErrorMsg badRequestErrorMsgBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BAD_REQUEST_ERROR_MSG_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBadRequestErrorMsg badRequestErrorMsgRead = OFBadRequestErrorMsgVer13.READER.readFrom(input);
+        assertEquals(BAD_REQUEST_ERROR_MSG_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(badRequestErrorMsgBuilt, badRequestErrorMsgRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BAD_REQUEST_ERROR_MSG_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBadRequestErrorMsg badRequestErrorMsg = OFBadRequestErrorMsgVer13.READER.readFrom(input);
+       assertEquals(BAD_REQUEST_ERROR_MSG_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       badRequestErrorMsg.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BAD_REQUEST_ERROR_MSG_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleVer13Test.java
new file mode 100644
index 0000000..6d593cd
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnFlowIdleVer13Test.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnFlowIdleVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_FLOW_IDLE_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x38, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x28, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, 0x42, 0x68, 0x14, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x16, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0x2a, 0x2, 0x0, 0x1, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnFlowIdle.Builder builder = factory.buildBsnFlowIdle();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setPriority(17000)
+    .setTableId(TableId.of(20))
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ARP_OP, ArpOpcode.of(1))
+                .build()
+    );;
+        OFBsnFlowIdle bsnFlowIdle = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnFlowIdle.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_FLOW_IDLE_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnFlowIdle.Builder builder = factory.buildBsnFlowIdle();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setPriority(17000)
+    .setTableId(TableId.of(20))
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ARP_OP, ArpOpcode.of(1))
+                .build()
+    );;
+        OFBsnFlowIdle bsnFlowIdleBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_FLOW_IDLE_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnFlowIdle bsnFlowIdleRead = OFBsnFlowIdleVer13.READER.readFrom(input);
+        assertEquals(BSN_FLOW_IDLE_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnFlowIdleBuilt, bsnFlowIdleRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_FLOW_IDLE_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnFlowIdle bsnFlowIdle = OFBsnFlowIdleVer13.READER.readFrom(input);
+       assertEquals(BSN_FLOW_IDLE_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnFlowIdle.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_FLOW_IDLE_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsReplyVer13Test.java
new file mode 100644
index 0000000..a9bacd6
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsReplyVer13Test.java
@@ -0,0 +1,105 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableBucketStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, 0x38, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x5, (byte) 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x12, 0x34, 0x23, 0x45, 0x34, 0x56, 0x45, 0x67, 0x56, 0x78, 0x67, (byte) 0x89, 0x78, (byte) 0x9a, (byte) 0x89, (byte) 0xab };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnGentableBucketStatsReply.Builder builder = factory.buildBsnGentableBucketStatsReply();
+        builder.setXid(0x12345678)
+    .setEntries(
+        ImmutableList.<OFBsnGentableBucketStatsEntry>of(
+            factory.bsnGentableBucketStatsEntry(U128.of(0x8877665544332211L, 0xFFEEDDCCBBAA9988L)),
+            factory.bsnGentableBucketStatsEntry(U128.of(0x1234234534564567L, 0x56786789789A89ABL))
+        )
+    );
+        OFBsnGentableBucketStatsReply bsnGentableBucketStatsReply = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnGentableBucketStatsReply.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnGentableBucketStatsReply.Builder builder = factory.buildBsnGentableBucketStatsReply();
+        builder.setXid(0x12345678)
+    .setEntries(
+        ImmutableList.<OFBsnGentableBucketStatsEntry>of(
+            factory.bsnGentableBucketStatsEntry(U128.of(0x8877665544332211L, 0xFFEEDDCCBBAA9988L)),
+            factory.bsnGentableBucketStatsEntry(U128.of(0x1234234534564567L, 0x56786789789A89ABL))
+        )
+    );
+        OFBsnGentableBucketStatsReply bsnGentableBucketStatsReplyBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnGentableBucketStatsReply bsnGentableBucketStatsReplyRead = OFBsnGentableBucketStatsReplyVer13.READER.readFrom(input);
+        assertEquals(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnGentableBucketStatsReplyBuilt, bsnGentableBucketStatsReplyRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableBucketStatsReply bsnGentableBucketStatsReply = OFBsnGentableBucketStatsReplyVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableBucketStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_BUCKET_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsRequestVer13Test.java
new file mode 100644
index 0000000..b89c812
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableBucketStatsRequestVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableBucketStatsRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_BUCKET_STATS_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x12, 0x0, 0x1a, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x5, 0x12, 0x34 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_BUCKET_STATS_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableBucketStatsRequest bsnGentableBucketStatsRequest = OFBsnGentableBucketStatsRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_BUCKET_STATS_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableBucketStatsRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_BUCKET_STATS_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearRequestVer13Test.java
new file mode 100644
index 0000000..83217a8
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableClearRequestVer13Test.java
@@ -0,0 +1,97 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableClearRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_CLEAR_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x34, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x30, 0x0, 0x14, 0x0, 0x0, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, (byte) 0xee, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnGentableClearRequest.Builder builder = factory.buildBsnGentableClearRequest();
+        builder.setXid(0x12345678)
+    .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA990000L))
+    .setChecksumMask(U128.of(0xFFFFFFFFFFFFFFFFL, 0xFFFFFFFFFFFF0000L))
+    .setTableId(GenTableId.of(20));
+        OFBsnGentableClearRequest bsnGentableClearRequest = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnGentableClearRequest.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_CLEAR_REQUEST_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnGentableClearRequest.Builder builder = factory.buildBsnGentableClearRequest();
+        builder.setXid(0x12345678)
+    .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA990000L))
+    .setChecksumMask(U128.of(0xFFFFFFFFFFFFFFFFL, 0xFFFFFFFFFFFF0000L))
+    .setTableId(GenTableId.of(20));
+        OFBsnGentableClearRequest bsnGentableClearRequestBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_CLEAR_REQUEST_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnGentableClearRequest bsnGentableClearRequestRead = OFBsnGentableClearRequestVer13.READER.readFrom(input);
+        assertEquals(BSN_GENTABLE_CLEAR_REQUEST_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnGentableClearRequestBuilt, bsnGentableClearRequestRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_CLEAR_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableClearRequest bsnGentableClearRequest = OFBsnGentableClearRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_CLEAR_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableClearRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_CLEAR_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsReplyVer13Test.java
new file mode 100644
index 0000000..b401c59
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsReplyVer13Test.java
@@ -0,0 +1,125 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableDescStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, 0x78, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x4, 0x0, 0x30, 0x0, 0x0, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x1, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x2e, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, (byte) 0x80, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnGentableDescStatsReply.Builder builder = factory.buildBsnGentableDescStatsReply();
+        builder.setXid(0x12345678)
+    .setEntries(
+        ImmutableList.<OFBsnGentableDescStatsEntry>of(
+            factory.buildBsnGentableDescStatsEntry()
+                .setTableId(GenTableId.of(0))
+                .setName("table 0")
+                .setBucketsSize(32)
+                .setMaxEntries(64)
+                .build(),
+            factory.buildBsnGentableDescStatsEntry()
+                .setTableId(GenTableId.of(1))
+                .setName("table 1.........................")
+                .setBucketsSize(64)
+                .setMaxEntries(128)
+                .build()
+        )
+    );
+        OFBsnGentableDescStatsReply bsnGentableDescStatsReply = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnGentableDescStatsReply.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnGentableDescStatsReply.Builder builder = factory.buildBsnGentableDescStatsReply();
+        builder.setXid(0x12345678)
+    .setEntries(
+        ImmutableList.<OFBsnGentableDescStatsEntry>of(
+            factory.buildBsnGentableDescStatsEntry()
+                .setTableId(GenTableId.of(0))
+                .setName("table 0")
+                .setBucketsSize(32)
+                .setMaxEntries(64)
+                .build(),
+            factory.buildBsnGentableDescStatsEntry()
+                .setTableId(GenTableId.of(1))
+                .setName("table 1.........................")
+                .setBucketsSize(64)
+                .setMaxEntries(128)
+                .build()
+        )
+    );
+        OFBsnGentableDescStatsReply bsnGentableDescStatsReplyBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnGentableDescStatsReply bsnGentableDescStatsReplyRead = OFBsnGentableDescStatsReplyVer13.READER.readFrom(input);
+        assertEquals(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnGentableDescStatsReplyBuilt, bsnGentableDescStatsReplyRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableDescStatsReply bsnGentableDescStatsReply = OFBsnGentableDescStatsReplyVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableDescStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_DESC_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsRequestVer13Test.java
new file mode 100644
index 0000000..dc5a452
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableDescStatsRequestVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableDescStatsRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_DESC_STATS_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x12, 0x0, 0x18, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x4 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_DESC_STATS_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableDescStatsRequest bsnGentableDescStatsRequest = OFBsnGentableDescStatsRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_DESC_STATS_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableDescStatsRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_DESC_STATS_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryAddVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryAddVer13Test.java
new file mode 100644
index 0000000..c7d7dda
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryAddVer13Test.java
@@ -0,0 +1,121 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableEntryAddVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_ENTRY_ADD_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x48, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2e, 0x0, 0x14, 0x0, 0x12, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, (byte) 0xee, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x77, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5, 0x0, 0x1, 0x0, 0xa, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x6, 0x0, 0x1, 0x0, 0xa, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnGentableEntryAdd.Builder builder = factory.buildBsnGentableEntryAdd();
+        builder.setXid(0x12345678)
+    .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998877L))
+    .setTableId(GenTableId.of(20))
+    .setKey(
+        ImmutableList.<OFBsnTlv>of(
+            factory.bsnTlvs().port(OFPort.of(5)),
+            factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab"))
+        )
+    )
+    .setValue(
+        ImmutableList.<OFBsnTlv>of(
+            factory.bsnTlvs().port(OFPort.of(6)),
+            factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:aa"))
+        )
+    );
+        OFBsnGentableEntryAdd bsnGentableEntryAdd = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnGentableEntryAdd.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_ADD_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnGentableEntryAdd.Builder builder = factory.buildBsnGentableEntryAdd();
+        builder.setXid(0x12345678)
+    .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998877L))
+    .setTableId(GenTableId.of(20))
+    .setKey(
+        ImmutableList.<OFBsnTlv>of(
+            factory.bsnTlvs().port(OFPort.of(5)),
+            factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab"))
+        )
+    )
+    .setValue(
+        ImmutableList.<OFBsnTlv>of(
+            factory.bsnTlvs().port(OFPort.of(6)),
+            factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:aa"))
+        )
+    );
+        OFBsnGentableEntryAdd bsnGentableEntryAddBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_ADD_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnGentableEntryAdd bsnGentableEntryAddRead = OFBsnGentableEntryAddVer13.READER.readFrom(input);
+        assertEquals(BSN_GENTABLE_ENTRY_ADD_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnGentableEntryAddBuilt, bsnGentableEntryAddRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_ADD_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableEntryAdd bsnGentableEntryAdd = OFBsnGentableEntryAddVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_ENTRY_ADD_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableEntryAdd.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_ADD_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDeleteVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDeleteVer13Test.java
new file mode 100644
index 0000000..bea5123
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDeleteVer13Test.java
@@ -0,0 +1,107 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableEntryDeleteVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_ENTRY_DELETE_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x24, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2f, 0x0, 0x14, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5, 0x0, 0x1, 0x0, 0xa, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnGentableEntryDelete.Builder builder = factory.buildBsnGentableEntryDelete();
+        builder.setXid(0x12345678)
+    .setTableId(GenTableId.of(20))
+    .setKey(
+        ImmutableList.<OFBsnTlv>of(
+            factory.bsnTlvs().port(OFPort.of(5)),
+            factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab"))
+        )
+    );
+        OFBsnGentableEntryDelete bsnGentableEntryDelete = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnGentableEntryDelete.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnGentableEntryDelete.Builder builder = factory.buildBsnGentableEntryDelete();
+        builder.setXid(0x12345678)
+    .setTableId(GenTableId.of(20))
+    .setKey(
+        ImmutableList.<OFBsnTlv>of(
+            factory.bsnTlvs().port(OFPort.of(5)),
+            factory.bsnTlvs().mac(MacAddress.of("01:23:45:67:89:ab"))
+        )
+    );
+        OFBsnGentableEntryDelete bsnGentableEntryDeleteBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnGentableEntryDelete bsnGentableEntryDeleteRead = OFBsnGentableEntryDeleteVer13.READER.readFrom(input);
+        assertEquals(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnGentableEntryDeleteBuilt, bsnGentableEntryDeleteRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableEntryDelete bsnGentableEntryDelete = OFBsnGentableEntryDeleteVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableEntryDelete.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DELETE_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsReplyVer13Test.java
new file mode 100644
index 0000000..f71edae
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsReplyVer13Test.java
@@ -0,0 +1,137 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableEntryDescStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, 0x64, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2, 0x0, 0x26, 0x0, 0x8, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, (byte) 0xee, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5, 0x0, 0x1, 0x0, 0xa, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb, 0x0, 0x0, 0x26, 0x0, 0x8, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, (byte) 0xee, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, (byte) 0x88, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x6, 0x0, 0x1, 0x0, 0xa, (byte) 0xff, (byte) 0xee, (byte) 0xdd, (byte) 0xcc, (byte) 0xbb, 0x1 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnGentableEntryDescStatsReply.Builder builder = factory.buildBsnGentableEntryDescStatsReply();
+        builder.setXid(0x12345678)
+    .setEntries(
+        ImmutableList.<OFBsnGentableEntryDescStatsEntry>of(
+            factory.buildBsnGentableEntryDescStatsEntry()
+                .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998800L))
+                .setKey(ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().port(OFPort.of(5))
+                ))
+                .setValue(ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:00"))
+                ))
+                .build(),
+            factory.buildBsnGentableEntryDescStatsEntry()
+                .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998801L))
+                .setKey(ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().port(OFPort.of(6))
+                ))
+                .setValue(ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:01"))
+                ))
+                .build()
+        )
+    );
+        OFBsnGentableEntryDescStatsReply bsnGentableEntryDescStatsReply = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnGentableEntryDescStatsReply.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnGentableEntryDescStatsReply.Builder builder = factory.buildBsnGentableEntryDescStatsReply();
+        builder.setXid(0x12345678)
+    .setEntries(
+        ImmutableList.<OFBsnGentableEntryDescStatsEntry>of(
+            factory.buildBsnGentableEntryDescStatsEntry()
+                .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998800L))
+                .setKey(ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().port(OFPort.of(5))
+                ))
+                .setValue(ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:00"))
+                ))
+                .build(),
+            factory.buildBsnGentableEntryDescStatsEntry()
+                .setChecksum(U128.of(0xFEDCBA9876543210L, 0xFFEECCBBAA998801L))
+                .setKey(ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().port(OFPort.of(6))
+                ))
+                .setValue(ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().mac(MacAddress.of("ff:ee:dd:cc:bb:01"))
+                ))
+                .build()
+        )
+    );
+        OFBsnGentableEntryDescStatsReply bsnGentableEntryDescStatsReplyBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnGentableEntryDescStatsReply bsnGentableEntryDescStatsReplyRead = OFBsnGentableEntryDescStatsReplyVer13.READER.readFrom(input);
+        assertEquals(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnGentableEntryDescStatsReplyBuilt, bsnGentableEntryDescStatsReplyRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableEntryDescStatsReply bsnGentableEntryDescStatsReply = OFBsnGentableEntryDescStatsReplyVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableEntryDescStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DESC_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsRequestVer13Test.java
new file mode 100644
index 0000000..7f889c1
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryDescStatsRequestVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableEntryDescStatsRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_ENTRY_DESC_STATS_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x12, 0x0, 0x3c, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x2, 0x0, 0x14, 0x0, 0x0, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, (byte) 0xee, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_DESC_STATS_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableEntryDescStatsRequest bsnGentableEntryDescStatsRequest = OFBsnGentableEntryDescStatsRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_ENTRY_DESC_STATS_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableEntryDescStatsRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_DESC_STATS_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsReplyVer13Test.java
new file mode 100644
index 0000000..28c85b2
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsReplyVer13Test.java
@@ -0,0 +1,137 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableEntryStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, 0x60, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x3, 0x0, 0x24, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5, 0x0, 0x2, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x64, 0x0, 0x3, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x65, 0x0, 0x24, 0x0, 0x8, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x6, 0x0, 0x2, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x64, 0x0, 0x3, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x65 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnGentableEntryStatsReply.Builder builder = factory.buildBsnGentableEntryStatsReply();
+        builder.setXid(0x12345678)
+    .setEntries(
+        ImmutableList.<OFBsnGentableEntryStatsEntry>of(
+            factory.bsnGentableEntryStatsEntry(
+                ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().port(OFPort.of(5))
+                ),
+                ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().rxPackets(U64.of(100)),
+                    factory.bsnTlvs().txPackets(U64.of(101))
+                )
+            ),
+            factory.bsnGentableEntryStatsEntry(
+                ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().port(OFPort.of(6))
+                ),
+                ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().rxPackets(U64.of(100)),
+                    factory.bsnTlvs().txPackets(U64.of(101))
+                )
+            )
+        )
+    );
+        OFBsnGentableEntryStatsReply bsnGentableEntryStatsReply = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnGentableEntryStatsReply.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnGentableEntryStatsReply.Builder builder = factory.buildBsnGentableEntryStatsReply();
+        builder.setXid(0x12345678)
+    .setEntries(
+        ImmutableList.<OFBsnGentableEntryStatsEntry>of(
+            factory.bsnGentableEntryStatsEntry(
+                ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().port(OFPort.of(5))
+                ),
+                ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().rxPackets(U64.of(100)),
+                    factory.bsnTlvs().txPackets(U64.of(101))
+                )
+            ),
+            factory.bsnGentableEntryStatsEntry(
+                ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().port(OFPort.of(6))
+                ),
+                ImmutableList.<OFBsnTlv>of(
+                    factory.bsnTlvs().rxPackets(U64.of(100)),
+                    factory.bsnTlvs().txPackets(U64.of(101))
+                )
+            )
+        )
+    );
+        OFBsnGentableEntryStatsReply bsnGentableEntryStatsReplyBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnGentableEntryStatsReply bsnGentableEntryStatsReplyRead = OFBsnGentableEntryStatsReplyVer13.READER.readFrom(input);
+        assertEquals(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnGentableEntryStatsReplyBuilt, bsnGentableEntryStatsReplyRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableEntryStatsReply bsnGentableEntryStatsReply = OFBsnGentableEntryStatsReplyVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableEntryStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsRequestVer13Test.java
new file mode 100644
index 0000000..8fb2165
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableEntryStatsRequestVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableEntryStatsRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_ENTRY_STATS_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x12, 0x0, 0x3c, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x3, 0x0, 0x14, 0x0, 0x0, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, (byte) 0xee, (byte) 0xcc, (byte) 0xbb, (byte) 0xaa, (byte) 0x99, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_ENTRY_STATS_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableEntryStatsRequest bsnGentableEntryStatsRequest = OFBsnGentableEntryStatsRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_ENTRY_STATS_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableEntryStatsRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_ENTRY_STATS_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableSetBucketsSizeVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableSetBucketsSizeVer13Test.java
new file mode 100644
index 0000000..80b54f1
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnGentableSetBucketsSizeVer13Test.java
@@ -0,0 +1,66 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnGentableSetBucketsSizeVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_GENTABLE_SET_BUCKETS_SIZE_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x18, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x32, 0x0, 0x14, 0x0, 0x0, 0x0, 0x11, 0x22, 0x33 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_GENTABLE_SET_BUCKETS_SIZE_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnGentableSetBucketsSize bsnGentableSetBucketsSize = OFBsnGentableSetBucketsSizeVer13.READER.readFrom(input);
+       assertEquals(BSN_GENTABLE_SET_BUCKETS_SIZE_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnGentableSetBucketsSize.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_GENTABLE_SET_BUCKETS_SIZE_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsReplyVer13Test.java
new file mode 100644
index 0000000..a0019e6
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsReplyVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnLacpStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_LACP_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, 0x3c, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, (byte) 0xf1, 0x11, (byte) 0xf2, 0x22, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, (byte) 0xf3, 0x33, (byte) 0xf4, 0x44, (byte) 0xf5, 0x55, 0x2, 0x0, (byte) 0xf6, 0x66, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, (byte) 0xf7, 0x77, (byte) 0xf8, (byte) 0x88, (byte) 0xf9, (byte) 0x99, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_LACP_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnLacpStatsReply bsnLacpStatsReply = OFBsnLacpStatsReplyVer13.READER.readFrom(input);
+       assertEquals(BSN_LACP_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnLacpStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_LACP_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsRequestVer13Test.java
new file mode 100644
index 0000000..28f054c
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnLacpStatsRequestVer13Test.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnLacpStatsRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_LACP_STATS_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x12, 0x0, 0x18, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x1 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnLacpStatsRequest.Builder builder = factory.buildBsnLacpStatsRequest();
+        builder.setXid(0x12345678);
+        OFBsnLacpStatsRequest bsnLacpStatsRequest = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnLacpStatsRequest.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_LACP_STATS_REQUEST_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnLacpStatsRequest.Builder builder = factory.buildBsnLacpStatsRequest();
+        builder.setXid(0x12345678);
+        OFBsnLacpStatsRequest bsnLacpStatsRequestBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_LACP_STATS_REQUEST_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnLacpStatsRequest bsnLacpStatsRequestRead = OFBsnLacpStatsRequestVer13.READER.readFrom(input);
+        assertEquals(BSN_LACP_STATS_REQUEST_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnLacpStatsRequestBuilt, bsnLacpStatsRequestRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_LACP_STATS_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnLacpStatsRequest bsnLacpStatsRequest = OFBsnLacpStatsRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_LACP_STATS_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnLacpStatsRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_LACP_STATS_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsReplyVer13Test.java
new file mode 100644
index 0000000..b0528e6
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnPortCounterStatsReplyVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnPortCounterStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_PORT_COUNTER_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, 0x50, 0x12, 0x34, 0x56, 0x78, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x12, 0x34, 0x56, 0x78, (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x12, 0x34, 0x56, 0x78, (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_PORT_COUNTER_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnPortCounterStatsReply bsnPortCounterStatsReply = OFBsnPortCounterStatsReplyVer13.READER.readFrom(input);
+       assertEquals(BSN_PORT_COUNTER_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnPortCounterStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_PORT_COUNTER_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsReplyVer13Test.java
new file mode 100644
index 0000000..39331d0
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsReplyVer13Test.java
@@ -0,0 +1,96 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnSetAuxCxnsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_SET_AUX_CXNS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x18, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x3b, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnSetAuxCxnsReply.Builder builder = factory.buildBsnSetAuxCxnsReply();
+        builder.setXid(0x12345678)
+        .setNumAux(1)
+        .setStatus(0);
+        OFBsnSetAuxCxnsReply bsnSetAuxCxnsReply = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnSetAuxCxnsReply.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_SET_AUX_CXNS_REPLY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnSetAuxCxnsReply.Builder builder = factory.buildBsnSetAuxCxnsReply();
+        builder.setXid(0x12345678)
+        .setNumAux(1)
+        .setStatus(0);
+        OFBsnSetAuxCxnsReply bsnSetAuxCxnsReplyBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_SET_AUX_CXNS_REPLY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnSetAuxCxnsReply bsnSetAuxCxnsReplyRead = OFBsnSetAuxCxnsReplyVer13.READER.readFrom(input);
+        assertEquals(BSN_SET_AUX_CXNS_REPLY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnSetAuxCxnsReplyBuilt, bsnSetAuxCxnsReplyRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_SET_AUX_CXNS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnSetAuxCxnsReply bsnSetAuxCxnsReply = OFBsnSetAuxCxnsReplyVer13.READER.readFrom(input);
+       assertEquals(BSN_SET_AUX_CXNS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnSetAuxCxnsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_SET_AUX_CXNS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsRequestVer13Test.java
new file mode 100644
index 0000000..1dca579
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnSetAuxCxnsRequestVer13Test.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnSetAuxCxnsRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] BSN_SET_AUX_CXNS_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x14, 0x12, 0x34, 0x56, 0x78, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x3a, 0x0, 0x0, 0x0, 0x1 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnSetAuxCxnsRequest.Builder builder = factory.buildBsnSetAuxCxnsRequest();
+        builder.setXid(0x12345678)
+       .setNumAux(1);
+        OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnSetAuxCxnsRequest.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnSetAuxCxnsRequest.Builder builder = factory.buildBsnSetAuxCxnsRequest();
+        builder.setXid(0x12345678)
+       .setNumAux(1);
+        OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequestBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequestRead = OFBsnSetAuxCxnsRequestVer13.READER.readFrom(input);
+        assertEquals(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnSetAuxCxnsRequestBuilt, bsnSetAuxCxnsRequestRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnSetAuxCxnsRequest bsnSetAuxCxnsRequest = OFBsnSetAuxCxnsRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnSetAuxCxnsRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_SET_AUX_CXNS_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvPortVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvPortVer13Test.java
new file mode 100644
index 0000000..b310306
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnTlvPortVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnTlvPortVer13Test {
+    OFBsnTlvs factory;
+
+    final static byte[] BSN_TLV_PORT_SERIALIZED =
+        new byte[] { 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x5 };
+
+    @Before
+    public void setup() {
+        factory = OFBsnTlvsVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_TLV_PORT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnTlvPort bsnTlvPort = OFBsnTlvPortVer13.READER.readFrom(input);
+       assertEquals(BSN_TLV_PORT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnTlvPort.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_TLV_PORT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13L2GreTest.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13L2GreTest.java
new file mode 100644
index 0000000..686c414
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13L2GreTest.java
@@ -0,0 +1,139 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnVirtualPortCreateRequestVer13L2GreTest {
+    OFFactory factory;
+
+    final static byte[] BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x50, 0x1, 0x2, 0x3, 0x4, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0xf, 0x0, 0x1, 0x0, 0x40, 0x0, 0x0, 0x0, 0x1b, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, (byte) 0xc0, 0x0, 0x0, 0x2, (byte) 0xc0, 0x0, 0x10, 0x2, 0x1, 0x40, 0x0, 0x0, 0x0, 0x0, (byte) 0xbe, (byte) 0xef, 0x0, 0x0, 0x4, 0x0, 0x66, 0x6f, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnVirtualPortCreateRequest.Builder builder = factory.buildBsnVirtualPortCreateRequest();
+        builder.setXid(0x01020304)
+    .setVport(
+        factory.buildBsnVportL2Gre()
+            .setFlags(
+                ImmutableSet.<OFBsnVportL2GreFlags>of(
+                    OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID,
+                    OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN,
+                    OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID,
+                    OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID
+                )
+            )
+            .setPortNo(OFPort.of(1))
+            .setLoopbackPortNo(OFPort.of(2))
+            .setLocalMac(MacAddress.of("0a:0b:0c:0d:0e:0f"))
+            .setNhMac(MacAddress.of("01:02:03:04:05:06"))
+            .setSrcIp(IPv4Address.of("192.0.0.2"))
+            .setDstIp(IPv4Address.of("192.0.16.2"))
+            .setDscp((short)1)
+            .setTtl((short)64)
+            .setVpn(0xbeef)
+            .setRateLimit(0x400)
+            .setIfName("foo")
+            .build()
+    );;
+        OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnVirtualPortCreateRequest.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnVirtualPortCreateRequest.Builder builder = factory.buildBsnVirtualPortCreateRequest();
+        builder.setXid(0x01020304)
+    .setVport(
+        factory.buildBsnVportL2Gre()
+            .setFlags(
+                ImmutableSet.<OFBsnVportL2GreFlags>of(
+                    OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID,
+                    OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN,
+                    OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID,
+                    OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID
+                )
+            )
+            .setPortNo(OFPort.of(1))
+            .setLoopbackPortNo(OFPort.of(2))
+            .setLocalMac(MacAddress.of("0a:0b:0c:0d:0e:0f"))
+            .setNhMac(MacAddress.of("01:02:03:04:05:06"))
+            .setSrcIp(IPv4Address.of("192.0.0.2"))
+            .setDstIp(IPv4Address.of("192.0.16.2"))
+            .setDscp((short)1)
+            .setTtl((short)64)
+            .setVpn(0xbeef)
+            .setRateLimit(0x400)
+            .setIfName("foo")
+            .build()
+    );;
+        OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequestBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequestRead = OFBsnVirtualPortCreateRequestVer13.READER.readFrom(input);
+        assertEquals(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnVirtualPortCreateRequestBuilt, bsnVirtualPortCreateRequestRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest = OFBsnVirtualPortCreateRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnVirtualPortCreateRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13QInQTest.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13QInQTest.java
new file mode 100644
index 0000000..b36d99f
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFBsnVirtualPortCreateRequestVer13QInQTest.java
@@ -0,0 +1,111 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFBsnVirtualPortCreateRequestVer13QInQTest {
+    OFFactory factory;
+
+    final static byte[] BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x4, 0x0, 0x30, 0x1, 0x2, 0x3, 0x4, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x1, 0x0, 0x2, 0x0, 0x3, 0x0, 0x4, 0x0, 0x5, 0x66, 0x6f, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFBsnVirtualPortCreateRequest.Builder builder = factory.buildBsnVirtualPortCreateRequest();
+        builder.setXid(0x01020304)
+    .setVport(
+        factory.buildBsnVportQInQ()
+            .setPortNo(1)
+            .setIngressTpid(2)
+            .setIngressVlanId(3)
+            .setEgressTpid(4)
+            .setEgressVlanId(5)
+            .setIfName("foo")
+            .build()
+    );;
+        OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        bsnVirtualPortCreateRequest.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFBsnVirtualPortCreateRequest.Builder builder = factory.buildBsnVirtualPortCreateRequest();
+        builder.setXid(0x01020304)
+    .setVport(
+        factory.buildBsnVportQInQ()
+            .setPortNo(1)
+            .setIngressTpid(2)
+            .setIngressVlanId(3)
+            .setEgressTpid(4)
+            .setEgressVlanId(5)
+            .setIfName("foo")
+            .build()
+    );;
+        OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequestBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequestRead = OFBsnVirtualPortCreateRequestVer13.READER.readFrom(input);
+        assertEquals(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(bsnVirtualPortCreateRequestBuilt, bsnVirtualPortCreateRequestRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFBsnVirtualPortCreateRequest bsnVirtualPortCreateRequest = OFBsnVirtualPortCreateRequestVer13.READER.readFrom(input);
+       assertEquals(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       bsnVirtualPortCreateRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(BSN_VIRTUAL_PORT_CREATE_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoReplyVer13Test.java
new file mode 100644
index 0000000..f1afdb4
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoReplyVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFEchoReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] ECHO_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x3, 0x0, 0xb, 0x12, 0x34, 0x56, 0x78, 0x61, 0x62, 0x63 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ECHO_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFEchoReply echoReply = OFEchoReplyVer13.READER.readFrom(input);
+       assertEquals(ECHO_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       echoReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ECHO_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoRequestVer13Test.java
new file mode 100644
index 0000000..a546e9c
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFEchoRequestVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFEchoRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] ECHO_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x2, 0x0, 0xb, 0x12, 0x34, 0x56, 0x78, 0x61, 0x62, 0x63 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(ECHO_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFEchoRequest echoRequest = OFEchoRequestVer13.READER.readFrom(input);
+       assertEquals(ECHO_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       echoRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(ECHO_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesReplyVer13Test.java
new file mode 100644
index 0000000..89606ee
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesReplyVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFeaturesReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] FEATURES_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x6, 0x0, 0x20, 0x12, 0x34, 0x56, 0x78, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, 0x0, 0x0, 0x0, 0x40, (byte) 0xc8, 0x5, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FEATURES_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFeaturesReply featuresReply = OFFeaturesReplyVer13.READER.readFrom(input);
+       assertEquals(FEATURES_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       featuresReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FEATURES_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesRequestVer13Test.java
new file mode 100644
index 0000000..6fd5a74
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFeaturesRequestVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFeaturesRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] FEATURES_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x5, 0x0, 0x8, 0x12, 0x34, 0x56, 0x78 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FEATURES_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFeaturesRequest featuresRequest = OFFeaturesRequestVer13.READER.readFrom(input);
+       assertEquals(FEATURES_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       featuresRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FEATURES_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowAddVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowAddVer13Test.java
new file mode 100644
index 0000000..7797c1d
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowAddVer13Test.java
@@ -0,0 +1,147 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowAddVer13Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_ADD_SERIALIZED =
+        new byte[] { 0x4, 0xe, 0x0, (byte) 0x80, 0x12, 0x34, 0x56, 0x78, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, 0x3, 0x0, 0x0, 0x5, 0x0, 0xa, 0x17, 0x70, 0x0, 0x0, 0x0, 0x32, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x3f, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0xa, 0x2, (byte) 0x86, (byte) 0xdd, (byte) 0x80, 0x0, 0x14, 0x1, 0x6, (byte) 0x80, 0x0, 0x35, 0x20, 0x1c, (byte) 0xca, (byte) 0xfe, 0x1c, (byte) 0xb1, 0x10, 0x1c, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xf0, (byte) 0xff, (byte) 0xff, 0x1c, 0x2c, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x7, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFFlowAdd.Builder builder = factory.buildFlowAdd();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowAdd flowAdd = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        flowAdd.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(FLOW_ADD_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFFlowAdd.Builder builder = factory.buildFlowAdd();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowAdd flowAddBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_ADD_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFFlowAdd flowAddRead = OFFlowAddVer13.READER.readFrom(input);
+        assertEquals(FLOW_ADD_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(flowAddBuilt, flowAddRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_ADD_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowAdd flowAdd = OFFlowAddVer13.READER.readFrom(input);
+       assertEquals(FLOW_ADD_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowAdd.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_ADD_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteStrictVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteStrictVer13Test.java
new file mode 100644
index 0000000..f260e52
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteStrictVer13Test.java
@@ -0,0 +1,147 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowDeleteStrictVer13Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_DELETE_STRICT_SERIALIZED =
+        new byte[] { 0x4, 0xe, 0x0, (byte) 0x80, 0x12, 0x34, 0x56, 0x78, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, 0x3, 0x4, 0x0, 0x5, 0x0, 0xa, 0x17, 0x70, 0x0, 0x0, 0x0, 0x32, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x3f, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0xa, 0x2, (byte) 0x86, (byte) 0xdd, (byte) 0x80, 0x0, 0x14, 0x1, 0x6, (byte) 0x80, 0x0, 0x35, 0x20, 0x1c, (byte) 0xca, (byte) 0xfe, 0x1c, (byte) 0xb1, 0x10, 0x1c, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xf0, (byte) 0xff, (byte) 0xff, 0x1c, 0x2c, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x7, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFFlowDeleteStrict.Builder builder = factory.buildFlowDeleteStrict();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowDeleteStrict flowDeleteStrict = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        flowDeleteStrict.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(FLOW_DELETE_STRICT_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFFlowDeleteStrict.Builder builder = factory.buildFlowDeleteStrict();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowDeleteStrict flowDeleteStrictBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_DELETE_STRICT_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFFlowDeleteStrict flowDeleteStrictRead = OFFlowDeleteStrictVer13.READER.readFrom(input);
+        assertEquals(FLOW_DELETE_STRICT_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(flowDeleteStrictBuilt, flowDeleteStrictRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_DELETE_STRICT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowDeleteStrict flowDeleteStrict = OFFlowDeleteStrictVer13.READER.readFrom(input);
+       assertEquals(FLOW_DELETE_STRICT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowDeleteStrict.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_DELETE_STRICT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteVer13Test.java
new file mode 100644
index 0000000..84b7964
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowDeleteVer13Test.java
@@ -0,0 +1,147 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowDeleteVer13Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_DELETE_SERIALIZED =
+        new byte[] { 0x4, 0xe, 0x0, (byte) 0x80, 0x12, 0x34, 0x56, 0x78, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, 0x3, 0x3, 0x0, 0x5, 0x0, 0xa, 0x17, 0x70, 0x0, 0x0, 0x0, 0x32, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x3f, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0xa, 0x2, (byte) 0x86, (byte) 0xdd, (byte) 0x80, 0x0, 0x14, 0x1, 0x6, (byte) 0x80, 0x0, 0x35, 0x20, 0x1c, (byte) 0xca, (byte) 0xfe, 0x1c, (byte) 0xb1, 0x10, 0x1c, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xf0, (byte) 0xff, (byte) 0xff, 0x1c, 0x2c, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x7, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFFlowDelete.Builder builder = factory.buildFlowDelete();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowDelete flowDelete = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        flowDelete.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(FLOW_DELETE_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFFlowDelete.Builder builder = factory.buildFlowDelete();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowDelete flowDeleteBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_DELETE_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFFlowDelete flowDeleteRead = OFFlowDeleteVer13.READER.readFrom(input);
+        assertEquals(FLOW_DELETE_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(flowDeleteBuilt, flowDeleteRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_DELETE_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowDelete flowDelete = OFFlowDeleteVer13.READER.readFrom(input);
+       assertEquals(FLOW_DELETE_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowDelete.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_DELETE_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyStrictVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyStrictVer13Test.java
new file mode 100644
index 0000000..311b3df
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyStrictVer13Test.java
@@ -0,0 +1,147 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowModifyStrictVer13Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_MODIFY_STRICT_SERIALIZED =
+        new byte[] { 0x4, 0xe, 0x0, (byte) 0x80, 0x12, 0x34, 0x56, 0x78, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, 0x3, 0x2, 0x0, 0x5, 0x0, 0xa, 0x17, 0x70, 0x0, 0x0, 0x0, 0x32, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x3f, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0xa, 0x2, (byte) 0x86, (byte) 0xdd, (byte) 0x80, 0x0, 0x14, 0x1, 0x6, (byte) 0x80, 0x0, 0x35, 0x20, 0x1c, (byte) 0xca, (byte) 0xfe, 0x1c, (byte) 0xb1, 0x10, 0x1c, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xf0, (byte) 0xff, (byte) 0xff, 0x1c, 0x2c, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x7, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFFlowModifyStrict.Builder builder = factory.buildFlowModifyStrict();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowModifyStrict flowModifyStrict = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        flowModifyStrict.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(FLOW_MODIFY_STRICT_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFFlowModifyStrict.Builder builder = factory.buildFlowModifyStrict();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowModifyStrict flowModifyStrictBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_MODIFY_STRICT_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFFlowModifyStrict flowModifyStrictRead = OFFlowModifyStrictVer13.READER.readFrom(input);
+        assertEquals(FLOW_MODIFY_STRICT_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(flowModifyStrictBuilt, flowModifyStrictRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_MODIFY_STRICT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowModifyStrict flowModifyStrict = OFFlowModifyStrictVer13.READER.readFrom(input);
+       assertEquals(FLOW_MODIFY_STRICT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowModifyStrict.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_MODIFY_STRICT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyVer13Test.java
new file mode 100644
index 0000000..75cb4be
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowModifyVer13Test.java
@@ -0,0 +1,147 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.Set;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowModifyVer13Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_MODIFY_SERIALIZED =
+        new byte[] { 0x4, 0xe, 0x0, (byte) 0x80, 0x12, 0x34, 0x56, 0x78, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, (byte) 0xff, 0x0, 0x3, 0x1, 0x0, 0x5, 0x0, 0xa, 0x17, 0x70, 0x0, 0x0, 0x0, 0x32, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x3f, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0xa, 0x2, (byte) 0x86, (byte) 0xdd, (byte) 0x80, 0x0, 0x14, 0x1, 0x6, (byte) 0x80, 0x0, 0x35, 0x20, 0x1c, (byte) 0xca, (byte) 0xfe, 0x1c, (byte) 0xb1, 0x10, 0x1c, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xf0, (byte) 0xff, (byte) 0xff, 0x1c, 0x2c, 0x3c, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x4, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x8, 0x7, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFFlowModify.Builder builder = factory.buildFlowModify();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowModify flowModify = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        flowModify.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(FLOW_MODIFY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFFlowModify.Builder builder = factory.buildFlowModify();
+        builder.setXid(0x12345678)
+    .setCookie(U64.parseHex("FEDCBA9876543210"))
+    .setCookieMask(U64.parseHex("FF00FF00FF00FF00"))
+    .setTableId(TableId.of(3))
+    .setIdleTimeout(5)
+    .setHardTimeout(10)
+    .setPriority(6000)
+    .setBufferId(OFBufferId.of(50))
+    .setOutPort(OFPort.of(6))
+    .setOutGroup(OFGroup.of(8))
+    .setFlags(ImmutableSet.<OFFlowModFlags>of())
+    .setMatch(
+        factory.buildMatch()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ETH_TYPE, EthType.IPv6)
+            .setExact(MatchField.IP_PROTO, IpProtocol.TCP)
+            .setMasked(MatchField.IPV6_SRC,
+                       IPv6Address.of(0x1CCAFE1CB1101C00l, 0x0028000000000000l),
+                       IPv6Address.of(0xFFFFFFFFFFF0FFFFl, 0x1C2C3C0000000000l))
+        	.build()
+    )
+    .setInstructions(
+        ImmutableList.<OFInstruction>of(
+                factory.instructions().gotoTable(TableId.of(4)),
+                factory.instructions().gotoTable(TableId.of(7))
+        )
+    );;
+        OFFlowModify flowModifyBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_MODIFY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFFlowModify flowModifyRead = OFFlowModifyVer13.READER.readFrom(input);
+        assertEquals(FLOW_MODIFY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(flowModifyBuilt, flowModifyRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_MODIFY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowModify flowModify = OFFlowModifyVer13.READER.readFrom(input);
+       assertEquals(FLOW_MODIFY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowModify.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_MODIFY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedVer13Test.java
new file mode 100644
index 0000000..2f5862b
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFFlowRemovedVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFFlowRemovedVer13Test {
+    OFFactory factory;
+
+    final static byte[] FLOW_REMOVED_SERIALIZED =
+        new byte[] { 0x4, 0xb, 0x0, 0x48, 0x12, 0x34, 0x56, 0x78, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, 0x42, 0x68, 0x2, 0x14, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x3, (byte) 0xe8, 0x0, 0x5, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x1, 0x0, 0x16, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0x2a, 0x2, 0x0, 0x1, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(FLOW_REMOVED_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFFlowRemoved flowRemoved = OFFlowRemovedVer13.READER.readFrom(input);
+       assertEquals(FLOW_REMOVED_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       flowRemoved.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(FLOW_REMOVED_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigReplyVer13Test.java
new file mode 100644
index 0000000..c9f9933
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigReplyVer13Test.java
@@ -0,0 +1,100 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.EnumSet;
+import java.util.Set;
+import com.google.common.collect.Sets;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFGetConfigReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] GET_CONFIG_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x8, 0x0, 0xc, 0x12, 0x34, 0x56, 0x78, 0x0, 0x2, (byte) 0xff, (byte) 0xff };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFGetConfigReply.Builder builder = factory.buildGetConfigReply();
+        builder.setXid(0x12345678)
+    .setFlags(Sets.immutableEnumSet(OFConfigFlags.FRAG_REASM))
+    .setMissSendLen(0xffff)
+    .build();
+        OFGetConfigReply getConfigReply = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        getConfigReply.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(GET_CONFIG_REPLY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFGetConfigReply.Builder builder = factory.buildGetConfigReply();
+        builder.setXid(0x12345678)
+    .setFlags(Sets.immutableEnumSet(OFConfigFlags.FRAG_REASM))
+    .setMissSendLen(0xffff)
+    .build();
+        OFGetConfigReply getConfigReplyBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(GET_CONFIG_REPLY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFGetConfigReply getConfigReplyRead = OFGetConfigReplyVer13.READER.readFrom(input);
+        assertEquals(GET_CONFIG_REPLY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(getConfigReplyBuilt, getConfigReplyRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(GET_CONFIG_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFGetConfigReply getConfigReply = OFGetConfigReplyVer13.READER.readFrom(input);
+       assertEquals(GET_CONFIG_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       getConfigReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(GET_CONFIG_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigRequestVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigRequestVer13Test.java
new file mode 100644
index 0000000..8ad0cdd
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGetConfigRequestVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFGetConfigRequestVer13Test {
+    OFFactory factory;
+
+    final static byte[] GET_CONFIG_REQUEST_SERIALIZED =
+        new byte[] { 0x4, 0x7, 0x0, 0x8, 0x12, 0x34, 0x56, 0x78 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(GET_CONFIG_REQUEST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFGetConfigRequest getConfigRequest = OFGetConfigRequestVer13.READER.readFrom(input);
+       assertEquals(GET_CONFIG_REQUEST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       getConfigRequest.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(GET_CONFIG_REQUEST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsReplyVer13Test.java
new file mode 100644
index 0000000..e5e12e6
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupDescStatsReplyVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFGroupDescStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] GROUP_DESC_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, (byte) 0x80, 0x12, 0x34, 0x56, 0x78, 0x0, 0x7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x68, 0x3, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x30, 0x0, 0x1, 0x0, 0x0, 0x0, 0x5, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x1, 0x0, 0x0, 0x0, 0x6, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x3, 0x0, 0x0, 0x0, 0x0, 0x2 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(GROUP_DESC_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFGroupDescStatsReply groupDescStatsReply = OFGroupDescStatsReplyVer13.READER.readFrom(input);
+       assertEquals(GROUP_DESC_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       groupDescStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(GROUP_DESC_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModifyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModifyVer13Test.java
new file mode 100644
index 0000000..2e5fe81
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupModifyVer13Test.java
@@ -0,0 +1,145 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import java.util.List;
+import com.google.common.collect.ImmutableList;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFGroupModifyVer13Test {
+    OFFactory factory;
+
+    final static byte[] GROUP_MODIFY_SERIALIZED =
+        new byte[] { 0x4, 0xf, 0x0, 0x70, 0x12, 0x34, 0x56, 0x78, 0x0, 0x1, 0x3, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x30, 0x0, 0x1, 0x0, 0x0, 0x0, 0x5, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x30, 0x0, 0x1, 0x0, 0x0, 0x0, 0x6, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFGroupModify.Builder builder = factory.buildGroupModify();
+            OFActions actions = factory.actions();
+    builder
+      .setXid(0x12345678)
+      .setGroupType(OFGroupType.FF)
+      .setGroup(OFGroup.of(5))
+      .setBuckets(ImmutableList.<OFBucket>of(
+        factory.buildBucket()
+          .setWeight(1)
+          .setWatchPort(OFPort.of(5))
+          .setWatchGroup(OFGroup.ANY)
+          .setActions(ImmutableList.<OFAction>of(
+            actions.output(OFPort.of(5), 0),
+            actions.output(OFPort.of(6), 0)
+          ))
+          .build(),
+        factory.buildBucket()
+          .setWeight(1)
+          .setWatchPort(OFPort.of(6))
+          .setWatchGroup(OFGroup.ANY)
+          .setActions(ImmutableList.<OFAction>of(
+            actions.output(OFPort.of(5), 0),
+            actions.output(OFPort.of(6), 0)
+          ))
+          .build()
+         )
+      )
+      .build();;
+        OFGroupModify groupModify = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        groupModify.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(GROUP_MODIFY_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFGroupModify.Builder builder = factory.buildGroupModify();
+            OFActions actions = factory.actions();
+    builder
+      .setXid(0x12345678)
+      .setGroupType(OFGroupType.FF)
+      .setGroup(OFGroup.of(5))
+      .setBuckets(ImmutableList.<OFBucket>of(
+        factory.buildBucket()
+          .setWeight(1)
+          .setWatchPort(OFPort.of(5))
+          .setWatchGroup(OFGroup.ANY)
+          .setActions(ImmutableList.<OFAction>of(
+            actions.output(OFPort.of(5), 0),
+            actions.output(OFPort.of(6), 0)
+          ))
+          .build(),
+        factory.buildBucket()
+          .setWeight(1)
+          .setWatchPort(OFPort.of(6))
+          .setWatchGroup(OFGroup.ANY)
+          .setActions(ImmutableList.<OFAction>of(
+            actions.output(OFPort.of(5), 0),
+            actions.output(OFPort.of(6), 0)
+          ))
+          .build()
+         )
+      )
+      .build();;
+        OFGroupModify groupModifyBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(GROUP_MODIFY_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFGroupModify groupModifyRead = OFGroupModifyVer13.READER.readFrom(input);
+        assertEquals(GROUP_MODIFY_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(groupModifyBuilt, groupModifyRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(GROUP_MODIFY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFGroupModify groupModify = OFGroupModifyVer13.READER.readFrom(input);
+       assertEquals(GROUP_MODIFY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       groupModify.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(GROUP_MODIFY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsReplyVer13Test.java
new file mode 100644
index 0000000..7a71ee6
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFGroupStatsReplyVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFGroupStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] GROUP_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, (byte) 0x80, 0x12, 0x34, 0x56, 0x78, 0x0, 0x6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x48, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x14, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x14, 0x0, 0x0, 0x0, 0x64 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(GROUP_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFGroupStatsReply groupStatsReply = OFGroupStatsReplyVer13.READER.readFrom(input);
+       assertEquals(GROUP_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       groupStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(GROUP_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVersionbitmapVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVersionbitmapVer13Test.java
new file mode 100644
index 0000000..a7eab1c2
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloElemVersionbitmapVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFHelloElemVersionbitmapVer13Test {
+    OFFactory factory;
+
+    final static byte[] HELLO_ELEM_VERSIONBITMAP_SERIALIZED =
+        new byte[] { 0x0, 0x1, 0x0, 0xc, 0x1, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xab, (byte) 0xcd, (byte) 0xef };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(HELLO_ELEM_VERSIONBITMAP_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFHelloElemVersionbitmap helloElemVersionbitmap = OFHelloElemVersionbitmapVer13.READER.readFrom(input);
+       assertEquals(HELLO_ELEM_VERSIONBITMAP_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       helloElemVersionbitmap.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(HELLO_ELEM_VERSIONBITMAP_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloVer13Test.java
new file mode 100644
index 0000000..587f8d0
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFHelloVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFHelloVer13Test {
+    OFFactory factory;
+
+    final static byte[] HELLO_SERIALIZED =
+        new byte[] { 0x4, 0x0, 0x0, 0x20, 0x12, 0x34, 0x56, 0x78, 0x0, 0x1, 0x0, 0xc, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x1, 0x0, 0xc, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(HELLO_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFHello hello = OFHelloVer13.READER.readFrom(input);
+       assertEquals(HELLO_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       hello.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(HELLO_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSrcMacCheckVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSrcMacCheckVer13Test.java
new file mode 100644
index 0000000..e578baa
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionBsnDisableSrcMacCheckVer13Test.java
@@ -0,0 +1,87 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFInstructionBsnDisableSrcMacCheckVer13Test {
+    OFInstructions factory;
+
+    final static byte[] INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED =
+        new byte[] { (byte) 0xff, (byte) 0xff, 0x0, 0x10, 0x0, 0x5c, 0x16, (byte) 0xc7, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFInstructionsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFInstructionBsnDisableSrcMacCheck instructionBsnDisableSrcMacCheck = factory.bsnDisableSrcMacCheck();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        instructionBsnDisableSrcMacCheck.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFInstructionBsnDisableSrcMacCheck instructionBsnDisableSrcMacCheckBuilt = factory.bsnDisableSrcMacCheck();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFInstructionBsnDisableSrcMacCheck instructionBsnDisableSrcMacCheckRead = OFInstructionBsnDisableSrcMacCheckVer13.READER.readFrom(input);
+        assertEquals(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(instructionBsnDisableSrcMacCheckBuilt, instructionBsnDisableSrcMacCheckRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFInstructionBsnDisableSrcMacCheck instructionBsnDisableSrcMacCheck = OFInstructionBsnDisableSrcMacCheckVer13.READER.readFrom(input);
+       assertEquals(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       instructionBsnDisableSrcMacCheck.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(INSTRUCTION_BSN_DISABLE_SRC_MAC_CHECK_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionGotoTableVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionGotoTableVer13Test.java
new file mode 100644
index 0000000..60c2e6a
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionGotoTableVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFInstructionGotoTableVer13Test {
+    OFInstructions factory;
+
+    final static byte[] INSTRUCTION_GOTO_TABLE_SERIALIZED =
+        new byte[] { 0x0, 0x1, 0x0, 0x8, 0x5, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFInstructionsVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(INSTRUCTION_GOTO_TABLE_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFInstructionGotoTable instructionGotoTable = OFInstructionGotoTableVer13.READER.readFrom(input);
+       assertEquals(INSTRUCTION_GOTO_TABLE_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       instructionGotoTable.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(INSTRUCTION_GOTO_TABLE_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdGotoTableVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdGotoTableVer13Test.java
new file mode 100644
index 0000000..3e7139a
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFInstructionIdGotoTableVer13Test.java
@@ -0,0 +1,87 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFInstructionIdGotoTableVer13Test {
+    OFInstructionIds factory;
+
+    final static byte[] INSTRUCTION_ID_GOTO_TABLE_SERIALIZED =
+        new byte[] { 0x0, 0x1, 0x0, 0x4 };
+
+    @Before
+    public void setup() {
+        factory = OFInstructionIdsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFInstructionIdGotoTable instructionIdGotoTable = factory.gotoTable();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        instructionIdGotoTable.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(INSTRUCTION_ID_GOTO_TABLE_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFInstructionIdGotoTable instructionIdGotoTableBuilt = factory.gotoTable();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(INSTRUCTION_ID_GOTO_TABLE_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFInstructionIdGotoTable instructionIdGotoTableRead = OFInstructionIdGotoTableVer13.READER.readFrom(input);
+        assertEquals(INSTRUCTION_ID_GOTO_TABLE_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(instructionIdGotoTableBuilt, instructionIdGotoTableRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(INSTRUCTION_ID_GOTO_TABLE_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFInstructionIdGotoTable instructionIdGotoTable = OFInstructionIdGotoTableVer13.READER.readFrom(input);
+       assertEquals(INSTRUCTION_ID_GOTO_TABLE_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       instructionIdGotoTable.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(INSTRUCTION_ID_GOTO_TABLE_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchV3Ver13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchV3Ver13Test.java
new file mode 100644
index 0000000..8aadb17
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMatchV3Ver13Test.java
@@ -0,0 +1,101 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFMatchV3Ver13Test {
+    OFFactory factory;
+
+    final static byte[] MATCH_V3_SERIALIZED =
+        new byte[] { 0x0, 0x1, 0x0, 0x3c, (byte) 0x80, 0x0, 0x5, 0x10, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x12, 0x14, 0x12, 0x10, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x12, 0x34, 0x56, 0x78, (byte) 0x80, 0x0, 0x8, 0x6, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, (byte) 0x80, 0x0, 0x20, 0x2, 0x0, 0x35, (byte) 0x80, 0x0, 0x36, 0x10, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x0, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFMatchV3.Builder builder = factory.buildMatchV3();
+        builder
+       .setMasked(MatchField.METADATA, OFMetadata.ofRaw(0xFEDCBA9812141210l), OFMetadata.ofRaw(0xFFFFFFFF12345678l))
+       .setExact(MatchField.ETH_SRC, MacAddress.of(new byte[] {1,2,3,4,5,6}))
+       .setExact(MatchField.UDP_DST, TransportPort.of(53))
+       .setExact(MatchField.IPV6_DST, IPv6Address.of(new byte[] { 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12,
+                                                                  0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12 }));
+        OFMatchV3 matchV3 = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        matchV3.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(MATCH_V3_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFMatchV3.Builder builder = factory.buildMatchV3();
+        builder
+       .setMasked(MatchField.METADATA, OFMetadata.ofRaw(0xFEDCBA9812141210l), OFMetadata.ofRaw(0xFFFFFFFF12345678l))
+       .setExact(MatchField.ETH_SRC, MacAddress.of(new byte[] {1,2,3,4,5,6}))
+       .setExact(MatchField.UDP_DST, TransportPort.of(53))
+       .setExact(MatchField.IPV6_DST, IPv6Address.of(new byte[] { 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12,
+                                                                  0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12 }));
+        OFMatchV3 matchV3Built = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(MATCH_V3_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFMatchV3 matchV3Read = OFMatchV3Ver13.READER.readFrom(input);
+        assertEquals(MATCH_V3_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(matchV3Built, matchV3Read);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(MATCH_V3_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFMatchV3 matchV3 = OFMatchV3Ver13.READER.readFrom(input);
+       assertEquals(MATCH_V3_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       matchV3.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(MATCH_V3_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsReplyVer13Test.java
new file mode 100644
index 0000000..23cb0f3
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterConfigStatsReplyVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFMeterConfigStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] METER_CONFIG_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, 0x30, 0x12, 0x34, 0x56, 0x78, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x10, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x10, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x4, 0x5, 0x0, 0x0, 0x0 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(METER_CONFIG_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFMeterConfigStatsReply meterConfigStatsReply = OFMeterConfigStatsReplyVer13.READER.readFrom(input);
+       assertEquals(METER_CONFIG_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       meterConfigStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(METER_CONFIG_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsReplyVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsReplyVer13Test.java
new file mode 100644
index 0000000..91dfe09
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFMeterStatsReplyVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFMeterStatsReplyVer13Test {
+    OFFactory factory;
+
+    final static byte[] METER_STATS_REPLY_SERIALIZED =
+        new byte[] { 0x4, 0x13, 0x0, (byte) 0x80, 0x12, 0x34, 0x56, 0x78, 0x0, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x48, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x14, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x2, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x14, 0x0, 0x0, 0x0, 0x64 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(METER_STATS_REPLY_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFMeterStatsReply meterStatsReply = OFMeterStatsReplyVer13.READER.readFrom(input);
+       assertEquals(METER_STATS_REPLY_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       meterStatsReply.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(METER_STATS_REPLY_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedVer13Test.java
new file mode 100644
index 0000000..3b0ae82
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnGlobalVrfAllowedVer13Test.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmBsnGlobalVrfAllowedVer13Test {
+    OFOxms factory;
+
+    final static byte[] OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED =
+        new byte[] { 0x0, 0x3, 0x6, 0x1, 0x1 };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFOxmBsnGlobalVrfAllowed.Builder builder = factory.buildBsnGlobalVrfAllowed();
+        builder.setValue(OFBooleanValue.TRUE);
+        OFOxmBsnGlobalVrfAllowed oxmBsnGlobalVrfAllowed = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        oxmBsnGlobalVrfAllowed.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFOxmBsnGlobalVrfAllowed.Builder builder = factory.buildBsnGlobalVrfAllowed();
+        builder.setValue(OFBooleanValue.TRUE);
+        OFOxmBsnGlobalVrfAllowed oxmBsnGlobalVrfAllowedBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFOxmBsnGlobalVrfAllowed oxmBsnGlobalVrfAllowedRead = OFOxmBsnGlobalVrfAllowedVer13.READER.readFrom(input);
+        assertEquals(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(oxmBsnGlobalVrfAllowedBuilt, oxmBsnGlobalVrfAllowedRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmBsnGlobalVrfAllowed oxmBsnGlobalVrfAllowed = OFOxmBsnGlobalVrfAllowedVer13.READER.readFrom(input);
+       assertEquals(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmBsnGlobalVrfAllowed.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_BSN_GLOBAL_VRF_ALLOWED_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdVer13Test.java
new file mode 100644
index 0000000..b4bd1be
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnL3SrcClassIdVer13Test.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmBsnL3SrcClassIdVer13Test {
+    OFOxms factory;
+
+    final static byte[] OXM_BSN_L3_SRC_CLASS_ID_SERIALIZED =
+        new byte[] { 0x0, 0x3, 0xa, 0x4, 0x12, 0x34, 0x56, 0x78 };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFOxmBsnL3SrcClassId.Builder builder = factory.buildBsnL3SrcClassId();
+        builder.setValue(ClassId.of(0x12345678));
+        OFOxmBsnL3SrcClassId oxmBsnL3SrcClassId = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        oxmBsnL3SrcClassId.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(OXM_BSN_L3_SRC_CLASS_ID_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFOxmBsnL3SrcClassId.Builder builder = factory.buildBsnL3SrcClassId();
+        builder.setValue(ClassId.of(0x12345678));
+        OFOxmBsnL3SrcClassId oxmBsnL3SrcClassIdBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_BSN_L3_SRC_CLASS_ID_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFOxmBsnL3SrcClassId oxmBsnL3SrcClassIdRead = OFOxmBsnL3SrcClassIdVer13.READER.readFrom(input);
+        assertEquals(OXM_BSN_L3_SRC_CLASS_ID_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(oxmBsnL3SrcClassIdBuilt, oxmBsnL3SrcClassIdRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_BSN_L3_SRC_CLASS_ID_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmBsnL3SrcClassId oxmBsnL3SrcClassId = OFOxmBsnL3SrcClassIdVer13.READER.readFrom(input);
+       assertEquals(OXM_BSN_L3_SRC_CLASS_ID_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmBsnL3SrcClassId.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_BSN_L3_SRC_CLASS_ID_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdVer13Test.java
new file mode 100644
index 0000000..390b37d
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmBsnLagIdVer13Test.java
@@ -0,0 +1,91 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmBsnLagIdVer13Test {
+    OFOxms factory;
+
+    final static byte[] OXM_BSN_LAG_ID_SERIALIZED =
+        new byte[] { 0x0, 0x3, 0x2, 0x4, 0x12, 0x34, 0x56, 0x78 };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFOxmBsnLagId.Builder builder = factory.buildBsnLagId();
+        builder.setValue(LagId.of(0x12345678));
+        OFOxmBsnLagId oxmBsnLagId = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        oxmBsnLagId.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(OXM_BSN_LAG_ID_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFOxmBsnLagId.Builder builder = factory.buildBsnLagId();
+        builder.setValue(LagId.of(0x12345678));
+        OFOxmBsnLagId oxmBsnLagIdBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_BSN_LAG_ID_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFOxmBsnLagId oxmBsnLagIdRead = OFOxmBsnLagIdVer13.READER.readFrom(input);
+        assertEquals(OXM_BSN_LAG_ID_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(oxmBsnLagIdBuilt, oxmBsnLagIdRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_BSN_LAG_ID_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmBsnLagId oxmBsnLagId = OFOxmBsnLagIdVer13.READER.readFrom(input);
+       assertEquals(OXM_BSN_LAG_ID_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmBsnLagId.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_BSN_LAG_ID_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortMaskedVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortMaskedVer13Test.java
new file mode 100644
index 0000000..efd963d
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortMaskedVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmInPhyPortMaskedVer13Test {
+    OFOxms factory;
+
+    final static byte[] OXM_IN_PHY_PORT_MASKED_SERIALIZED =
+        new byte[] { (byte) 0x80, 0x0, 0x3, 0x8, 0x0, 0x0, 0x0, 0x2a, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xdd };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_IN_PHY_PORT_MASKED_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmInPhyPortMasked oxmInPhyPortMasked = OFOxmInPhyPortMaskedVer13.READER.readFrom(input);
+       assertEquals(OXM_IN_PHY_PORT_MASKED_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmInPhyPortMasked.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_IN_PHY_PORT_MASKED_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortVer13Test.java
new file mode 100644
index 0000000..06ed4ee
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmInPhyPortVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmInPhyPortVer13Test {
+    OFOxms factory;
+
+    final static byte[] OXM_IN_PHY_PORT_SERIALIZED =
+        new byte[] { (byte) 0x80, 0x0, 0x2, 0x4, 0x0, 0x0, 0x0, 0x2a };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_IN_PHY_PORT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmInPhyPort oxmInPhyPort = OFOxmInPhyPortVer13.READER.readFrom(input);
+       assertEquals(OXM_IN_PHY_PORT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmInPhyPort.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_IN_PHY_PORT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstVer13Test.java
new file mode 100644
index 0000000..eb469f6
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFOxmIpv6DstVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFOxmIpv6DstVer13Test {
+    OFOxms factory;
+
+    final static byte[] OXM_IPV6_DST_SERIALIZED =
+        new byte[] { (byte) 0x80, 0x0, 0x36, 0x10, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf };
+
+    @Before
+    public void setup() {
+        factory = OFOxmsVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(OXM_IPV6_DST_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFOxmIpv6Dst oxmIpv6Dst = OFOxmIpv6DstVer13.READER.readFrom(input);
+       assertEquals(OXM_IPV6_DST_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       oxmIpv6Dst.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(OXM_IPV6_DST_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInVer13Test.java
new file mode 100644
index 0000000..4463de8
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketInVer13Test.java
@@ -0,0 +1,117 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPacketInVer13Test {
+    OFFactory factory;
+
+    final static byte[] PACKET_IN_SERIALIZED =
+        new byte[] { 0x4, 0xa, 0x0, 0x35, 0x12, 0x34, 0x56, 0x78, 0x0, 0x0, 0x0, 0x64, 0x42, 0x68, 0x1, 0x14, (byte) 0xfe, (byte) 0xdc, (byte) 0xba, (byte) 0x98, 0x76, 0x54, 0x32, 0x10, 0x0, 0x1, 0x0, 0x16, (byte) 0x80, 0x0, 0x1, 0x8, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x5, (byte) 0x80, 0x0, 0x2a, 0x2, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x61, 0x62, 0x63 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+    @Test
+    public void testWrite() {
+        OFPacketIn.Builder builder = factory.buildPacketIn();
+        builder
+   .setXid(0x12345678)
+   .setBufferId(OFBufferId.of(100))
+   .setTotalLen(17000)
+   .setReason(OFPacketInReason.ACTION)
+   .setTableId(TableId.of(20))
+   .setCookie(U64.parseHex("FEDCBA9876543210"))
+   .setMatch(
+        factory.buildMatchV3()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ARP_OP, ArpOpcode.REQUEST)
+        	.build()
+    )
+    .setData(new byte[] { 97, 98, 99 } );;
+        OFPacketIn packetIn = builder.build();
+        ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+        packetIn.writeTo(bb);
+        byte[] written = new byte[bb.readableBytes()];
+        bb.readBytes(written);
+
+        assertThat(written, CoreMatchers.equalTo(PACKET_IN_SERIALIZED));
+    }
+
+    @Test
+    public void testRead() throws Exception {
+        OFPacketIn.Builder builder = factory.buildPacketIn();
+        builder
+   .setXid(0x12345678)
+   .setBufferId(OFBufferId.of(100))
+   .setTotalLen(17000)
+   .setReason(OFPacketInReason.ACTION)
+   .setTableId(TableId.of(20))
+   .setCookie(U64.parseHex("FEDCBA9876543210"))
+   .setMatch(
+        factory.buildMatchV3()
+            .setMasked(MatchField.IN_PORT, OFPort.of(4), OFPort.of(5))
+            .setExact(MatchField.ARP_OP, ArpOpcode.REQUEST)
+        	.build()
+    )
+    .setData(new byte[] { 97, 98, 99 } );;
+        OFPacketIn packetInBuilt = builder.build();
+
+        ChannelBuffer input = ChannelBuffers.copiedBuffer(PACKET_IN_SERIALIZED);
+
+        // FIXME should invoke the overall reader once implemented
+        OFPacketIn packetInRead = OFPacketInVer13.READER.readFrom(input);
+        assertEquals(PACKET_IN_SERIALIZED.length, input.readerIndex());
+
+        assertEquals(packetInBuilt, packetInRead);
+   }
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PACKET_IN_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPacketIn packetIn = OFPacketInVer13.READER.readFrom(input);
+       assertEquals(PACKET_IN_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       packetIn.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PACKET_IN_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketOutVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketOutVer13Test.java
new file mode 100644
index 0000000..faef63f
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPacketOutVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPacketOutVer13Test {
+    OFFactory factory;
+
+    final static byte[] PACKET_OUT_SERIALIZED =
+        new byte[] { 0x4, 0xd, 0x0, 0x33, 0x12, 0x34, 0x56, 0x78, 0x0, 0x0, 0x0, 0x64, 0x0, 0x0, 0x0, 0x4, 0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x2, (byte) 0xff, (byte) 0xff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x18, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, 0x61, 0x62, 0x63 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PACKET_OUT_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPacketOut packetOut = OFPacketOutVer13.READER.readFrom(input);
+       assertEquals(PACKET_OUT_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       packetOut.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PACKET_OUT_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatusVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatusVer13Test.java
new file mode 100644
index 0000000..b37030b
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFPortStatusVer13Test.java
@@ -0,0 +1,65 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFPortStatusVer13Test {
+    OFFactory factory;
+
+    final static byte[] PORT_STATUS_SERIALIZED =
+        new byte[] { 0x4, 0xc, 0x0, 0x50, 0x12, 0x34, 0x56, 0x78, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x0, 0x0, 0x66, 0x6f, 0x6f, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x14 };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(PORT_STATUS_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFPortStatus portStatus = OFPortStatusVer13.READER.readFrom(input);
+       assertEquals(PORT_STATUS_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       portStatus.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(PORT_STATUS_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFSetConfigVer13Test.java b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFSetConfigVer13Test.java
new file mode 100644
index 0000000..aeeb935
--- /dev/null
+++ b/of/lib/gen-src/test/java/org/projectfloodlight/openflow/protocol/ver13/OFSetConfigVer13Test.java
@@ -0,0 +1,66 @@
+// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
+// Copyright (c) 2011, 2012 Open Networking Foundation
+// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
+// This library was generated by the LoxiGen Compiler.
+// See the file LICENSE.txt which should have been included in the source distribution
+
+// Automatically generated by LOXI from template unit_test.java
+// Do not modify
+
+package org.projectfloodlight.openflow.protocol.ver13;
+
+import org.projectfloodlight.openflow.protocol.*;
+import org.projectfloodlight.openflow.protocol.action.*;
+import org.projectfloodlight.openflow.protocol.actionid.*;
+import org.projectfloodlight.openflow.protocol.bsntlv.*;
+import org.projectfloodlight.openflow.protocol.errormsg.*;
+import org.projectfloodlight.openflow.protocol.meterband.*;
+import org.projectfloodlight.openflow.protocol.instruction.*;
+import org.projectfloodlight.openflow.protocol.instructionid.*;
+import org.projectfloodlight.openflow.protocol.match.*;
+import org.projectfloodlight.openflow.protocol.oxm.*;
+import org.projectfloodlight.openflow.protocol.queueprop.*;
+import org.projectfloodlight.openflow.types.*;
+import org.projectfloodlight.openflow.util.*;
+import org.projectfloodlight.openflow.exceptions.*;
+import static org.junit.Assert.*;
+import java.util.Set;
+import org.junit.Test;
+import org.junit.Before;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.hamcrest.CoreMatchers;
+
+
+
+public class OFSetConfigVer13Test {
+    OFFactory factory;
+
+    final static byte[] SET_CONFIG_SERIALIZED =
+        new byte[] { 0x4, 0x9, 0x0, 0xc, 0x12, 0x34, 0x56, 0x78, 0x0, 0x2, (byte) 0xff, (byte) 0xff };
+
+    @Before
+    public void setup() {
+        factory = OFFactoryVer13.INSTANCE;
+    }
+
+   // FIXME: No java stanza in test_data for this class. Add for more comprehensive unit testing
+
+   @Test
+   public void testReadWrite() throws Exception {
+       ChannelBuffer input = ChannelBuffers.copiedBuffer(SET_CONFIG_SERIALIZED);
+
+       // FIXME should invoke the overall reader once implemented
+       OFSetConfig setConfig = OFSetConfigVer13.READER.readFrom(input);
+       assertEquals(SET_CONFIG_SERIALIZED.length, input.readerIndex());
+
+       // write message again
+       ChannelBuffer bb = ChannelBuffers.dynamicBuffer();
+       setConfig.writeTo(bb);
+       byte[] written = new byte[bb.readableBytes()];
+       bb.readBytes(written);
+
+       assertThat(written, CoreMatchers.equalTo(SET_CONFIG_SERIALIZED));
+   }
+
+}
diff --git a/of/lib/pom.xml b/of/lib/pom.xml
index 148bc69..bc7563a 100644
--- a/of/lib/pom.xml
+++ b/of/lib/pom.xml
@@ -10,7 +10,7 @@
 
     <groupId>org.projectfloodlight</groupId>
     <artifactId>openflowj</artifactId>
-    <version>0.3.6-SNAPSHOT</version>
+    <version>0.3.8-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>OpenFlowJ-Loxi</name>
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java b/of/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
index f103230..78e6075 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchField.java
@@ -232,6 +232,9 @@
     public final static MatchField<U16> BSN_TCP_FLAGS =
             new MatchField<U16>("bsn_tcp_flags", MatchFields.BSN_TCP_FLAGS);
 
+    public final static MatchField<ClassId> BSN_VLAN_XLATE_PORT_GROUP_ID =
+            new MatchField<ClassId>("bsn_vlan_xlate_port_group_id", MatchFields.BSN_VLAN_XLATE_PORT_GROUP_ID);
+
     public String getName() {
         return name;
     }
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java b/of/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java
index 354a528..863634e 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/protocol/match/MatchFields.java
@@ -56,4 +56,5 @@
     BSN_UDF6,
     BSN_UDF7,
     BSN_TCP_FLAGS,
+    BSN_VLAN_XLATE_PORT_GROUP_ID,
 }
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/HashValue.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/HashValue.java
index 1dd55d5..3030e3e 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/HashValue.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/HashValue.java
@@ -17,6 +17,23 @@
      */
     int prefixBits(int numBits);
 
+    /** perform an arithmetic addition of this value and other. Wraps around on
+     * overflow of the defined word size.
+     *
+     * @param other
+     * @return this + other
+     */
+    H add(H other);
+
+    /**
+     * arithmetically substract the given 'other' value from this value.
+     * around on overflow.
+     *
+     * @param other
+     * @return this - other
+     */
+    H subtract(H other);
+
     /** @return the bitwise inverse of this value */
     H inverse();
 
@@ -29,26 +46,57 @@
     /** xor this value with another value value of the same type */
     H xor(H other);
 
-    /** calculate a combined hash value of this hash value (the <b>Key</b>) and the hash value
-     *  specified as a parameter (the <b>Value</b>).
-     *  <p>
-     *  The value is constructed as follows:
-     *  <ul>
-     *   <li>the first keyBits bits are taken only from the Key
-     *   <li>the other bits are taken from key xor value.
-     *  </ul>
-     *  The overall result looks like this:
-     *  <pre>
-     *  MSB                      LSB
-     *   +---------+--------------+
-     *   | key     | key ^ value  |
-     *   +---------+--------------+
-     *   |-keyBits-|
-     *  </pre>
+    /** create and return a builder */
+    Builder<H> builder();
+
+    /** a mutator for HashValues. Allows perfomring a series of
+     *  operations on a hashv value without the associated cost of object
+     *  reallocation.
      *
-     * @param value - hash value to be compared with this value (the key)
-     * @param keyBits number of prefix bits that are just taken from key
-     * @return the combined value.
+     * @author Andreas Wundsam <andreas.wundsam@bigswitch.com>
+     *
+     * @param <H> - the hashvalue
      */
-    H combineWithValue(H value, int keyBits);
+    public interface Builder<H> {
+        /** perform an arithmetic addition of this value and other. Wraps around on
+         * overflow of the defined word size.
+         *
+         * @param other
+         * @return this mutator
+         */
+        Builder<H> add(H other);
+
+        /**
+         * arithmetically substract the given 'other' value from the value stored in this mutator.
+         * around on overflow.
+         *
+         * @param other
+         * @return this mutator
+         */
+        Builder<H> subtract(H other);
+
+        /** bitwise invert the value stored in this mutator
+         *
+         * @return this mutator
+         */
+        Builder<H> invert();
+
+        /** or the value stored in this mutator with another value value of the same type
+        * @return this mutator
+        */
+        Builder<H> or(H other);
+
+        /** and the value stored in this mutator with another value value of the same type
+        * @return this mutator
+        */
+        Builder<H> and(H other);
+
+        /** xor the value stored in this mutator with another value value of the same type
+        * @return this mutator
+        */
+        Builder<H> xor(H other);
+
+        /** @return the hash value */
+        public H build();
+    }
 }
\ No newline at end of file
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
index 5e4e818..cee9ad1 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPAddress.java
@@ -10,6 +10,11 @@
 
 public abstract class IPAddress<F extends IPAddress<F>> implements OFValueType<F> {
 
+    /**
+     * Returns the Internet Protocol (IP) version of this object
+     *
+     * @return  the Internet Protocol (IP) version of this object
+     */
     public abstract IPVersion getIpVersion();
 
     /**
@@ -55,6 +60,52 @@
      */
     public abstract F not();
 
+    /**
+     * Returns an {@code IPAddressWithMask<F>} object that represents this
+     * IP address masked by the given IP address mask.
+     *
+     * @param mask  the {@code F} object that represents the mask
+     * @return      an {@code IPAddressWithMask<F>} object that represents this
+     *              IP address masked by the given mask
+     * @throws NullPointerException  if the given mask was {@code null}
+     */
+    @Nonnull
+    public abstract IPAddressWithMask<F> withMask(@Nonnull final F mask);
+
+    /**
+     * Returns an {@code IPAddressWithMask<F>} object that represents this
+     * IP address masked by the CIDR subnet mask of the given prefix length.
+     *
+     * @param cidrMaskLength  the prefix length of the CIDR subnet mask
+     *                        (i.e. the number of leading one-bits),
+     *                        where <code>
+     *                        0 <= cidrMaskLength <= (F.getLength() * 8)
+     *                        </code>
+     * @return                an {@code IPAddressWithMask<F>} object that
+     *                        represents this IP address masked by the CIDR
+     *                        subnet mask of the given prefix length
+     * @throws IllegalArgumentException  if the given prefix length was invalid
+     * @see #ofCidrMaskLength(int)
+     */
+    @Nonnull
+    public abstract IPAddressWithMask<F> withMaskOfLength(
+            final int cidrMaskLength);
+
+    /**
+     * Returns the raw IP address of this {@code IPAddress} object. The result
+     * is in network byte order: the highest order byte of the address is in
+     * {@code getBytes()[0]}.
+     * <p>
+     * Similar to {@link InetAddress#getAddress()}
+     *
+     * @return  the raw IP address of this object
+     * @see InetAddress#getAddress()
+     */
+    public abstract byte[] getBytes();
+
+    @Override
+    public abstract String toString();
+
     @Override
     public abstract boolean equals(Object other);
 
@@ -88,14 +139,26 @@
      * @throws NullPointerException if address is null
      */
     @Nonnull
-    public static IPAddress<?> fromInetAddress(@Nonnull InetAddress address) {
+    public static IPAddress<?> of(@Nonnull InetAddress address) {
         Preconditions.checkNotNull(address, "address must not be null");
-        byte [] bytes = address.getAddress();
         if(address instanceof Inet4Address)
-            return IPv4Address.of(bytes);
+            return IPv4Address.of((Inet4Address) address);
         else if (address instanceof Inet6Address)
-            return IPv6Address.of(bytes);
+            return IPv6Address.of((Inet6Address) address);
         else
             return IPAddress.of(address.getHostAddress());
     }
+
+    /**
+     * Factory function for InetAddress values.
+     * @param address the InetAddress you wish to parse into an IPAddress object.
+     * @return the IPAddress object.
+     * @throws NullPointerException if address is null
+     * @deprecated  replaced by {@link #of(InetAddress)}
+     */
+    @Deprecated
+    @Nonnull
+    public static IPAddress<?> fromInetAddress(@Nonnull InetAddress address) {
+        return of(address);
+    }
 }
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
index ba7eb93..7cd8099 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPAddressWithMask.java
@@ -1,5 +1,7 @@
 package org.projectfloodlight.openflow.types;
 
+import com.google.common.base.Preconditions;
+
 
 public abstract class IPAddressWithMask<F extends IPAddress<F>> extends Masked<F> {
 
@@ -8,6 +10,8 @@
     }
 
     public abstract IPVersion getIpVersion();
+    
+    public abstract boolean contains(IPAddress<?> ip);
 
     public F getSubnetBroadcastAddress() {
         if (!mask.isCidrMask()) {
@@ -22,9 +26,8 @@
     }
 
     public static IPAddressWithMask<?> of(String ip) {
-        if (ip == null) {
-            throw new NullPointerException("String ip must not be null");
-        }
+        Preconditions.checkNotNull(ip, "string ip must not be null");
+
         if (ip.indexOf('.') != -1)
             return IPv4AddressWithMask.of(ip);
         else if (ip.indexOf(':') != -1)
@@ -49,5 +52,4 @@
 
         return res.toString();
     }
-
 }
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
index 865fb79..3a1b15e 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv4Address.java
@@ -1,11 +1,14 @@
 package org.projectfloodlight.openflow.types;
 
+import java.net.Inet4Address;
+import java.net.InetAddress;
 import java.util.Arrays;
 
 import javax.annotation.Nonnull;
 
 import org.jboss.netty.buffer.ChannelBuffer;
 
+import com.google.common.base.Preconditions;
 import com.google.common.hash.PrimitiveSink;
 import com.google.common.primitives.UnsignedInts;
 
@@ -78,19 +81,17 @@
 
     @Override
     public IPv4Address and(IPv4Address other) {
-        if (other == null) {
-            throw new NullPointerException("Other IP Address must not be null");
-        }
-        IPv4Address otherIp = (IPv4Address) other;
+        Preconditions.checkNotNull(other, "other must not be null");
+
+        IPv4Address otherIp = other;
         return IPv4Address.of(rawValue & otherIp.rawValue);
     }
 
     @Override
     public IPv4Address or(IPv4Address other) {
-        if (other == null) {
-            throw new NullPointerException("Other IP Address must not be null");
-        }
-        IPv4Address otherIp = (IPv4Address) other;
+        Preconditions.checkNotNull(other, "other must not be null");
+
+        IPv4Address otherIp = other;
         return IPv4Address.of(rawValue | otherIp.rawValue);
     }
 
@@ -99,13 +100,30 @@
         return IPv4Address.of(~rawValue);
     }
 
-    public static IPv4Address of(final byte[] address) {
-        if (address == null) {
-            throw new NullPointerException("Address must not be null");
-        }
+    /**
+     * Returns an {@code IPv4Address} object that represents the given
+     * IP address. The argument is in network byte order: the highest
+     * order byte of the address is in {@code address[0]}.
+     * <p>
+     * The address byte array must be 4 bytes long (32 bits long).
+     * <p>
+     * Similar to {@link InetAddress#getByAddress(byte[])}.
+     *
+     * @param address  the raw IP address in network byte order
+     * @return         an {@code IPv4Address} object that represents the given
+     *                 raw IP address
+     * @throws NullPointerException      if the given address was {@code null}
+     * @throws IllegalArgumentException  if the given address was of an invalid
+     *                                   byte array length
+     * @see InetAddress#getByAddress(byte[])
+     */
+    @Nonnull
+    public static IPv4Address of(@Nonnull final byte[] address) {
+        Preconditions.checkNotNull(address, "address must not be null");
+
         if (address.length != LENGTH) {
             throw new IllegalArgumentException(
-                    "Invalid byte array length for IPv4Address address: " + address.length);
+                    "Invalid byte array length for IPv4 address: " + address.length);
         }
 
         int raw =
@@ -114,30 +132,37 @@
         return IPv4Address.of(raw);
     }
 
-    /** construct an IPv4Address from a 32-bit integer value.
+    /**
+     * Returns an {@code IPv4Address} object that represents the given
+     * IP address.
      *
-     * @param raw the IPAdress represented as a 32-bit integer
-     * @return the constructed IPv4Address
+     * @param raw  the raw IP address represented as a 32-bit integer
+     * @return     an {@code IPv4Address} object that represents the given
+     *             raw IP address
      */
+    @Nonnull
     public static IPv4Address of(final int raw) {
         if(raw == NONE_VAL)
             return NONE;
         return new IPv4Address(raw);
     }
 
-    /** parse an IPv4Address from the canonical dotted-quad representation
-     * (1.2.3.4).
+    /**
+     * Returns an {@code IPv4Address} object that represents the given
+     * IP address. The argument is in the canonical quad-dotted notation.
+     * For example, {@code 1.2.3.4}.
      *
-     * @param string an IPv4 address in dotted-quad representation
-     * @return the parsed IPv4 address
-     * @throws NullPointerException if string is null
-     * @throws IllegalArgumentException if string is not a valid IPv4Address
+     * @param string  the IP address in the canonical quad-dotted notation
+     * @return        an {@code IPv4Address} object that represents the given
+     *                IP address
+     * @throws NullPointerException      if the given string was {@code null}
+     * @throws IllegalArgumentException  if the given string was not a valid
+     *                                   IPv4 address
      */
     @Nonnull
     public static IPv4Address of(@Nonnull final String string) throws IllegalArgumentException {
-        if (string == null) {
-            throw new NullPointerException("String must not be null");
-        }
+        Preconditions.checkNotNull(string, "string must not be null");
+
         int start = 0;
         int shift = 24;
 
@@ -161,12 +186,90 @@
         return IPv4Address.of(raw);
     }
 
+    /**
+     * Returns an {@code IPv4Address} object that represents the given
+     * IP address. The argument is given as an {@code Inet4Address} object.
+     *
+     * @param address  the IP address as an {@code Inet4Address} object
+     * @return         an {@code IPv4Address} object that represents the
+     *                 given IP address
+     * @throws NullPointerException  if the given {@code Inet4Address} was
+     *                               {@code null}
+     */
+    @Nonnull
+    public static IPv4Address of(@Nonnull final Inet4Address address) {
+        Preconditions.checkNotNull(address, "address must not be null");
+        return IPv4Address.of(address.getAddress());
+    }
+
+    /**
+     * Returns an {@code IPv4Address} object that represents the
+     * CIDR subnet mask of the given prefix length.
+     *
+     * @param cidrMaskLength  the prefix length of the CIDR subnet mask
+     *                        (i.e. the number of leading one-bits),
+     *                        where {@code 0 <= cidrMaskLength <= 32}
+     * @return                an {@code IPv4Address} object that represents the
+     *                        CIDR subnet mask of the given prefix length
+     * @throws IllegalArgumentException  if the given prefix length was invalid
+     */
+    @Nonnull
+    public static IPv4Address ofCidrMaskLength(final int cidrMaskLength) {
+        Preconditions.checkArgument(
+                cidrMaskLength >= 0 && cidrMaskLength <= 32,
+                "Invalid IPv4 CIDR mask length: %s", cidrMaskLength);
+
+        if (cidrMaskLength == 32) {
+            return IPv4Address.NO_MASK;
+        } else if (cidrMaskLength == 0) {
+            return IPv4Address.FULL_MASK;
+        } else {
+            int mask = (-1) << (32 - cidrMaskLength);
+            return IPv4Address.of(mask);
+        }
+    }
+
+    /**
+     * Returns an {@code IPv4AddressWithMask} object that represents this
+     * IP address masked by the given IP address mask.
+     *
+     * @param mask  the {@code IPv4Address} object that represents the mask
+     * @return      an {@code IPv4AddressWithMask} object that represents this
+     *              IP address masked by the given mask
+     * @throws NullPointerException  if the given mask was {@code null}
+     */
+    @Nonnull
+    @Override
+    public IPv4AddressWithMask withMask(@Nonnull final IPv4Address mask) {
+        return IPv4AddressWithMask.of(this, mask);
+    }
+
+    /**
+     * Returns an {@code IPv4AddressWithMask} object that represents this
+     * IP address masked by the CIDR subnet mask of the given prefix length.
+     *
+     * @param cidrMaskLength  the prefix length of the CIDR subnet mask
+     *                        (i.e. the number of leading one-bits),
+     *                        where {@code 0 <= cidrMaskLength <= 32}
+     * @return                an {@code IPv4AddressWithMask} object that
+     *                        represents this IP address masked by the CIDR
+     *                        subnet mask of the given prefix length
+     * @throws IllegalArgumentException  if the given prefix length was invalid
+     * @see #ofCidrMaskLength(int)
+     */
+    @Nonnull
+    @Override
+    public IPv4AddressWithMask withMaskOfLength(final int cidrMaskLength) {
+        return this.withMask(IPv4Address.ofCidrMaskLength(cidrMaskLength));
+    }
+
     public int getInt() {
         return rawValue;
     }
 
     private volatile byte[] bytesCache = null;
 
+    @Override
     public byte[] getBytes() {
         if (bytesCache == null) {
             synchronized (this) {
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
index 9b60c6a..b6dc1b9 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv4AddressWithMask.java
@@ -1,5 +1,9 @@
 package org.projectfloodlight.openflow.types;
 
+import javax.annotation.Nonnull;
+
+import com.google.common.base.Preconditions;
+
 
 public class IPv4AddressWithMask extends IPAddressWithMask<IPv4Address> {
     public final static IPv4AddressWithMask NONE = of(IPv4Address.NONE, IPv4Address.NONE);
@@ -17,27 +21,77 @@
         return IPVersion.IPv4;
     }
 
-    public static IPv4AddressWithMask of(int rawValue, int rawMask) {
+    /**
+     * Returns an {@code IPv4AddressWithMask} object that represents the given
+     * raw IP address masked by the given raw IP address mask.
+     *
+     * @param rawValue  the raw IP address to be masked
+     * @param rawMask   the raw IP address mask
+     * @return          an {@code IPv4AddressWithMask} object that represents
+     *                  the given raw IP address masked by the given raw IP
+     *                  address mask
+     * @deprecated      replaced by {@link IPv4Address#of(int)} and
+     *                  {@link IPv4Address#withMask(IPv4Address), e.g. <code>
+     *                  IPv4Address.of(int).withMask(IPv4Address.of(int))
+     *                  </code>
+     */
+    @Nonnull
+    @Deprecated
+    public static IPv4AddressWithMask of(final int rawValue, final int rawMask) {
         return new IPv4AddressWithMask(rawValue, rawMask);
     }
 
-    public static IPv4AddressWithMask of(IPv4Address value, IPv4Address mask) {
-        if (value == null) {
-            throw new NullPointerException("Value must not be null");
-        }
-        if (mask == null) {
-            throw new NullPointerException("Mask must not be null");
-        }
+    /**
+     * Returns an {@code IPv4AddressWithMask} object that represents the given
+     * IP address masked by the given IP address mask. Both arguments are given
+     * as {@code IPv4Address} objects.
+     *
+     * @param value  the IP address to be masked
+     * @param mask   the IP address mask
+     * @return       an {@code IPv4AddressWithMask} object that represents
+     *               the given IP address masked by the given IP address mask
+     * @throws NullPointerException  if any of the given {@code IPv4Address}
+     *                               objects were {@code null}
+     */
+    @Nonnull
+    public static IPv4AddressWithMask of(
+            @Nonnull final IPv4Address value,
+            @Nonnull final IPv4Address mask) {
+        Preconditions.checkNotNull(value, "value must not be null");
+        Preconditions.checkNotNull(mask, "mask must not be null");
+
         return new IPv4AddressWithMask(value, mask);
     }
 
-    public static IPv4AddressWithMask of(final String string) {
-        if (string == null) {
-            throw new NullPointerException("String must not be null");
-        }
+    /**
+     * Returns an {@code IPv4AddressWithMask} object that corresponds to
+     * the given string in CIDR notation or other acceptable notations.
+     * <p>
+     * The following notations are accepted.
+     * <table><tr>
+     * <th>Notation</th><th>Example</th><th>Notes</th>
+     * </tr><tr>
+     * <td>IPv4 address only</td><td>{@code 1.2.3.4}</td><td>The subnet mask of
+     * prefix length 32 (i.e. {@code 255.255.255.255}) is assumed.</td>
+     * </tr><tr>
+     * <td>IPv4 address/mask</td><td>{@code 1.2.3.4/255.255.255.0}</td>
+     * </tr><tr>
+     * <td>CIDR notation</td><td>{@code 1.2.3.4/24}</td>
+     * </tr></table>
+     *
+     * @param string  the string in acceptable notations
+     * @return        an {@code IPv4AddressWithMask} object that corresponds to
+     *                the given string in acceptable notations
+     * @throws NullPointerException      if the given string was {@code null}
+     * @throws IllegalArgumentException  if the given string was malformed
+     */
+    @Nonnull
+    public static IPv4AddressWithMask of(@Nonnull final String string) {
+        Preconditions.checkNotNull(string, "string must not be null");
+
         int slashPos;
         String ip = string;
-        int maskBits = 32;
+        int cidrMaskLength = 32;
         IPv4Address maskAddress = null;
 
         // Read mask suffix
@@ -52,14 +106,11 @@
                     maskAddress = IPv4Address.of(suffix);
                 } else {
                     // CIDR Suffix
-                    maskBits = Integer.parseInt(suffix);
+                    cidrMaskLength = Integer.parseInt(suffix);
                 }
             } catch (NumberFormatException e) {
                 throw new IllegalArgumentException("IP Address not well formed: " + string);
             }
-            if (maskBits < 0 || maskBits > 32) {
-                throw new IllegalArgumentException("IP Address not well formed: " + string);
-            }
         }
 
         // Read IP
@@ -68,17 +119,21 @@
         if (maskAddress != null) {
             // Full address mask
             return IPv4AddressWithMask.of(ipv4, maskAddress);
-        } else if (maskBits == 32) {
-            // No mask
-            return IPv4AddressWithMask.of(ipv4, IPv4Address.NO_MASK);
-        } else if (maskBits == 0) {
-            // No mask
-            return IPv4AddressWithMask.of(ipv4, IPv4Address.FULL_MASK);
         } else {
-            // With mask
-            int mask = (-1) << (32 - maskBits);
-            return IPv4AddressWithMask.of(ipv4, IPv4Address.of(mask));
+            return IPv4AddressWithMask.of(
+                    ipv4, IPv4Address.ofCidrMaskLength(cidrMaskLength));
         }
     }
 
+    @Override
+    public boolean contains(IPAddress<?> ip) {
+        Preconditions.checkNotNull(ip, "ip must not be null");
+
+        if(ip.getIpVersion() == IPVersion.IPv4) {
+            IPv4Address ipv4 = (IPv4Address) ip;
+            return this.matches(ipv4);
+        }
+
+        return false;
+    }
 }
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
index 83fb31a..471d0fb 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6Address.java
@@ -1,5 +1,7 @@
 package org.projectfloodlight.openflow.types;
 
+import java.net.Inet6Address;
+import java.net.InetAddress;
 import java.util.Arrays;
 import java.util.regex.Pattern;
 
@@ -8,6 +10,7 @@
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.projectfloodlight.openflow.exceptions.OFParseError;
 
+import com.google.common.base.Preconditions;
 import com.google.common.hash.PrimitiveSink;
 import com.google.common.primitives.Longs;
 
@@ -102,19 +105,17 @@
 
     @Override
     public IPv6Address and(IPv6Address other) {
-        if (other == null) {
-            throw new NullPointerException("Other IP Address must not be null");
-        }
-        IPv6Address otherIp = (IPv6Address) other;
+        Preconditions.checkNotNull(other, "other must not be null");
+
+        IPv6Address otherIp = other;
         return IPv6Address.of((raw1 & otherIp.raw1), (raw2 & otherIp.raw2));
     }
 
     @Override
     public IPv6Address or(IPv6Address other) {
-        if (other == null) {
-            throw new NullPointerException("Other IP Address must not be null");
-        }
-        IPv6Address otherIp = (IPv6Address) other;
+        Preconditions.checkNotNull(other, "other must not be null");
+
+        IPv6Address otherIp = other;
         return IPv6Address.of((raw1 | otherIp.raw1), (raw2 | otherIp.raw2));
     }
 
@@ -123,10 +124,27 @@
         return IPv6Address.of(~raw1, ~raw2);
     }
 
-    public static IPv6Address of(final byte[] address) {
-        if (address == null) {
-            throw new NullPointerException("Address must not be null");
-        }
+    /**
+     * Returns an {@code IPv6Address} object that represents the given
+     * IP address. The argument is in network byte order: the highest
+     * order byte of the address is in {@code address[0]}.
+     * <p>
+     * The address byte array must be 16 bytes long (128 bits long).
+     * <p>
+     * Similar to {@link InetAddress#getByAddress(byte[])}.
+     *
+     * @param address  the raw IP address in network byte order
+     * @return         an {@code IPv6Address} object that represents the given
+     *                 raw IP address
+     * @throws NullPointerException      if the given address was {@code null}
+     * @throws IllegalArgumentException  if the given address was of an invalid
+     *                                   byte array length
+     * @see InetAddress#getByAddress(byte[])
+     */
+    @Nonnull
+    public static IPv6Address of(@Nonnull final byte[] address) {
+        Preconditions.checkNotNull(address, "address must not be null");
+
         if (address.length != LENGTH) {
             throw new IllegalArgumentException(
                     "Invalid byte array length for IPv6 address: " + address.length);
@@ -171,25 +189,30 @@
 
     private final static Pattern colonPattern = Pattern.compile(":");
 
-    /** parse an IPv6Address from its conventional string representation.
-     *  <p>
-     *  Expects up to 8 groups of 16-bit hex words seperated by colons
-     *  (e.g., 2001:db8:85a3:8d3:1319:8a2e:370:7348).
-     *  <p>
-     *  Supports zero compression (e.g., 2001:db8::7348).
-     *  Does <b>not</b> currently support embedding a dotted-quad IPv4 address
-     *  into the IPv6 address (e.g., 2001:db8::192.168.0.1).
+    /**
+     * Returns an {@code IPv6Address} object that represents the given
+     * IP address. The argument is in the conventional string representation
+     * of IPv6 addresses.
+     * <p>
+     * Expects up to 8 groups of 16-bit hex words seperated by colons
+     * (e.g., 2001:db8:85a3:8d3:1319:8a2e:370:7348).
+     * <p>
+     * Supports zero compression (e.g., 2001:db8::7348).
+     * Does <b>not</b> currently support embedding a dotted-quad IPv4 address
+     * into the IPv6 address (e.g., 2001:db8::192.168.0.1).
      *
-     * @param string a string representation of an IPv6 address
-     * @return the parsed IPv6 address
-     * @throws NullPointerException if string is null
-     * @throws IllegalArgumentException if string is not a valid IPv6Address
+     * @param string  the IP address in the conventional string representation
+     *                of IPv6 addresses
+     * @return        an {@code IPv6Address} object that represents the given
+     *                IP address
+     * @throws NullPointerException      if the given string was {@code null}
+     * @throws IllegalArgumentException  if the given string was not a valid
+     *                                   IPv6 address
      */
     @Nonnull
     public static IPv6Address of(@Nonnull final String string) throws IllegalArgumentException {
-        if (string == null) {
-            throw new NullPointerException("String must not be null");
-        }
+        Preconditions.checkNotNull(string, "string must not be null");
+
         IPv6Builder builder = new IPv6Builder();
         String[] parts = colonPattern.split(string, -1);
 
@@ -242,19 +265,104 @@
         return builder.getIPv6();
     }
 
-    /** construct an IPv6 adress from two 64 bit integers representing the first and
-     *  second 8-byte blocks of the address.
+    /**
+     * Returns an {@code IPv6Address} object that represents the given
+     * IP address. The arguments are the two 64-bit integers representing
+     * the first (higher-order) and second (lower-order) 64-bit blocks
+     * of the IP address.
      *
-     * @param raw1 - the first 8 byte block of the address
-     * @param raw2 - the second 8 byte block of the address
-     * @return the constructed IPv6Address
+     * @param raw1  the first (higher-order) 64-bit block of the IP address
+     * @param raw2  the second (lower-order) 64-bit block of the IP address
+     * @return      an {@code IPv6Address} object that represents the given
+     *              raw IP address
      */
+    @Nonnull
     public static IPv6Address of(final long raw1, final long raw2) {
         if(raw1==NONE_VAL1 && raw2 == NONE_VAL2)
             return NONE;
         return new IPv6Address(raw1, raw2);
     }
 
+    /**
+     * Returns an {@code IPv6Address} object that represents the given
+     * IP address. The argument is given as an {@code Inet6Address} object.
+     *
+     * @param address  the IP address as an {@code Inet6Address} object
+     * @return         an {@code IPv6Address} object that represents the
+     *                 given IP address
+     * @throws NullPointerException  if the given {@code Inet6Address} was
+     *                               {@code null}
+     */
+    @Nonnull
+    public static IPv6Address of(@Nonnull final Inet6Address address) {
+        Preconditions.checkNotNull(address, "address must not be null");
+        return IPv6Address.of(address.getAddress());
+    }
+
+    /**
+     * Returns an {@code IPv6Address} object that represents the
+     * CIDR subnet mask of the given prefix length.
+     *
+     * @param cidrMaskLength  the prefix length of the CIDR subnet mask
+     *                        (i.e. the number of leading one-bits),
+     *                        where {@code 0 <= cidrMaskLength <= 128}
+     * @return                an {@code IPv6Address} object that represents the
+     *                        CIDR subnet mask of the given prefix length
+     * @throws IllegalArgumentException  if the given prefix length was invalid
+     */
+    @Nonnull
+    public static IPv6Address ofCidrMaskLength(final int cidrMaskLength) {
+        Preconditions.checkArgument(
+                cidrMaskLength >= 0 && cidrMaskLength <= 128,
+                "Invalid IPv6 CIDR mask length: %s", cidrMaskLength);
+
+        if (cidrMaskLength == 128) {
+            return IPv6Address.NO_MASK;
+        } else if (cidrMaskLength == 0) {
+            return IPv6Address.FULL_MASK;
+        } else {
+            int shift1 = Math.min(cidrMaskLength, 64);
+            long raw1 = shift1 == 0 ? 0 : -1L << (64 - shift1);
+            int shift2 = Math.max(cidrMaskLength - 64, 0);
+            long raw2 = shift2 == 0 ? 0 : -1L << (64 - shift2);
+            return IPv6Address.of(raw1, raw2);
+        }
+    }
+
+    /**
+     * Returns an {@code IPv6AddressWithMask} object that represents this
+     * IP address masked by the given IP address mask.
+     *
+     * @param mask  the {@code IPv6Address} object that represents the mask
+     * @return      an {@code IPv6AddressWithMask} object that represents this
+     *              IP address masked by the given mask
+     * @throws NullPointerException  if the given mask was {@code null}
+     */
+    @Nonnull
+    @Override
+    public IPv6AddressWithMask withMask(@Nonnull final IPv6Address mask) {
+        return IPv6AddressWithMask.of(this, mask);
+    }
+
+    /**
+     * Returns an {@code IPv6AddressWithMask} object that represents this
+     * IP address masked by the CIDR subnet mask of the given prefix length.
+     *
+     * @param cidrMaskLength  the prefix length of the CIDR subnet mask
+     *                        (i.e. the number of leading one-bits),
+     *                        where {@code 0 <= cidrMaskLength <= 128}
+     * @return                an {@code IPv6AddressWithMask} object that
+     *                        represents this IP address masked by the CIDR
+     *                        subnet mask of the given prefix length
+     * @throws IllegalArgumentException  if the given prefix length was invalid
+     * @see #ofCidrMaskLength(int)
+     */
+    @Nonnull
+    @Override
+    public IPv6AddressWithMask withMaskOfLength(final int cidrMaskLength) {
+        return this.withMask(IPv6Address.ofCidrMaskLength(cidrMaskLength));
+    }
+
     private volatile byte[] bytesCache = null;
 
     public byte[] getBytes() {
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
index 7259c7f..ee34923 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/IPv6AddressWithMask.java
@@ -1,7 +1,6 @@
 package org.projectfloodlight.openflow.types;
 
-import java.math.BigInteger;
-import java.util.Arrays;
+import com.google.common.base.Preconditions;
 
 public class IPv6AddressWithMask extends IPAddressWithMask<IPv6Address> {
     public final static IPv6AddressWithMask NONE = of(IPv6Address.NONE, IPv6Address.NONE);
@@ -16,23 +15,17 @@
     }
 
     public static IPv6AddressWithMask of(IPv6Address value, IPv6Address mask) {
-        if (value == null) {
-            throw new NullPointerException("Value must not be null");
-        }
-        if (mask == null) {
-            throw new NullPointerException("Mask must not be null");
-        }
+        Preconditions.checkNotNull(value, "value must not be null");
+        Preconditions.checkNotNull(mask, "mask must not be null");
         return new IPv6AddressWithMask(value, mask);
     }
 
-
     public static IPv6AddressWithMask of(final String string) {
-        if (string == null) {
-            throw new NullPointerException("String must not be null");
-        }
+        Preconditions.checkNotNull(string, "string must not be null");
+
         int slashPos;
         String ip = string;
-        int maskBits = 128;
+        int cidrMaskLength = 128;
         IPv6Address maskAddress = null;
 
         // Read mask suffix
@@ -47,14 +40,11 @@
                     maskAddress = IPv6Address.of(suffix);
                 } else {
                     // CIDR Suffix
-                    maskBits = Integer.parseInt(suffix);
+                    cidrMaskLength = Integer.parseInt(suffix);
                 }
             } catch (NumberFormatException e) {
                 throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
             }
-            if (maskBits < 0 || maskBits > 128) {
-                throw new IllegalArgumentException("IPv6 Address not well formed: " + string);
-            }
         }
 
         // Read IP
@@ -63,30 +53,21 @@
         if (maskAddress != null) {
             // Full address mask
             return IPv6AddressWithMask.of(ipv6, maskAddress);
-        } else if (maskBits == 128) {
-            // No mask
-            return IPv6AddressWithMask.of(ipv6, IPv6Address.NO_MASK);
-        } else if (maskBits == 0) {
-            // Entirely masked out
-            return IPv6AddressWithMask.of(ipv6, IPv6Address.FULL_MASK);
-        }else {
-            // With mask
-            BigInteger mask = BigInteger.ONE.negate().shiftLeft(128 - maskBits);
-            byte[] maskBytesTemp = mask.toByteArray();
-            byte[] maskBytes;
-            if (maskBytesTemp.length < 16) {
-                maskBytes = new byte[16];
-                System.arraycopy(maskBytesTemp, 0, maskBytes, 16 - maskBytesTemp.length, maskBytesTemp.length);
-                Arrays.fill(maskBytes, 0, 16 - maskBytesTemp.length, (byte)(0xFF));
-            } else if (maskBytesTemp.length > 16) {
-                maskBytes = new byte[16];
-                System.arraycopy(maskBytesTemp, 0, maskBytes, 0, maskBytes.length);
-            } else {
-                maskBytes = maskBytesTemp;
-            }
-            return IPv6AddressWithMask.of(ipv6, IPv6Address.of(maskBytes));
+        } else {
+            return IPv6AddressWithMask.of(ipv6,
+                    IPv6Address.ofCidrMaskLength(cidrMaskLength));
         }
     }
 
+    @Override
+    public boolean contains(IPAddress<?> ip) {
+        Preconditions.checkNotNull(ip, "ip must not be null");
 
+        if(ip.getIpVersion() == IPVersion.IPv6) {
+            IPv6Address ipv6 = (IPv6Address) ip;
+            return this.matches(ipv6);
+        }
+
+        return false;
+    }
 }
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/U128.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/U128.java
index 35ef846..ddf4faa 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/U128.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/U128.java
@@ -123,15 +123,100 @@
     }
 
     @Override
+    public U128 add(U128 other) {
+        long newRaw2 = this.raw2 + other.raw2;
+        long newRaw1 = this.raw1 + other.raw1;
+        if(UnsignedLongs.compare(newRaw2, this.raw2) < 0) {
+            // raw2 overflow
+            newRaw1+=1;
+        }
+        return U128.of(newRaw1, newRaw2);
+    }
+
+    @Override
+    public U128 subtract(U128 other) {
+        long newRaw2 = this.raw2 - other.raw2;
+        long newRaw1 = this.raw1 - other.raw1;
+        if(UnsignedLongs.compare(this.raw2, other.raw2) < 0) {
+            newRaw1 -= 1;
+        }
+        return U128.of(newRaw1, newRaw2);
+    }
+    @Override
     public int prefixBits(int numBits) {
         return HashValueUtils.prefixBits(this.raw1, numBits);
     }
 
     @Override
-    public U128 combineWithValue(U128 value, int keyBits) {
-        return U128.of(
-                HashValueUtils.combineWithValue(this.raw1, value.raw1, Math.min(64, keyBits)),
-                HashValueUtils.combineWithValue(this.raw2, value.raw2, Math.max(0,keyBits-64))
-        );
+    public HashValue.Builder<U128> builder() {
+        return new U128Builder(raw1, raw2);
     }
+
+    static class U128Builder implements HashValue.Builder<U128> {
+        private long raw1, raw2;
+
+        public U128Builder(long raw1, long raw2) {
+            this.raw1 = raw1;
+            this.raw2 = raw2;
+        }
+
+        @Override
+        public Builder<U128> add(U128 other) {
+            raw2 += other.raw2;
+            raw1 += other.raw1;
+            if(UnsignedLongs.compare(raw2, other.raw2) < 0) {
+                // raw2 overflow
+                raw1+=1;
+            }
+            return this;
+        }
+
+        @Override
+        public Builder<U128> subtract(
+                U128 other) {
+            if(UnsignedLongs.compare(this.raw2, other.raw2) >= 0) {
+                raw2 -= other.raw2;
+                raw1 -= other.raw1;
+            } else {
+                // raw2 overflow
+                raw2 -= other.raw2;
+                raw1 = this.raw1 - other.raw1 - 1;
+            }
+            return this;
+        }
+
+        @Override
+        public Builder<U128> invert() {
+            raw1 = ~raw1;
+            raw2 = ~raw2;
+            return this;
+        }
+
+        @Override
+        public Builder<U128> or(U128 other) {
+            raw1 |= other.raw1;
+            raw2 |= other.raw2;
+            return this;
+        }
+
+        @Override
+        public Builder<U128> and(U128 other) {
+            raw1 &= other.raw1;
+            raw2 &= other.raw2;
+            return this;
+        }
+
+        @Override
+        public Builder<U128> xor(U128 other) {
+            raw1 ^= other.raw1;
+            raw2 ^= other.raw2;
+            return this;
+        }
+
+        @Override
+        public U128 build() {
+            return U128.of(raw1, raw2);
+        }
+    }
+
 }
diff --git a/of/lib/src/main/java/org/projectfloodlight/openflow/types/U64.java b/of/lib/src/main/java/org/projectfloodlight/openflow/types/U64.java
index 1353b42..f15544f 100644
--- a/of/lib/src/main/java/org/projectfloodlight/openflow/types/U64.java
+++ b/of/lib/src/main/java/org/projectfloodlight/openflow/types/U64.java
@@ -151,6 +151,16 @@
         return U64.of(raw ^ other.raw);
     }
 
+    @Override
+    public U64 add(U64 other) {
+        return U64.of(this.raw + other.raw);
+    }
+
+    @Override
+    public U64 subtract(U64 other) {
+        return U64.of(this.raw - other.raw);
+    }
+
     /** return the "numBits" highest-order bits of the hash.
      *  @param numBits number of higest-order bits to return [0-32].
      *  @return a numberic value of the 0-32 highest-order bits.
@@ -160,11 +170,6 @@
         return HashValueUtils.prefixBits(raw, numBits);
     }
 
-    @Override
-    public U64 combineWithValue(U64 value, int keyBits) {
-        return U64.of(HashValueUtils.combineWithValue(this.raw, value.raw, keyBits));
-    }
-
     public final static Reader READER = new Reader();
 
     private static class Reader implements OFMessageReader<U64> {
@@ -174,5 +179,59 @@
         }
     }
 
+    @Override
+    public HashValue.Builder<U64> builder() {
+        return new U64Builder(raw);
+    }
+
+    static class U64Builder implements Builder<U64> {
+        long raw;
+
+        public U64Builder(long raw) {
+            this.raw = raw;
+        }
+
+        @Override
+        public Builder<U64> add(U64 other) {
+            raw += other.raw;
+            return this;
+        }
+
+        @Override
+        public Builder<U64> subtract(
+                U64 other) {
+            raw -= other.raw;
+            return this;
+        }
+
+        @Override
+        public Builder<U64> invert() {
+            raw = ~raw;
+            return this;
+        }
+
+        @Override
+        public Builder<U64> or(U64 other) {
+            raw |= other.raw;
+            return this;
+        }
+
+        @Override
+        public Builder<U64> and(U64 other) {
+            raw &= other.raw;
+            return this;
+        }
+
+        @Override
+        public Builder<U64> xor(U64 other) {
+            raw ^= other.raw;
+            return this;
+        }
+
+        @Override
+        public U64 build() {
+            return U64.of(raw);
+        }
+    }
 
 }
diff --git a/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java b/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
index 865df75..2ba4528 100644
--- a/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
+++ b/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPAddressTest.java
@@ -1,8 +1,12 @@
 package org.projectfloodlight.openflow.types;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.net.InetAddress;
 import java.net.UnknownHostException;
 
 import org.junit.Test;
@@ -29,7 +33,7 @@
             // expected
         }
         try {
-            IPAddress.of(null);
+            IPAddress.of((String) null);
             fail("Should have thrown NullPointerException");
         } catch (NullPointerException e) {
             assertNotNull(e.getMessage());
@@ -41,7 +45,7 @@
             assertNotNull(e.getMessage());
         }
         try {
-            IPAddress.of(null);
+            IPAddress.of((String) null);
             fail("Should have thrown NullPointerException");
         } catch (NullPointerException e) {
             assertNotNull(e.getMessage());
@@ -55,6 +59,29 @@
     }
 
     @Test
+    public void testOfString() {
+        IPAddress<?> ip0 = IPAddress.of("1.2.3.4");
+        IPAddress<?> ip1 = IPAddress.of("abcd::1234");
+        assertTrue(ip0 instanceof IPv4Address);
+        assertTrue(ip1 instanceof IPv6Address);
+        assertEquals(ip0, IPv4Address.of("1.2.3.4"));
+        assertEquals(ip1, IPv6Address.of("abcd::1234"));
+    }
+
+    @Test
+    public void testOfInetAddress() throws Exception {
+        InetAddress ia0 = InetAddress.getByName("192.168.1.123");
+        InetAddress ia1 = InetAddress.getByName("fd00::4321");
+        IPAddress<?> ip0 = IPAddress.of(ia0);
+        IPAddress<?> ip1 = IPAddress.of(ia1);
+        assertTrue(ip0 instanceof IPv4Address);
+        assertTrue(ip1 instanceof IPv6Address);
+        assertEquals(ip0, IPv4Address.of(ia0));
+        assertEquals(ip1, IPv6Address.of(ia1));
+    }
+
+    @SuppressWarnings("deprecation")
+    @Test
     public void testFromInetAddressException() throws UnknownHostException {
         try {
             IPAddress.fromInetAddress(null);
@@ -64,4 +91,43 @@
         }
     }
 
+    @Test
+    public void testContains() {
+
+        // Test IPv4 Mask
+        IPAddressWithMask<?> mask = IPAddressWithMask.of("1.2.3.4/24");
+
+        IPAddress<?> validIp = IPAddress.of("1.2.3.5");
+        assertTrue(mask.contains(validIp));
+
+        IPAddress<?> invalidIp = IPAddress.of("1.2.5.5");
+        assertFalse(mask.contains(invalidIp));
+
+        IPAddress<?> invalidIpv6 = IPAddress.of("10:10::ffff");
+        assertFalse(mask.contains(invalidIpv6));
+
+        // Test IPv6 Mask
+        mask = IPAddressWithMask.of("10:10::1/112");
+
+        validIp = IPAddress.of("10:10::f");
+        assertTrue(mask.contains(validIp));
+
+        invalidIp = IPAddress.of("11:10::f");
+        assertFalse(mask.contains(invalidIp));
+
+        IPAddress<?> invalidIpv4 = IPAddress.of("10.0.0.1");
+        assertFalse(mask.contains(invalidIpv4));
+    }
+
+    @Test 
+    public void testContainsException() {
+        try {
+            IPAddressWithMask<?> mask = IPAddressWithMask.of("1.2.3.4/24");
+            mask.contains(null);
+            fail("Should have thrown NullPointerException");
+        } catch (NullPointerException e) {
+            assertNotNull(e.getMessage());
+        }
+    }
+
 }
diff --git a/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java b/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java
index a57b42a..0716b50 100644
--- a/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java
+++ b/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPv4AddressTest.java
@@ -9,6 +9,9 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.net.Inet4Address;
+import java.net.InetAddress;
+
 import org.hamcrest.CoreMatchers;
 import org.jboss.netty.buffer.ChannelBuffers;
 import org.junit.Test;
@@ -224,6 +227,83 @@
     }
 
     @Test
+    public void testOfCidrMaskLength() {
+        for (int i = 0; i <= 32; i++) {
+            assertEquals(IPv4Address.ofCidrMaskLength(i).asCidrMaskLength(), i);
+        }
+
+        assertEquals(IPv4Address.ofCidrMaskLength(0).getInt(), 0x0000_0000);
+
+        assertEquals(IPv4Address.ofCidrMaskLength(1).getInt(), 0x8000_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(2).getInt(), 0xC000_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(3).getInt(), 0xE000_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(4).getInt(), 0xF000_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(5).getInt(), 0xF800_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(6).getInt(), 0xFC00_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(7).getInt(), 0xFE00_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(8).getInt(), 0xFF00_0000);
+
+        assertEquals(IPv4Address.ofCidrMaskLength(9).getInt(), 0xFF80_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(10).getInt(), 0xFFC0_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(11).getInt(), 0xFFE0_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(12).getInt(), 0xFFF0_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(13).getInt(), 0xFFF8_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(14).getInt(), 0xFFFC_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(15).getInt(), 0xFFFE_0000);
+        assertEquals(IPv4Address.ofCidrMaskLength(16).getInt(), 0xFFFF_0000);
+
+        assertEquals(IPv4Address.ofCidrMaskLength(17).getInt(), 0xFFFF_8000);
+        assertEquals(IPv4Address.ofCidrMaskLength(18).getInt(), 0xFFFF_C000);
+        assertEquals(IPv4Address.ofCidrMaskLength(19).getInt(), 0xFFFF_E000);
+        assertEquals(IPv4Address.ofCidrMaskLength(20).getInt(), 0xFFFF_F000);
+        assertEquals(IPv4Address.ofCidrMaskLength(21).getInt(), 0xFFFF_F800);
+        assertEquals(IPv4Address.ofCidrMaskLength(22).getInt(), 0xFFFF_FC00);
+        assertEquals(IPv4Address.ofCidrMaskLength(23).getInt(), 0xFFFF_FE00);
+        assertEquals(IPv4Address.ofCidrMaskLength(24).getInt(), 0xFFFF_FF00);
+
+        assertEquals(IPv4Address.ofCidrMaskLength(25).getInt(), 0xFFFF_FF80);
+        assertEquals(IPv4Address.ofCidrMaskLength(26).getInt(), 0xFFFF_FFC0);
+        assertEquals(IPv4Address.ofCidrMaskLength(27).getInt(), 0xFFFF_FFE0);
+        assertEquals(IPv4Address.ofCidrMaskLength(28).getInt(), 0xFFFF_FFF0);
+        assertEquals(IPv4Address.ofCidrMaskLength(29).getInt(), 0xFFFF_FFF8);
+        assertEquals(IPv4Address.ofCidrMaskLength(30).getInt(), 0xFFFF_FFFC);
+        assertEquals(IPv4Address.ofCidrMaskLength(31).getInt(), 0xFFFF_FFFE);
+        assertEquals(IPv4Address.ofCidrMaskLength(32).getInt(), 0xFFFF_FFFF);
+    }
+
+    @Test
+    public void testWithMask() throws Exception {
+        // Sanity tests for the withMask*() syntactic sugars
+
+        IPv4Address original = IPv4Address.of("192.168.1.101");
+        IPv4Address expectedValue = IPv4Address.of("192.168.1.0");
+        IPv4Address expectedMask = IPv4Address.of("255.255.255.0");
+
+        IPv4AddressWithMask v;
+
+        v = original.withMask(IPv4Address.of(new byte[] {-1, -1, -1, 0}));
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+
+        v = original.withMask(IPv4Address.of(0xFFFF_FF00));
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+
+        v = original.withMask(IPv4Address.of("255.255.255.0"));
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+
+        Inet4Address i4a = (Inet4Address) InetAddress.getByName("255.255.255.0");
+        v = original.withMask(IPv4Address.of(i4a));
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+
+        v = original.withMaskOfLength(24);
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+    }
+
+    @Test
     public void testReadFrom() throws OFParseError {
         for(int i=0; i < testAddresses.length; i++ ) {
             IPv4Address ip = IPv4Address.read4Bytes(ChannelBuffers.copiedBuffer(testAddresses[i]));
@@ -367,5 +447,17 @@
         } catch (IllegalArgumentException e) {
             assertNotNull(e.getMessage());
         }
+        try {
+            IPv4Address.ofCidrMaskLength(-1);
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e.getMessage());
+        }
+        try {
+            IPv4Address.ofCidrMaskLength(33);
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e.getMessage());
+        }
     }
 }
diff --git a/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java b/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java
index 6963c21..a397c2a 100644
--- a/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java
+++ b/of/lib/src/test/java/org/projectfloodlight/openflow/types/IPv6AddressTest.java
@@ -198,6 +198,79 @@
         }
     }
 
+    private static void testOfCidrMaskLengthHelper(
+            int cidrMaskLength, String ipStr) throws UnknownHostException {
+        byte[] ba0 = IPv6Address.ofCidrMaskLength(cidrMaskLength).getBytes();
+        byte[] ba1 = Inet6Address.getByName(ipStr).getAddress();
+        assertArrayEquals(ba0, ba1);
+    }
+
+    @Test
+    public void testOfCidrMaskLength() throws UnknownHostException {
+        for (int i = 0; i <= 128; i++) {
+            assertTrue(IPv6Address.ofCidrMaskLength(i).isCidrMask());
+            assertEquals(IPv6Address.ofCidrMaskLength(i).asCidrMaskLength(), i);
+        }
+        testOfCidrMaskLengthHelper(0, "::");
+        testOfCidrMaskLengthHelper(1, "8000::");
+        testOfCidrMaskLengthHelper(2, "c000::");
+        testOfCidrMaskLengthHelper(8, "ff00::");
+        testOfCidrMaskLengthHelper(16, "ffff::");
+        testOfCidrMaskLengthHelper(17, "ffff:8000::");
+        testOfCidrMaskLengthHelper(31, "ffff:fffe::");
+        testOfCidrMaskLengthHelper(32, "ffff:ffff::");
+        testOfCidrMaskLengthHelper(33, "ffff:ffff:8000::");
+        testOfCidrMaskLengthHelper(46, "ffff:ffff:fffc::");
+        testOfCidrMaskLengthHelper(48, "ffff:ffff:ffff::");
+        testOfCidrMaskLengthHelper(55, "ffff:ffff:ffff:fe00::");
+        testOfCidrMaskLengthHelper(56, "ffff:ffff:ffff:ff00::");
+        testOfCidrMaskLengthHelper(59, "ffff:ffff:ffff:ffe0::");
+        testOfCidrMaskLengthHelper(63, "ffff:ffff:ffff:fffe::");
+        testOfCidrMaskLengthHelper(64, "ffff:ffff:ffff:ffff::");
+        testOfCidrMaskLengthHelper(65, "ffff:ffff:ffff:ffff:8000::");
+        testOfCidrMaskLengthHelper(67, "ffff:ffff:ffff:ffff:e000::");
+        testOfCidrMaskLengthHelper(100, "ffff:ffff:ffff:ffff:ffff:ffff:f000::");
+        testOfCidrMaskLengthHelper(101, "ffff:ffff:ffff:ffff:ffff:ffff:f800::");
+        testOfCidrMaskLengthHelper(126, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffc");
+        testOfCidrMaskLengthHelper(127, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fffe");
+        testOfCidrMaskLengthHelper(128, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+    }
+
+    @Test
+    public void testWithMask() throws Exception {
+        // Sanity tests for the withMask*() syntactic sugars
+
+        IPv6Address original = IPv6Address.of("fd12:3456:ABCD:7890::1");
+        IPv6Address expectedValue = IPv6Address.of("fd12:3456:ABCD::");
+        IPv6Address expectedMask = IPv6Address.of("ffff:ffff:ffff::");
+
+        IPv6AddressWithMask v;
+
+        v = original.withMask(IPv6Address.of(new byte[] {
+                -1, -1, -1, -1, -1, -1, 0, 0,
+                0, 0, 0, 0, 0, 0, 0, 0 }));
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+
+        v = original.withMask(IPv6Address.of(
+                0xFFFF_FFFF_FFFF_0000L, 0x0000_0000_0000_0000L));
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+
+        v = original.withMask(IPv6Address.of("ffff:ffff:ffff::"));
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+
+        Inet6Address i6a = (Inet6Address) InetAddress.getByName("ffff:ffff:ffff::");
+        v = original.withMask(IPv6Address.of(i6a));
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+
+        v = original.withMaskOfLength(48);
+        assertEquals(v.getValue(), expectedValue);
+        assertEquals(v.getMask(), expectedMask);
+    }
+
     @Test
     public void testReadFrom() throws OFParseError, UnknownHostException {
         for(int i=0; i < testStrings.length; i++ ) {
@@ -313,5 +386,17 @@
         } catch (IllegalArgumentException e) {
             assertNotNull(e.getMessage());
         }
+        try {
+            IPv6Address.ofCidrMaskLength(-1);
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e.getMessage());
+        }
+        try {
+            IPv6Address.ofCidrMaskLength(129);
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            assertNotNull(e.getMessage());
+        }
     }
 }
diff --git a/of/lib/src/test/java/org/projectfloodlight/openflow/types/U128Test.java b/of/lib/src/test/java/org/projectfloodlight/openflow/types/U128Test.java
index fb5cd23..81d9d7f 100644
--- a/of/lib/src/test/java/org/projectfloodlight/openflow/types/U128Test.java
+++ b/of/lib/src/test/java/org/projectfloodlight/openflow/types/U128Test.java
@@ -9,7 +9,12 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.text.MessageFormat;
+
 import org.hamcrest.Matchers;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.google.common.hash.HashCode;
@@ -17,6 +22,9 @@
 import com.google.common.hash.Hashing;
 
 public class U128Test {
+    private Triple[] triples;
+
+
     @Test
     public void testPositiveRaws() {
         assertThat(U128.of(0, 0).getMsb(), equalTo(0L));
@@ -27,6 +35,22 @@
     }
 
     @Test
+    public void testReadBytes() {
+        ChannelBuffer empty = ChannelBuffers.wrappedBuffer(new byte[16]);
+        U128 uEmpty = U128.read16Bytes(empty);
+        assertThat(uEmpty.getMsb(), equalTo(0L));
+        assertThat(uEmpty.getLsb(), equalTo(0L));
+
+        ChannelBuffer value = ChannelBuffers.wrappedBuffer(
+                new byte[] { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, (byte) 0x88,
+                        (byte) 0x99, (byte) 0xaa, (byte) 0xbb, (byte) 0xcc, (byte) 0xdd,
+                        (byte) 0xee, (byte) 0xff, 0x11 });
+        U128 uValue = U128.read16Bytes(value);
+        assertThat(uValue.getMsb(), equalTo(0x1122334455667788L));
+        assertThat(uValue.getLsb(), equalTo(0x99aabbccddeeff11L));
+    }
+
+    @Test
     public void testPutTo() {
         U128 h         = U128.of(0x1234_5678_90ab_cdefL,0xdeafbeefdeadbeefL);
         U128 hSame     = U128.of(0x1234_5678_90ab_cdefL,0xdeafbeefdeadbeefL);
@@ -123,6 +147,80 @@
         }
     }
 
+    public static class Triple {
+        U128 a, b, c;
+
+        public Triple(U128 a, U128 b, U128 c) {
+            this.a = a;
+            this.b = b;
+            this.c = c;
+        }
+
+        public static Triple of(U128 a, U128 b, U128 c) {
+            return new Triple(a, b, c);
+        }
+
+        public String msg(String string) {
+            return MessageFormat.format(string, a,b,c);
+        }
+    }
+
+    @Before
+    public void setup() {
+        U128 u0_0 = U128.of(0, 0);
+        U128 u0_1 = U128.of(0, 1);
+        U128 u1_0 = U128.of(1, 0);
+        U128 u1_1 = U128.of(1, 1);
+
+        U128 u0_2 = U128.of(0, 2);
+        U128 u2_0 = U128.of(2, 0);
+
+        U128 u0_f = U128.of(0, -1L);
+        U128 uf_0 = U128.of(-1L, 0);
+
+        triples = new Triple[] {
+              Triple.of(u0_0, u0_0, u0_0),
+              Triple.of(u0_0, u0_1, u0_1),
+              Triple.of(u0_0, u1_0, u1_0),
+              Triple.of(u0_1, u1_0, u1_1),
+
+              Triple.of(u0_1, u0_1, u0_2),
+              Triple.of(u1_0, u1_0, u2_0),
+
+              Triple.of(u0_1, u0_f, u1_0),
+
+              Triple.of(u0_1, u0_f, u1_0),
+              Triple.of(u0_f, u0_f, U128.of(1, 0xffff_ffff_ffff_fffeL)),
+              Triple.of(uf_0, u0_f, U128.of(-1, -1)),
+              Triple.of(uf_0, u1_0, U128.ZERO),
+
+              Triple.of(U128.of(0x1234_5678_9abc_def1L, 0x1234_5678_9abc_def1L),
+                        U128.of(0xedcb_a987_6543_210eL, 0xedcb_a987_6543_210fL),
+                        U128.ZERO)
+        };
+    }
+
+    @Test
+    public void testAddSubtract() {
+        for(Triple t: triples) {
+            assertThat(t.msg("{0} + {1} = {2}"), t.a.add(t.b), equalTo(t.c));
+            assertThat(t.msg("{1} + {0} = {2}"), t.b.add(t.a), equalTo(t.c));
+
+            assertThat(t.msg("{2} - {0} = {1}"), t.c.subtract(t.a), equalTo(t.b));
+            assertThat(t.msg("{2} - {1} = {0}"), t.c.subtract(t.b), equalTo(t.a));
+        }
+    }
+
+    @Test
+    public void testAddSubtractBuilder() {
+        for(Triple t: triples) {
+            assertThat(t.msg("{0} + {1} = {2}"), t.a.builder().add(t.b).build(), equalTo(t.c));
+            assertThat(t.msg("{1} + {0} = {2}"), t.b.builder().add(t.a).build(), equalTo(t.c));
+
+            assertThat(t.msg("{2} - {0} = {1}"), t.c.builder().subtract(t.a).build(), equalTo(t.b));
+            assertThat(t.msg("{2} - {1} = {0}"), t.c.builder().subtract(t.b).build(), equalTo(t.a));
+        }
+    }
 
     @Test
     public void testCompare() {
@@ -163,20 +261,25 @@
     }
 
     @Test
-    public void testCombine() {
-        long key = 0x1234567890abcdefL;
-        long val = 0xdeafbeefdeadbeefL;
-        U128 hkey = U128.of(key, key*2);
-        U128 hVal = U128.of(val, val/2);
+    public void testBitwiseOperators() {
+        U128 one =   U128.of(0x5, 0x8);
+        U128 two = U128.of(0x7, 0x3);
 
-        assertThat(hkey.combineWithValue(hVal, 0), equalTo(hkey.xor(hVal)));
-        assertThat(hkey.combineWithValue(hVal, 64), equalTo(U128.of(hkey.getMsb(), hkey.getLsb() ^ hVal.getLsb())));
-        assertThat(hkey.combineWithValue(hVal, 128), equalTo(hkey));
+        assertThat(one.inverse(), equalTo(U128.of(0xfffffffffffffffaL, 0xfffffffffffffff7L)));
+        assertThat(one.and(two), equalTo(U128.of(0x5L, 0x0L)));
+        assertThat(one.or(two), equalTo(U128.of(0x7L, 0xbL)));
+        assertThat(one.xor(two), equalTo(U128.of(0x2L, 0xbL)));
+    }
 
-        long mask8 = 0xFF00_0000_0000_0000L;
+    @Test
+    public void testBitwiseOperatorsBuilder() {
+        U128 one =   U128.of(0x5, 0x8);
+        U128 two = U128.of(0x7, 0x3);
 
-        assertThat(hkey.combineWithValue(hVal, 8), equalTo(U128.of(hkey.getMsb() & mask8 |  hkey.getMsb() ^ hVal.getMsb() & ~mask8,
-                                                                   hkey.getLsb() ^ hVal.getLsb() )));
+        assertThat(one.builder().invert().build(), equalTo(U128.of(0xfffffffffffffffaL, 0xfffffffffffffff7L)));
+        assertThat(one.builder().and(two).build(), equalTo(U128.of(0x5L, 0x0L)));
+        assertThat(one.builder().or(two).build(), equalTo(U128.of(0x7L, 0xbL)));
+        assertThat(one.builder().xor(two).build(), equalTo(U128.of(0x2L, 0xbL)));
     }
 
 }
diff --git a/of/lib/src/test/java/org/projectfloodlight/openflow/types/U64Test.java b/of/lib/src/test/java/org/projectfloodlight/openflow/types/U64Test.java
index b0cca23..4066bf8 100644
--- a/of/lib/src/test/java/org/projectfloodlight/openflow/types/U64Test.java
+++ b/of/lib/src/test/java/org/projectfloodlight/openflow/types/U64Test.java
@@ -9,11 +9,15 @@
 import static org.junit.Assert.fail;
 
 import java.math.BigInteger;
+import java.text.MessageFormat;
 
+import org.junit.Before;
 import org.junit.Test;
 
 public class U64Test {
 
+    private Triple[] triples;
+
     @Test
     public void testPositiveRaws() {
         for(long positive: new long[] { 0, 1, 100, Long.MAX_VALUE }) {
@@ -24,10 +28,10 @@
 
     @Test
     public void testNegativeRaws() {
-        long minus_1 = 0xFFFF_FFFF_FFFF_FFFFL;
-        assertEquals(minus_1, U64.ofRaw(minus_1).getValue());
-        assertEquals(new BigInteger("FFFF_FFFF_FFFF_FFFF".replace("_", ""), 16),  U64.ofRaw(minus_1).getBigInteger());
-        assertEquals(new BigInteger("18446744073709551615"),  U64.ofRaw(minus_1).getBigInteger());
+        long minu1 = 0xFFFF_FFFF_FFFF_FFFFL;
+        assertEquals(minu1, U64.ofRaw(minu1).getValue());
+        assertEquals(new BigInteger("FFFF_FFFF_FFFF_FFFF".replace("_", ""), 16),  U64.ofRaw(minu1).getBigInteger());
+        assertEquals(new BigInteger("18446744073709551615"),  U64.ofRaw(minu1).getBigInteger());
     }
 
     @Test
@@ -62,24 +66,6 @@
     }
 
     @Test
-    public void testCombine() {
-        long key = 0x1234567890abcdefL;
-        long val = 0xdeafbeefdeadbeefL;
-        U64 hkey = U64.of(key);
-        U64 hVal = U64.of(val);
-
-        assertThat(hkey.combineWithValue(hVal, 0), equalTo(hkey.xor(hVal)));
-        assertThat(hkey.combineWithValue(hVal, 64), equalTo(hkey));
-        long mask32 = 0x00000000FFFFFFFFL;
-        assertThat(hkey.combineWithValue(hVal, 32),
-                equalTo(U64.of(key & ~mask32| (key ^ val) & mask32)));
-
-        long tenMask = 0x003FFFFFFFFFFFFFL;
-        assertThat(hkey.combineWithValue(hVal, 10),
-                equalTo(U64.of(key & ~tenMask | (key ^ val) & tenMask)));
-    }
-
-    @Test
     public void testKeyBits() {
         U64 zeroU = U64.of(0);
         assertThat(zeroU.prefixBits(0), equalTo(0));
@@ -105,6 +91,76 @@
         checkInvalidKeyBitSize(signedBitU, 64);
     }
 
+    public static class Triple {
+        U64 a, b, c;
+
+        public Triple(U64 a, U64 b, U64 c) {
+            this.a = a;
+            this.b = b;
+            this.c = c;
+        }
+
+        public static Triple of(U64 a, U64 b, U64 c) {
+            return new Triple(a, b, c);
+        }
+
+        public String msg(String string) {
+            return MessageFormat.format(string, a,b,c);
+        }
+    }
+
+    @Before
+    public void setup() {
+        U64 u0 = U64.of(0);
+        U64 u1 = U64.of(1);
+
+        U64 u2 = U64.of(2);
+        U64 u7f = U64.of(0x7fff_ffff_ffff_ffffL);
+        U64 u8 = U64.of(0x8000_0000_0000_0000L);
+
+        U64 uf = U64.of(-1L);
+
+        triples = new Triple[] {
+              Triple.of(u0, u0, u0),
+              Triple.of(u0, u1, u1),
+
+              Triple.of(u1, u1, u2),
+
+              Triple.of(u1, uf, u0),
+
+              Triple.of(uf, uf, U64.of(0xffff_ffff_ffff_fffeL)),
+              Triple.of(u0, uf, uf),
+
+              Triple.of(u7f, u1, u8),
+
+              Triple.of(U64.of(0x1234_5678_9abc_def1L),
+                        U64.of(0xedcb_a987_6543_210fL),
+                        U64.ZERO)
+        };
+    }
+
+    @Test
+    public void testAddSubtract() {
+        for(Triple t: triples) {
+            assertThat(t.msg("{0} + {1} = {2}"), t.a.add(t.b), equalTo(t.c));
+            assertThat(t.msg("{1} + {0} = {2}"), t.b.add(t.a), equalTo(t.c));
+
+            assertThat(t.msg("{2} - {0} = {1}"), t.c.subtract(t.a), equalTo(t.b));
+            assertThat(t.msg("{2} - {1} = {0}"), t.c.subtract(t.b), equalTo(t.a));
+        }
+    }
+
+    @Test
+    public void testAddSubtractBuilder() {
+        for(Triple t: triples) {
+            assertThat(t.msg("{0} + {1} = {2}"), t.a.builder().add(t.b).build(), equalTo(t.c));
+            assertThat(t.msg("{1} + {0} = {2}"), t.b.builder().add(t.a).build(), equalTo(t.c));
+
+            assertThat(t.msg("{2} - {0} = {1}"), t.c.builder().subtract(t.a).build(), equalTo(t.b));
+            assertThat(t.msg("{2} - {1} = {0}"), t.c.builder().subtract(t.b).build(), equalTo(t.a));
+        }
+    }
+
     private void
             checkInvalidKeyBitSize(U64 u, int prefixBit) {
         try {
@@ -115,4 +171,25 @@
         }
     }
 
+    @Test
+    public void testBitwiseOperators() {
+        U64 notPi = U64.of(0x3141_5926_5358_9793L);
+        U64 notE =  U64.of(0x2718_2818_8459_4523L);
+
+        assertThat(notPi.inverse(), equalTo(U64.of(0xcebe_a6d9_aca7_686cL)));
+        assertThat(notPi.and(notE), equalTo(U64.of(0x2100_0800_0058_0503L)));
+        assertThat(notPi.or(notE),  equalTo(U64.of(0x3759_793e_d759_d7b3L)));
+        assertThat(notPi.xor(notE), equalTo(U64.of(0x1659_713e_d701_d2b0L)));
+    }
+
+    @Test
+    public void testBitwiseOperatorsBuilder() {
+        U64 notPi = U64.of(0x3141_5926_5358_9793L);
+        U64 notE =  U64.of(0x2718_2818_8459_4523L);
+
+        assertThat(notPi.builder().invert().build(), equalTo(U64.of(0xcebe_a6d9_aca7_686cL)));
+        assertThat(notPi.builder().and(notE).build(), equalTo(U64.of(0x2100_0800_0058_0503L)));
+        assertThat(notPi.builder().or(notE).build(),  equalTo(U64.of(0x3759_793e_d759_d7b3L)));
+        assertThat(notPi.builder().xor(notE).build(), equalTo(U64.of(0x1659_713e_d701_d2b0L)));
+    }
 }
diff --git a/of/pom.xml b/of/pom.xml
index e69de29..27d2bdb 100644
--- a/of/pom.xml
+++ b/of/pom.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  
+  <groupId>inet.onrc.onos.of</groupId>
+  <artifactId>oflib</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <modelVersion>4.0.0</modelVersion>
+
+  <name>OpenFlow library and IO</name>
+  <description>The OpenFlow library and IO</description>
+
+  
+  <modules>
+    <module>lib</module>
+    <module>ctl</module>
+  </modules>
+  
+
+</project>
diff --git a/pom.xml b/pom.xml
index eebb8f2..020f4b7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,30 +18,6 @@
 
     <name>onos-features</name>
     <description>Apache Karaf features repository</description>
-
-    <dependencies>
-        <!--<dependency>
-            <groupId>commons-codec</groupId>
-            <artifactId>commons-codec</artifactId>
-            <version>1.7</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.4</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-lang</groupId>
-            <artifactId>commons-lang</artifactId>
-            <version>2.6</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-configuration</groupId>
-            <artifactId>commons-configuration</artifactId>
-            <version>1.10</version>
-        </dependency>-->
-    </dependencies>
-
     <build>
         <plugins>
             <plugin>
